Codebase list fcitx-configtool / d3a565f
Imported Upstream version 0.4.5 YunQiang Su 11 years ago
29 changed file(s) with 1228 addition(s) and 423 deletion(s). Raw diff Collapse all Expand all
00 *~
1 build/*
1 /build*/
2 .*
3 !.git*
4 .git/
25 data/pinyin.tar.gz
36 data/pinyin.tar.gz.md5
47 data/table/table.tar.gz
1114 .directory
1215 *.kate-swp
1316 *.orig
17 tags
18 astyle.sh
19 cscope.*
66
77 find_package(PkgConfig REQUIRED)
88
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)
1313
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)
1717
1818 PKG_CHECK_MODULES(ISO_CODES "iso-codes" REQUIRED)
1919 _pkgconfig_invoke("iso-codes" ISO_CODES PREFIX "" "--variable=prefix")
2929
3030 include(FindPkgConfig)
3131 FIND_PACKAGE(Gettext REQUIRED)
32 find_package(Fcitx 4.2.4 REQUIRED)
32 find_package(Fcitx 4.2.6 REQUIRED)
3333 FIND_PROGRAM(INTLTOOL_EXTRACT intltool-extract)
3434 FIND_PROGRAM(INTLTOOL_UPDATE intltool-update)
3535 FIND_PROGRAM(INTLTOOL_MERGE intltool-merge)
5151 configure_file(config.h.in config.h)
5252 include_directories(${CMAKE_CURRENT_BINARY_DIR})
5353
54 if (ENABLE_GTK3)
55 add_subdirectory(gtk3)
56 endif (ENABLE_GTK3)
54 if(ENABLE_GTK3)
55 add_subdirectory(gtk3)
56 endif(ENABLE_GTK3)
5757
5858 if (ENABLE_GTK2)
5959 add_subdirectory(gtk)
162162 for (; codesc != NULL;
163163 codesc = (FcitxConfigOptionDesc*)codesc->hh.next, i++) {
164164 const char *s;
165 FcitxConfigOptionDesc2 *codesc2 =
166 (FcitxConfigOptionDesc2*)codesc;
165167 if (codesc->desc && strlen(codesc->desc) != 0)
166168 s = D_(cfdesc->domain, codesc->desc);
167169 else
237239 if (inputWidget) {
238240 GtkWidget* label = gtk_label_new(s);
239241 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);
243258 }
244259 }
245260 }
283298 "prefix", prefix,
284299 "name", name,
285300 "subconfig", subconfig,
286 NULL
287 );
301 NULL);
288302 fcitx_config_widget_setup_ui(widget);
289303 return widget;
290304 }
520520
521521 gboolean flag = TRUE;
522522 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 }
529531 return flag;
530532 } else {
531533 gchar* lang = NULL;
533535 iter,
534536 AVAIL_TREE_LANG, &lang,
535537 -1);
538 if (lang && strcmp(lang, "en") == 0)
539 return TRUE;
536540 flag = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self->onlycurlangcheckbox)) ?
537541 lang != NULL && strncmp(lang, _get_current_lang() , 2) == 0 : TRUE) ;
538542 g_free(lang);
559563 gpointer data)
560564 {
561565 gtk_entry_set_text (entry, "");
562 }
566 }
2626 #include "keygrab.h"
2727
2828 #define _(s) gettext(s)
29 //定义枚举类型,说明信号的名称和次序
29
3030 enum {
3131 KEYGRAB_BUTTON_CHANGED,
32 KEYGRAB_BUTTON_CURRENT_CHANGED,
3332 LAST_SIGNAL
3433 };
3534 static gint keygrab_button_signals[LAST_SIGNAL] = { 0 };
6059 NULL, NULL,
6160 g_cclosure_marshal_VOID__VOID,
6261 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);
7062 }
71 //创建新的自定义控件
63
7264 GtkWidget* keygrab_button_new(void)
7365 {
74 return GTK_WIDGET(g_object_new(TYPE_KEYGRAB_BUTTON, 0));
66 return GTK_WIDGET(g_object_new(TYPE_KEYGRAB_BUTTON, NULL));
7567 }
7668
7769
2020 #define KEYGRAB_H
2121
2222 #include <gtk/gtk.h>
23 //定义类型宏和转换宏
23
2424 #define TYPE_KEYGRAB_BUTTON (keygrab_button_get_type())
2525 #define KEYGRAB_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj,TYPE_KEYGRAB_BUTTON,KeyGrabButton))
26 //定义实例结构和类结构
26
2727 typedef struct _KeyGrabButton KeyGrabButton;
2828 typedef struct _KeyGrabButtonClass KeyGrabButtonClass;
2929 struct _KeyGrabButton {
30 GtkButton parent; //父控件为横向盒状容器
30 GtkButton parent;
3131 GtkWidget* popup;
3232 gulong handler;
3333 guint key;
2727 main.c
2828 main_window.c
2929 im_widget.c
30 ui_widget.c
3031 gdm-languages.c
3132 im_dialog.c
3233 common.c
3334 im_config_dialog.c
35 dummy_config.c
3436 )
3537
3638 add_executable( fcitx-config-gtk3 ${fcitx_config_gtk3_sources} )
1818
1919 #include "common.h"
2020
21 FcitxAddon* find_addon_by_name(UT_array* array, gchar* name)
21 FcitxAddon* find_addon_by_name(UT_array* array, const gchar* name)
2222 {
2323 FcitxAddon* addon = NULL;
2424 for (addon = (FcitxAddon *) utarray_front(array);
2828 break;
2929 }
3030 return addon;
31 }
31 }
1616 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
1717 ***************************************************************************/
1818
19 #ifndef COMMON_H
20 #define COMMON_H
19 #ifndef FCITX_CONFIGTOOL_COMMON_H
20 #define FCITX_CONFIGTOOL_COMMON_H
2121
2222 #include <libintl.h>
2323 #include <fcitx/addon.h>
2525
2626 #define _(x) gettext(x)
2727
28 FcitxAddon* find_addon_by_name(UT_array* array, gchar* name);
28 FcitxAddon* find_addon_by_name(UT_array* array, const gchar* name);
2929
3030 #endif
2424 #include <libgen.h>
2525 #include <sys/stat.h>
2626 #include <unistd.h>
27 #include <ctype.h>
2728
2829 #include <fcitx-config/fcitx-config.h>
2930 #include <fcitx-utils/uthash.h>
3435 #include "keygrab.h"
3536 #include "sub_config_widget.h"
3637 #include "configdesc.h"
38 #include "dummy_config.h"
3739
3840 #define _(s) gettext(s)
3941 #define D_(d, x) dgettext (d, x)
4547 int i;
4648 FcitxConfigWidget* widget;
4749 GtkWidget* grid;
50 int j;
4851 } HashForeachContext;
4952
5053 enum {
6265 const GValue *value,
6366 GParamSpec *pspec);
6467
68
69 static void
70 fcitx_config_widget_check_can_use_simple(FcitxConfigWidget* self);
6571
6672 static void sync_filter(FcitxGenericConfig* gconfig, FcitxConfigGroup *group, FcitxConfigOption *option, void *value, FcitxConfigSync sync, void *arg);
6773
118124 static void
119125 fcitx_config_widget_init(FcitxConfigWidget *self)
120126 {
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)
125152 {
126153 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;
128420 GtkWidget *configNotebook = gtk_notebook_new();
129 gtk_box_pack_start(GTK_BOX(cvbox), configNotebook, TRUE, TRUE, 0);
130421 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
138422 FcitxConfigGroupDesc *cgdesc = NULL;
139423 FcitxConfigOptionDesc *codesc = NULL;
140424 for (cgdesc = cfdesc->groupsDesc;
164448 int i = 0;
165449 for (; codesc != NULL;
166450 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
173451 GtkWidget *inputWidget = NULL;
174452 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);
239455
240456 if (inputWidget) {
241457 GtkWidget* label = gtk_label_new(s);
242458 g_object_set(label, "xalign", 0.0f, NULL);
243459 gtk_grid_attach(GTK_GRID(grid), label, 0, i, 1, 1);
244460 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);
246467 }
468 g_free(s);
469 g_free(tooltip);
247470 }
248471 }
249
250 FcitxConfigBindSync(&self->gconfig);
251472 }
252473
253474 if (self->parser) {
268489
269490 HashForeachContext context;
270491 context.i = 0;
492 context.j = 0;
271493 context.grid = grid;
272494 context.widget = self;
273495 g_hash_table_foreach(subconfigs, hash_foreach_cb, &context);
276498
277499 gtk_widget_set_size_request(configNotebook, 500, -1);
278500 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
280570 FcitxConfigWidget*
281571 fcitx_config_widget_new(FcitxConfigFileDesc* cfdesc, const gchar* prefix, const gchar* name, const char* subconfig)
282572 {
286576 "prefix", prefix,
287577 "name", name,
288578 "subconfig", subconfig,
289 NULL
290 );
579 NULL);
291580 fcitx_config_widget_setup_ui(widget);
292581 return widget;
293582 }
339628 case T_I18NString:
340629 break;
341630 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);
344633 }
345634 break;
346635 case T_Color: {
347636 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];
353642 snprintf(scolor, 8 , "#%02X%02X%02X", r, g, b);
354643 GdkRGBA color;
355644 gdk_rgba_parse(&color, scolor);
361650 }
362651 break;
363652 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);
371656 }
372657 break;
373658 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);
375660 }
376661 break;
377662 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;
385664 gtk_combo_box_set_active(GTK_COMBO_BOX(arg), index);
386665 }
387666 break;
388667 case T_Hotkey: {
389 FcitxHotkey hotkey[2];
668 FcitxHotkey* hotkey = (FcitxHotkey*) value;
390669 int j;
391 FcitxHotkeySetKey(option->rawValue, hotkey);
392670 GArray *array = (GArray*) arg;
393671
394672 for (j = 0; j < 2; j ++) {
395673 GtkWidget *button = g_array_index(array, GtkWidget*, j);
396674 keygrab_button_set_key(KEYGRAB_BUTTON(button), hotkey[j].sym, hotkey[j].state);
397 if (hotkey[j].desc)
398 free(hotkey[j].desc);
399675 }
400676 }
401677 break;
402678 case T_File:
403679 case T_Char:
404680 case T_String: {
405 gtk_entry_set_text(GTK_ENTRY(arg), option->rawValue);
681 gtk_entry_set_text(GTK_ENTRY(arg), *(char**) value);
406682 }
407683 break;
408684 }
415691 case T_I18NString:
416692 break;
417693 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));;
421696 }
422697 break;
423698 case T_Color: {
424 int r = 0, g = 0, b = 0;
425699 GdkRGBA color;
426700 #if GTK_CHECK_VERSION(3,3,0)
427701 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(arg), &color);
428702 #else
429703 gtk_color_button_get_rgba(GTK_COLOR_BUTTON(arg), &color);
430704 #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;
438709 }
439710 break;
440711 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));
447714 }
448715 break;
449716 case T_Font: {
717 char** fontname = (char**) value;
450718 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);
461736 }
462737 break;
463738 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));
468741 }
469742 break;
470743 case T_Hotkey: {
471744 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;
477747
478748 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);
484754 }
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
495755 }
496756 break;
497757 case T_File:
498758 case T_Char:
499759 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)));
501762 }
502763 break;
503764 }
514775 return;
515776
516777 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);
519780 } else if (action == CONFIG_WIDGET_SAVE) {
520781 FILE* fp = FcitxXDGGetFileUserWithPrefix(config_widget->prefix, config_widget->name, "w", NULL);
521782
522783 if (fp) {
523 FcitxConfigSaveConfigFileFp(fp, &config_widget->gconfig, config_widget->cfdesc);
784 FcitxConfigSaveConfigFileFp(fp, &config_widget->config->config, config_widget->cfdesc);
524785 fclose(fp);
525786
526787 GError* error;
535796
536797 void fcitx_config_widget_finalize(GObject *object)
537798 {
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);
542808 G_OBJECT_CLASS(fcitx_config_widget_parent_class)->finalize(object);
543809 }
544810
558824 int i = context->i;
559825
560826 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);
562828
563829 GtkWidget *inputWidget = GTK_WIDGET(fcitx_sub_config_widget_new(subconfig));
564830
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);
567833 context->i ++;
568834 }
569835
2626 #include <fcitx-config/fcitx-config.h>
2727 #include <fcitx/addon.h>
2828 #include "sub_config_parser.h"
29 #include "dummy_config.h"
2930
3031 G_BEGIN_DECLS
3132
4647 #define FCITX_CONFIG_WIDGET_GET_CLASS(obj) \
4748 (G_TYPE_INSTANCE_GET_CLASS ((obj), FCITX_TYPE_CONFIG_WIDGET, FcitxConfigWidgetClass))
4849
50
51 enum UIType {
52 CW_Simple = 0x1,
53 CW_Full = 0x2,
54 CW_NoShow = 0x0
55 };
56
4957 typedef struct {
5058 GtkBox parent;
5159 FcitxConfigFileDesc* cfdesc;
5260 gchar* prefix;
5361 gchar* name;
5462 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;
5670 } FcitxConfigWidget;
5771
5872 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
118118 if (parent)
119119 gtk_window_set_transient_for (GTK_WINDOW (self), parent);
120120
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"));
122126 GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(self));
127 g_object_set(G_OBJECT(content_area), "margin", 5, NULL);
123128 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 }
124138
125139 do {
126140
140154 self->model = gtk_list_store_new(N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
141155 GtkTreeIter iter;
142156 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);
144158 layout_foreach_ct context;
145159 context.model = self->model;
146160 context.layout = layout;
167181 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combobox), &context.iter);
168182 else
169183 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 }
173193 gtk_box_pack_start(GTK_BOX(content_area), combobox, FALSE, TRUE, 5);
174194 self->combobox = combobox;
175195
176196 } while(0);
177197
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);
193218
194219 g_signal_connect(self, "response",
195220 G_CALLBACK(_fcitx_im_config_dialog_response_cb),
4343 {
4444 FcitxImDialog* self = FCITX_IM_DIALOG(object);
4545 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);
4747 g_ptr_array_free(self->array, FALSE);
4848 self->array = NULL;
4949 }
169169 gtk_list_store_clear(self->availimstore);
170170
171171 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);
173173 g_ptr_array_free(self->array, FALSE);
174174 self->array = NULL;
175175 }
255255
256256 gboolean flag = TRUE;
257257 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 }
264267 }
265268 return flag;
266269 }
318321 gpointer data)
319322 {
320323 gtk_entry_set_text (entry, "");
321 }
324 }
5959 static void _fcitx_im_widget_moveup_button_clicked(GtkButton* button, gpointer user_data);
6060 static void _fcitx_im_widget_movedown_button_clicked(GtkButton* button, gpointer user_data);
6161 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);
6263
6364 static void
6465 fcitx_im_widget_class_init(FcitxImWidgetClass *klass)
104105 GtkToolItem* item;
105106 /* add and remove */
106107 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));
108110
109111 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));
111114 gtk_widget_set_sensitive(self->delimbutton, FALSE);
112115
113116 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
125128
126129 /* move up and move down */
127130 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));
129133 gtk_widget_set_sensitive(self->moveupbutton, FALSE);
130134
131135 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));
133138 gtk_widget_set_sensitive(self->movedownbutton, FALSE);
134139
135140 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
147152
148153 /* configure */
149154 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));
151157 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));
152161
153162 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
154163
155164 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);
156166 item = gtk_tool_item_new();
157167 gtk_container_add(GTK_CONTAINER(item), hbox);
158168
174184 g_signal_connect(G_OBJECT(self->moveupbutton), "clicked", G_CALLBACK(_fcitx_im_widget_moveup_button_clicked), self);
175185 g_signal_connect(G_OBJECT(self->movedownbutton), "clicked", G_CALLBACK(_fcitx_im_widget_movedown_button_clicked), self);
176186 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);
177188
178189
179190 _fcitx_im_widget_connect(self);
193204 {
194205 FcitxImWidget* self = FCITX_IM_WIDGET(object);
195206 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);
197208 g_ptr_array_free(self->array, FALSE);
198209 self->array = NULL;
199210 }
232243 gtk_list_store_clear(self->imstore);
233244
234245 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);
236247 g_ptr_array_free(self->array, FALSE);
237248 self->array = NULL;
238249 }
412423 }
413424 }
414425
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
415440 void _fcitx_im_widget_configure_button_clicked(GtkButton* button, gpointer user_data)
416441 {
417442 FcitxImWidget* self = user_data;
5757 GtkWidget* moveupbutton;
5858 GtkWidget* movedownbutton;
5959 GtkWidget* configurebutton;
60 GtkWidget* default_layout_button;
6061 };
6162
6263 struct _FcitxImWidgetClass {
2525 #include <fcitx-config/hotkey.h>
2626
2727 #define _(s) gettext(s)
28 //定义枚举类型,说明信号的名称和次序
28
2929 enum {
3030 KEYGRAB_BUTTON_CHANGED,
31 KEYGRAB_BUTTON_CURRENT_CHANGED,
3231 LAST_SIGNAL
3332 };
3433 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);
3635 static void keygrab_button_class_init(KeyGrabButtonClass *keygrabbuttonclass);
3736 static void begin_key_grab(KeyGrabButton* self, gpointer v);
3837 static void end_key_grab(KeyGrabButton *self);
4140
4241 G_DEFINE_TYPE(KeyGrabButton, keygrab_button, GTK_TYPE_BUTTON)
4342
44 static void keygrab_button_init(KeyGrabButton *keygrabbutton)
43 static void keygrab_button_init(KeyGrabButton *self)
4544 {
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);
5045 }
5146
5247 static void keygrab_button_class_init(KeyGrabButtonClass *keygrabbuttonclass)
5651 keygrab_button_signals[KEYGRAB_BUTTON_CHANGED] = g_signal_new("changed",
5752 G_TYPE_FROM_CLASS(object_class),
5853 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,
6755 NULL, NULL,
6856 g_cclosure_marshal_VOID__VOID,
6957 G_TYPE_NONE, 0, NULL);
7159 //创建新的自定义控件
7260 GtkWidget* keygrab_button_new(void)
7361 {
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);
7571 }
7672
7773
121117
122118 if ((event->keyval == GDK_KEY_Escape
123119 || 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);
126120 end_key_grab(b);
127121 keygrab_button_set_key(b, 0, 0);
128122 return;
136130 || (key == GDK_KEY_Tab && mods)) {
137131 keygrab_button_set_key(b, key, mods);
138132 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);
142133 return;
143134 }
144135
151142 mods &= ~GDK_SUPER_MASK;
152143 mods |= FcitxKeyState_Super;
153144 }
154 KeyGrabButton* b = KEYGRAB_BUTTON(self);
155145 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 }
158154
159155 label = FcitxHotkeyGetKeyString(key, mods);
160156
161157 if (label == NULL || strlen(label) == 0) {
162 gtk_button_set_label(GTK_BUTTON(b), _("Empty"));
158 gtk_button_set_label(GTK_BUTTON(self), _("Empty"));
163159 } else {
164 gchar* lb = label;
165 gtk_button_set_label(GTK_BUTTON(b), lb);
160 gtk_button_set_label(GTK_BUTTON(self), label);
166161 }
167162
168163 if (label)
2020 #define KEYGRAB_H
2121
2222 #include <gtk/gtk.h>
23 //定义类型宏和转换宏
23
2424 #define TYPE_KEYGRAB_BUTTON (keygrab_button_get_type())
2525 #define KEYGRAB_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj,TYPE_KEYGRAB_BUTTON,KeyGrabButton))
26 //定义实例结构和类结构
26
2727 typedef struct _KeyGrabButton KeyGrabButton;
2828 typedef struct _KeyGrabButtonClass KeyGrabButtonClass;
2929 struct _KeyGrabButton {
30 GtkButton parent; //父控件为横向盒状容器
30 GtkButton parent;
3131 GtkWidget* popup;
3232 gulong handler;
3333 guint key;
3535 };
3636 struct _KeyGrabButtonClass {
3737 GtkButtonClass parent_class;
38 void (*changed)(int, int);
39 void (*current_changed)(int, int);
4038 };
4139
4240 GType keygrab_button_get_type(void);
3030 #include "config_widget.h"
3131 #include "configdesc.h"
3232 #include "im_widget.h"
33 #include "ui_widget.h"
3334
3435 enum {
3536 LIST_ADDON,
4546 static void _fcitx_main_window_add_addon_page(FcitxMainWindow* self);
4647
4748 static void _fcitx_main_window_add_im_page(FcitxMainWindow* self);
49
50 static void _fcitx_main_window_add_ui_page(FcitxMainWindow* self);
4851
4952 void _fcitx_main_window_add_page(FcitxMainWindow* self, const char* name, GtkWidget* widget, const char* stock);
5053
8891
8992 _fcitx_main_window_add_im_page(self);
9093 _fcitx_main_window_add_config_file_page(self);
94 _fcitx_main_window_add_ui_page(self);
9195 _fcitx_main_window_add_addon_page(self);
9296
9397 gtk_widget_set_size_request(GTK_WIDGET(self), -1, 400);
183187 _fcitx_main_window_add_page(self, _("Input Method"), imwidget, GTK_STOCK_EDIT);
184188 }
185189
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
186204 gboolean _filter_addon_func(GtkTreeModel *model,
187205 GtkTreeIter *iter,
188206 gpointer data)
197215
198216 gboolean flag = TRUE;
199217 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))) {
201219 return false;
202220 }
203221 flag = flag && (strlen(filter_text) == 0
4545 if (strcmp(str, "configfile") == 0) {
4646 return SC_ConfigFile;
4747 }
48 if (strcmp(str, "program") == 0) {
49 return SC_Program;
50 }
4851 return SC_None;
4952 }
5053
8588 goto end;
8689 if (strlen(items[2]) == 0 || items[2][0] == '/')
8790 goto end;
88 } else if (type == SC_NativeFile) {
91 } else if (type == SC_NativeFile || type == SC_Program) {
8992 if (g_strv_length(items) != 3)
9093 goto end;
9194 if (strchr(items[2], '*') != NULL)
117120 pattern->configdesc = g_strdup(items[3]);
118121 else if (type == SC_NativeFile)
119122 pattern->nativepath = g_strdup(items[2]);
123 else if (type == SC_Program)
124 pattern->path = g_strdup(items[2]);
120125
121126 g_hash_table_insert(parser->subconfigs, g_strdup(items[0]), pattern);
122127 end:
147152 if (pattern->patternlist)
148153 g_strfreev(pattern->patternlist);
149154
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);
155159
156160 g_free(pattern);
157161 }
165169 subconfig->type = pattern->type;
166170 subconfig->configdesc = g_strdup(pattern->configdesc);
167171 subconfig->nativepath = g_strdup(pattern->nativepath);
172 subconfig->path = g_strdup(pattern->path);
168173 subconfig->name = g_strdup(name);
169174 subconfig->filelist = sub_config_pattern_get_filelist(pattern);
170175
192197 {
193198 size_t size, i;
194199 GHashTable* result = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
195 #if FCITX_CHECK_VERSION(4,2,1)
196200 char** xdgpath = FcitxXDGGetPathWithPrefix(&size, "");
197 #else
198 char** xdgpath = FcitxXDGGetPath(&size, "XDG_CONFIG_HOME", ".config" , PACKAGE , DATADIR, PACKAGE);
199 #endif
200201
201202 for (i = 0; i < size; i ++) {
202203 char* dirpath = realpath(xdgpath[i], NULL);
2323 typedef enum {
2424 SC_None,
2525 SC_ConfigFile,
26 SC_Program,
2627 SC_NativeFile
2728 } SubConfigType;
2829
3132 gchar* configdesc;
3233 gchar* nativepath;
3334 gchar** patternlist;
35 gchar* path;
3436 } FcitxSubConfigPattern;
3537
3638 typedef struct {
3941 GHashTable* filelist;
4042 gchar* nativepath;
4143 gchar* configdesc;
44 gchar* path;
4245 } FcitxSubConfig;
4346
4447 typedef struct {
2828
2929 static void open_subconfig_file(GtkButton *button, gpointer user_data);
3030 static void open_native_file(GtkButton *button, gpointer user_data);
31 static void run_program(GtkButton *button, gpointer user_data);
3132 static void push_into_store_cb(gpointer data, gpointer value, gpointer user_data);
3233
3334 static void
9495 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
9596
9697 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);
9899 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);
100101 g_object_set(G_OBJECT(swin), "margin-left", 5, "margin-right", 5, "shadow-type", GTK_SHADOW_IN, NULL);
101102
102103 GtkListStore* store = gtk_list_store_new(1, G_TYPE_STRING);
120121 GtkWidget* button = gtk_button_new();
121122 gtk_button_set_image(GTK_BUTTON(button), gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON));
122123 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);
123131 gtk_box_pack_start(GTK_BOX(widget), button, FALSE, FALSE, 0);
124132 }
125133 break;
202210 }
203211 }
204212
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 }
205220
206221 void push_into_store_cb(gpointer data,
207222 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
2525 ${REL_SOURCE_ROOT}/gtk3/im_config_dialog.h
2626 ${REL_SOURCE_ROOT}/gtk3/im_dialog.c
2727 ${REL_SOURCE_ROOT}/gtk3/im_dialog.h
28 ${REL_SOURCE_ROOT}/gtk3/ui_widget.c
29 ${REL_SOURCE_ROOT}/gtk3/ui_widget.h
2830 ${REL_SOURCE_ROOT}/gtk3/im_widget.c
2931 ${REL_SOURCE_ROOT}/gtk3/im_widget.h
3032 ${REL_SOURCE_ROOT}/gtk3/keygrab.c
77 msgstr ""
88 "Project-Id-Version: PACKAGE VERSION\n"
99 "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"
1111 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1212 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1313 "Language-Team: LANGUAGE <LL@li.org>\n"
1616 "Content-Type: text/plain; charset=CHARSET\n"
1717 "Content-Transfer-Encoding: 8bit\n"
1818
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
2121 msgid "Clear font setting"
2222 msgstr ""
2323
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
2626 msgid "Other"
2727 msgstr ""
2828
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
3030 msgid "Available Input Method"
3131 msgstr ""
3232
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
3939 msgid "Input Method"
4040 msgstr ""
4141
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
4444 msgid "Only Show Current Language"
4545 msgstr ""
4646
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
4848 msgid "Current Input Method"
4949 msgstr ""
5050
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
5353 msgid "Unknown"
5454 msgstr ""
5555
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
5858 msgid "Please press the new key combination"
5959 msgstr ""
6060
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
6364 msgid "Empty"
6465 msgstr ""
6566
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
6869 msgid "Fcitx Config"
6970 msgstr ""
7071
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
7374 msgid "Global Config"
7475 msgstr ""
7576
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
7879 msgid "Configure"
7980 msgstr ""
8081
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
8384 msgid "Addon"
8485 msgstr ""
8586
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"
8889 msgstr ""
8990
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
91104 msgid "Keyboard layout:"
92105 msgstr ""
93106
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
95112 msgid "Input method settings:"
96113 msgstr ""
97114
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
99116 msgid "Add input method"
100117 msgstr ""
101118
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
103120 msgid "Search Input Method"
104121 msgstr ""
105122
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
106136 #. 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
108138 msgid "Advance"
109139 msgstr ""
110140
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
112142 msgid "Search Addon"
113143 msgstr ""
66 msgstr ""
77 "Project-Id-Version: fcitx\n"
88 "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"
1212 "Language-Team: Chinese Simplified <kde-i18n-doc@kde.org>\n"
1313 "Language: zh_CN\n"
1414 "MIME-Version: 1.0\n"
1515 "Content-Type: text/plain; charset=UTF-8\n"
1616 "Content-Transfer-Encoding: 8bit\n"
1717 "Plural-Forms: nplurals=1; plural=0\n"
18 "X-Generator: Lokalize 1.4\n"
18 "X-Generator: Lokalize 1.5\n"
1919
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
2121 msgid "Add input method"
2222 msgstr "添加输入法"
2323
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
2626 msgid "Addon"
2727 msgstr "附加组件"
2828
2929 #. 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
3131 msgid "Advance"
3232 msgstr "高级"
3333
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
3539 msgid "Available Input Method"
3640 msgstr "可用的输入法"
3741
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
4048 msgid "Clear font setting"
4149 msgstr "清除字体设置"
4250
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
4553 msgid "Configure"
4654 msgstr "配置 "
4755
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
4957 msgid "Current Input Method"
5058 msgstr "当前的输入法"
5159
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
5471 msgid "Empty"
5572 msgstr "空"
5673
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
5976 msgid "Fcitx Config"
6077 msgstr "Fcitx配置"
6178
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
6481 msgid "Global Config"
6582 msgstr "全局配置"
6683
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
7390 msgid "Input Method"
7491 msgstr "输入法"
7592
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
7798 msgid "Input method settings:"
7899 msgstr "输入法设置:"
79100
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
81106 msgid "Keyboard layout:"
82107 msgstr "键盘布局:"
83108
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
86116 msgid "Only Show Current Language"
87117 msgstr "仅显示当前语言"
88118
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
91121 msgid "Other"
92122 msgstr "其他"
93123
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
96126 msgid "Please press the new key combination"
97127 msgstr "请按下新按键组合"
98128
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
100130 msgid "Search Addon"
101131 msgstr "搜索附加组件"
102132
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
104134 msgid "Search Input Method"
105135 msgstr "搜索输入法"
106136
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 "显示高级选项"
110140
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
113143 msgid "Unknown"
114144 msgstr "未知"
145
146 #~ msgid "<b>%s</b>"
147 #~ msgstr "<b>%s</b>"
148
149 #~ msgid "<b>Other</b>"
150 #~ msgstr "<b>其它</b>"
115151
116152 #~ msgid "Addon Configuration"
117153 #~ msgstr "附加组件配置"
66 msgstr ""
77 "Project-Id-Version: fcitx\n"
88 "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"
1212 "Language-Team: Chinese Simplified <kde-i18n-doc@kde.org>\n"
1313 "Language: zh_TW\n"
1414 "MIME-Version: 1.0\n"
1616 "Content-Transfer-Encoding: 8bit\n"
1717 "team/zh_TW/)\n"
1818 "Plural-Forms: nplurals=1; plural=0\n"
19 "X-Generator: Lokalize 1.4\n"
19 "X-Generator: Lokalize 1.5\n"
2020
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
2222 msgid "Add input method"
2323 msgstr "添加輸入法"
2424
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
2727 msgid "Addon"
2828 msgstr "附加元件"
2929
3030 #. 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
3232 msgid "Advance"
3333 msgstr "高級"
3434
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
3640 msgid "Available Input Method"
3741 msgstr "可用輸入法"
3842
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
4149 msgid "Clear font setting"
4250 msgstr "清除字體設定"
4351
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
4654 msgid "Configure"
4755 msgstr "設定"
4856
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
5058 msgid "Current Input Method"
5159 msgstr "目前輸入法"
5260
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
5572 msgid "Empty"
5673 msgstr "空"
5774
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
6077 msgid "Fcitx Config"
6178 msgstr "Fcitx 設定"
6279
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
6582 msgid "Global Config"
6683 msgstr "全局設定"
6784
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
7491 msgid "Input Method"
7592 msgstr "輸入法"
7693
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
7899 msgid "Input method settings:"
79100 msgstr "輸入法設定:"
80101
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
82107 msgid "Keyboard layout:"
83108 msgstr "鍵盤佈局:"
84109
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
87117 msgid "Only Show Current Language"
88118 msgstr "僅顯示当前語言"
89119
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
92122 msgid "Other"
93123 msgstr "其他"
94124
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
97127 msgid "Please press the new key combination"
98128 msgstr "請按下新按鍵組合"
99129
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
101131 msgid "Search Addon"
102132 msgstr "搜索附加元件"
103133
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
105135 msgid "Search Input Method"
106136 msgstr "搜尋輸入法"
107137
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 "顯示高級選項"
111141
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
114144 msgid "Unknown"
115145 msgstr "未知"
116146