2002-04-27 20:26:10 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim:expandtab:shiftwidth=4:tabstop=4:
|
|
|
|
*/
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-12-07 08:23:56 +03:00
|
|
|
|
2008-04-17 00:03:19 +04:00
|
|
|
#include "prlink.h"
|
|
|
|
|
2001-12-07 08:23:56 +03:00
|
|
|
#include "nsBidiKeyboard.h"
|
2008-04-17 00:03:19 +04:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2012-09-14 05:56:58 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2008-10-10 19:04:34 +04:00
|
|
|
typedef gboolean (*GdkKeymapHaveBidiLayoutsType)(GdkKeymap *keymap);
|
2012-07-30 18:20:58 +04:00
|
|
|
static GdkKeymapHaveBidiLayoutsType GdkKeymapHaveBidiLayouts = nullptr;
|
2012-09-14 05:56:58 +04:00
|
|
|
#endif
|
2001-12-07 08:23:56 +03:00
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(nsBidiKeyboard, nsIBidiKeyboard)
|
|
|
|
|
2008-04-17 00:03:19 +04:00
|
|
|
nsBidiKeyboard::nsBidiKeyboard()
|
2013-07-10 11:57:33 +04:00
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBidiKeyboard::Reset()
|
2001-12-07 08:23:56 +03:00
|
|
|
{
|
2012-09-14 05:56:58 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
|
|
|
PRLibrary *gtklib = nullptr;
|
2008-08-07 00:48:55 +04:00
|
|
|
#if defined(MOZ_X11)
|
2012-09-14 05:56:58 +04:00
|
|
|
if (!GdkKeymapHaveBidiLayouts) {
|
|
|
|
GdkKeymapHaveBidiLayouts = (GdkKeymapHaveBidiLayoutsType)
|
|
|
|
PR_FindFunctionSymbolAndLibrary("gdk_keymap_have_bidi_layouts",
|
|
|
|
>klib);
|
|
|
|
if (gtklib)
|
|
|
|
PR_UnloadLibrary(gtklib);
|
|
|
|
}
|
2008-08-07 00:48:55 +04:00
|
|
|
#endif
|
2008-04-17 00:03:19 +04:00
|
|
|
|
2012-09-14 05:56:58 +04:00
|
|
|
mHaveBidiKeyboards = false;
|
|
|
|
if (GdkKeymapHaveBidiLayouts)
|
2013-10-08 22:47:37 +04:00
|
|
|
mHaveBidiKeyboards = (*GdkKeymapHaveBidiLayouts)(nullptr);
|
2012-09-14 05:56:58 +04:00
|
|
|
#else
|
|
|
|
mHaveBidiKeyboards = gdk_keymap_have_bidi_layouts(gdk_keymap_get_default());
|
|
|
|
#endif
|
2013-07-10 11:57:33 +04:00
|
|
|
return NS_OK;
|
2001-12-07 08:23:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsBidiKeyboard::~nsBidiKeyboard()
|
|
|
|
{
|
2012-09-14 05:56:58 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
|
|
|
GdkKeymapHaveBidiLayouts = nullptr;
|
|
|
|
#endif
|
2001-12-07 08:23:56 +03:00
|
|
|
}
|
|
|
|
|
2008-04-17 00:03:19 +04:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsBidiKeyboard::IsLangRTL(bool *aIsRTL)
|
2001-12-07 08:23:56 +03:00
|
|
|
{
|
2008-04-17 00:03:19 +04:00
|
|
|
if (!mHaveBidiKeyboards)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-09-14 05:56:58 +04:00
|
|
|
*aIsRTL = (gdk_keymap_get_direction(gdk_keymap_get_default()) == PANGO_DIRECTION_RTL);
|
2008-04-17 00:03:19 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP nsBidiKeyboard::GetHaveBidiKeyboards(bool* aResult)
|
2011-09-15 18:54:50 +04:00
|
|
|
{
|
|
|
|
// not implemented yet
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|