/src/mozilla-central/widget/gtk/nsBidiKeyboard.cpp
Line | Count | Source (jump to first uncovered line) |
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 "nsIWidget.h" |
12 | | #include <gtk/gtk.h> |
13 | | |
14 | | NS_IMPL_ISUPPORTS(nsBidiKeyboard, nsIBidiKeyboard) |
15 | | |
16 | | nsBidiKeyboard::nsBidiKeyboard() |
17 | 0 | { |
18 | 0 | Reset(); |
19 | 0 | } |
20 | | |
21 | | NS_IMETHODIMP |
22 | | nsBidiKeyboard::Reset() |
23 | 0 | { |
24 | 0 | // NB: The default keymap can be null (e.g. in xpcshell). In that case, |
25 | 0 | // simply assume that we don't have bidi keyboards. |
26 | 0 | mHaveBidiKeyboards = false; |
27 | 0 |
|
28 | 0 | GdkDisplay *display = gdk_display_get_default(); |
29 | 0 | if (!display) |
30 | 0 | return NS_OK; |
31 | 0 | |
32 | 0 | GdkKeymap *keymap = gdk_keymap_get_for_display(display); |
33 | 0 | mHaveBidiKeyboards = keymap && gdk_keymap_have_bidi_layouts(keymap); |
34 | 0 | return NS_OK; |
35 | 0 | } |
36 | | |
37 | | nsBidiKeyboard::~nsBidiKeyboard() |
38 | 0 | { |
39 | 0 | } |
40 | | |
41 | | NS_IMETHODIMP |
42 | | nsBidiKeyboard::IsLangRTL(bool *aIsRTL) |
43 | 0 | { |
44 | 0 | if (!mHaveBidiKeyboards) |
45 | 0 | return NS_ERROR_FAILURE; |
46 | 0 | |
47 | 0 | *aIsRTL = (gdk_keymap_get_direction(gdk_keymap_get_default()) == PANGO_DIRECTION_RTL); |
48 | 0 |
|
49 | 0 | return NS_OK; |
50 | 0 | } |
51 | | |
52 | | NS_IMETHODIMP nsBidiKeyboard::GetHaveBidiKeyboards(bool* aResult) |
53 | 0 | { |
54 | 0 | // not implemented yet |
55 | 0 | return NS_ERROR_NOT_IMPLEMENTED; |
56 | 0 | } |
57 | | |
58 | | // static |
59 | | already_AddRefed<nsIBidiKeyboard> |
60 | | nsIWidget::CreateBidiKeyboardInner() |
61 | 0 | { |
62 | 0 | return do_AddRef(new nsBidiKeyboard()); |
63 | 0 | } |