Imported Upstream version 0.4.5
YunQiang Su
11 years ago
0 | 0 | *~ |
1 | build/* | |
1 | /build*/ | |
2 | .* | |
3 | !.git* | |
4 | .git/ | |
2 | 5 | data/pinyin.tar.gz |
3 | 6 | data/pinyin.tar.gz.md5 |
4 | 7 | data/table/table.tar.gz |
11 | 14 | .directory |
12 | 15 | *.kate-swp |
13 | 16 | *.orig |
17 | tags | |
18 | astyle.sh | |
19 | cscope.* |
6 | 6 | |
7 | 7 | find_package(PkgConfig REQUIRED) |
8 | 8 | |
9 | if (ENABLE_GTK3) | |
10 | PKG_CHECK_MODULES (FCITX_GCLIENT "fcitx-gclient >= 4.2.4" REQUIRED) | |
11 | PKG_CHECK_MODULES (GTK3 "gtk+-3.0" REQUIRED) | |
12 | endif (ENABLE_GTK3) | |
9 | if(ENABLE_GTK3) | |
10 | PKG_CHECK_MODULES(FCITX_GCLIENT "fcitx-gclient>=4.2.6" REQUIRED) | |
11 | PKG_CHECK_MODULES(GTK3 "gtk+-3.0" REQUIRED) | |
12 | endif(ENABLE_GTK3) | |
13 | 13 | |
14 | if (ENABLE_GTK3) | |
15 | PKG_CHECK_MODULES (GTK2 "gtk+-2.0 >= 2.22" REQUIRED) | |
16 | endif (ENABLE_GTK3) | |
14 | if (ENABLE_GTK2) | |
15 | PKG_CHECK_MODULES (GTK2 "gtk+-2.0>=2.22" REQUIRED) | |
16 | endif (ENABLE_GTK2) | |
17 | 17 | |
18 | 18 | PKG_CHECK_MODULES(ISO_CODES "iso-codes" REQUIRED) |
19 | 19 | _pkgconfig_invoke("iso-codes" ISO_CODES PREFIX "" "--variable=prefix") |
29 | 29 | |
30 | 30 | include(FindPkgConfig) |
31 | 31 | FIND_PACKAGE(Gettext REQUIRED) |
32 | find_package(Fcitx 4.2.4 REQUIRED) | |
32 | find_package(Fcitx 4.2.6 REQUIRED) | |
33 | 33 | FIND_PROGRAM(INTLTOOL_EXTRACT intltool-extract) |
34 | 34 | FIND_PROGRAM(INTLTOOL_UPDATE intltool-update) |
35 | 35 | FIND_PROGRAM(INTLTOOL_MERGE intltool-merge) |
51 | 51 | configure_file(config.h.in config.h) |
52 | 52 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) |
53 | 53 | |
54 | if (ENABLE_GTK3) | |
55 | add_subdirectory(gtk3) | |
56 | endif (ENABLE_GTK3) | |
54 | if(ENABLE_GTK3) | |
55 | add_subdirectory(gtk3) | |
56 | endif(ENABLE_GTK3) | |
57 | 57 | |
58 | 58 | if (ENABLE_GTK2) |
59 | 59 | add_subdirectory(gtk) |
162 | 162 | for (; codesc != NULL; |
163 | 163 | codesc = (FcitxConfigOptionDesc*)codesc->hh.next, i++) { |
164 | 164 | const char *s; |
165 | FcitxConfigOptionDesc2 *codesc2 = | |
166 | (FcitxConfigOptionDesc2*)codesc; | |
165 | 167 | if (codesc->desc && strlen(codesc->desc) != 0) |
166 | 168 | s = D_(cfdesc->domain, codesc->desc); |
167 | 169 | else |
237 | 239 | if (inputWidget) { |
238 | 240 | GtkWidget* label = gtk_label_new(s); |
239 | 241 | g_object_set(label, "xalign", 0.0f, NULL); |
240 | gtk_table_attach(GTK_TABLE(table), label, 0, 1, i, i + 1, GTK_FILL, GTK_SHRINK, 5, 5); | |
241 | gtk_table_attach(GTK_TABLE(table), inputWidget, 1, 2, i, i + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 4); | |
242 | FcitxConfigBindValue(self->gconfig.configFile, cgdesc->groupName, codesc->optionName, NULL, sync_filter, argument); | |
242 | gtk_table_attach(GTK_TABLE(table), label, 0, 1, i, i + 1, | |
243 | GTK_FILL, GTK_SHRINK, 5, 5); | |
244 | gtk_table_attach(GTK_TABLE(table), inputWidget, 1, 2, i, | |
245 | i + 1, GTK_EXPAND | GTK_FILL, | |
246 | GTK_SHRINK | GTK_FILL, 0, 4); | |
247 | if (codesc2->longDesc && *codesc2->longDesc) { | |
248 | const char *tooltip = D_(cfdesc->domain, | |
249 | codesc2->longDesc); | |
250 | gtk_widget_set_tooltip_text(GTK_WIDGET(label), | |
251 | tooltip); | |
252 | gtk_widget_set_tooltip_text(GTK_WIDGET(inputWidget), | |
253 | tooltip); | |
254 | } | |
255 | FcitxConfigBindValue(self->gconfig.configFile, | |
256 | cgdesc->groupName, codesc->optionName, | |
257 | NULL, sync_filter, argument); | |
243 | 258 | } |
244 | 259 | } |
245 | 260 | } |
283 | 298 | "prefix", prefix, |
284 | 299 | "name", name, |
285 | 300 | "subconfig", subconfig, |
286 | NULL | |
287 | ); | |
301 | NULL); | |
288 | 302 | fcitx_config_widget_setup_ui(widget); |
289 | 303 | return widget; |
290 | 304 | } |
520 | 520 | |
521 | 521 | gboolean flag = TRUE; |
522 | 522 | if (item) { |
523 | flag = flag && (strlen(filter_text) == 0 | |
524 | || strstr(item->name, filter_text) | |
525 | || strstr(item->unique_name, filter_text) | |
526 | || strstr(item->langcode, filter_text)); | |
527 | flag = flag && (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self->onlycurlangcheckbox)) ? | |
528 | strncmp(item->langcode, _get_current_lang() , 2) == 0 : TRUE) ; | |
523 | if (strcmp(item->unique_name, "fcitx-keyboard-us") != 0) { | |
524 | flag = flag && (strlen(filter_text) == 0 | |
525 | || strstr(item->name, filter_text) | |
526 | || strstr(item->unique_name, filter_text) | |
527 | || strstr(item->langcode, filter_text)); | |
528 | flag = flag && (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self->onlycurlangcheckbox)) ? | |
529 | strncmp(item->langcode, _get_current_lang() , 2) == 0 : TRUE) ; | |
530 | } | |
529 | 531 | return flag; |
530 | 532 | } else { |
531 | 533 | gchar* lang = NULL; |
533 | 535 | iter, |
534 | 536 | AVAIL_TREE_LANG, &lang, |
535 | 537 | -1); |
538 | if (lang && strcmp(lang, "en") == 0) | |
539 | return TRUE; | |
536 | 540 | flag = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self->onlycurlangcheckbox)) ? |
537 | 541 | lang != NULL && strncmp(lang, _get_current_lang() , 2) == 0 : TRUE) ; |
538 | 542 | g_free(lang); |
559 | 563 | gpointer data) |
560 | 564 | { |
561 | 565 | gtk_entry_set_text (entry, ""); |
562 | }⏎ | |
566 | } |
26 | 26 | #include "keygrab.h" |
27 | 27 | |
28 | 28 | #define _(s) gettext(s) |
29 | //定义枚举类型,说明信号的名称和次序 | |
29 | ||
30 | 30 | enum { |
31 | 31 | KEYGRAB_BUTTON_CHANGED, |
32 | KEYGRAB_BUTTON_CURRENT_CHANGED, | |
33 | 32 | LAST_SIGNAL |
34 | 33 | }; |
35 | 34 | static gint keygrab_button_signals[LAST_SIGNAL] = { 0 }; |
60 | 59 | NULL, NULL, |
61 | 60 | g_cclosure_marshal_VOID__VOID, |
62 | 61 | G_TYPE_NONE, 0, NULL); |
63 | keygrab_button_signals[KEYGRAB_BUTTON_CURRENT_CHANGED] = g_signal_new("current-changed", | |
64 | G_TYPE_FROM_CLASS(object_class), | |
65 | G_SIGNAL_RUN_FIRST, | |
66 | G_STRUCT_OFFSET(KeyGrabButtonClass, current_changed), | |
67 | NULL, NULL, | |
68 | g_cclosure_marshal_VOID__VOID, | |
69 | G_TYPE_NONE, 0, NULL); | |
70 | 62 | } |
71 | //创建新的自定义控件 | |
63 | ||
72 | 64 | GtkWidget* keygrab_button_new(void) |
73 | 65 | { |
74 | return GTK_WIDGET(g_object_new(TYPE_KEYGRAB_BUTTON, 0)); | |
66 | return GTK_WIDGET(g_object_new(TYPE_KEYGRAB_BUTTON, NULL)); | |
75 | 67 | } |
76 | 68 | |
77 | 69 |
20 | 20 | #define KEYGRAB_H |
21 | 21 | |
22 | 22 | #include <gtk/gtk.h> |
23 | //定义类型宏和转换宏 | |
23 | ||
24 | 24 | #define TYPE_KEYGRAB_BUTTON (keygrab_button_get_type()) |
25 | 25 | #define KEYGRAB_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj,TYPE_KEYGRAB_BUTTON,KeyGrabButton)) |
26 | //定义实例结构和类结构 | |
26 | ||
27 | 27 | typedef struct _KeyGrabButton KeyGrabButton; |
28 | 28 | typedef struct _KeyGrabButtonClass KeyGrabButtonClass; |
29 | 29 | struct _KeyGrabButton { |
30 | GtkButton parent; //父控件为横向盒状容器 | |
30 | GtkButton parent; | |
31 | 31 | GtkWidget* popup; |
32 | 32 | gulong handler; |
33 | 33 | guint key; |
27 | 27 | main.c |
28 | 28 | main_window.c |
29 | 29 | im_widget.c |
30 | ui_widget.c | |
30 | 31 | gdm-languages.c |
31 | 32 | im_dialog.c |
32 | 33 | common.c |
33 | 34 | im_config_dialog.c |
35 | dummy_config.c | |
34 | 36 | ) |
35 | 37 | |
36 | 38 | add_executable( fcitx-config-gtk3 ${fcitx_config_gtk3_sources} ) |
18 | 18 | |
19 | 19 | #include "common.h" |
20 | 20 | |
21 | FcitxAddon* find_addon_by_name(UT_array* array, gchar* name) | |
21 | FcitxAddon* find_addon_by_name(UT_array* array, const gchar* name) | |
22 | 22 | { |
23 | 23 | FcitxAddon* addon = NULL; |
24 | 24 | for (addon = (FcitxAddon *) utarray_front(array); |
28 | 28 | break; |
29 | 29 | } |
30 | 30 | return addon; |
31 | }⏎ | |
31 | } |
16 | 16 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * |
17 | 17 | ***************************************************************************/ |
18 | 18 | |
19 | #ifndef COMMON_H | |
20 | #define COMMON_H | |
19 | #ifndef FCITX_CONFIGTOOL_COMMON_H | |
20 | #define FCITX_CONFIGTOOL_COMMON_H | |
21 | 21 | |
22 | 22 | #include <libintl.h> |
23 | 23 | #include <fcitx/addon.h> |
25 | 25 | |
26 | 26 | #define _(x) gettext(x) |
27 | 27 | |
28 | FcitxAddon* find_addon_by_name(UT_array* array, gchar* name); | |
28 | FcitxAddon* find_addon_by_name(UT_array* array, const gchar* name); | |
29 | 29 | |
30 | 30 | #endif⏎ |
24 | 24 | #include <libgen.h> |
25 | 25 | #include <sys/stat.h> |
26 | 26 | #include <unistd.h> |
27 | #include <ctype.h> | |
27 | 28 | |
28 | 29 | #include <fcitx-config/fcitx-config.h> |
29 | 30 | #include <fcitx-utils/uthash.h> |
34 | 35 | #include "keygrab.h" |
35 | 36 | #include "sub_config_widget.h" |
36 | 37 | #include "configdesc.h" |
38 | #include "dummy_config.h" | |
37 | 39 | |
38 | 40 | #define _(s) gettext(s) |
39 | 41 | #define D_(d, x) dgettext (d, x) |
45 | 47 | int i; |
46 | 48 | FcitxConfigWidget* widget; |
47 | 49 | GtkWidget* grid; |
50 | int j; | |
48 | 51 | } HashForeachContext; |
49 | 52 | |
50 | 53 | enum { |
62 | 65 | const GValue *value, |
63 | 66 | GParamSpec *pspec); |
64 | 67 | |
68 | ||
69 | static void | |
70 | fcitx_config_widget_check_can_use_simple(FcitxConfigWidget* self); | |
65 | 71 | |
66 | 72 | static void sync_filter(FcitxGenericConfig* gconfig, FcitxConfigGroup *group, FcitxConfigOption *option, void *value, FcitxConfigSync sync, void *arg); |
67 | 73 | |
118 | 124 | static void |
119 | 125 | fcitx_config_widget_init(FcitxConfigWidget *self) |
120 | 126 | { |
121 | } | |
122 | ||
123 | static void | |
124 | fcitx_config_widget_setup_ui(FcitxConfigWidget *self) | |
127 | gtk_orientable_set_orientation(GTK_ORIENTABLE(self), GTK_ORIENTATION_VERTICAL); | |
128 | self->argmap = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); | |
129 | } | |
130 | ||
131 | static void | |
132 | sync_hotkey(KeyGrabButton* button, gpointer user_data) | |
133 | { | |
134 | guint key1, key2; | |
135 | GdkModifierType mod1, mod2; | |
136 | keygrab_button_get_key(button, &key1, &mod1); | |
137 | keygrab_button_get_key(KEYGRAB_BUTTON(user_data), &key2, &mod2); | |
138 | ||
139 | if (key1 != key2 || mod1 != mod2) | |
140 | keygrab_button_set_key(KEYGRAB_BUTTON(user_data), key1, mod1); | |
141 | } | |
142 | ||
143 | static void | |
144 | fcitx_config_widget_create_option_widget( | |
145 | FcitxConfigWidget *self, | |
146 | FcitxConfigGroupDesc* cgdesc, | |
147 | FcitxConfigOptionDesc* codesc, | |
148 | char** label, | |
149 | char** tooltip, | |
150 | GtkWidget** inputWidget, | |
151 | void** newarg) | |
125 | 152 | { |
126 | 153 | FcitxConfigFileDesc* cfdesc = self->cfdesc; |
127 | GtkWidget *cvbox = GTK_WIDGET(self); | |
154 | FcitxConfigOptionDesc2* codesc2 = (FcitxConfigOptionDesc2*) codesc; | |
155 | void* oldarg = NULL; | |
156 | void* argument = NULL; | |
157 | char* name = g_strdup_printf("%s/%s", cgdesc->groupName, codesc->optionName); | |
158 | oldarg = g_hash_table_lookup(self->argmap, name); | |
159 | ||
160 | if (codesc->desc && strlen(codesc->desc) != 0) { | |
161 | *label = strdup(D_(cfdesc->domain, codesc->desc)); | |
162 | } else { | |
163 | *label = strdup(D_(cfdesc->domain, codesc->optionName)); | |
164 | } | |
165 | ||
166 | if (codesc2->longDesc && codesc2->longDesc[0]) { | |
167 | *tooltip = strdup(D_(cfdesc->domain, codesc2->longDesc)); | |
168 | } | |
169 | ||
170 | switch (codesc->type) { | |
171 | case T_Integer: | |
172 | *inputWidget = gtk_spin_button_new_with_range( | |
173 | codesc2->constrain.integerConstrain.min, | |
174 | codesc2->constrain.integerConstrain.max, | |
175 | 1.0); | |
176 | g_object_set(*inputWidget, "hexpand", TRUE, NULL); | |
177 | if (oldarg) { | |
178 | g_object_bind_property(*inputWidget, "value", oldarg, "value", G_BINDING_BIDIRECTIONAL); | |
179 | } | |
180 | else | |
181 | argument = *inputWidget; | |
182 | break; | |
183 | case T_Color: | |
184 | *inputWidget = gtk_color_button_new(); | |
185 | g_object_set(*inputWidget, "hexpand", TRUE, NULL); | |
186 | if (oldarg) { | |
187 | g_object_bind_property(*inputWidget, "color", oldarg, "color", G_BINDING_BIDIRECTIONAL); | |
188 | } | |
189 | else | |
190 | argument = *inputWidget; | |
191 | break; | |
192 | case T_Boolean: | |
193 | *inputWidget = gtk_check_button_new(); | |
194 | g_object_set(*inputWidget, "hexpand", TRUE, NULL); | |
195 | if (oldarg) { | |
196 | g_object_bind_property(*inputWidget, "active", oldarg, "active", G_BINDING_BIDIRECTIONAL); | |
197 | } | |
198 | else | |
199 | argument = *inputWidget; | |
200 | break; | |
201 | case T_Font: { | |
202 | *inputWidget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); | |
203 | g_object_set(*inputWidget, "hexpand", TRUE, NULL); | |
204 | GtkWidget* arg = gtk_font_button_new(); | |
205 | GtkWidget *button = gtk_button_new_with_label(_("Clear font setting")); | |
206 | gtk_box_pack_start(GTK_BOX(*inputWidget), arg, TRUE, TRUE, 0); | |
207 | gtk_box_pack_start(GTK_BOX(*inputWidget), button, FALSE, FALSE, 0); | |
208 | gtk_font_button_set_use_size(GTK_FONT_BUTTON(arg), FALSE); | |
209 | gtk_font_button_set_show_size(GTK_FONT_BUTTON(arg), FALSE); | |
210 | g_signal_connect(G_OBJECT(button), "clicked", (GCallback) set_none_font_clicked, arg); | |
211 | if (oldarg) { | |
212 | g_object_bind_property(arg, "font-name", oldarg, "font-name", G_BINDING_BIDIRECTIONAL); | |
213 | } | |
214 | else | |
215 | argument = arg; | |
216 | } | |
217 | break; | |
218 | case T_Enum: { | |
219 | int i; | |
220 | FcitxConfigEnum *e = &codesc->configEnum; | |
221 | *inputWidget = gtk_combo_box_text_new(); | |
222 | for (i = 0; i < e->enumCount; i ++) { | |
223 | gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(*inputWidget), D_(cfdesc->domain, e->enumDesc[i])); | |
224 | } | |
225 | g_object_set(*inputWidget, "hexpand", TRUE, NULL); | |
226 | if (oldarg) { | |
227 | g_object_bind_property(*inputWidget, "active", oldarg, "active", G_BINDING_BIDIRECTIONAL); | |
228 | } | |
229 | else | |
230 | argument = *inputWidget; | |
231 | } | |
232 | break; | |
233 | case T_Hotkey: { | |
234 | GtkWidget *button[2]; | |
235 | button[0] = keygrab_button_new(); | |
236 | button[1] = keygrab_button_new(); | |
237 | *inputWidget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); | |
238 | gtk_box_pack_start(GTK_BOX(*inputWidget), button[0], FALSE, TRUE, 0); | |
239 | gtk_box_pack_start(GTK_BOX(*inputWidget), button[1], FALSE, TRUE, 0); | |
240 | g_object_set(G_OBJECT(button[0]), "hexpand", TRUE, NULL); | |
241 | g_object_set(G_OBJECT(button[1]), "hexpand", TRUE, NULL); | |
242 | if (oldarg) { | |
243 | GArray* array = oldarg; | |
244 | int j; | |
245 | for (j = 0; j < 2; j ++) { | |
246 | GtkWidget *oldbutton = g_array_index(array, GtkWidget*, j); | |
247 | g_signal_connect(oldbutton, "changed", (GCallback) sync_hotkey, button[j]); | |
248 | g_signal_connect(button[j], "changed", (GCallback) sync_hotkey, oldbutton); | |
249 | } | |
250 | } | |
251 | else { | |
252 | argument = g_array_new(FALSE, FALSE, sizeof(void*)); | |
253 | g_array_append_val(argument, button[0]); | |
254 | g_array_append_val(argument, button[1]); | |
255 | } | |
256 | } | |
257 | break; | |
258 | case T_File: | |
259 | case T_Char: | |
260 | case T_String: | |
261 | *inputWidget = gtk_entry_new(); | |
262 | g_object_set(*inputWidget, "hexpand", TRUE, NULL); | |
263 | if (oldarg) { | |
264 | g_object_bind_property(*inputWidget, "text", oldarg, "text", G_BINDING_BIDIRECTIONAL); | |
265 | } | |
266 | else | |
267 | argument = *inputWidget; | |
268 | break; | |
269 | default: | |
270 | break; | |
271 | } | |
272 | ||
273 | ||
274 | if (argument) { | |
275 | g_hash_table_insert(self->argmap, name, argument); | |
276 | *newarg = argument; | |
277 | } | |
278 | else | |
279 | g_free(name); | |
280 | } | |
281 | ||
282 | static void | |
283 | fcitx_config_widget_check_can_use_simple(FcitxConfigWidget* self) | |
284 | { | |
285 | int count = 0; | |
286 | int simpleCount = 0; | |
287 | if (self->cfdesc) { | |
288 | HASH_FOREACH(cgdesc, self->cfdesc->groupsDesc, FcitxConfigGroupDesc) { | |
289 | if (cgdesc->optionsDesc == NULL) | |
290 | continue; | |
291 | else { | |
292 | HASH_FOREACH(codesc, cgdesc->optionsDesc, FcitxConfigOptionDesc) { | |
293 | FcitxConfigOptionDesc2* codesc2 = (FcitxConfigOptionDesc2*) codesc; | |
294 | if (!codesc2->advance) | |
295 | simpleCount++; | |
296 | count ++; | |
297 | } | |
298 | } | |
299 | } | |
300 | } | |
301 | ||
302 | int subconfig_count = self->parser ? g_hash_table_size(self->parser->subconfigs) : 0; | |
303 | /* if option is quite few */ | |
304 | if (count + subconfig_count <= 10) { | |
305 | self->fullUiType = CW_Simple; | |
306 | } | |
307 | else { | |
308 | self->fullUiType = CW_Full; | |
309 | } | |
310 | if (simpleCount + subconfig_count <= 10) { | |
311 | self->simpleUiType = CW_Simple; | |
312 | } | |
313 | else | |
314 | self->simpleUiType = CW_Full; | |
315 | ||
316 | if (count == simpleCount) | |
317 | self->simpleUiType = CW_NoShow; | |
318 | } | |
319 | ||
320 | static | |
321 | GtkWidget* | |
322 | fcitx_config_widget_create_simple_ui(FcitxConfigWidget* self, gboolean skipAdvance) | |
323 | { | |
324 | FcitxConfigFileDesc* cfdesc = self->cfdesc; | |
325 | GtkWidget *configGrid = gtk_grid_new(); | |
326 | gtk_grid_set_row_spacing(GTK_GRID(configGrid), 3); | |
327 | int i = 0; | |
328 | if (cfdesc) { | |
329 | FcitxConfigGroupDesc *cgdesc = NULL; | |
330 | FcitxConfigOptionDesc *codesc = NULL; | |
331 | for (cgdesc = cfdesc->groupsDesc; | |
332 | cgdesc != NULL; | |
333 | cgdesc = (FcitxConfigGroupDesc*)cgdesc->hh.next) { | |
334 | codesc = cgdesc->optionsDesc; | |
335 | if (codesc == NULL) | |
336 | continue; | |
337 | else { | |
338 | int count = 0; | |
339 | HASH_FOREACH(codesc, cgdesc->optionsDesc, FcitxConfigOptionDesc) { | |
340 | FcitxConfigOptionDesc2* codesc2 = (FcitxConfigOptionDesc2*) codesc; | |
341 | if (!skipAdvance || !codesc2->advance) | |
342 | count++; | |
343 | } | |
344 | if (!count) | |
345 | continue; | |
346 | } | |
347 | ||
348 | gchar* s = g_strdup_printf("<b>%s</b>", D_(cfdesc->domain, cgdesc->groupName)); | |
349 | GtkWidget *plabel = gtk_label_new(NULL); | |
350 | gtk_label_set_markup(GTK_LABEL(plabel), s); | |
351 | g_free(s); | |
352 | g_object_set(plabel, "xalign", 0.0f, "yalign", 0.5f, NULL); | |
353 | gtk_grid_attach(GTK_GRID(configGrid), plabel, 0, i, 3, 1); | |
354 | i ++; | |
355 | ||
356 | HASH_FOREACH(codesc, cgdesc->optionsDesc, FcitxConfigOptionDesc) { | |
357 | FcitxConfigOptionDesc2* codesc2 = (FcitxConfigOptionDesc2*) codesc; | |
358 | if (skipAdvance && codesc2->advance) | |
359 | continue; | |
360 | GtkWidget *inputWidget = NULL; | |
361 | void *argument = NULL; | |
362 | char* s = NULL, *tooltip = NULL; | |
363 | fcitx_config_widget_create_option_widget(self, cgdesc, codesc, &s, &tooltip, &inputWidget, &argument); | |
364 | ||
365 | if (inputWidget) { | |
366 | GtkWidget* label = gtk_label_new(s); | |
367 | g_object_set(label, "xalign", 1.0f, NULL); | |
368 | gtk_grid_attach(GTK_GRID(configGrid), label, 1, i, 1, 1); | |
369 | gtk_grid_attach(GTK_GRID(configGrid), inputWidget, 2, i, 1, 1); | |
370 | gtk_widget_set_tooltip_text(GTK_WIDGET(label), | |
371 | tooltip); | |
372 | gtk_widget_set_tooltip_text(GTK_WIDGET(inputWidget), | |
373 | tooltip); | |
374 | i++; | |
375 | if (argument) | |
376 | dummy_config_bind(self->config, cgdesc->groupName, codesc->optionName, sync_filter, argument); | |
377 | } | |
378 | g_free(s); | |
379 | g_free(tooltip); | |
380 | } | |
381 | } | |
382 | } | |
383 | ||
384 | if (self->parser) { | |
385 | GHashTable* subconfigs = self->parser->subconfigs; | |
386 | if (g_hash_table_size(subconfigs) != 0) { | |
387 | GtkWidget *plabel = gtk_label_new(NULL); | |
388 | gchar* markup = g_strdup_printf("<b>%s</b>", "Other"); | |
389 | gtk_label_set_markup(GTK_LABEL(plabel), markup); | |
390 | g_free(markup); | |
391 | g_object_set(plabel, "xalign", 0.0f, NULL); | |
392 | gtk_grid_attach(GTK_GRID(configGrid), plabel, 0, i, 3, 1); | |
393 | i ++; | |
394 | ||
395 | HashForeachContext context; | |
396 | context.i = i; | |
397 | context.j = 1; | |
398 | context.grid = configGrid; | |
399 | context.widget = self; | |
400 | g_hash_table_foreach(subconfigs, hash_foreach_cb, &context); | |
401 | i = context.i; | |
402 | } | |
403 | } | |
404 | if (i >= 2) { | |
405 | ||
406 | GtkWidget *plabel = gtk_label_new(NULL); | |
407 | gtk_widget_set_size_request(plabel, 20, 20); | |
408 | gtk_grid_attach(GTK_GRID(configGrid), plabel, 0, 2, 1, 1); | |
409 | i ++; | |
410 | } | |
411 | ||
412 | return configGrid; | |
413 | } | |
414 | ||
415 | static | |
416 | GtkWidget* | |
417 | fcitx_config_widget_create_full_ui(FcitxConfigWidget* self) | |
418 | { | |
419 | FcitxConfigFileDesc* cfdesc = self->cfdesc; | |
128 | 420 | GtkWidget *configNotebook = gtk_notebook_new(); |
129 | gtk_box_pack_start(GTK_BOX(cvbox), configNotebook, TRUE, TRUE, 0); | |
130 | 421 | if (cfdesc) { |
131 | bindtextdomain(cfdesc->domain, LOCALEDIR); | |
132 | bind_textdomain_codeset(cfdesc->domain, "UTF-8"); | |
133 | ||
134 | FILE *fp; | |
135 | fp = FcitxXDGGetFileWithPrefix(self->prefix, self->name, "r", NULL); | |
136 | self->gconfig.configFile = FcitxConfigParseConfigFileFp(fp, cfdesc); | |
137 | ||
138 | 422 | FcitxConfigGroupDesc *cgdesc = NULL; |
139 | 423 | FcitxConfigOptionDesc *codesc = NULL; |
140 | 424 | for (cgdesc = cfdesc->groupsDesc; |
164 | 448 | int i = 0; |
165 | 449 | for (; codesc != NULL; |
166 | 450 | codesc = (FcitxConfigOptionDesc*)codesc->hh.next, i++) { |
167 | const char *s; | |
168 | if (codesc->desc && strlen(codesc->desc) != 0) | |
169 | s = D_(cfdesc->domain, codesc->desc); | |
170 | else | |
171 | s = D_(cfdesc->domain, codesc->optionName); | |
172 | ||
173 | 451 | GtkWidget *inputWidget = NULL; |
174 | 452 | void *argument = NULL; |
175 | ||
176 | switch (codesc->type) { | |
177 | case T_Integer: | |
178 | inputWidget = gtk_spin_button_new_with_range(-10000.0, 10000.0, 1.0); | |
179 | g_object_set(G_OBJECT(inputWidget), "hexpand", TRUE, NULL); | |
180 | argument = inputWidget; | |
181 | break; | |
182 | case T_Color: | |
183 | inputWidget = gtk_color_button_new(); | |
184 | g_object_set(G_OBJECT(inputWidget), "hexpand", TRUE, NULL); | |
185 | argument = inputWidget; | |
186 | break; | |
187 | case T_Boolean: | |
188 | inputWidget = gtk_check_button_new(); | |
189 | g_object_set(G_OBJECT(inputWidget), "hexpand", TRUE, NULL); | |
190 | argument = inputWidget; | |
191 | break; | |
192 | case T_Font: { | |
193 | inputWidget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); | |
194 | g_object_set(G_OBJECT(inputWidget), "hexpand", TRUE, NULL); | |
195 | argument = gtk_font_button_new(); | |
196 | GtkWidget *button = gtk_button_new_with_label(_("Clear font setting")); | |
197 | gtk_box_pack_start(GTK_BOX(inputWidget), argument, TRUE, TRUE, 0); | |
198 | gtk_box_pack_start(GTK_BOX(inputWidget), button, FALSE, FALSE, 0); | |
199 | gtk_font_button_set_use_size(GTK_FONT_BUTTON(argument), FALSE); | |
200 | gtk_font_button_set_show_size(GTK_FONT_BUTTON(argument), FALSE); | |
201 | g_signal_connect(G_OBJECT(button), "clicked", (GCallback) set_none_font_clicked, argument); | |
202 | } | |
203 | break; | |
204 | case T_Enum: { | |
205 | int i; | |
206 | FcitxConfigEnum *e = &codesc->configEnum; | |
207 | inputWidget = gtk_combo_box_text_new(); | |
208 | for (i = 0; i < e->enumCount; i ++) { | |
209 | gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(inputWidget), D_(cfdesc->domain, e->enumDesc[i])); | |
210 | } | |
211 | g_object_set(G_OBJECT(inputWidget), "hexpand", TRUE, NULL); | |
212 | argument = inputWidget; | |
213 | } | |
214 | break; | |
215 | case T_Hotkey: { | |
216 | GtkWidget *button[2]; | |
217 | button[0] = keygrab_button_new(); | |
218 | button[1] = keygrab_button_new(); | |
219 | inputWidget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); | |
220 | gtk_box_pack_start(GTK_BOX(inputWidget), button[0], FALSE, TRUE, 0); | |
221 | gtk_box_pack_start(GTK_BOX(inputWidget), button[1], FALSE, TRUE, 0); | |
222 | g_object_set(G_OBJECT(button[0]), "hexpand", TRUE, NULL); | |
223 | g_object_set(G_OBJECT(button[1]), "hexpand", TRUE, NULL); | |
224 | argument = g_array_new(FALSE, FALSE, sizeof(void*)); | |
225 | g_array_append_val(argument, button[0]); | |
226 | g_array_append_val(argument, button[1]); | |
227 | } | |
228 | break; | |
229 | case T_File: | |
230 | case T_Char: | |
231 | case T_String: | |
232 | inputWidget = gtk_entry_new(); | |
233 | g_object_set(G_OBJECT(inputWidget), "hexpand", TRUE, NULL); | |
234 | argument = inputWidget; | |
235 | break; | |
236 | default: | |
237 | break; | |
238 | } | |
453 | char* s = NULL, *tooltip = NULL; | |
454 | fcitx_config_widget_create_option_widget(self, cgdesc, codesc, &s, &tooltip, &inputWidget, &argument); | |
239 | 455 | |
240 | 456 | if (inputWidget) { |
241 | 457 | GtkWidget* label = gtk_label_new(s); |
242 | 458 | g_object_set(label, "xalign", 0.0f, NULL); |
243 | 459 | gtk_grid_attach(GTK_GRID(grid), label, 0, i, 1, 1); |
244 | 460 | gtk_grid_attach(GTK_GRID(grid), inputWidget, 1, i, 1, 1); |
245 | FcitxConfigBindValue(self->gconfig.configFile, cgdesc->groupName, codesc->optionName, NULL, sync_filter, argument); | |
461 | gtk_widget_set_tooltip_text(GTK_WIDGET(label), | |
462 | tooltip); | |
463 | gtk_widget_set_tooltip_text(GTK_WIDGET(inputWidget), | |
464 | tooltip); | |
465 | if (argument) | |
466 | dummy_config_bind(self->config, cgdesc->groupName, codesc->optionName, sync_filter, argument); | |
246 | 467 | } |
468 | g_free(s); | |
469 | g_free(tooltip); | |
247 | 470 | } |
248 | 471 | } |
249 | ||
250 | FcitxConfigBindSync(&self->gconfig); | |
251 | 472 | } |
252 | 473 | |
253 | 474 | if (self->parser) { |
268 | 489 | |
269 | 490 | HashForeachContext context; |
270 | 491 | context.i = 0; |
492 | context.j = 0; | |
271 | 493 | context.grid = grid; |
272 | 494 | context.widget = self; |
273 | 495 | g_hash_table_foreach(subconfigs, hash_foreach_cb, &context); |
276 | 498 | |
277 | 499 | gtk_widget_set_size_request(configNotebook, 500, -1); |
278 | 500 | gtk_notebook_set_scrollable(GTK_NOTEBOOK(configNotebook), TRUE); |
279 | } | |
501 | ||
502 | return configNotebook; | |
503 | } | |
504 | ||
505 | static void | |
506 | _fcitx_config_widget_toggle_simple_full(GtkToggleButton* button, gpointer user_data) | |
507 | { | |
508 | FcitxConfigWidget *self = user_data; | |
509 | if (gtk_toggle_button_get_active(button)) { | |
510 | if (gtk_widget_get_parent(self->simpleWidget)) | |
511 | gtk_container_remove(GTK_CONTAINER(self), self->simpleWidget); | |
512 | gtk_box_pack_start(GTK_BOX(self), self->fullWidget, TRUE, TRUE, 0); | |
513 | gtk_widget_show_all(self->fullWidget); | |
514 | } | |
515 | else { | |
516 | if (gtk_widget_get_parent(self->fullWidget)) | |
517 | gtk_container_remove(GTK_CONTAINER(self), self->fullWidget); | |
518 | gtk_box_pack_start(GTK_BOX(self), self->simpleWidget, TRUE, TRUE, 0); | |
519 | gtk_widget_show_all(self->simpleWidget); | |
520 | } | |
521 | } | |
522 | ||
523 | static void | |
524 | fcitx_config_widget_setup_ui(FcitxConfigWidget *self) | |
525 | { | |
526 | self->config = dummy_config_new(self->cfdesc); | |
527 | fcitx_config_widget_check_can_use_simple(self); | |
528 | ||
529 | if (self->cfdesc) { | |
530 | bindtextdomain(self->cfdesc->domain, LOCALEDIR); | |
531 | bind_textdomain_codeset(self->cfdesc->domain, "UTF-8"); | |
532 | FILE *fp; | |
533 | fp = FcitxXDGGetFileWithPrefix(self->prefix, self->name, "r", NULL); | |
534 | dummy_config_load(self->config, fp); | |
535 | ||
536 | if (fp) | |
537 | fclose(fp); | |
538 | } | |
539 | if (self->simpleUiType != CW_NoShow) { | |
540 | if (self->simpleUiType == CW_Simple) | |
541 | self->simpleWidget = fcitx_config_widget_create_simple_ui(self, true); | |
542 | else | |
543 | self->simpleWidget = fcitx_config_widget_create_full_ui(self); | |
544 | g_object_ref(self->simpleWidget); | |
545 | } | |
546 | ||
547 | if (self->fullUiType != CW_NoShow) { | |
548 | if (self->fullUiType == CW_Simple) | |
549 | self->fullWidget = fcitx_config_widget_create_simple_ui(self, false); | |
550 | else | |
551 | self->fullWidget = fcitx_config_widget_create_full_ui(self); | |
552 | gtk_box_pack_start(GTK_BOX(self), self->fullWidget, TRUE, TRUE, 0); | |
553 | g_object_ref(self->fullWidget); | |
554 | } | |
555 | ||
556 | if (self->simpleWidget && self->fullWidget) | |
557 | { | |
558 | self->advanceCheckBox = gtk_check_button_new(); | |
559 | gtk_box_pack_end(GTK_BOX(self), self->advanceCheckBox, FALSE, TRUE, 0); | |
560 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(self->advanceCheckBox), FALSE); | |
561 | gtk_button_set_label(GTK_BUTTON(self->advanceCheckBox), _("Show Advance Option")); | |
562 | g_signal_connect(self->advanceCheckBox, "toggled", (GCallback) _fcitx_config_widget_toggle_simple_full, self); | |
563 | _fcitx_config_widget_toggle_simple_full(GTK_TOGGLE_BUTTON(self->advanceCheckBox), self); | |
564 | } | |
565 | ||
566 | if (self->config) | |
567 | dummy_config_sync(self->config); | |
568 | } | |
569 | ||
280 | 570 | FcitxConfigWidget* |
281 | 571 | fcitx_config_widget_new(FcitxConfigFileDesc* cfdesc, const gchar* prefix, const gchar* name, const char* subconfig) |
282 | 572 | { |
286 | 576 | "prefix", prefix, |
287 | 577 | "name", name, |
288 | 578 | "subconfig", subconfig, |
289 | NULL | |
290 | ); | |
579 | NULL); | |
291 | 580 | fcitx_config_widget_setup_ui(widget); |
292 | 581 | return widget; |
293 | 582 | } |
339 | 628 | case T_I18NString: |
340 | 629 | break; |
341 | 630 | case T_Integer: { |
342 | int value = atoi(option->rawValue); | |
343 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(arg), value); | |
631 | int i = *(int*) value; | |
632 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(arg), i); | |
344 | 633 | } |
345 | 634 | break; |
346 | 635 | case T_Color: { |
347 | 636 | int r = 0, g = 0, b = 0; |
348 | char scolor[9]; | |
349 | sscanf(option->rawValue, "%d %d %d", &r, &g, &b); | |
350 | r = RoundColor(r); | |
351 | g = RoundColor(g); | |
352 | b = RoundColor(b); | |
637 | FcitxConfigColor* rawcolor = (FcitxConfigColor*) value; | |
638 | r = RoundColor(rawcolor->r * 255); | |
639 | g = RoundColor(rawcolor->g * 255); | |
640 | b = RoundColor(rawcolor->b * 255); | |
641 | char scolor[10]; | |
353 | 642 | snprintf(scolor, 8 , "#%02X%02X%02X", r, g, b); |
354 | 643 | GdkRGBA color; |
355 | 644 | gdk_rgba_parse(&color, scolor); |
361 | 650 | } |
362 | 651 | break; |
363 | 652 | case T_Boolean: { |
364 | gboolean bl; | |
365 | if (strcmp(option->rawValue, "True") == 0) | |
366 | bl = TRUE; | |
367 | else | |
368 | bl = FALSE; | |
369 | ||
370 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(arg), bl); | |
653 | boolean *bl = (boolean*) value; | |
654 | ||
655 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(arg), *bl); | |
371 | 656 | } |
372 | 657 | break; |
373 | 658 | case T_Font: { |
374 | gtk_font_button_set_font_name(GTK_FONT_BUTTON(arg), option->rawValue); | |
659 | gtk_font_button_set_font_name(GTK_FONT_BUTTON(arg), *(char**) value); | |
375 | 660 | } |
376 | 661 | break; |
377 | 662 | case T_Enum: { |
378 | FcitxConfigEnum* cenum = &codesc->configEnum; | |
379 | int index = 0, i; | |
380 | for (i = 0; i < cenum->enumCount; i++) { | |
381 | if (strcmp(cenum->enumDesc[i], option->rawValue) == 0) { | |
382 | index = i; | |
383 | } | |
384 | } | |
663 | int index = *(int*) value; | |
385 | 664 | gtk_combo_box_set_active(GTK_COMBO_BOX(arg), index); |
386 | 665 | } |
387 | 666 | break; |
388 | 667 | case T_Hotkey: { |
389 | FcitxHotkey hotkey[2]; | |
668 | FcitxHotkey* hotkey = (FcitxHotkey*) value; | |
390 | 669 | int j; |
391 | FcitxHotkeySetKey(option->rawValue, hotkey); | |
392 | 670 | GArray *array = (GArray*) arg; |
393 | 671 | |
394 | 672 | for (j = 0; j < 2; j ++) { |
395 | 673 | GtkWidget *button = g_array_index(array, GtkWidget*, j); |
396 | 674 | keygrab_button_set_key(KEYGRAB_BUTTON(button), hotkey[j].sym, hotkey[j].state); |
397 | if (hotkey[j].desc) | |
398 | free(hotkey[j].desc); | |
399 | 675 | } |
400 | 676 | } |
401 | 677 | break; |
402 | 678 | case T_File: |
403 | 679 | case T_Char: |
404 | 680 | case T_String: { |
405 | gtk_entry_set_text(GTK_ENTRY(arg), option->rawValue); | |
681 | gtk_entry_set_text(GTK_ENTRY(arg), *(char**) value); | |
406 | 682 | } |
407 | 683 | break; |
408 | 684 | } |
415 | 691 | case T_I18NString: |
416 | 692 | break; |
417 | 693 | case T_Integer: { |
418 | int value; | |
419 | value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(arg)); | |
420 | option->rawValue = g_strdup_printf("%d", value); | |
694 | int* i = (int*) value; | |
695 | *i = gtk_spin_button_get_value(GTK_SPIN_BUTTON(arg));; | |
421 | 696 | } |
422 | 697 | break; |
423 | 698 | case T_Color: { |
424 | int r = 0, g = 0, b = 0; | |
425 | 699 | GdkRGBA color; |
426 | 700 | #if GTK_CHECK_VERSION(3,3,0) |
427 | 701 | gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(arg), &color); |
428 | 702 | #else |
429 | 703 | gtk_color_button_get_rgba(GTK_COLOR_BUTTON(arg), &color); |
430 | 704 | #endif |
431 | r = color.red * 256; | |
432 | g = color.green * 256; | |
433 | b = color.blue * 256; | |
434 | r = RoundColor(r); | |
435 | g = RoundColor(g); | |
436 | b = RoundColor(b); | |
437 | option->rawValue = g_strdup_printf("%d %d %d", r, g, b); | |
705 | FcitxConfigColor* rawcolor = (FcitxConfigColor*) value; | |
706 | rawcolor->r = color.red; | |
707 | rawcolor->g = color.green; | |
708 | rawcolor->b = color.blue; | |
438 | 709 | } |
439 | 710 | break; |
440 | 711 | case T_Boolean: { |
441 | gboolean bl; | |
442 | bl = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(arg)); | |
443 | if (bl) | |
444 | option->rawValue = strdup("True"); | |
445 | else | |
446 | option->rawValue = strdup("False"); | |
712 | boolean* bl = (boolean*) value; | |
713 | *bl = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(arg)); | |
447 | 714 | } |
448 | 715 | break; |
449 | 716 | case T_Font: { |
717 | char** fontname = (char**) value; | |
450 | 718 | const char *font = gtk_font_button_get_font_name(GTK_FONT_BUTTON(arg)); |
451 | PangoFontDescription *fontdesc = pango_font_description_from_string(font); | |
452 | if (fontdesc) { | |
453 | const char *family = pango_font_description_get_family(fontdesc); | |
454 | if (family) | |
455 | option->rawValue = strdup(family); | |
456 | else | |
457 | option->rawValue = strdup(""); | |
458 | pango_font_description_free(fontdesc); | |
459 | } else | |
460 | option->rawValue = strdup(""); | |
719 | UT_array* array = fcitx_utils_split_string(font, ' '); | |
720 | if (utarray_len(array) > 0) { | |
721 | char** s = (char**) utarray_back(array); | |
722 | char* p = *s; | |
723 | while (*p) { | |
724 | if (!isdigit(*p)) | |
725 | break; | |
726 | p++; | |
727 | } | |
728 | if (*p == '\0') | |
729 | utarray_pop_back(array); | |
730 | fcitx_utils_string_swap(fontname, fcitx_utils_join_string_list(array, ' ')); | |
731 | } | |
732 | else { | |
733 | fcitx_utils_string_swap(fontname, font); | |
734 | } | |
735 | fcitx_utils_free_string_list(array); | |
461 | 736 | } |
462 | 737 | break; |
463 | 738 | case T_Enum: { |
464 | FcitxConfigEnum* cenum = &codesc->configEnum; | |
465 | int index = 0; | |
466 | index = gtk_combo_box_get_active(GTK_COMBO_BOX(arg)); | |
467 | option->rawValue = strdup(cenum->enumDesc[index]); | |
739 | int* index = (int*) value; | |
740 | *index = gtk_combo_box_get_active(GTK_COMBO_BOX(arg)); | |
468 | 741 | } |
469 | 742 | break; |
470 | 743 | case T_Hotkey: { |
471 | 744 | GArray *array = (GArray*) arg; |
472 | GtkWidget *button; | |
473 | guint key; | |
474 | GdkModifierType mods; | |
475 | char *strkey[2] = { NULL, NULL }; | |
476 | int j = 0, k = 0; | |
745 | FcitxHotkey* hotkey = value; | |
746 | int j = 0; | |
477 | 747 | |
478 | 748 | for (j = 0; j < 2 ; j ++) { |
479 | button = g_array_index(array, GtkWidget*, j); | |
480 | keygrab_button_get_key(KEYGRAB_BUTTON(button), &key, &mods); | |
481 | strkey[k] = FcitxHotkeyGetKeyString(key, mods); | |
482 | if (strkey[k]) | |
483 | k ++; | |
749 | GtkWidget *button = g_array_index(array, GtkWidget*, j); | |
750 | keygrab_button_get_key(KEYGRAB_BUTTON(button), &hotkey[j].sym, &hotkey[j].state); | |
751 | char* keystring = FcitxHotkeyGetKeyString(hotkey[j].sym, hotkey[j].state); | |
752 | fcitx_utils_string_swap(&hotkey[j].desc, keystring); | |
753 | fcitx_utils_free(keystring); | |
484 | 754 | } |
485 | if (strkey[1]) | |
486 | option->rawValue = g_strdup_printf("%s %s", strkey[0], strkey[1]); | |
487 | else if (strkey[0]) { | |
488 | option->rawValue = strdup(strkey[0]); | |
489 | } else | |
490 | option->rawValue = strdup(""); | |
491 | ||
492 | for (j = 0 ; j < k ; j ++) | |
493 | free(strkey[j]); | |
494 | ||
495 | 755 | } |
496 | 756 | break; |
497 | 757 | case T_File: |
498 | 758 | case T_Char: |
499 | 759 | case T_String: { |
500 | option->rawValue = strdup(gtk_entry_get_text(GTK_ENTRY(arg))); | |
760 | char** str = (char**) value; | |
761 | fcitx_utils_string_swap(str, gtk_entry_get_text(GTK_ENTRY(arg))); | |
501 | 762 | } |
502 | 763 | break; |
503 | 764 | } |
514 | 775 | return; |
515 | 776 | |
516 | 777 | if (action == CONFIG_WIDGET_DEFAULT) { |
517 | FcitxConfigResetConfigToDefaultValue(&config_widget->gconfig); | |
518 | FcitxConfigBindSync(&config_widget->gconfig); | |
778 | FcitxConfigResetConfigToDefaultValue(&config_widget->config->config); | |
779 | dummy_config_sync(config_widget->config); | |
519 | 780 | } else if (action == CONFIG_WIDGET_SAVE) { |
520 | 781 | FILE* fp = FcitxXDGGetFileUserWithPrefix(config_widget->prefix, config_widget->name, "w", NULL); |
521 | 782 | |
522 | 783 | if (fp) { |
523 | FcitxConfigSaveConfigFileFp(fp, &config_widget->gconfig, config_widget->cfdesc); | |
784 | FcitxConfigSaveConfigFileFp(fp, &config_widget->config->config, config_widget->cfdesc); | |
524 | 785 | fclose(fp); |
525 | 786 | |
526 | 787 | GError* error; |
535 | 796 | |
536 | 797 | void fcitx_config_widget_finalize(GObject *object) |
537 | 798 | { |
538 | FcitxConfigWidget* config_widget = FCITX_CONFIG_WIDGET(object); | |
539 | g_free(config_widget->name); | |
540 | g_free(config_widget->prefix); | |
541 | sub_config_parser_free(config_widget->parser); | |
799 | FcitxConfigWidget* self = FCITX_CONFIG_WIDGET(object); | |
800 | g_free(self->name); | |
801 | g_free(self->prefix); | |
802 | sub_config_parser_free(self->parser); | |
803 | if (self->simpleWidget) | |
804 | g_object_unref(self->simpleWidget); | |
805 | if (self->fullWidget) | |
806 | g_object_unref(self->fullWidget); | |
807 | dummy_config_free(self->config); | |
542 | 808 | G_OBJECT_CLASS(fcitx_config_widget_parent_class)->finalize(object); |
543 | 809 | } |
544 | 810 | |
558 | 824 | int i = context->i; |
559 | 825 | |
560 | 826 | GtkWidget* label = gtk_label_new(dgettext(widget->parser->domain, subconfig->name)); |
561 | g_object_set(G_OBJECT(label),"xalign", 0.0f, "yalign", 0.0f, "margin", 5, NULL); | |
827 | g_object_set(G_OBJECT(label),"xalign", 1.0f, "yalign", 0.0f, NULL); | |
562 | 828 | |
563 | 829 | GtkWidget *inputWidget = GTK_WIDGET(fcitx_sub_config_widget_new(subconfig)); |
564 | 830 | |
565 | gtk_grid_attach(GTK_GRID(context->grid), label, 0, i, 1, 1); | |
566 | gtk_grid_attach(GTK_GRID(context->grid), inputWidget, 1, i, 1, 1); | |
831 | gtk_grid_attach(GTK_GRID(context->grid), label, context->j, i, 1, 1); | |
832 | gtk_grid_attach(GTK_GRID(context->grid), inputWidget, context->j + 1, i, 1, 1); | |
567 | 833 | context->i ++; |
568 | 834 | } |
569 | 835 |
26 | 26 | #include <fcitx-config/fcitx-config.h> |
27 | 27 | #include <fcitx/addon.h> |
28 | 28 | #include "sub_config_parser.h" |
29 | #include "dummy_config.h" | |
29 | 30 | |
30 | 31 | G_BEGIN_DECLS |
31 | 32 | |
46 | 47 | #define FCITX_CONFIG_WIDGET_GET_CLASS(obj) \ |
47 | 48 | (G_TYPE_INSTANCE_GET_CLASS ((obj), FCITX_TYPE_CONFIG_WIDGET, FcitxConfigWidgetClass)) |
48 | 49 | |
50 | ||
51 | enum UIType { | |
52 | CW_Simple = 0x1, | |
53 | CW_Full = 0x2, | |
54 | CW_NoShow = 0x0 | |
55 | }; | |
56 | ||
49 | 57 | typedef struct { |
50 | 58 | GtkBox parent; |
51 | 59 | FcitxConfigFileDesc* cfdesc; |
52 | 60 | gchar* prefix; |
53 | 61 | gchar* name; |
54 | 62 | FcitxSubConfigParser* parser; |
55 | FcitxGenericConfig gconfig; | |
63 | GHashTable* argmap; | |
64 | enum UIType fullUiType; | |
65 | enum UIType simpleUiType; | |
66 | GtkWidget* simpleWidget; | |
67 | GtkWidget* fullWidget; | |
68 | GtkWidget* advanceCheckBox; | |
69 | DummyConfig* config; | |
56 | 70 | } FcitxConfigWidget; |
57 | 71 | |
58 | 72 | typedef struct { |
0 | #include "dummy_config.h" | |
1 | #include <fcitx-config/hotkey.h> | |
2 | ||
3 | DummyConfig* dummy_config_new(FcitxConfigFileDesc* cfdesc) | |
4 | { | |
5 | DummyConfig* self = g_new0(DummyConfig, 1); | |
6 | self->cfdesc = cfdesc; | |
7 | self->config.configFile = NULL; | |
8 | self->dummy_value = g_hash_table_new_full(g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) free); | |
9 | /* malloc necessary value */ | |
10 | HASH_FOREACH(cgdesc, self->cfdesc->groupsDesc, FcitxConfigGroupDesc) { | |
11 | HASH_FOREACH(codesc, cgdesc->optionsDesc, FcitxConfigOptionDesc) { | |
12 | gchar* name = g_strdup_printf("%s/%s", cgdesc->groupName, codesc->optionName); | |
13 | void* value = g_hash_table_lookup(self->dummy_value, name); | |
14 | if (value) { | |
15 | g_free(name); | |
16 | continue; | |
17 | } | |
18 | switch (codesc->type) | |
19 | { | |
20 | #define OPTION_TYPE_CASE(NAME, TYPE) \ | |
21 | case T_##NAME: \ | |
22 | value = fcitx_utils_new(TYPE); \ | |
23 | break; | |
24 | OPTION_TYPE_CASE(Integer, int); | |
25 | OPTION_TYPE_CASE(Boolean, boolean); | |
26 | OPTION_TYPE_CASE(Char, char); | |
27 | OPTION_TYPE_CASE(Color, FcitxConfigColor); | |
28 | OPTION_TYPE_CASE(Enum, int); | |
29 | OPTION_TYPE_CASE(File, char*); | |
30 | OPTION_TYPE_CASE(Font, char*); | |
31 | OPTION_TYPE_CASE(Hotkey, FcitxHotkeys); | |
32 | OPTION_TYPE_CASE(String, char*); | |
33 | OPTION_TYPE_CASE(I18NString, char*); | |
34 | default: | |
35 | break; | |
36 | } | |
37 | if (value) | |
38 | g_hash_table_insert(self->dummy_value, name, value); | |
39 | else | |
40 | g_free(name); | |
41 | } | |
42 | } | |
43 | return self; | |
44 | } | |
45 | ||
46 | ||
47 | void dummy_config_free(DummyConfig* self) | |
48 | { | |
49 | FcitxConfigFree(&self->config); | |
50 | g_hash_table_destroy(self->dummy_value); | |
51 | g_free(self); | |
52 | } | |
53 | ||
54 | void dummy_config_load(DummyConfig* self, FILE* fp) | |
55 | { | |
56 | if (!self->config.configFile) { | |
57 | self->config.configFile = FcitxConfigParseConfigFileFp(fp, self->cfdesc); | |
58 | ||
59 | HASH_FOREACH(cgdesc, self->cfdesc->groupsDesc, FcitxConfigGroupDesc) { | |
60 | HASH_FOREACH(codesc, cgdesc->optionsDesc, FcitxConfigOptionDesc) { | |
61 | gchar* name = g_strdup_printf("%s/%s", cgdesc->groupName, codesc->optionName); | |
62 | void* value = g_hash_table_lookup(self->dummy_value, name); | |
63 | g_free(name); | |
64 | if (!value) | |
65 | continue; | |
66 | // assert(self->dummyValue[name]); | |
67 | FcitxConfigBindValue(self->config.configFile, cgdesc->groupName, codesc->optionName, value, NULL, NULL); | |
68 | } | |
69 | } | |
70 | } | |
71 | else { | |
72 | self->config.configFile = FcitxConfigParseIniFp(fp, self->config.configFile); | |
73 | } | |
74 | ||
75 | } | |
76 | ||
77 | void dummy_config_sync(DummyConfig* self) | |
78 | { | |
79 | FcitxConfigBindSync(&self->config); | |
80 | } | |
81 | ||
82 | gboolean dummy_config_valid(DummyConfig* self) | |
83 | { | |
84 | return self->config.configFile != NULL; | |
85 | } | |
86 | ||
87 | void dummy_config_bind(DummyConfig* self, char* group, char* option, FcitxSyncFilter filter, void* arg) | |
88 | { | |
89 | if (!self->config.configFile) | |
90 | return; | |
91 | gchar* name = g_strdup_printf("%s/%s", group, option); | |
92 | void* value = g_hash_table_lookup(self->dummy_value, name); | |
93 | g_free(name); | |
94 | if (!value) | |
95 | return; | |
96 | ||
97 | // assert(self->dummyValue[name]); | |
98 | FcitxConfigBindValue(self->config.configFile, group, option, value, filter, arg); | |
99 | ||
100 | }⏎ |
0 | #ifndef DUMMY_CONFIG_H | |
1 | #define DUMMY_CONFIG_H | |
2 | ||
3 | #include <glib.h> | |
4 | #include <fcitx-config/fcitx-config.h> | |
5 | ||
6 | typedef struct _DummyConfig { | |
7 | GHashTable* dummy_value; | |
8 | FcitxGenericConfig config; | |
9 | FcitxConfigFile* cfile; | |
10 | FcitxConfigFileDesc* cfdesc; | |
11 | } DummyConfig; | |
12 | ||
13 | DummyConfig* dummy_config_new(FcitxConfigFileDesc* cfdesc); | |
14 | void dummy_config_free(DummyConfig* self); | |
15 | void dummy_config_load(DummyConfig* self, FILE* fp); | |
16 | void dummy_config_bind(DummyConfig* self, char* group, char* option, FcitxSyncFilter filter, void* arg); | |
17 | gboolean dummy_config_valid(DummyConfig* self); | |
18 | void dummy_config_sync(DummyConfig* self); | |
19 | ||
20 | ||
21 | #endif // DUMMY_CONFIG_H⏎ |
118 | 118 | if (parent) |
119 | 119 | gtk_window_set_transient_for (GTK_WINDOW (self), parent); |
120 | 120 | |
121 | gtk_window_set_title(GTK_WINDOW(self), addon->generalname); | |
121 | if (addon) { | |
122 | gtk_window_set_title(GTK_WINDOW(self), addon->generalname); | |
123 | } | |
124 | else | |
125 | gtk_window_set_title(GTK_WINDOW(self), _("Default keyboard layout")); | |
122 | 126 | GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(self)); |
127 | g_object_set(G_OBJECT(content_area), "margin", 5, NULL); | |
123 | 128 | self->imname = g_strdup(imname); |
129 | ||
130 | FcitxConfigFileDesc* cfdesc = NULL; | |
131 | gboolean configurable = FALSE; | |
132 | if (addon) { | |
133 | gchar* config_desc_name = g_strdup_printf("%s.desc", addon->name); | |
134 | cfdesc = get_config_desc(config_desc_name); | |
135 | g_free(config_desc_name); | |
136 | configurable = (gboolean)(cfdesc != NULL || strlen(addon->subconfig) != 0); | |
137 | } | |
124 | 138 | |
125 | 139 | do { |
126 | 140 | |
140 | 154 | self->model = gtk_list_store_new(N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); |
141 | 155 | GtkTreeIter iter; |
142 | 156 | gtk_list_store_append(self->model, &iter); |
143 | gtk_list_store_set(self->model, &iter, LIST_NAME, _("System Default"), LIST_LAYOUT, "", LIST_VARIANT, "", -1); | |
157 | gtk_list_store_set(self->model, &iter, LIST_NAME, addon ? _("Input Method Default") : _("Default"), LIST_LAYOUT, "", LIST_VARIANT, "", -1); | |
144 | 158 | layout_foreach_ct context; |
145 | 159 | context.model = self->model; |
146 | 160 | context.layout = layout; |
167 | 181 | gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combobox), &context.iter); |
168 | 182 | else |
169 | 183 | gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combobox), &iter); |
170 | GtkWidget* label = gtk_label_new(_("Keyboard layout:")); | |
171 | g_object_set(label, "xalign", 0.0f, NULL); | |
172 | gtk_box_pack_start(GTK_BOX(content_area), label, TRUE, TRUE, 5); | |
184 | ||
185 | if (configurable || !addon) { | |
186 | gchar* markup = g_strdup_printf("<b>%s</b>", addon ? _("Keyboard layout:") : _("Keyboard layout to use when no input method active:")); | |
187 | GtkWidget* label = gtk_label_new(NULL); | |
188 | gtk_label_set_markup(GTK_LABEL(label), markup); | |
189 | g_free(markup); | |
190 | g_object_set(label, "xalign", 0.0f, NULL); | |
191 | gtk_box_pack_start(GTK_BOX(content_area), label, TRUE, TRUE, 5); | |
192 | } | |
173 | 193 | gtk_box_pack_start(GTK_BOX(content_area), combobox, FALSE, TRUE, 5); |
174 | 194 | self->combobox = combobox; |
175 | 195 | |
176 | 196 | } while(0); |
177 | 197 | |
178 | gchar* config_desc_name = g_strdup_printf("%s.desc", addon->name); | |
179 | FcitxConfigFileDesc* cfdesc = get_config_desc(config_desc_name); | |
180 | g_free(config_desc_name); | |
181 | gboolean configurable = (gboolean)(cfdesc != NULL || strlen(addon->subconfig) != 0); | |
182 | if (configurable) { | |
183 | GtkWidget* label = gtk_label_new(_("Input method settings:")); | |
184 | g_object_set(label, "xalign", 0.0f, NULL); | |
185 | gtk_box_pack_start(GTK_BOX(content_area), label, TRUE, TRUE, 5); | |
186 | gchar* config_file_name = g_strdup_printf("%s.config", addon->name); | |
187 | self->config_widget = fcitx_config_widget_new(cfdesc, "conf", config_file_name, addon->subconfig); | |
188 | gtk_box_pack_start(GTK_BOX(content_area), GTK_WIDGET(self->config_widget), TRUE, TRUE, 0); | |
189 | g_free(config_file_name); | |
190 | gtk_widget_set_size_request(GTK_WIDGET(self->config_widget), -1, 400); | |
191 | } | |
192 | ||
198 | do { | |
199 | if (!addon) | |
200 | break; | |
201 | if (configurable) { | |
202 | if (self->combobox) { | |
203 | gchar* markup = g_strdup_printf("<b>%s</b>", _("Input method settings:")); | |
204 | GtkWidget* label = gtk_label_new(NULL); | |
205 | gtk_label_set_markup(GTK_LABEL(label), markup); | |
206 | g_free(markup); | |
207 | g_object_set(label, "xalign", 0.0f, NULL); | |
208 | gtk_box_pack_start(GTK_BOX(content_area), label, TRUE, TRUE, 5); | |
209 | } | |
210 | gchar* config_file_name = g_strdup_printf("%s.config", addon->name); | |
211 | self->config_widget = fcitx_config_widget_new(cfdesc, "conf", config_file_name, addon->subconfig); | |
212 | g_object_set(G_OBJECT(self->config_widget), "margin", 5, NULL); | |
213 | gtk_box_pack_start(GTK_BOX(content_area), GTK_WIDGET(self->config_widget), TRUE, TRUE, 0); | |
214 | g_free(config_file_name); | |
215 | gtk_widget_set_size_request(GTK_WIDGET(self->config_widget), -1, 400); | |
216 | } | |
217 | } while(0); | |
193 | 218 | |
194 | 219 | g_signal_connect(self, "response", |
195 | 220 | G_CALLBACK(_fcitx_im_config_dialog_response_cb), |
43 | 43 | { |
44 | 44 | FcitxImDialog* self = FCITX_IM_DIALOG(object); |
45 | 45 | if (self->array) { |
46 | g_ptr_array_set_free_func(self->array, fcitx_im_item_free); | |
46 | g_ptr_array_set_free_func(self->array, (GDestroyNotify) fcitx_im_item_free); | |
47 | 47 | g_ptr_array_free(self->array, FALSE); |
48 | 48 | self->array = NULL; |
49 | 49 | } |
169 | 169 | gtk_list_store_clear(self->availimstore); |
170 | 170 | |
171 | 171 | if (self->array) { |
172 | g_ptr_array_set_free_func(self->array, fcitx_im_item_free); | |
172 | g_ptr_array_set_free_func(self->array, (GDestroyNotify) fcitx_im_item_free); | |
173 | 173 | g_ptr_array_free(self->array, FALSE); |
174 | 174 | self->array = NULL; |
175 | 175 | } |
255 | 255 | |
256 | 256 | gboolean flag = TRUE; |
257 | 257 | if (item) { |
258 | flag = flag && (strlen(filter_text) == 0 | |
259 | || strstr(item->name, filter_text) | |
260 | || strstr(item->unique_name, filter_text) | |
261 | || strstr(item->langcode, filter_text)); | |
262 | flag = flag && (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self->onlycurlangcheckbox)) ? | |
263 | strncmp(item->langcode, _get_current_lang() , 2) == 0 : TRUE) ; | |
258 | if (strcmp(item->unique_name, "fcitx-keyboard-us") != 0) { | |
259 | flag = flag && ( | |
260 | strlen(filter_text) == 0 | |
261 | || strstr(item->name, filter_text) | |
262 | || strstr(item->unique_name, filter_text) | |
263 | || strstr(item->langcode, filter_text)); | |
264 | flag = flag && (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self->onlycurlangcheckbox)) ? | |
265 | strncmp(item->langcode, _get_current_lang() , 2) == 0 : TRUE) ; | |
266 | } | |
264 | 267 | } |
265 | 268 | return flag; |
266 | 269 | } |
318 | 321 | gpointer data) |
319 | 322 | { |
320 | 323 | gtk_entry_set_text (entry, ""); |
321 | }⏎ | |
324 | } |
59 | 59 | static void _fcitx_im_widget_moveup_button_clicked(GtkButton* button, gpointer user_data); |
60 | 60 | static void _fcitx_im_widget_movedown_button_clicked(GtkButton* button, gpointer user_data); |
61 | 61 | static void _fcitx_im_widget_configure_button_clicked(GtkButton* button, gpointer user_data); |
62 | static void _fcitx_im_widget_default_layout_button_clicked(GtkButton* button, gpointer user_data); | |
62 | 63 | |
63 | 64 | static void |
64 | 65 | fcitx_im_widget_class_init(FcitxImWidgetClass *klass) |
104 | 105 | GtkToolItem* item; |
105 | 106 | /* add and remove */ |
106 | 107 | self->addimbutton = gtk_button_new(); |
107 | gtk_button_set_image(GTK_BUTTON(self->addimbutton), gtk_image_new_from_icon_name("list-add-symbolic", GTK_ICON_SIZE_BUTTON)); | |
108 | gtk_button_set_image(GTK_BUTTON(self->addimbutton), | |
109 | gtk_image_new_from_gicon(g_themed_icon_new_with_default_fallbacks("list-add-symbolic"), GTK_ICON_SIZE_BUTTON)); | |
108 | 110 | |
109 | 111 | self->delimbutton = gtk_button_new(); |
110 | gtk_button_set_image(GTK_BUTTON(self->delimbutton), gtk_image_new_from_icon_name("list-remove-symbolic", GTK_ICON_SIZE_BUTTON)); | |
112 | gtk_button_set_image(GTK_BUTTON(self->delimbutton), | |
113 | gtk_image_new_from_gicon(g_themed_icon_new_with_default_fallbacks("list-remove-symbolic"), GTK_ICON_SIZE_BUTTON)); | |
111 | 114 | gtk_widget_set_sensitive(self->delimbutton, FALSE); |
112 | 115 | |
113 | 116 | hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); |
125 | 128 | |
126 | 129 | /* move up and move down */ |
127 | 130 | self->moveupbutton = gtk_button_new(); |
128 | gtk_button_set_image(GTK_BUTTON(self->moveupbutton), gtk_image_new_from_icon_name("go-up-symbolic", GTK_ICON_SIZE_BUTTON)); | |
131 | gtk_button_set_image(GTK_BUTTON(self->moveupbutton), | |
132 | gtk_image_new_from_gicon(g_themed_icon_new_with_default_fallbacks("go-up-symbolic"), GTK_ICON_SIZE_BUTTON)); | |
129 | 133 | gtk_widget_set_sensitive(self->moveupbutton, FALSE); |
130 | 134 | |
131 | 135 | self->movedownbutton = gtk_button_new(); |
132 | gtk_button_set_image(GTK_BUTTON(self->movedownbutton), gtk_image_new_from_icon_name("go-down-symbolic", GTK_ICON_SIZE_BUTTON)); | |
136 | gtk_button_set_image(GTK_BUTTON(self->movedownbutton), | |
137 | gtk_image_new_from_gicon(g_themed_icon_new_with_default_fallbacks("go-down-symbolic"), GTK_ICON_SIZE_BUTTON)); | |
133 | 138 | gtk_widget_set_sensitive(self->movedownbutton, FALSE); |
134 | 139 | |
135 | 140 | hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); |
147 | 152 | |
148 | 153 | /* configure */ |
149 | 154 | self->configurebutton = gtk_button_new(); |
150 | gtk_button_set_image(GTK_BUTTON(self->configurebutton), gtk_image_new_from_icon_name("preferences-system-symbolic", GTK_ICON_SIZE_BUTTON)); | |
155 | gtk_button_set_image(GTK_BUTTON(self->configurebutton), | |
156 | gtk_image_new_from_gicon(g_themed_icon_new_with_default_fallbacks("preferences-system-symbolic"), GTK_ICON_SIZE_BUTTON)); | |
151 | 157 | gtk_widget_set_sensitive(self->configurebutton, FALSE); |
158 | self->default_layout_button = gtk_button_new(); | |
159 | gtk_button_set_image(GTK_BUTTON(self->default_layout_button), | |
160 | gtk_image_new_from_gicon(g_themed_icon_new_with_default_fallbacks("input-keyboard-symbolic"), GTK_ICON_SIZE_BUTTON)); | |
152 | 161 | |
153 | 162 | hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); |
154 | 163 | |
155 | 164 | gtk_box_pack_start(GTK_BOX(hbox), self->configurebutton, FALSE, FALSE, 0); |
165 | gtk_box_pack_start(GTK_BOX(hbox), self->default_layout_button, FALSE, FALSE, 0); | |
156 | 166 | item = gtk_tool_item_new(); |
157 | 167 | gtk_container_add(GTK_CONTAINER(item), hbox); |
158 | 168 | |
174 | 184 | g_signal_connect(G_OBJECT(self->moveupbutton), "clicked", G_CALLBACK(_fcitx_im_widget_moveup_button_clicked), self); |
175 | 185 | g_signal_connect(G_OBJECT(self->movedownbutton), "clicked", G_CALLBACK(_fcitx_im_widget_movedown_button_clicked), self); |
176 | 186 | g_signal_connect(G_OBJECT(self->configurebutton), "clicked", G_CALLBACK(_fcitx_im_widget_configure_button_clicked), self); |
187 | g_signal_connect(G_OBJECT(self->default_layout_button), "clicked", G_CALLBACK(_fcitx_im_widget_default_layout_button_clicked), self); | |
177 | 188 | |
178 | 189 | |
179 | 190 | _fcitx_im_widget_connect(self); |
193 | 204 | { |
194 | 205 | FcitxImWidget* self = FCITX_IM_WIDGET(object); |
195 | 206 | if (self->array) { |
196 | g_ptr_array_set_free_func(self->array, fcitx_im_item_free); | |
207 | g_ptr_array_set_free_func(self->array, (GDestroyNotify) fcitx_im_item_free); | |
197 | 208 | g_ptr_array_free(self->array, FALSE); |
198 | 209 | self->array = NULL; |
199 | 210 | } |
232 | 243 | gtk_list_store_clear(self->imstore); |
233 | 244 | |
234 | 245 | if (self->array) { |
235 | g_ptr_array_set_free_func(self->array, fcitx_im_item_free); | |
246 | g_ptr_array_set_free_func(self->array, (GDestroyNotify) fcitx_im_item_free); | |
236 | 247 | g_ptr_array_free(self->array, FALSE); |
237 | 248 | self->array = NULL; |
238 | 249 | } |
412 | 423 | } |
413 | 424 | } |
414 | 425 | |
426 | void _fcitx_im_widget_default_layout_button_clicked(GtkButton* button, gpointer user_data) | |
427 | { | |
428 | FcitxImWidget* self = user_data; | |
429 | FcitxMainWindow* mainwindow = FCITX_MAIN_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET(self))); | |
430 | do { | |
431 | if (!mainwindow) | |
432 | break; | |
433 | ||
434 | GtkWidget* dialog = fcitx_im_config_dialog_new(GTK_WINDOW(mainwindow), NULL, "default"); | |
435 | if (dialog) | |
436 | gtk_widget_show_all(GTK_WIDGET(dialog)); | |
437 | } while(0); | |
438 | } | |
439 | ||
415 | 440 | void _fcitx_im_widget_configure_button_clicked(GtkButton* button, gpointer user_data) |
416 | 441 | { |
417 | 442 | FcitxImWidget* self = user_data; |
57 | 57 | GtkWidget* moveupbutton; |
58 | 58 | GtkWidget* movedownbutton; |
59 | 59 | GtkWidget* configurebutton; |
60 | GtkWidget* default_layout_button; | |
60 | 61 | }; |
61 | 62 | |
62 | 63 | struct _FcitxImWidgetClass { |
25 | 25 | #include <fcitx-config/hotkey.h> |
26 | 26 | |
27 | 27 | #define _(s) gettext(s) |
28 | //定义枚举类型,说明信号的名称和次序 | |
28 | ||
29 | 29 | enum { |
30 | 30 | KEYGRAB_BUTTON_CHANGED, |
31 | KEYGRAB_BUTTON_CURRENT_CHANGED, | |
32 | 31 | LAST_SIGNAL |
33 | 32 | }; |
34 | 33 | static gint keygrab_button_signals[LAST_SIGNAL] = { 0 }; |
35 | static void keygrab_button_init(KeyGrabButton *keygrab_button); | |
34 | static void keygrab_button_init(KeyGrabButton* self); | |
36 | 35 | static void keygrab_button_class_init(KeyGrabButtonClass *keygrabbuttonclass); |
37 | 36 | static void begin_key_grab(KeyGrabButton* self, gpointer v); |
38 | 37 | static void end_key_grab(KeyGrabButton *self); |
41 | 40 | |
42 | 41 | G_DEFINE_TYPE(KeyGrabButton, keygrab_button, GTK_TYPE_BUTTON) |
43 | 42 | |
44 | static void keygrab_button_init(KeyGrabButton *keygrabbutton) | |
43 | static void keygrab_button_init(KeyGrabButton *self) | |
45 | 44 | { |
46 | keygrab_button_set_key(keygrabbutton, 0, 0); | |
47 | gtk_widget_set_size_request(GTK_WIDGET(keygrabbutton), 150, -1); | |
48 | ||
49 | g_signal_connect(G_OBJECT(keygrabbutton), "clicked", (GCallback) begin_key_grab, NULL); | |
50 | 45 | } |
51 | 46 | |
52 | 47 | static void keygrab_button_class_init(KeyGrabButtonClass *keygrabbuttonclass) |
56 | 51 | keygrab_button_signals[KEYGRAB_BUTTON_CHANGED] = g_signal_new("changed", |
57 | 52 | G_TYPE_FROM_CLASS(object_class), |
58 | 53 | G_SIGNAL_RUN_FIRST, |
59 | G_STRUCT_OFFSET(KeyGrabButtonClass, changed), | |
60 | NULL, NULL, | |
61 | g_cclosure_marshal_VOID__VOID, | |
62 | G_TYPE_NONE, 0, NULL); | |
63 | keygrab_button_signals[KEYGRAB_BUTTON_CURRENT_CHANGED] = g_signal_new("current-changed", | |
64 | G_TYPE_FROM_CLASS(object_class), | |
65 | G_SIGNAL_RUN_FIRST, | |
66 | G_STRUCT_OFFSET(KeyGrabButtonClass, current_changed), | |
54 | 0, | |
67 | 55 | NULL, NULL, |
68 | 56 | g_cclosure_marshal_VOID__VOID, |
69 | 57 | G_TYPE_NONE, 0, NULL); |
71 | 59 | //创建新的自定义控件 |
72 | 60 | GtkWidget* keygrab_button_new(void) |
73 | 61 | { |
74 | return GTK_WIDGET(g_object_new(TYPE_KEYGRAB_BUTTON, 0)); | |
62 | KeyGrabButton *self = KEYGRAB_BUTTON(g_object_new(TYPE_KEYGRAB_BUTTON, | |
63 | "label", _("Empty"), | |
64 | NULL)); | |
65 | self->key = 0; | |
66 | self->mods = 0; | |
67 | gtk_widget_set_size_request(GTK_WIDGET(self), 150, -1); | |
68 | ||
69 | g_signal_connect(G_OBJECT(self), "clicked", (GCallback) begin_key_grab, NULL); | |
70 | return GTK_WIDGET(self); | |
75 | 71 | } |
76 | 72 | |
77 | 73 | |
121 | 117 | |
122 | 118 | if ((event->keyval == GDK_KEY_Escape |
123 | 119 | || event->keyval == GDK_KEY_Return) && !mods) { |
124 | if (event->keyval == GDK_KEY_Escape) | |
125 | g_signal_emit_by_name(G_OBJECT(b), "changed", b->key, b->mods); | |
126 | 120 | end_key_grab(b); |
127 | 121 | keygrab_button_set_key(b, 0, 0); |
128 | 122 | return; |
136 | 130 | || (key == GDK_KEY_Tab && mods)) { |
137 | 131 | keygrab_button_set_key(b, key, mods); |
138 | 132 | end_key_grab(b); |
139 | b->key = key; | |
140 | b->mods = mods; | |
141 | g_signal_emit_by_name(G_OBJECT(b), "changed", b->key, b->mods); | |
142 | 133 | return; |
143 | 134 | } |
144 | 135 | |
151 | 142 | mods &= ~GDK_SUPER_MASK; |
152 | 143 | mods |= FcitxKeyState_Super; |
153 | 144 | } |
154 | KeyGrabButton* b = KEYGRAB_BUTTON(self); | |
155 | 145 | gchar *label; |
156 | b->key = key; | |
157 | b->mods = mods; | |
146 | if (self->key != key || self->mods != mods) { | |
147 | self->key = key; | |
148 | self->mods = mods; | |
149 | g_signal_emit_by_name(G_OBJECT(self), "changed", self->key, self->mods); | |
150 | } | |
151 | else { | |
152 | return; | |
153 | } | |
158 | 154 | |
159 | 155 | label = FcitxHotkeyGetKeyString(key, mods); |
160 | 156 | |
161 | 157 | if (label == NULL || strlen(label) == 0) { |
162 | gtk_button_set_label(GTK_BUTTON(b), _("Empty")); | |
158 | gtk_button_set_label(GTK_BUTTON(self), _("Empty")); | |
163 | 159 | } else { |
164 | gchar* lb = label; | |
165 | gtk_button_set_label(GTK_BUTTON(b), lb); | |
160 | gtk_button_set_label(GTK_BUTTON(self), label); | |
166 | 161 | } |
167 | 162 | |
168 | 163 | if (label) |
20 | 20 | #define KEYGRAB_H |
21 | 21 | |
22 | 22 | #include <gtk/gtk.h> |
23 | //定义类型宏和转换宏 | |
23 | ||
24 | 24 | #define TYPE_KEYGRAB_BUTTON (keygrab_button_get_type()) |
25 | 25 | #define KEYGRAB_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj,TYPE_KEYGRAB_BUTTON,KeyGrabButton)) |
26 | //定义实例结构和类结构 | |
26 | ||
27 | 27 | typedef struct _KeyGrabButton KeyGrabButton; |
28 | 28 | typedef struct _KeyGrabButtonClass KeyGrabButtonClass; |
29 | 29 | struct _KeyGrabButton { |
30 | GtkButton parent; //父控件为横向盒状容器 | |
30 | GtkButton parent; | |
31 | 31 | GtkWidget* popup; |
32 | 32 | gulong handler; |
33 | 33 | guint key; |
35 | 35 | }; |
36 | 36 | struct _KeyGrabButtonClass { |
37 | 37 | GtkButtonClass parent_class; |
38 | void (*changed)(int, int); | |
39 | void (*current_changed)(int, int); | |
40 | 38 | }; |
41 | 39 | |
42 | 40 | GType keygrab_button_get_type(void); |
30 | 30 | #include "config_widget.h" |
31 | 31 | #include "configdesc.h" |
32 | 32 | #include "im_widget.h" |
33 | #include "ui_widget.h" | |
33 | 34 | |
34 | 35 | enum { |
35 | 36 | LIST_ADDON, |
45 | 46 | static void _fcitx_main_window_add_addon_page(FcitxMainWindow* self); |
46 | 47 | |
47 | 48 | static void _fcitx_main_window_add_im_page(FcitxMainWindow* self); |
49 | ||
50 | static void _fcitx_main_window_add_ui_page(FcitxMainWindow* self); | |
48 | 51 | |
49 | 52 | void _fcitx_main_window_add_page(FcitxMainWindow* self, const char* name, GtkWidget* widget, const char* stock); |
50 | 53 | |
88 | 91 | |
89 | 92 | _fcitx_main_window_add_im_page(self); |
90 | 93 | _fcitx_main_window_add_config_file_page(self); |
94 | _fcitx_main_window_add_ui_page(self); | |
91 | 95 | _fcitx_main_window_add_addon_page(self); |
92 | 96 | |
93 | 97 | gtk_widget_set_size_request(GTK_WIDGET(self), -1, 400); |
183 | 187 | _fcitx_main_window_add_page(self, _("Input Method"), imwidget, GTK_STOCK_EDIT); |
184 | 188 | } |
185 | 189 | |
190 | gboolean _ui_connect(gpointer user_data) | |
191 | { | |
192 | fcitx_ui_widget_connect(FCITX_UI_WIDGET(user_data)); | |
193 | return false; | |
194 | } | |
195 | ||
196 | void _fcitx_main_window_add_ui_page(FcitxMainWindow* self) | |
197 | { | |
198 | GtkWidget* uiwidget = fcitx_ui_widget_new(); | |
199 | _fcitx_main_window_add_page(self, _("Appearance"), uiwidget, GTK_STOCK_ABOUT); | |
200 | ||
201 | g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, (GSourceFunc)_ui_connect, g_object_ref(uiwidget), (GDestroyNotify) g_object_unref); | |
202 | } | |
203 | ||
186 | 204 | gboolean _filter_addon_func(GtkTreeModel *model, |
187 | 205 | GtkTreeIter *iter, |
188 | 206 | gpointer data) |
197 | 215 | |
198 | 216 | gboolean flag = TRUE; |
199 | 217 | if (addon) { |
200 | if ((addon->category == AC_FRONTEND || addon->advance) && !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self->advancecheckbox))) { | |
218 | if ((addon->category == AC_FRONTEND || !addon->bEnabled || addon->advance) && !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self->advancecheckbox))) { | |
201 | 219 | return false; |
202 | 220 | } |
203 | 221 | flag = flag && (strlen(filter_text) == 0 |
45 | 45 | if (strcmp(str, "configfile") == 0) { |
46 | 46 | return SC_ConfigFile; |
47 | 47 | } |
48 | if (strcmp(str, "program") == 0) { | |
49 | return SC_Program; | |
50 | } | |
48 | 51 | return SC_None; |
49 | 52 | } |
50 | 53 | |
85 | 88 | goto end; |
86 | 89 | if (strlen(items[2]) == 0 || items[2][0] == '/') |
87 | 90 | goto end; |
88 | } else if (type == SC_NativeFile) { | |
91 | } else if (type == SC_NativeFile || type == SC_Program) { | |
89 | 92 | if (g_strv_length(items) != 3) |
90 | 93 | goto end; |
91 | 94 | if (strchr(items[2], '*') != NULL) |
117 | 120 | pattern->configdesc = g_strdup(items[3]); |
118 | 121 | else if (type == SC_NativeFile) |
119 | 122 | pattern->nativepath = g_strdup(items[2]); |
123 | else if (type == SC_Program) | |
124 | pattern->path = g_strdup(items[2]); | |
120 | 125 | |
121 | 126 | g_hash_table_insert(parser->subconfigs, g_strdup(items[0]), pattern); |
122 | 127 | end: |
147 | 152 | if (pattern->patternlist) |
148 | 153 | g_strfreev(pattern->patternlist); |
149 | 154 | |
150 | if (pattern->configdesc) | |
151 | g_free(pattern->configdesc); | |
152 | ||
153 | if (pattern->nativepath) | |
154 | g_free(pattern->nativepath); | |
155 | g_free(pattern->configdesc); | |
156 | ||
157 | g_free(pattern->nativepath); | |
158 | g_free(pattern->path); | |
155 | 159 | |
156 | 160 | g_free(pattern); |
157 | 161 | } |
165 | 169 | subconfig->type = pattern->type; |
166 | 170 | subconfig->configdesc = g_strdup(pattern->configdesc); |
167 | 171 | subconfig->nativepath = g_strdup(pattern->nativepath); |
172 | subconfig->path = g_strdup(pattern->path); | |
168 | 173 | subconfig->name = g_strdup(name); |
169 | 174 | subconfig->filelist = sub_config_pattern_get_filelist(pattern); |
170 | 175 | |
192 | 197 | { |
193 | 198 | size_t size, i; |
194 | 199 | GHashTable* result = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); |
195 | #if FCITX_CHECK_VERSION(4,2,1) | |
196 | 200 | char** xdgpath = FcitxXDGGetPathWithPrefix(&size, ""); |
197 | #else | |
198 | char** xdgpath = FcitxXDGGetPath(&size, "XDG_CONFIG_HOME", ".config" , PACKAGE , DATADIR, PACKAGE); | |
199 | #endif | |
200 | 201 | |
201 | 202 | for (i = 0; i < size; i ++) { |
202 | 203 | char* dirpath = realpath(xdgpath[i], NULL); |
23 | 23 | typedef enum { |
24 | 24 | SC_None, |
25 | 25 | SC_ConfigFile, |
26 | SC_Program, | |
26 | 27 | SC_NativeFile |
27 | 28 | } SubConfigType; |
28 | 29 | |
31 | 32 | gchar* configdesc; |
32 | 33 | gchar* nativepath; |
33 | 34 | gchar** patternlist; |
35 | gchar* path; | |
34 | 36 | } FcitxSubConfigPattern; |
35 | 37 | |
36 | 38 | typedef struct { |
39 | 41 | GHashTable* filelist; |
40 | 42 | gchar* nativepath; |
41 | 43 | gchar* configdesc; |
44 | gchar* path; | |
42 | 45 | } FcitxSubConfig; |
43 | 46 | |
44 | 47 | typedef struct { |
28 | 28 | |
29 | 29 | static void open_subconfig_file(GtkButton *button, gpointer user_data); |
30 | 30 | static void open_native_file(GtkButton *button, gpointer user_data); |
31 | static void run_program(GtkButton *button, gpointer user_data); | |
31 | 32 | static void push_into_store_cb(gpointer data, gpointer value, gpointer user_data); |
32 | 33 | |
33 | 34 | static void |
94 | 95 | gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE); |
95 | 96 | |
96 | 97 | GtkWidget* swin = gtk_scrolled_window_new(NULL, NULL); |
97 | g_object_set(swin, "hscrollbar-policy", GTK_POLICY_NEVER, "vscrollbar-policy", GTK_POLICY_NEVER, NULL); | |
98 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); | |
98 | 99 | gtk_container_add(GTK_CONTAINER(swin), view); |
99 | gtk_box_pack_start(GTK_BOX(widget), swin, FALSE, FALSE, 0); | |
100 | gtk_box_pack_start(GTK_BOX(widget), swin, TRUE, TRUE, 0); | |
100 | 101 | g_object_set(G_OBJECT(swin), "margin-left", 5, "margin-right", 5, "shadow-type", GTK_SHADOW_IN, NULL); |
101 | 102 | |
102 | 103 | GtkListStore* store = gtk_list_store_new(1, G_TYPE_STRING); |
120 | 121 | GtkWidget* button = gtk_button_new(); |
121 | 122 | gtk_button_set_image(GTK_BUTTON(button), gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON)); |
122 | 123 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(open_native_file), widget); |
124 | gtk_box_pack_start(GTK_BOX(widget), button, FALSE, FALSE, 0); | |
125 | } | |
126 | break; | |
127 | case SC_Program: { | |
128 | GtkWidget* button = gtk_button_new(); | |
129 | gtk_button_set_image(GTK_BUTTON(button), gtk_image_new_from_stock(GTK_STOCK_EXECUTE, GTK_ICON_SIZE_BUTTON)); | |
130 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(run_program), widget); | |
123 | 131 | gtk_box_pack_start(GTK_BOX(widget), button, FALSE, FALSE, 0); |
124 | 132 | } |
125 | 133 | break; |
202 | 210 | } |
203 | 211 | } |
204 | 212 | |
213 | void run_program(GtkButton* button, gpointer user_data) | |
214 | { | |
215 | FcitxSubConfigWidget* widget = (FcitxSubConfigWidget*) user_data; | |
216 | char*args[] = {widget->subconfig->path}; | |
217 | fcitx_utils_start_process(args); | |
218 | ||
219 | } | |
205 | 220 | |
206 | 221 | void push_into_store_cb(gpointer data, |
207 | 222 | gpointer value, |
0 | /*************************************************************************** | |
1 | * Copyright (C) 2010~2012 by CSSlayer * | |
2 | * * | |
3 | * This program is free software; you can redistribute it and/or modify * | |
4 | * it under the terms of the GNU General Public License as published by * | |
5 | * the Free Software Foundation; either version 2 of the License, or * | |
6 | * (at your option) any later version. * | |
7 | * * | |
8 | * This program is distributed in the hope that it will be useful, * | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
11 | * GNU General Public License for more details. * | |
12 | * * | |
13 | * You should have received a copy of the GNU General Public License * | |
14 | * along with this program; if not, write to the * | |
15 | * Free Software Foundation, Inc., * | |
16 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * | |
17 | ***************************************************************************/ | |
18 | ||
19 | #include <fcitx-utils/utils.h> | |
20 | #include <fcitx/module/dbus/dbusstuff.h> | |
21 | #include <fcitx/module/ipc/ipc.h> | |
22 | ||
23 | #include "common.h" | |
24 | #include "ui_widget.h" | |
25 | #include "gdm-languages.h" | |
26 | #include "config_widget.h" | |
27 | #include "main_window.h" | |
28 | #include "configdesc.h" | |
29 | ||
30 | G_DEFINE_TYPE(FcitxUIWidget, fcitx_ui_widget, GTK_TYPE_BOX) | |
31 | ||
32 | static void fcitx_ui_widget_finalize(GObject* object); | |
33 | static void _fcitx_ui_widget_load(FcitxUIWidget* self, const gchar* uiname); | |
34 | static void _fcitx_ui_widget_apply_button_clicked(GtkButton* button, gpointer user_data); | |
35 | ||
36 | static void | |
37 | fcitx_ui_widget_class_init(FcitxUIWidgetClass *klass) | |
38 | { | |
39 | GObjectClass *gobject_class = G_OBJECT_CLASS(klass); | |
40 | gobject_class->finalize = fcitx_ui_widget_finalize; | |
41 | } | |
42 | ||
43 | static void | |
44 | fcitx_ui_widget_init(FcitxUIWidget* self) | |
45 | { | |
46 | gtk_orientable_set_orientation(GTK_ORIENTABLE(self), GTK_ORIENTATION_VERTICAL); | |
47 | self->label = gtk_label_new(_("Cannot load currently used user interface info")); | |
48 | gtk_box_pack_start(GTK_BOX(self), self->label, TRUE, TRUE, 0); | |
49 | } | |
50 | ||
51 | GtkWidget* | |
52 | fcitx_ui_widget_new(void) | |
53 | { | |
54 | FcitxUIWidget* widget = | |
55 | g_object_new(FCITX_TYPE_UI_WIDGET, | |
56 | NULL); | |
57 | ||
58 | return GTK_WIDGET(widget); | |
59 | } | |
60 | ||
61 | void fcitx_ui_widget_finalize(GObject* object) | |
62 | { | |
63 | FcitxUIWidget* self = FCITX_UI_WIDGET(object); | |
64 | if (self->improxy) | |
65 | g_object_unref(self->improxy); | |
66 | ||
67 | G_OBJECT_CLASS (fcitx_ui_widget_parent_class)->finalize (object); | |
68 | } | |
69 | ||
70 | void fcitx_ui_widget_connect(FcitxUIWidget* self) | |
71 | { | |
72 | GError* error = NULL; | |
73 | self->improxy = fcitx_input_method_new(G_BUS_TYPE_SESSION, | |
74 | G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, | |
75 | fcitx_utils_get_display_number(), | |
76 | NULL, | |
77 | &error | |
78 | ); | |
79 | if (self->improxy == NULL) { | |
80 | g_error_free(error); | |
81 | return; | |
82 | } | |
83 | ||
84 | gchar* uiname = fcitx_input_method_get_current_ui(self->improxy); | |
85 | if (uiname) { | |
86 | _fcitx_ui_widget_load(self, uiname); | |
87 | g_free(uiname); | |
88 | } | |
89 | } | |
90 | ||
91 | void _fcitx_ui_widget_load(FcitxUIWidget* self, const gchar* uiname) | |
92 | { | |
93 | FcitxMainWindow* mainwindow = FCITX_MAIN_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET(self))); | |
94 | FcitxAddon* addon = find_addon_by_name(mainwindow->addons, uiname); | |
95 | if (!addon) | |
96 | return; | |
97 | ||
98 | gchar* config_desc_name = g_strdup_printf("%s.desc", addon->name); | |
99 | FcitxConfigFileDesc* cfdesc = get_config_desc(config_desc_name); | |
100 | g_free(config_desc_name); | |
101 | gboolean configurable = (gboolean)(cfdesc != NULL || strlen(addon->subconfig) != 0); | |
102 | if (!configurable) { | |
103 | gchar* text = g_strdup_printf(_("No configuration option for %s."), addon->generalname); | |
104 | gtk_label_set_text(GTK_LABEL(self->label), text); | |
105 | g_free(text); | |
106 | } | |
107 | else { | |
108 | gtk_container_remove(GTK_CONTAINER(self), self->label); | |
109 | self->label = NULL; | |
110 | gchar* config_file_name = g_strdup_printf("%s.config", addon->name); | |
111 | FcitxConfigWidget* config_widget = fcitx_config_widget_new(cfdesc, "conf", config_file_name, addon->subconfig); | |
112 | g_free(config_file_name); | |
113 | gtk_box_pack_start(GTK_BOX(self), GTK_WIDGET(config_widget), TRUE, TRUE, 0); | |
114 | g_object_set(G_OBJECT(config_widget), "margin", 5, NULL); | |
115 | ||
116 | GtkWidget* hbuttonbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL); | |
117 | gtk_box_pack_start(GTK_BOX(self), hbuttonbox, FALSE, TRUE, 0); | |
118 | g_object_set(G_OBJECT(hbuttonbox), "margin", 5, NULL); | |
119 | ||
120 | GtkWidget* applybutton = gtk_button_new_from_stock(GTK_STOCK_APPLY); | |
121 | gtk_box_pack_start(GTK_BOX(hbuttonbox), applybutton, TRUE, TRUE, 0); | |
122 | g_signal_connect(G_OBJECT(applybutton), "clicked", G_CALLBACK(_fcitx_ui_widget_apply_button_clicked), config_widget); | |
123 | gtk_widget_show_all(GTK_WIDGET(self)); | |
124 | } | |
125 | } | |
126 | ||
127 | void _fcitx_ui_widget_apply_button_clicked(GtkButton* button, gpointer user_data) | |
128 | { | |
129 | FcitxConfigWidget* config_widget = user_data; | |
130 | fcitx_config_widget_response(config_widget, CONFIG_WIDGET_SAVE); | |
131 | } |
0 | /*************************************************************************** | |
1 | * Copyright (C) 2010~2012 by CSSlayer * | |
2 | * * | |
3 | * This program is free software; you can redistribute it and/or modify * | |
4 | * it under the terms of the GNU General Public License as published by * | |
5 | * the Free Software Foundation; either version 2 of the License, or * | |
6 | * (at your option) any later version. * | |
7 | * * | |
8 | * This program is distributed in the hope that it will be useful, * | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
11 | * GNU General Public License for more details. * | |
12 | * * | |
13 | * You should have received a copy of the GNU General Public License * | |
14 | * along with this program; if not, write to the * | |
15 | * Free Software Foundation, Inc., * | |
16 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * | |
17 | ***************************************************************************/ | |
18 | ||
19 | #ifndef UI_WIDGET_H | |
20 | #define UI_WIDGET_H | |
21 | ||
22 | #include <gtk/gtk.h> | |
23 | #include <gio/gio.h> | |
24 | #include "fcitx-gclient/fcitxinputmethod.h" | |
25 | ||
26 | G_BEGIN_DECLS | |
27 | ||
28 | #define FCITX_TYPE_UI_WIDGET fcitx_ui_widget_get_type() | |
29 | ||
30 | #define FCITX_UI_WIDGET(obj) \ | |
31 | (G_TYPE_CHECK_INSTANCE_CAST ((obj), FCITX_TYPE_UI_WIDGET, FcitxUIWidget)) | |
32 | ||
33 | #define FCITX_UI_WIDGET_CLASS(klass) \ | |
34 | (G_TYPE_CHECK_CLASS_CAST ((klass), FCITX_TYPE_UI_WIDGET, FcitxUIWidgetClass)) | |
35 | ||
36 | #define FCITX_IS_UI_WIDGET(obj) \ | |
37 | (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FCITX_TYPE_UI_WIDGET)) | |
38 | ||
39 | #define FCITX_IS_UI_WIDGET_CLASS(klass) \ | |
40 | (G_TYPE_CHECK_CLASS_TYPE ((klass), FCITX_TYPE_UI_WIDGET)) | |
41 | ||
42 | #define FCITX_UI_WIDGET_GET_CLASS(obj) \ | |
43 | (G_TYPE_INSTANCE_GET_CLASS ((obj), FCITX_TYPE_UI_WIDGET, FcitxUIWidgetClass)) | |
44 | ||
45 | typedef struct _FcitxUIWidget FcitxUIWidget; | |
46 | typedef struct _FcitxUIWidgetClass FcitxUIWidgetClass; | |
47 | ||
48 | struct _FcitxUIWidget { | |
49 | GtkBox parent; | |
50 | FcitxInputMethod* improxy; | |
51 | GtkWidget* label; | |
52 | }; | |
53 | ||
54 | struct _FcitxUIWidgetClass { | |
55 | GtkBoxClass parent_class; | |
56 | }; | |
57 | ||
58 | GType fcitx_ui_widget_get_type(void) G_GNUC_CONST; | |
59 | ||
60 | GtkWidget* | |
61 | fcitx_ui_widget_new(void); | |
62 | ||
63 | void | |
64 | fcitx_ui_widget_connect(FcitxUIWidget* widget); | |
65 | ||
66 | G_END_DECLS | |
67 | ||
68 | ||
69 | #endif⏎ |
25 | 25 | ${REL_SOURCE_ROOT}/gtk3/im_config_dialog.h |
26 | 26 | ${REL_SOURCE_ROOT}/gtk3/im_dialog.c |
27 | 27 | ${REL_SOURCE_ROOT}/gtk3/im_dialog.h |
28 | ${REL_SOURCE_ROOT}/gtk3/ui_widget.c | |
29 | ${REL_SOURCE_ROOT}/gtk3/ui_widget.h | |
28 | 30 | ${REL_SOURCE_ROOT}/gtk3/im_widget.c |
29 | 31 | ${REL_SOURCE_ROOT}/gtk3/im_widget.h |
30 | 32 | ${REL_SOURCE_ROOT}/gtk3/keygrab.c |
7 | 7 | msgstr "" |
8 | 8 | "Project-Id-Version: PACKAGE VERSION\n" |
9 | 9 | "Report-Msgid-Bugs-To: \n" |
10 | "POT-Creation-Date: 2012-05-28 03:18+0800\n" | |
10 | "POT-Creation-Date: 2012-09-06 18:33-0400\n" | |
11 | 11 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
12 | 12 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
13 | 13 | "Language-Team: LANGUAGE <LL@li.org>\n" |
16 | 16 | "Content-Type: text/plain; charset=CHARSET\n" |
17 | 17 | "Content-Transfer-Encoding: 8bit\n" |
18 | 18 | |
19 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/config_widget.c:190 | |
20 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/config_widget.c:192 | |
19 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/config_widget.c:192 | |
20 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/config_widget.c:206 | |
21 | 21 | msgid "Clear font setting" |
22 | 22 | msgstr "" |
23 | 23 | |
24 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/config_widget.c:255 | |
25 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/config_widget.c:257 | |
24 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/config_widget.c:270 | |
25 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/config_widget.c:479 | |
26 | 26 | msgid "Other" |
27 | 27 | msgstr "" |
28 | 28 | |
29 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:91 | |
29 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:91 | |
30 | 30 | msgid "Available Input Method" |
31 | 31 | msgstr "" |
32 | 32 | |
33 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:101 | |
34 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:152 | |
35 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/main_window.c:278 | |
36 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_dialog.c:98 | |
37 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_widget.c:86 | |
38 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:182 | |
33 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:101 | |
34 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:152 | |
35 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/main_window.c:278 | |
36 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_dialog.c:98 | |
37 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_widget.c:86 | |
38 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:188 | |
39 | 39 | msgid "Input Method" |
40 | 40 | msgstr "" |
41 | 41 | |
42 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:114 | |
43 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_dialog.c:114 | |
42 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:114 | |
43 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_dialog.c:115 | |
44 | 44 | msgid "Only Show Current Language" |
45 | 45 | msgstr "" |
46 | 46 | |
47 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:145 | |
47 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:145 | |
48 | 48 | msgid "Current Input Method" |
49 | 49 | msgstr "" |
50 | 50 | |
51 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:290 | |
52 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:292 | |
51 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:290 | |
52 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:292 | |
53 | 53 | msgid "Unknown" |
54 | 54 | msgstr "" |
55 | 55 | |
56 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/keygrab.c:81 | |
57 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/keygrab.c:80 | |
56 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/keygrab.c:74 | |
57 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/keygrab.c:78 | |
58 | 58 | msgid "Please press the new key combination" |
59 | 59 | msgstr "" |
60 | 60 | |
61 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/keygrab.c:144 | |
62 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/keygrab.c:160 | |
61 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/keygrab.c:138 | |
62 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/keygrab.c:64 | |
63 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/keygrab.c:159 | |
63 | 64 | msgid "Empty" |
64 | 65 | msgstr "" |
65 | 66 | |
66 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/main_window.c:144 | |
67 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:100 | |
67 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/main_window.c:144 | |
68 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:104 | |
68 | 69 | msgid "Fcitx Config" |
69 | 70 | msgstr "" |
70 | 71 | |
71 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/main_window.c:272 | |
72 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:176 | |
72 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/main_window.c:272 | |
73 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:182 | |
73 | 74 | msgid "Global Config" |
74 | 75 | msgstr "" |
75 | 76 | |
76 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/main_window.c:338 | |
77 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:312 | |
77 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/main_window.c:338 | |
78 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:337 | |
78 | 79 | msgid "Configure" |
79 | 80 | msgstr "" |
80 | 81 | |
81 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/main_window.c:349 | |
82 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:325 | |
82 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/main_window.c:349 | |
83 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:350 | |
83 | 84 | msgid "Addon" |
84 | 85 | msgstr "" |
85 | 86 | |
86 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_config_dialog.c:144 | |
87 | msgid "System Default" | |
87 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/config_widget.c:562 | |
88 | msgid "Show Advance Option" | |
88 | 89 | msgstr "" |
89 | 90 | |
90 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_config_dialog.c:171 | |
91 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_config_dialog.c:126 | |
92 | msgid "Default keyboard layout" | |
93 | msgstr "" | |
94 | ||
95 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_config_dialog.c:158 | |
96 | msgid "Input Method Default" | |
97 | msgstr "" | |
98 | ||
99 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_config_dialog.c:158 | |
100 | msgid "Default" | |
101 | msgstr "" | |
102 | ||
103 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_config_dialog.c:187 | |
91 | 104 | msgid "Keyboard layout:" |
92 | 105 | msgstr "" |
93 | 106 | |
94 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_config_dialog.c:184 | |
107 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_config_dialog.c:187 | |
108 | msgid "Keyboard layout to use when no input method active:" | |
109 | msgstr "" | |
110 | ||
111 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_config_dialog.c:204 | |
95 | 112 | msgid "Input method settings:" |
96 | 113 | msgstr "" |
97 | 114 | |
98 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_dialog.c:61 | |
115 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_dialog.c:61 | |
99 | 116 | msgid "Add input method" |
100 | 117 | msgstr "" |
101 | 118 | |
102 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_dialog.c:123 | |
119 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_dialog.c:125 | |
103 | 120 | msgid "Search Input Method" |
104 | 121 | msgstr "" |
105 | 122 | |
123 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/ui_widget.c:48 | |
124 | msgid "Cannot load currently used user interface info" | |
125 | msgstr "" | |
126 | ||
127 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/ui_widget.c:104 | |
128 | #, c-format | |
129 | msgid "No configuration option for %s." | |
130 | msgstr "" | |
131 | ||
132 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:200 | |
133 | msgid "Appearance" | |
134 | msgstr "" | |
135 | ||
106 | 136 | #. advance check box |
107 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:242 | |
137 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:262 | |
108 | 138 | msgid "Advance" |
109 | 139 | msgstr "" |
110 | 140 | |
111 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:252 | |
141 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:273 | |
112 | 142 | msgid "Search Addon" |
113 | 143 | msgstr "" |
6 | 6 | msgstr "" |
7 | 7 | "Project-Id-Version: fcitx\n" |
8 | 8 | "Report-Msgid-Bugs-To: \n" |
9 | "POT-Creation-Date: 2012-05-28 03:18+0800\n" | |
10 | "PO-Revision-Date: 2012-05-28 03:19+0800\n" | |
11 | "Last-Translator: Xuetian Weng <wengxt@gmail.com>\n" | |
9 | "POT-Creation-Date: 2012-09-06 18:33-0400\n" | |
10 | "PO-Revision-Date: 2012-09-06 18:34-0400\n" | |
11 | "Last-Translator: Weng Xuetian <wengxt@gmail.com>\n" | |
12 | 12 | "Language-Team: Chinese Simplified <kde-i18n-doc@kde.org>\n" |
13 | 13 | "Language: zh_CN\n" |
14 | 14 | "MIME-Version: 1.0\n" |
15 | 15 | "Content-Type: text/plain; charset=UTF-8\n" |
16 | 16 | "Content-Transfer-Encoding: 8bit\n" |
17 | 17 | "Plural-Forms: nplurals=1; plural=0\n" |
18 | "X-Generator: Lokalize 1.4\n" | |
18 | "X-Generator: Lokalize 1.5\n" | |
19 | 19 | |
20 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_dialog.c:61 | |
20 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_dialog.c:61 | |
21 | 21 | msgid "Add input method" |
22 | 22 | msgstr "添加输入法" |
23 | 23 | |
24 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/main_window.c:349 | |
25 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:325 | |
24 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/main_window.c:349 | |
25 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:350 | |
26 | 26 | msgid "Addon" |
27 | 27 | msgstr "附加组件" |
28 | 28 | |
29 | 29 | #. advance check box |
30 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:242 | |
30 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:262 | |
31 | 31 | msgid "Advance" |
32 | 32 | msgstr "高级" |
33 | 33 | |
34 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:91 | |
34 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:200 | |
35 | msgid "Appearance" | |
36 | msgstr "外观" | |
37 | ||
38 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:91 | |
35 | 39 | msgid "Available Input Method" |
36 | 40 | msgstr "可用的输入法" |
37 | 41 | |
38 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/config_widget.c:190 | |
39 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/config_widget.c:192 | |
42 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/ui_widget.c:48 | |
43 | msgid "Cannot load currently used user interface info" | |
44 | msgstr "无法加载当前用户界面信息" | |
45 | ||
46 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/config_widget.c:192 | |
47 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/config_widget.c:206 | |
40 | 48 | msgid "Clear font setting" |
41 | 49 | msgstr "清除字体设置" |
42 | 50 | |
43 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/main_window.c:338 | |
44 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:312 | |
51 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/main_window.c:338 | |
52 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:337 | |
45 | 53 | msgid "Configure" |
46 | 54 | msgstr "配置 " |
47 | 55 | |
48 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:145 | |
56 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:145 | |
49 | 57 | msgid "Current Input Method" |
50 | 58 | msgstr "当前的输入法" |
51 | 59 | |
52 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/keygrab.c:144 | |
53 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/keygrab.c:160 | |
60 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_config_dialog.c:158 | |
61 | msgid "Default" | |
62 | msgstr "默认" | |
63 | ||
64 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_config_dialog.c:126 | |
65 | msgid "Default keyboard layout" | |
66 | msgstr "默认键盘布局" | |
67 | ||
68 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/keygrab.c:138 | |
69 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/keygrab.c:64 | |
70 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/keygrab.c:159 | |
54 | 71 | msgid "Empty" |
55 | 72 | msgstr "空" |
56 | 73 | |
57 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/main_window.c:144 | |
58 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:100 | |
74 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/main_window.c:144 | |
75 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:104 | |
59 | 76 | msgid "Fcitx Config" |
60 | 77 | msgstr "Fcitx配置" |
61 | 78 | |
62 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/main_window.c:272 | |
63 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:176 | |
79 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/main_window.c:272 | |
80 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:182 | |
64 | 81 | msgid "Global Config" |
65 | 82 | msgstr "全局配置" |
66 | 83 | |
67 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:101 | |
68 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:152 | |
69 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/main_window.c:278 | |
70 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_dialog.c:98 | |
71 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_widget.c:86 | |
72 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:182 | |
84 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:101 | |
85 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:152 | |
86 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/main_window.c:278 | |
87 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_dialog.c:98 | |
88 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_widget.c:86 | |
89 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:188 | |
73 | 90 | msgid "Input Method" |
74 | 91 | msgstr "输入法" |
75 | 92 | |
76 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_config_dialog.c:184 | |
93 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_config_dialog.c:158 | |
94 | msgid "Input Method Default" | |
95 | msgstr "输入法默认" | |
96 | ||
97 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_config_dialog.c:204 | |
77 | 98 | msgid "Input method settings:" |
78 | 99 | msgstr "输入法设置:" |
79 | 100 | |
80 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_config_dialog.c:171 | |
101 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_config_dialog.c:187 | |
102 | msgid "Keyboard layout to use when no input method active:" | |
103 | msgstr "无输入法时的使用的键盘布局:" | |
104 | ||
105 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_config_dialog.c:187 | |
81 | 106 | msgid "Keyboard layout:" |
82 | 107 | msgstr "键盘布局:" |
83 | 108 | |
84 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:114 | |
85 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_dialog.c:114 | |
109 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/ui_widget.c:104 | |
110 | #, c-format | |
111 | msgid "No configuration option for %s." | |
112 | msgstr "%s 无配置选项。" | |
113 | ||
114 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:114 | |
115 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_dialog.c:115 | |
86 | 116 | msgid "Only Show Current Language" |
87 | 117 | msgstr "仅显示当前语言" |
88 | 118 | |
89 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/config_widget.c:255 | |
90 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/config_widget.c:257 | |
119 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/config_widget.c:270 | |
120 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/config_widget.c:479 | |
91 | 121 | msgid "Other" |
92 | 122 | msgstr "其他" |
93 | 123 | |
94 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/keygrab.c:81 | |
95 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/keygrab.c:80 | |
124 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/keygrab.c:74 | |
125 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/keygrab.c:78 | |
96 | 126 | msgid "Please press the new key combination" |
97 | 127 | msgstr "请按下新按键组合" |
98 | 128 | |
99 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:252 | |
129 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:273 | |
100 | 130 | msgid "Search Addon" |
101 | 131 | msgstr "搜索附加组件" |
102 | 132 | |
103 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_dialog.c:123 | |
133 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_dialog.c:125 | |
104 | 134 | msgid "Search Input Method" |
105 | 135 | msgstr "搜索输入法" |
106 | 136 | |
107 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_config_dialog.c:144 | |
108 | msgid "System Default" | |
109 | msgstr "系统默认" | |
137 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/config_widget.c:562 | |
138 | msgid "Show Advance Option" | |
139 | msgstr "显示高级选项" | |
110 | 140 | |
111 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:290 | |
112 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:292 | |
141 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:290 | |
142 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:292 | |
113 | 143 | msgid "Unknown" |
114 | 144 | msgstr "未知" |
145 | ||
146 | #~ msgid "<b>%s</b>" | |
147 | #~ msgstr "<b>%s</b>" | |
148 | ||
149 | #~ msgid "<b>Other</b>" | |
150 | #~ msgstr "<b>其它</b>" | |
115 | 151 | |
116 | 152 | #~ msgid "Addon Configuration" |
117 | 153 | #~ msgstr "附加组件配置" |
6 | 6 | msgstr "" |
7 | 7 | "Project-Id-Version: fcitx\n" |
8 | 8 | "Report-Msgid-Bugs-To: \n" |
9 | "POT-Creation-Date: 2012-05-28 03:18+0800\n" | |
10 | "PO-Revision-Date: 2012-05-28 03:19+0800\n" | |
11 | "Last-Translator: Xuetian Weng <wengxt@gmail.com>\n" | |
9 | "POT-Creation-Date: 2012-09-06 18:33-0400\n" | |
10 | "PO-Revision-Date: 2012-09-06 18:35-0400\n" | |
11 | "Last-Translator: Weng Xuetian <wengxt@gmail.com>\n" | |
12 | 12 | "Language-Team: Chinese Simplified <kde-i18n-doc@kde.org>\n" |
13 | 13 | "Language: zh_TW\n" |
14 | 14 | "MIME-Version: 1.0\n" |
16 | 16 | "Content-Transfer-Encoding: 8bit\n" |
17 | 17 | "team/zh_TW/)\n" |
18 | 18 | "Plural-Forms: nplurals=1; plural=0\n" |
19 | "X-Generator: Lokalize 1.4\n" | |
19 | "X-Generator: Lokalize 1.5\n" | |
20 | 20 | |
21 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_dialog.c:61 | |
21 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_dialog.c:61 | |
22 | 22 | msgid "Add input method" |
23 | 23 | msgstr "添加輸入法" |
24 | 24 | |
25 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/main_window.c:349 | |
26 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:325 | |
25 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/main_window.c:349 | |
26 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:350 | |
27 | 27 | msgid "Addon" |
28 | 28 | msgstr "附加元件" |
29 | 29 | |
30 | 30 | #. advance check box |
31 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:242 | |
31 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:262 | |
32 | 32 | msgid "Advance" |
33 | 33 | msgstr "高級" |
34 | 34 | |
35 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:91 | |
35 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:200 | |
36 | msgid "Appearance" | |
37 | msgstr "外观" | |
38 | ||
39 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:91 | |
36 | 40 | msgid "Available Input Method" |
37 | 41 | msgstr "可用輸入法" |
38 | 42 | |
39 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/config_widget.c:190 | |
40 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/config_widget.c:192 | |
43 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/ui_widget.c:48 | |
44 | msgid "Cannot load currently used user interface info" | |
45 | msgstr "無法加載當前用戶界面信息" | |
46 | ||
47 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/config_widget.c:192 | |
48 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/config_widget.c:206 | |
41 | 49 | msgid "Clear font setting" |
42 | 50 | msgstr "清除字體設定" |
43 | 51 | |
44 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/main_window.c:338 | |
45 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:312 | |
52 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/main_window.c:338 | |
53 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:337 | |
46 | 54 | msgid "Configure" |
47 | 55 | msgstr "設定" |
48 | 56 | |
49 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:145 | |
57 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:145 | |
50 | 58 | msgid "Current Input Method" |
51 | 59 | msgstr "目前輸入法" |
52 | 60 | |
53 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/keygrab.c:144 | |
54 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/keygrab.c:160 | |
61 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_config_dialog.c:158 | |
62 | msgid "Default" | |
63 | msgstr "預設" | |
64 | ||
65 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_config_dialog.c:126 | |
66 | msgid "Default keyboard layout" | |
67 | msgstr "預設鍵盤佈局" | |
68 | ||
69 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/keygrab.c:138 | |
70 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/keygrab.c:64 | |
71 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/keygrab.c:159 | |
55 | 72 | msgid "Empty" |
56 | 73 | msgstr "空" |
57 | 74 | |
58 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/main_window.c:144 | |
59 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:100 | |
75 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/main_window.c:144 | |
76 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:104 | |
60 | 77 | msgid "Fcitx Config" |
61 | 78 | msgstr "Fcitx 設定" |
62 | 79 | |
63 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/main_window.c:272 | |
64 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:176 | |
80 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/main_window.c:272 | |
81 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:182 | |
65 | 82 | msgid "Global Config" |
66 | 83 | msgstr "全局設定" |
67 | 84 | |
68 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:101 | |
69 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:152 | |
70 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/main_window.c:278 | |
71 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_dialog.c:98 | |
72 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_widget.c:86 | |
73 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:182 | |
85 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:101 | |
86 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:152 | |
87 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/main_window.c:278 | |
88 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_dialog.c:98 | |
89 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_widget.c:86 | |
90 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:188 | |
74 | 91 | msgid "Input Method" |
75 | 92 | msgstr "輸入法" |
76 | 93 | |
77 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_config_dialog.c:184 | |
94 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_config_dialog.c:158 | |
95 | msgid "Input Method Default" | |
96 | msgstr "輸入法預設" | |
97 | ||
98 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_config_dialog.c:204 | |
78 | 99 | msgid "Input method settings:" |
79 | 100 | msgstr "輸入法設定:" |
80 | 101 | |
81 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_config_dialog.c:171 | |
102 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_config_dialog.c:187 | |
103 | msgid "Keyboard layout to use when no input method active:" | |
104 | msgstr "無活動輸入法時使用的鍵盤佈局:" | |
105 | ||
106 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_config_dialog.c:187 | |
82 | 107 | msgid "Keyboard layout:" |
83 | 108 | msgstr "鍵盤佈局:" |
84 | 109 | |
85 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:114 | |
86 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_dialog.c:114 | |
110 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/ui_widget.c:104 | |
111 | #, c-format | |
112 | msgid "No configuration option for %s." | |
113 | msgstr "%s 無設定選項。" | |
114 | ||
115 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:114 | |
116 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_dialog.c:115 | |
87 | 117 | msgid "Only Show Current Language" |
88 | 118 | msgstr "僅顯示当前語言" |
89 | 119 | |
90 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/config_widget.c:255 | |
91 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/config_widget.c:257 | |
120 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/config_widget.c:270 | |
121 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/config_widget.c:479 | |
92 | 122 | msgid "Other" |
93 | 123 | msgstr "其他" |
94 | 124 | |
95 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/keygrab.c:81 | |
96 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/keygrab.c:80 | |
125 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/keygrab.c:74 | |
126 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/keygrab.c:78 | |
97 | 127 | msgid "Please press the new key combination" |
98 | 128 | msgstr "請按下新按鍵組合" |
99 | 129 | |
100 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/main_window.c:252 | |
130 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/main_window.c:273 | |
101 | 131 | msgid "Search Addon" |
102 | 132 | msgstr "搜索附加元件" |
103 | 133 | |
104 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_dialog.c:123 | |
134 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/im_dialog.c:125 | |
105 | 135 | msgid "Search Input Method" |
106 | 136 | msgstr "搜尋輸入法" |
107 | 137 | |
108 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk3/im_config_dialog.c:144 | |
109 | msgid "System Default" | |
110 | msgstr "系統預設" | |
138 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk3/config_widget.c:562 | |
139 | msgid "Show Advance Option" | |
140 | msgstr "顯示高級選項" | |
111 | 141 | |
112 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:290 | |
113 | #: /home/saber/Develop/fcitx-config/build/po/../..//gtk/im_widget.c:292 | |
142 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:290 | |
143 | #: /home/saber/Develop/fcitx-configtool/build/po/../..//gtk/im_widget.c:292 | |
114 | 144 | msgid "Unknown" |
115 | 145 | msgstr "未知" |
116 | 146 |