Codebase list fcitx-configtool / dcb8cbc
Imported Upstream version 0.4.3 YunQiang Su 11 years ago
8 changed file(s) with 154 addition(s) and 274 deletion(s). Raw diff Collapse all Expand all
77 find_package(PkgConfig REQUIRED)
88
99 if (ENABLE_GTK3)
10 set(GLIB_REQUIRED_VERSION "2.28")
10 PKG_CHECK_MODULES (GLIB2 "glib-2.0 >= ${GLIB_REQUIRED_VERSION}" REQUIRED)
11 PKG_CHECK_MODULES (GIO2 "gio-2.0 >= 2.26" REQUIRED)
1112 else (ENABLE_GTK3)
12 set(GLIB_REQUIRED_VERSION "2.26")
13 PKG_CHECK_MODULES (GTK2 "gtk+-2.0 >= 2.22" REQUIRED)
1314 endif (ENABLE_GTK3)
1415
15 PKG_CHECK_MODULES (GLIB2 "glib-2.0 >= ${GLIB_REQUIRED_VERSION}" REQUIRED)
16 PKG_CHECK_MODULES (GIO2 "gio-2.0 >= 2.26" REQUIRED)
1716 PKG_CHECK_MODULES(ISO_CODES "iso-codes" REQUIRED)
1817 _pkgconfig_invoke("iso-codes" ISO_CODES PREFIX "" "--variable=prefix")
1918
5251
5352 if (ENABLE_GTK2)
5453 add_subdirectory(gtk)
55 endif (ENABLE_GTK2)
54 endif (ENABLE_GTK2)
5655 if (ENABLE_GTK3)
5756 add_subdirectory(gtk3)
5857 endif (ENABLE_GTK3)
0 PKG_CHECK_MODULES (GTK2 "gtk+-2.0 >= 2.22" REQUIRED)
0 PKG_CHECK_MODULES (DBUS_GLIB "dbus-glib-1" REQUIRED)
11 PKG_CHECK_MODULES (UNIQUE "unique-1.0")
22
33 include_directories (
77 ${FCITX4_FCITX_INCLUDE_DIRS}
88 ${FCITX4_FCITX_UTILS_INCLUDE_DIRS}
99 ${FCITX4_FCITX_CONFIG_INCLUDE_DIRS}
10 ${DBUS_GLIB_INCLUDE_DIRS}
1011 )
1112
1213 link_directories (
1617 ${FCITX4_FCITX_LIBRARY_DIRS}
1718 ${FCITX4_FCITX_UTILS_LIBRARY_DIRS}
1819 ${FCITX4_FCITX_CONFIG_LIBRARY_DIRS}
20 ${DBUS_GLIB_LIBRARY_DIRS}
1921 )
2022 if (UNIQUE_FOUND)
2123 include_directories (${UNIQUE_INCLUDE_DIRS})
4547 ${FCITX4_FCITX_CONFIG_LIBRARIES}
4648 ${FCITX4_FCITX_LIBRARIES}
4749 ${GLIB2_LIBRARIES}
48 ${GIO2_LIBRARIES}
50 ${DBUS_GLIB_LIBRARIES}
4951 )
5052
5153 if (UNIQUE_FOUND)
+105
-201
gtk/im.c less more
1616 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
1717 ***************************************************************************/
1818
19 #include <fcitx/module/dbus/dbusstuff.h>
19 #include <dbus/dbus-glib.h>
2020 #include <fcitx/module/ipc/ipc.h>
21
22
21 #include <string.h>
22 #include <stdio.h>
2323 #include "im.h"
2424
25 static const gchar introspection_xml[] =
26 "<node>"
27 " <interface name=\"org.fcitx.Fcitx.InputMethod\">"
28 " <property access=\"readwrite\" type=\"a(sssb)\" name=\"IMList\">"
29 " <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"true\"/>"
30 " </property>"
31 " </interface>"
32 "</node>";
25 #define TYPE_IM \
26 dbus_g_type_get_struct("GValueArray", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID)
3327
28 #define TYPE_ARRAY_IM \
29 dbus_g_type_get_collection("GPtrArray", TYPE_IM)
3430
35 enum {
36 IMLIST_CHANGED_SIGNAL,
37 LAST_SIGNAL
38 };
31 static void _fcitx_inputmethod_item_foreach_cb(gpointer data,
32 gpointer user_data);
3933
40 static guint signals[LAST_SIGNAL] = {0};
34 static FcitxIMItem*
35 _value_to_item (const GValue *value)
36 {
37 const gchar *name, *unique_name, *langcode;
38 gboolean enable;
39 GType type;
4140
41 type = G_VALUE_TYPE (value);
42 g_assert(dbus_g_type_is_struct (type));
43 g_assert(4 == dbus_g_type_get_struct_size (type));
44 g_assert(G_TYPE_STRING == dbus_g_type_get_struct_member_type (type, 0));
45 g_assert(G_TYPE_STRING == dbus_g_type_get_struct_member_type (type, 1));
46 g_assert(G_TYPE_STRING == dbus_g_type_get_struct_member_type (type, 2));
47 g_assert(G_TYPE_BOOLEAN == dbus_g_type_get_struct_member_type (type, 3));
4248
43 G_DEFINE_TYPE(FcitxInputMethod, fcitx_inputmethod, G_TYPE_DBUS_PROXY);
49 GValue cvalue;
50 memset(&cvalue, 0, sizeof(GValue));
4451
52 FcitxIMItem* item = g_malloc0(sizeof(FcitxIMItem));
4553
46 static GDBusInterfaceInfo *
47 fcitx_inputmethod_get_interface_info(void);
48 static void _fcitx_inputmethod_item_foreach_cb(gpointer data, gpointer user_data);
54 g_value_init (&cvalue, dbus_g_type_get_struct_member_type (type, 0));
55 dbus_g_type_struct_get_member (value, 0, &cvalue);
56 name = g_value_get_string(&cvalue);
57 item->name = strdup(name);
58 g_value_unset (&cvalue);
4959
50 static GDBusInterfaceInfo *
51 fcitx_inputmethod_get_interface_info(void)
52 {
53 static gsize has_info = 0;
54 static GDBusInterfaceInfo *info = NULL;
55 if (g_once_init_enter(&has_info)) {
56 GDBusNodeInfo *introspection_data;
57 introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
58 info = introspection_data->interfaces[0];
59 g_once_init_leave(&has_info, 1);
60 }
61 return info;
60 g_value_init (&cvalue, dbus_g_type_get_struct_member_type (type, 1));
61 dbus_g_type_struct_get_member (value, 1, &cvalue);
62 unique_name = g_value_get_string(&cvalue);
63 item->unique_name = strdup(unique_name);
64 g_value_unset (&cvalue);
65
66 g_value_init (&cvalue, dbus_g_type_get_struct_member_type (type, 2));
67 dbus_g_type_struct_get_member (value, 2, &cvalue);
68 langcode = g_value_get_string(&cvalue);
69 item->langcode = strdup(langcode);
70 g_value_unset (&cvalue);
71
72 g_value_init (&cvalue, dbus_g_type_get_struct_member_type (type, 3));
73 dbus_g_type_struct_get_member (value, 3, &cvalue);
74 enable = g_value_get_boolean(&cvalue);
75 item->enable = enable;
76 g_value_unset (&cvalue);
77 return item;
6278 }
6379
6480 static void
65 fcitx_inputmethod_finalize(GObject *object)
81 _item_to_value (FcitxIMItem* item, GValue *value)
6682 {
67 G_GNUC_UNUSED FcitxInputMethod *im = FCITX_INPUTMETHOD(object);
68
69 if (G_OBJECT_CLASS(fcitx_inputmethod_parent_class)->finalize != NULL)
70 G_OBJECT_CLASS(fcitx_inputmethod_parent_class)->finalize(object);
83 g_value_init (value, TYPE_IM);
84 GValueArray *va = g_value_array_new (4);
85 g_value_array_append (va, NULL);
86 g_value_init(&va->values[0], G_TYPE_STRING);
87 g_value_set_string(&va->values[0], item->name);
88 g_value_array_append (va, NULL);
89 g_value_init(&va->values[1], G_TYPE_STRING);
90 g_value_set_string(&va->values[1], item->unique_name);
91 g_value_array_append (va, NULL);
92 g_value_init(&va->values[2], G_TYPE_STRING);
93 g_value_set_string(&va->values[2], item->langcode);
94 g_value_array_append (va, NULL);
95 g_value_init(&va->values[3], G_TYPE_BOOLEAN);
96 g_value_set_boolean(&va->values[3], item->enable);
97 g_value_take_boxed (value, va);
7198 }
7299
73100 static void
74 fcitx_inputmethod_init(FcitxInputMethod *im)
101 _collection_iterator (const GValue *value,
102 gpointer user_data)
75103 {
76 /* Sets the expected interface */
77 g_dbus_proxy_set_interface_info(G_DBUS_PROXY(im), fcitx_inputmethod_get_interface_info());
104 GPtrArray *children = user_data;
105
106 g_ptr_array_add (children, _value_to_item (value));
78107 }
79108
80 GPtrArray *
81 fcitx_inputmethod_get_imlist(FcitxInputMethod* im)
109 void fcitx_inputmethod_set_imlist(DBusGProxy* proxy, GPtrArray* array)
110 {
111 GValue value;
112 memset(&value, 0, sizeof(GValue));
113 g_value_init(&value, TYPE_ARRAY_IM);
114 g_value_take_boxed (&value, dbus_g_type_specialized_construct (
115 G_VALUE_TYPE (&value)));
116 DBusGTypeSpecializedAppendContext ctx;
117
118 dbus_g_type_specialized_init_append (&value, &ctx);
119 g_ptr_array_foreach(array, _fcitx_inputmethod_item_foreach_cb, &ctx);
120 dbus_g_type_specialized_collection_end_append (&ctx);
121 dbus_g_proxy_call_no_reply(proxy, "Set", G_TYPE_STRING, FCITX_IM_DBUS_INTERFACE, G_TYPE_STRING, "IMList", G_TYPE_VALUE, &value, G_TYPE_INVALID);
122 g_value_unset(&value);
123 }
124
125 GPtrArray* fcitx_inputmethod_get_imlist(DBusGProxy* proxy)
82126 {
83127 GPtrArray *array = NULL;
84 GVariant* value;
85 GVariantIter *iter;
86 gchar *name, *unique_name, *langcode;
87 gboolean enable;
88 value = g_dbus_proxy_get_cached_property(G_DBUS_PROXY(im), "IMList");
128 GValue value;
129 memset(&value, 0, sizeof(GValue));
89130
90 if (value == NULL) {
91 GError* error = NULL;
92 GVariant* result = g_dbus_connection_call_sync(g_dbus_proxy_get_connection(G_DBUS_PROXY(im)),
93 g_dbus_proxy_get_name(G_DBUS_PROXY(im)),
94 FCITX_IM_DBUS_PATH,
95 "org.freedesktop.DBus.Properties",
96 "Get",
97 g_variant_new("(ss)", FCITX_IM_DBUS_INTERFACE, "IMList"),
98 G_VARIANT_TYPE("(v)"),
99 G_DBUS_CALL_FLAGS_NONE,
100 -1, /* timeout */
101 NULL,
102 &error);
103
104 if (error) {
105 g_warning("%s", error->message);
106 g_error_free(error);
107 } else if (result) {
108 g_variant_get(result, "(v)", &value);
109 }
110 }
111
112 if (value) {
113 array = g_ptr_array_new();
114 g_variant_get(value, "a(sssb)", &iter);
115 while (g_variant_iter_next(iter, "(sssb)", &name, &unique_name, &langcode, &enable, NULL)) {
116 FcitxIMItem* item = g_malloc0(sizeof(FcitxIMItem));
117 item->enable = enable;
118 item->name = strdup(name);
119 item->unique_name = strdup(unique_name);
120 item->langcode = strdup(langcode);
121 g_ptr_array_add(array, item);
122 g_free(name);
123 g_free(unique_name);
124 g_free(langcode);
125 }
126 g_variant_iter_free(iter);
127
128 g_variant_unref(value);
129 }
130
131 return array;
132 }
133
134
135 void
136 fcitx_inputmethod_set_imlist(FcitxInputMethod *im, GPtrArray* array)
137 {
138 GVariantBuilder builder;
139 g_variant_builder_init(&builder, G_VARIANT_TYPE("a(sssb)"));
140 g_ptr_array_foreach(array, _fcitx_inputmethod_item_foreach_cb, &builder);
141 GVariant* value = g_variant_builder_end(&builder);
142131 GError* error = NULL;
143 GVariant* result = g_dbus_connection_call_sync(g_dbus_proxy_get_connection(G_DBUS_PROXY(im)),
144 g_dbus_proxy_get_name(G_DBUS_PROXY(im)),
145 FCITX_IM_DBUS_PATH,
146 "org.freedesktop.DBus.Properties",
147 "Set",
148 g_variant_new("(ssv)", FCITX_IM_DBUS_INTERFACE, "IMList", value),
149 G_VARIANT_TYPE_UNIT,
150 G_DBUS_CALL_FLAGS_NONE,
151 -1, /* timeout */
152 NULL,
153 &error);
132 dbus_g_proxy_call(proxy, "Get", &error, G_TYPE_STRING, FCITX_IM_DBUS_INTERFACE, G_TYPE_STRING, "IMList", G_TYPE_INVALID, G_TYPE_VALUE, &value, G_TYPE_INVALID);
154133
155134 if (error) {
156135 g_warning("%s", error->message);
157136 g_error_free(error);
137 return NULL;
158138 }
159139
160 g_variant_unref(result);
161 g_variant_unref(value);
162 }
140 array = g_ptr_array_new();
141 GType type = G_VALUE_TYPE (&value);
163142
164 static void
165 fcitx_inputmethod_g_properties_changed(GDBusProxy *proxy,
166 GVariant *changed_properties,
167 const gchar* const *invalidated_properties)
168 {
169 FcitxInputMethod *user = FCITX_INPUTMETHOD(proxy);
170 GVariantIter *iter;
171 const gchar *key;
143 if (dbus_g_type_is_collection (type))
144 {
145 dbus_g_type_collection_value_iterate (&value, _collection_iterator,
146 array);
147 }
148 g_value_unset(&value);
172149
173 if (changed_properties != NULL) {
174 g_variant_get(changed_properties, "a{sv}", &iter);
175 while (g_variant_iter_next(iter, "{&sv}", &key, NULL)) {
176 if (g_strcmp0(key, "IMList") == 0)
177 g_signal_emit(user, signals[IMLIST_CHANGED_SIGNAL], 0);
178 }
179 g_variant_iter_free(iter);
180 }
181
182 if (invalidated_properties != NULL) {
183 const gchar*const* item = invalidated_properties;
184 while (*item) {
185 if (g_strcmp0(*item, "IMList") == 0)
186 g_signal_emit(user, signals[IMLIST_CHANGED_SIGNAL], 0);
187 item++;
188 }
189 }
190 }
191
192 static void
193 fcitx_inputmethod_g_signal(GDBusProxy *proxy,
194 const gchar *sender_name,
195 const gchar *signal_name,
196 GVariant *parameters)
197 {
198 }
199
200 static void
201 fcitx_inputmethod_class_init(FcitxInputMethodClass *klass)
202 {
203 GObjectClass *gobject_class;
204 GDBusProxyClass *proxy_class;
205
206 gobject_class = G_OBJECT_CLASS(klass);
207 gobject_class->finalize = fcitx_inputmethod_finalize;
208
209 proxy_class = G_DBUS_PROXY_CLASS(klass);
210 proxy_class->g_signal = fcitx_inputmethod_g_signal;
211 proxy_class->g_properties_changed = fcitx_inputmethod_g_properties_changed;
212
213 signals[IMLIST_CHANGED_SIGNAL] = g_signal_new("imlist-changed",
214 FCITX_TYPE_INPUT_METHOD,
215 G_SIGNAL_RUN_LAST,
216 G_STRUCT_OFFSET(FcitxInputMethod, imlist_changed),
217 NULL,
218 NULL,
219 g_cclosure_marshal_VOID__VOID,
220 G_TYPE_NONE,
221 0);
222 }
223
224 FcitxInputMethod*
225 fcitx_inputmethod_new(GBusType bus_type,
226 GDBusProxyFlags flags,
227 int display_number,
228 GCancellable *cancellable,
229 GError **error)
230 {
231 gchar servicename[64];
232 sprintf(servicename, "%s-%d", FCITX_DBUS_SERVICE, display_number);
233
234 char* name = servicename;
235 FcitxInputMethod* im = g_initable_new(FCITX_TYPE_INPUT_METHOD,
236 cancellable,
237 error,
238 "g-flags", flags,
239 "g-name", name,
240 "g-bus-type", bus_type,
241 "g-object-path", FCITX_IM_DBUS_PATH,
242 "g-interface-name", FCITX_IM_DBUS_INTERFACE,
243 NULL);
244
245 if (im != NULL)
246 return FCITX_INPUTMETHOD(im);
247 else
248 return NULL;
249 return im;
150 return array;
250151 }
251152
252153 void fcitx_inputmethod_item_free(gpointer data)
262163 gpointer user_data)
263164 {
264165 FcitxIMItem* item = data;
265 GVariantBuilder* builder = user_data;
166 DBusGTypeSpecializedAppendContext* ctx = user_data;
266167
267 g_variant_builder_add(builder, "(sssb)", item->name, item->unique_name, item->langcode, item->enable);
268 }
168 GValue v;
169 memset(&v, 0, sizeof(GValue));
170 _item_to_value(item, &v);
171 dbus_g_type_specialized_collection_append (ctx, &v);
172 }
1919 #ifndef _IM_H_
2020 #define _IM_H_
2121
22 #include <gio/gio.h>
22 #include <glib.h>
23 #include <dbus/dbus-glib.h>
2324
2425 G_BEGIN_DECLS
25
26 typedef struct _FcitxInputMethod FcitxInputMethod;
27 typedef struct _FcitxInputMethodClass FcitxInputMethodClass;
28
29 #define FCITX_TYPE_INPUT_METHOD (fcitx_inputmethod_get_type ())
30 #define FCITX_INPUTMETHOD(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), FCITX_TYPE_INPUT_METHOD, FcitxInputMethod))
31 #define FCITX_INPUTMETHOD_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), FCITX_TYPE_INPUT_METHOD, FcitxInputMethodClass))
32 #define FCITX_INPUTMETHOD_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), FCITX_TYPE_INPUT_METHOD, FcitxInputMethodClass))
33
34 struct _FcitxInputMethod {
35 GDBusProxy parent_instance;
36 void (*imlist_changed)(FcitxInputMethod* im);
37 };
38
39 struct _FcitxInputMethodClass {
40 GDBusProxyClass parent_class;
41 };
4226
4327 typedef struct _FcitxIMItem {
4428 gchar* name;
4731 gboolean enable;
4832 } FcitxIMItem;
4933
50
51 FcitxInputMethod* fcitx_inputmethod_new(GBusType bus_type,
52 GDBusProxyFlags flags,
53 int display_number,
54 GCancellable *cancellable,
55 GError **error);
56
57 GType fcitx_inputmethod_get_type(void) G_GNUC_CONST;
58
59 GPtrArray* fcitx_inputmethod_get_imlist(FcitxInputMethod* im);
60
61 void fcitx_inputmethod_set_imlist(FcitxInputMethod* im, GPtrArray* array);
62
34 void fcitx_inputmethod_set_imlist(DBusGProxy* proxy, GPtrArray* array);
35 GPtrArray* fcitx_inputmethod_get_imlist(DBusGProxy* proxy);
6336 void fcitx_inputmethod_item_free(gpointer data);
6437
6538 G_END_DECLS
2222
2323 #include "common.h"
2424 #include "im_widget.h"
25 #include "gdm-languages.h"
2526 #include "im.h"
26 #include "gdm-languages.h"
2727
2828 G_DEFINE_TYPE(FcitxImWidget, fcitx_im_widget, GTK_TYPE_HBOX)
2929
217217 g_free(self->focus);
218218 }
219219
220 void _fcitx_im_widget_imlist_changed_cb(FcitxInputMethod* im, gpointer user_data)
221 {
222 FcitxImWidget* self = user_data;
223 _fcitx_im_widget_load(self);
224 }
225220
226221 void _fcitx_im_widget_connect(FcitxImWidget* self)
227222 {
228223 GError* error = NULL;
229 self->improxy = fcitx_inputmethod_new(G_BUS_TYPE_SESSION,
230 G_DBUS_PROXY_FLAGS_NONE,
231 fcitx_utils_get_display_number(),
232 NULL,
233 &error
234 );
235 if (self->improxy == NULL) {
224 self->conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
225 if (self->conn == NULL) {
236226 g_error_free(error);
237227 return;
238228 }
239 g_signal_connect(self->improxy, "imlist-changed", G_CALLBACK(_fcitx_im_widget_imlist_changed_cb), self);
229 sprintf(self->servicename, "%s-%d", FCITX_DBUS_SERVICE, fcitx_utils_get_display_number());
230 self->improxy = dbus_g_proxy_new_for_name(self->conn,
231 self->servicename,
232 FCITX_IM_DBUS_PATH,
233 DBUS_INTERFACE_PROPERTIES);
240234
241235 _fcitx_im_widget_load(self);
242236 }
260254 ct.langTable = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
261255 g_ptr_array_foreach(self->array, _fcitx_inputmethod_insert_foreach_cb, &ct);
262256 g_hash_table_unref(ct.langTable);
263
257
264258 _fcitx_im_widget_im_selection_changed(gtk_tree_view_get_selection(GTK_TREE_VIEW(self->imview)), self);
265259 g_free(self->focus);
266260 self->focus = NULL;
267
261
268262 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self->onlycurlangcheckbox)))
269263 gtk_tree_view_expand_all (GTK_TREE_VIEW(self->availimview));
270264 }
277271 FcitxIMItem* item = data;
278272 FcitxImWidget* self = ct->widget;
279273 GtkTreeIter iter;
280
274
281275 GtkTreeIter* langIter = g_hash_table_lookup(ct->langTable, item->langcode);
282
276
283277 if (langIter == NULL) {
284278 langIter = g_new(GtkTreeIter, 1);
285279 gtk_tree_store_append(self->availimstore, langIter, NULL);
286
280
287281 char* lang = NULL;
288282 if (strlen(item->langcode) != 0)
289283 lang = gdm_get_language_from_name(item->langcode, NULL);
297291 gtk_tree_store_set(self->availimstore, langIter, AVAIL_TREE_LANG, item->langcode, -1);
298292 gtk_tree_store_set(self->availimstore, langIter, AVAIL_TREE_IM, NULL, -1);
299293 g_free(lang);
300
294
301295 g_hash_table_insert(ct->langTable, g_strdup(item->langcode), langIter);
302296 }
303297
310304 gtk_tree_selection_select_iter(selection, &iter);
311305 }
312306 } else {
313
307
314308 gtk_tree_store_append(self->availimstore, &iter, langIter);
315309 gtk_tree_store_set(self->availimstore, &iter, AVAIL_TREE_IM_STRING, item->name, -1);
316310 gtk_tree_store_set(self->availimstore, &iter, AVAIL_TREE_LANG, NULL, -1);
387381
388382 g_ptr_array_remove(self->array, item);
389383 g_ptr_array_add(self->array, item);
390
384
391385 g_free(self->focus);
392386 self->focus = g_strdup(item->unique_name);
393387
394388 fcitx_inputmethod_set_imlist(self->improxy, self->array);
389 _fcitx_im_widget_load(self);
395390 }
396391 }
397392
412407 item->enable = false;
413408
414409 fcitx_inputmethod_set_imlist(self->improxy, self->array);
410 _fcitx_im_widget_load(self);
415411 }
416412
417413 }
450446 self->focus = g_strdup(item->unique_name);
451447
452448 fcitx_inputmethod_set_imlist(self->improxy, self->array);
449 _fcitx_im_widget_load(self);
453450 }
454451 }
455452 }
488485 self->focus = g_strdup(item->unique_name);
489486
490487 fcitx_inputmethod_set_imlist(self->improxy, self->array);
488 _fcitx_im_widget_load(self);
491489 }
492490 }
493491 }
2121
2222 #include <gtk/gtk.h>
2323 #include <gio/gio.h>
24 #include "im.h"
24 #include <dbus/dbus-glib.h>
2525
2626 G_BEGIN_DECLS
2727
5555 GtkWidget* moveupbutton;
5656 GtkWidget* movedownbutton;
5757 char servicename[IC_NAME_MAX];
58 FcitxInputMethod* improxy;
58 DBusGProxy* improxy;
5959 GPtrArray* array;
6060 GtkWidget* filterentry;
6161 GtkTreeModel* filtermodel;
6262 GtkWidget* onlycurlangcheckbox;
6363 GtkTreeModel* sortmodel;
6464 gchar* focus;
65 DBusGConnection* conn;
6566 } FcitxImWidget;
6667
6768 typedef struct {
2121 #include <libintl.h>
2222 #include <string.h>
2323 #include <stdlib.h>
24 #include <unistd.h>
25 #include <fcitx-config/hotkey.h>
2426 #include "keygrab.h"
25 #include <fcitx-config/hotkey.h>
2627
2728 #define _(s) gettext(s)
2829 //定义枚举类型,说明信号的名称和次序
99100 guint key;
100101 GdkModifierType mods = event->state & gtk_accelerator_get_default_mod_mask();
101102
102 if ((event->keyval == GDK_KEY_Escape
103 || event->keyval == GDK_KEY_Return) && !mods) {
104 if (event->keyval == GDK_KEY_Escape)
103 if ((event->keyval == FcitxKey_Escape
104 || event->keyval == FcitxKey_Return) && !mods) {
105 if (event->keyval == FcitxKey_Escape)
105106 g_signal_emit_by_name(G_OBJECT(b), "changed", b->key, b->mods);
106107 end_key_grab(b);
107108 keygrab_button_set_key(b, 0, 0);
109110 }
110111
111112 key = gdk_keyval_to_upper(event->keyval);
112 if (key == GDK_KEY_ISO_Left_Tab)
113 key = GDK_KEY_Tab;
113 if (key == FcitxKey_ISO_Left_Tab)
114 key = FcitxKey_Tab;
114115
115116 if (gtk_accelerator_valid(key, mods)
116 || (key == GDK_KEY_Tab && mods)) {
117 || (key == FcitxKey_Tab && mods)) {
117118 keygrab_button_set_key(b, key, mods);
118119 end_key_grab(b);
119120 b->key = key;
9999
100100 self->pagestore = _fcitx_main_window_create_model();
101101 self->pageview = gtk_icon_view_new_with_model(GTK_TREE_MODEL(self->pagestore));
102
102
103103 gtk_icon_view_set_pixbuf_column(GTK_ICON_VIEW(self->pageview), PAGE_LIST_ICON);
104104 gtk_icon_view_set_text_column(GTK_ICON_VIEW(self->pageview), PAGE_LIST_NAME);
105 #if GTK_CHECK_VERSION(2, 22, 0)
105106 gtk_icon_view_set_item_orientation(GTK_ICON_VIEW(self->pageview), GTK_ORIENTATION_VERTICAL);
107 #endif
106108
107109 _fcitx_main_window_add_im_page(self);
108110 _fcitx_main_window_add_config_file_page(self);
187189 GtkTreeIter iter;
188190 ConfigPage* page;
189191 FcitxMainWindow* self = data;
190
192
191193 GList* list = gtk_icon_view_get_selected_items(iconview);
192194
193195 if (list) {
197199 PAGE_LIST_NAME, &title,
198200 PAGE_LIST_PAGE, &page,
199201 -1);
200
202
201203 gchar* text = g_strdup_printf("<b>%s</b>", title);
202204 gtk_label_set_markup(GTK_LABEL(self->pagelabel), text);
203205 g_free(text);
214216 gtk_icon_view_select_path(GTK_ICON_VIEW(self->pageview), path);
215217 gtk_tree_path_free(path);
216218 }
217
219
218220 g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
219221 g_list_free (list);
220222 }