зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
57747c2ed1
Коммит
7265377c19
|
@ -21,6 +21,7 @@
|
|||
* are Copyright (C) 2001 the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Behnam Esfahbod <behnam@zwnj.org>
|
||||
*
|
||||
* 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
|
||||
|
@ -36,27 +37,69 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "prlink.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)
|
||||
|
||||
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()
|
||||
{
|
||||
if (gtklib) {
|
||||
PR_UnloadLibrary(gtklib);
|
||||
gtklib = nsnull;
|
||||
|
||||
GdkKeymapHaveBidiLayouts = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBidiKeyboard::IsLangRTL(PRBool *aIsRTL)
|
||||
NS_IMETHODIMP
|
||||
nsBidiKeyboard::IsLangRTL(PRBool *aIsRTL)
|
||||
{
|
||||
*aIsRTL = PR_FALSE;
|
||||
// XXX Insert platform specific code to determine keyboard direction
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
if (!mHaveBidiKeyboards)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*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
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
* are Copyright (C) 2001 the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Behnam Esfahbod <behnam@zwnj.org>
|
||||
*
|
||||
* 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
|
||||
|
@ -47,8 +48,12 @@ public:
|
|||
NS_DECL_NSIBIDIKEYBOARD
|
||||
|
||||
nsBidiKeyboard();
|
||||
|
||||
protected:
|
||||
virtual ~nsBidiKeyboard();
|
||||
|
||||
PRPackedBool mHaveBidiKeyboards;
|
||||
nsresult SetHaveBidiKeyboards();
|
||||
};
|
||||
|
||||
|
||||
#endif // __nsBidiKeyboard
|
||||
|
|
Загрузка…
Ссылка в новой задаче