Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* vim:expandtab:shiftwidth=4:tabstop=4:
3 : */
4 : /* This Source Code Form is subject to the terms of the Mozilla Public
5 : * License, v. 2.0. If a copy of the MPL was not distributed with this
6 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 :
8 : #include "prlink.h"
9 :
10 : #include "nsBidiKeyboard.h"
11 : #include <gtk/gtk.h>
12 :
13 8 : NS_IMPL_ISUPPORTS(nsBidiKeyboard, nsIBidiKeyboard)
14 :
15 1 : nsBidiKeyboard::nsBidiKeyboard()
16 : {
17 1 : Reset();
18 1 : }
19 :
20 : NS_IMETHODIMP
21 1 : nsBidiKeyboard::Reset()
22 : {
23 : // NB: The default keymap can be null (e.g. in xpcshell). In that case,
24 : // simply assume that we don't have bidi keyboards.
25 1 : mHaveBidiKeyboards = false;
26 :
27 1 : GdkDisplay *display = gdk_display_get_default();
28 1 : if (!display)
29 0 : return NS_OK;
30 :
31 1 : GdkKeymap *keymap = gdk_keymap_get_for_display(display);
32 1 : mHaveBidiKeyboards = keymap && gdk_keymap_have_bidi_layouts(keymap);
33 1 : return NS_OK;
34 : }
35 :
36 0 : nsBidiKeyboard::~nsBidiKeyboard()
37 : {
38 0 : }
39 :
40 : NS_IMETHODIMP
41 2 : nsBidiKeyboard::IsLangRTL(bool *aIsRTL)
42 : {
43 2 : if (!mHaveBidiKeyboards)
44 2 : return NS_ERROR_FAILURE;
45 :
46 0 : *aIsRTL = (gdk_keymap_get_direction(gdk_keymap_get_default()) == PANGO_DIRECTION_RTL);
47 :
48 0 : return NS_OK;
49 : }
50 :
51 2 : NS_IMETHODIMP nsBidiKeyboard::GetHaveBidiKeyboards(bool* aResult)
52 : {
53 : // not implemented yet
54 2 : return NS_ERROR_NOT_IMPLEMENTED;
55 : }
|