2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim:expandtab:shiftwidth=4:tabstop=4:
|
|
|
|
*/
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-04-16 13:03:19 -07:00
|
|
|
#include "prlink.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsBidiKeyboard.h"
|
2008-04-16 13:03:19 -07:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
static PRLibrary *gtklib = nullptr;
|
2008-04-16 13:03:19 -07:00
|
|
|
|
2008-10-10 08:04:34 -07:00
|
|
|
typedef gboolean (*GdkKeymapHaveBidiLayoutsType)(GdkKeymap *keymap);
|
2012-07-30 07:20:58 -07:00
|
|
|
static GdkKeymapHaveBidiLayoutsType GdkKeymapHaveBidiLayouts = nullptr;
|
2008-04-16 13:03:19 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(nsBidiKeyboard, nsIBidiKeyboard)
|
|
|
|
|
2008-04-16 13:03:19 -07:00
|
|
|
nsBidiKeyboard::nsBidiKeyboard()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-08-06 13:48:55 -07:00
|
|
|
#if defined(MOZ_X11)
|
2008-04-16 13:03:19 -07:00
|
|
|
if (!gtklib)
|
|
|
|
gtklib = PR_LoadLibrary("libgtk-x11-2.0.so.0");
|
2008-08-06 13:48:55 -07:00
|
|
|
#else
|
|
|
|
return;
|
|
|
|
#endif
|
2008-04-16 13:03:19 -07:00
|
|
|
|
|
|
|
if (gtklib && !GdkKeymapHaveBidiLayouts)
|
|
|
|
GdkKeymapHaveBidiLayouts = (GdkKeymapHaveBidiLayoutsType) PR_FindFunctionSymbol(gtklib, "gdk_keymap_have_bidi_layouts");
|
|
|
|
|
|
|
|
SetHaveBidiKeyboards();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsBidiKeyboard::~nsBidiKeyboard()
|
|
|
|
{
|
2008-04-16 13:03:19 -07:00
|
|
|
if (gtklib) {
|
|
|
|
PR_UnloadLibrary(gtklib);
|
2012-07-30 07:20:58 -07:00
|
|
|
gtklib = nullptr;
|
2008-04-16 13:03:19 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
GdkKeymapHaveBidiLayouts = nullptr;
|
2008-04-16 13:03:19 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-04-16 13:03:19 -07:00
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsBidiKeyboard::IsLangRTL(bool *aIsRTL)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-04-16 13:03:19 -07:00
|
|
|
if (!mHaveBidiKeyboards)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
*aIsRTL = (gdk_keymap_get_direction(NULL) == PANGO_DIRECTION_RTL);
|
|
|
|
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-04-16 13:03:19 -07:00
|
|
|
nsresult
|
|
|
|
nsBidiKeyboard::SetHaveBidiKeyboards()
|
|
|
|
{
|
2011-10-03 00:56:21 -07:00
|
|
|
mHaveBidiKeyboards = false;
|
2008-04-16 13:03:19 -07:00
|
|
|
|
|
|
|
if (!gtklib || !GdkKeymapHaveBidiLayouts)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
mHaveBidiKeyboards = (*GdkKeymapHaveBidiLayouts)(NULL);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBidiKeyboard::SetLangFromBidiLevel(PRUint8 aLevel)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// XXX Insert platform specific code to set keyboard language
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2008-04-16 13:03:19 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHODIMP nsBidiKeyboard::GetHaveBidiKeyboards(bool* aResult)
|
2011-09-15 07:54:50 -07:00
|
|
|
{
|
|
|
|
// not implemented yet
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|