Bug 348724: nsBidiKeyboard for GTK2 backend, patch by Behnam ZWNJ Esfahbod <bugs+behnam@zwnj.org>, r=smontagu, sr=roc, a=beltzner

This commit is contained in:
gavin%gavinsharp.com 2008-04-16 20:03:19 +00:00
Родитель 57747c2ed1
Коммит 7265377c19
2 изменённых файлов: 55 добавлений и 7 удалений

Просмотреть файл

@ -21,6 +21,7 @@
* are Copyright (C) 2001 the Initial Developer. All Rights Reserved. * are Copyright (C) 2001 the Initial Developer. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
* Behnam Esfahbod <behnam@zwnj.org>
* *
* Alternatively, the contents of this file may be used under the terms of * Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or * either the GNU General Public License Version 2 or later (the "GPL"), or
@ -36,27 +37,69 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "prlink.h"
#include "nsBidiKeyboard.h" #include "nsBidiKeyboard.h"
#include <gtk/gtk.h>
static PRLibrary *gtklib = nsnull;
typedef gboolean (PR_CALLBACK *GdkKeymapHaveBidiLayoutsType)(GdkKeymap *keymap);
static GdkKeymapHaveBidiLayoutsType GdkKeymapHaveBidiLayouts = nsnull;
NS_IMPL_ISUPPORTS1(nsBidiKeyboard, nsIBidiKeyboard) NS_IMPL_ISUPPORTS1(nsBidiKeyboard, nsIBidiKeyboard)
nsBidiKeyboard::nsBidiKeyboard() : nsIBidiKeyboard() nsBidiKeyboard::nsBidiKeyboard()
{ {
if (!gtklib)
gtklib = PR_LoadLibrary("libgtk-x11-2.0.so.0");
if (gtklib && !GdkKeymapHaveBidiLayouts)
GdkKeymapHaveBidiLayouts = (GdkKeymapHaveBidiLayoutsType) PR_FindFunctionSymbol(gtklib, "gdk_keymap_have_bidi_layouts");
SetHaveBidiKeyboards();
} }
nsBidiKeyboard::~nsBidiKeyboard() nsBidiKeyboard::~nsBidiKeyboard()
{ {
if (gtklib) {
PR_UnloadLibrary(gtklib);
gtklib = nsnull;
GdkKeymapHaveBidiLayouts = nsnull;
}
} }
NS_IMETHODIMP nsBidiKeyboard::IsLangRTL(PRBool *aIsRTL) NS_IMETHODIMP
nsBidiKeyboard::IsLangRTL(PRBool *aIsRTL)
{ {
*aIsRTL = PR_FALSE; if (!mHaveBidiKeyboards)
// XXX Insert platform specific code to determine keyboard direction return NS_ERROR_FAILURE;
return NS_ERROR_NOT_IMPLEMENTED;
*aIsRTL = (gdk_keymap_get_direction(NULL) == PANGO_DIRECTION_RTL);
return NS_OK;
} }
NS_IMETHODIMP nsBidiKeyboard::SetLangFromBidiLevel(PRUint8 aLevel) nsresult
nsBidiKeyboard::SetHaveBidiKeyboards()
{
mHaveBidiKeyboards = PR_FALSE;
if (!gtklib || !GdkKeymapHaveBidiLayouts)
return NS_ERROR_FAILURE;
mHaveBidiKeyboards = (*GdkKeymapHaveBidiLayouts)(NULL);
return NS_OK;
}
NS_IMETHODIMP
nsBidiKeyboard::SetLangFromBidiLevel(PRUint8 aLevel)
{ {
// XXX Insert platform specific code to set keyboard language // XXX Insert platform specific code to set keyboard language
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }

Просмотреть файл

@ -21,6 +21,7 @@
* are Copyright (C) 2001 the Initial Developer. All Rights Reserved. * are Copyright (C) 2001 the Initial Developer. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
* Behnam Esfahbod <behnam@zwnj.org>
* *
* Alternatively, the contents of this file may be used under the terms of * Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or * either the GNU General Public License Version 2 or later (the "GPL"), or
@ -47,8 +48,12 @@ public:
NS_DECL_NSIBIDIKEYBOARD NS_DECL_NSIBIDIKEYBOARD
nsBidiKeyboard(); nsBidiKeyboard();
protected:
virtual ~nsBidiKeyboard(); virtual ~nsBidiKeyboard();
PRPackedBool mHaveBidiKeyboards;
nsresult SetHaveBidiKeyboards();
}; };
#endif // __nsBidiKeyboard #endif // __nsBidiKeyboard