Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: chromeos_language.h

Issue 460107: Adding IBus support to cros library. (Closed)
Patch Set: copied to writable tree Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « SConstruct ('k') | chromeos_language.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROMEOS_LANGUAGE_H_
6 #define CHROMEOS_LANGUAGE_H_
7
8 #include <string>
9 #include <vector>
10
11 #include <base/basictypes.h>
12
13 static const char kFallbackXKBId[] = "USA";
14 static const char kFallbackXKBDisplayName[] = "US";
15
16 namespace chromeos {
17
18 enum LanguageCategory {
19 LANGUAGE_CATEGORY_XKB,
20 LANGUAGE_CATEGORY_IME,
21 };
22
23 // A structure which represents an IME language or a XKB layout.
24 struct InputLanguage {
25 InputLanguage(LanguageCategory category,
26 const std::string& id,
27 const std::string& display_name,
28 const std::string& icon_path)
29 : category(category),
30 id(id),
31 display_name(display_name),
32 icon_path(icon_path) {
33 }
34
35 InputLanguage()
36 : category(LANGUAGE_CATEGORY_XKB) {
37 }
38
39 // Languages are sorted by category, then by display_name, then by id.
40 bool operator<(const InputLanguage& other) const {
41 if (category == other.category) {
42 if (display_name == other.display_name) {
43 return id < other.id;
44 }
45 return display_name < other.display_name;
46 }
47 return category < other.category;
48 }
49
50 bool operator==(const InputLanguage& other) const {
51 return (category == other.category) && (id == other.id);
52 }
53
54 LanguageCategory category;
55
56 // An ID that identifies an IME engine or a XKB layout (e.g., "anthy",
57 // "t:latn-post", "chewing").
58 std::string id;
59 // An IME or layout name which is used in the UI (e.g., "Anthy").
60 std::string display_name;
61 // Path to an icon (e.g., "/usr/share/ibus-chewing/icons/ibus-chewing.png").
62 // Empty if it does not exist.
63 std::string icon_path;
64 };
65 typedef std::vector<InputLanguage> InputLanguageList;
66
67 // Creates dummy InputLanguageList object. Usually, this function is called only
68 // on development enviromnent where libcros.so does not exist. So, obviously
69 // you can not move this function to libcros.so. This function is called by
70 // src/chrome/browser/chromeos/language_library.cc when EnsureLoaded() fails.
71 inline InputLanguageList* CreateFallbackInputLanguageList() {
72 InputLanguageList* language_list = new InputLanguageList;
73 language_list->push_back(
74 InputLanguage(LANGUAGE_CATEGORY_XKB,
75 kFallbackXKBId,
76 kFallbackXKBDisplayName,
77 "" /* no icon */));
78 return language_list;
79 }
80
81 class LanguageStatusConnection;
82 typedef void(*LanguageStatusMonitorFunction)(
83 void* language_library, const InputLanguage& current_language);
84
85 // Establishes IBus connection to the ibus-daemon and DBus connection to
86 // the candidate window process. |monitor_function| will be called when IME
87 // language or XKB layout is changed.
88 extern LanguageStatusConnection* (*MonitorLanguageStatus)(
89 LanguageStatusMonitorFunction monitor_funcion, void* language_library);
90
91 // Terminates IBus and DBus connections.
92 extern void (*DisconnectLanguageStatus)(LanguageStatusConnection* connection);
93
94 // Gets all IME languages and XKB layouts that are currently available. Caller
95 // has to delete the returned list. This function might return NULL on error.
96 extern InputLanguageList* (*GetLanguages)(LanguageStatusConnection* connection);
97
98 // Changes the current IME engine to |name| and enable IME (when |category| is
99 // LANGUAGE_CATEGORY_IME). Changes the current XKB layout to |name| and disable
100 // IME (when |category| is LANGUAGE_CATEGORY_XKB).
101 extern void (*ChangeLanguage)(LanguageStatusConnection* connection,
102 LanguageCategory category, const char* name);
103
104 } // namespace chromeos
105
106 #endif // CHROMEOS_POWER_H_
OLDNEW
« no previous file with comments | « SConstruct ('k') | chromeos_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698