| OLD | NEW |
| 1 /* vim:set et sts=4: */ | 1 /* vim:set et sts=4: */ |
| 2 /* ibus - The Input Bus | 2 /* ibus - The Input Bus |
| 3 * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com> | 3 * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com> |
| 4 * Copyright (C) 2008-2010 Red Hat, Inc. | 4 * Copyright (C) 2008-2010 Red Hat, Inc. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Lesser General Public | 7 * modify it under the terms of the GNU Lesser General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 /* functions prototype */ | 49 /* functions prototype */ |
| 50 static void bus_ibus_impl_destroy (BusIBusImpl *ibus); | 50 static void bus_ibus_impl_destroy (BusIBusImpl *ibus); |
| 51 static gboolean bus_ibus_impl_ibus_message (BusIBusImpl *ibus, | 51 static gboolean bus_ibus_impl_ibus_message (BusIBusImpl *ibus, |
| 52 BusConnection *connection, | 52 BusConnection *connection, |
| 53 IBusMessage *message); | 53 IBusMessage *message); |
| 54 static void bus_ibus_impl_add_factory (BusIBusImpl *ibus, | 54 static void bus_ibus_impl_add_factory (BusIBusImpl *ibus, |
| 55 BusFactoryProxy *factory); | 55 BusFactoryProxy *factory); |
| 56 static void bus_ibus_impl_set_trigger (BusIBusImpl *ibus, | 56 static void bus_ibus_impl_set_trigger (BusIBusImpl *ibus, |
| 57 GValue *value); | 57 GValue *value); |
| 58 static void bus_ibus_impl_set_next_engine_in_menu |
| 59 (BusIBusImpl *ibus, |
| 60 GValue *value); |
| 61 static void bus_ibus_impl_set_previous_engine |
| 62 (BusIBusImpl *ibus, |
| 63 GValue *value); |
| 64 |
| 58 static void bus_ibus_impl_set_preload_engines | 65 static void bus_ibus_impl_set_preload_engines |
| 59 (BusIBusImpl *ibus, | 66 (BusIBusImpl *ibus, |
| 60 GValue *value); | 67 GValue *value); |
| 61 static void bus_ibus_impl_set_use_sys_layout | 68 static void bus_ibus_impl_set_use_sys_layout |
| 62 (BusIBusImpl *ibus, | 69 (BusIBusImpl *ibus, |
| 63 GValue *value); | 70 GValue *value); |
| 64 static void bus_ibus_impl_set_embed_preedit_text | 71 static void bus_ibus_impl_set_embed_preedit_text |
| 65 (BusIBusImpl *ibus, | 72 (BusIBusImpl *ibus, |
| 66 GValue *value); | 73 GValue *value); |
| 74 static void bus_ibus_impl_set_enable_by_default |
| 75 (BusIBusImpl *ibus, |
| 76 GValue *value); |
| 67 | 77 |
| 68 static void bus_ibus_impl_set_use_global_engine | 78 static void bus_ibus_impl_set_use_global_engine |
| 69 (BusIBusImpl *ibus, | 79 (BusIBusImpl *ibus, |
| 70 GValue *value); | 80 GValue *value); |
| 71 static void bus_ibus_impl_set_global_engine (BusIBusImpl *ibus, | 81 static void bus_ibus_impl_set_global_engine (BusIBusImpl *ibus, |
| 72 BusEngineProxy *engine); | 82 BusEngineProxy *engine); |
| 73 | 83 |
| 74 static void bus_ibus_impl_registry_changed (BusIBusImpl *ibus); | 84 static void bus_ibus_impl_registry_changed (BusIBusImpl *ibus); |
| 75 static void _factory_destroy_cb (BusFactoryProxy *factory, | 85 static void _factory_destroy_cb (BusFactoryProxy *factory, |
| 76 BusIBusImpl *ibus); | 86 BusIBusImpl *ibus); |
| 77 | 87 |
| 88 static void bus_ibus_impl_set_context_engine(BusIBusImpl *ibus, |
| 89 BusInputContext *context, |
| 90 BusEngineProxy *engine); |
| 91 |
| 92 static gchar *bus_ibus_impl_load_global_engine_name_from_config |
| 93 (BusIBusImpl *ibus); |
| 94 static void bus_ibus_impl_save_global_engine_name_to_config |
| 95 (BusIBusImpl *ibus); |
| 96 |
| 97 static gchar *bus_ibus_impl_load_global_previous_engine_name_from_config |
| 98 (BusIBusImpl *ibus); |
| 99 static void bus_ibus_impl_save_global_previous_engine_name_to_config |
| 100 (BusIBusImpl *ibus); |
| 101 |
| 78 G_DEFINE_TYPE(BusIBusImpl, bus_ibus_impl, IBUS_TYPE_SERVICE) | 102 G_DEFINE_TYPE(BusIBusImpl, bus_ibus_impl, IBUS_TYPE_SERVICE) |
| 79 | 103 |
| 80 BusIBusImpl * | 104 BusIBusImpl * |
| 81 bus_ibus_impl_get_default (void) | 105 bus_ibus_impl_get_default (void) |
| 82 { | 106 { |
| 83 static BusIBusImpl *ibus = NULL; | 107 static BusIBusImpl *ibus = NULL; |
| 84 | 108 |
| 85 if (ibus == NULL) { | 109 if (ibus == NULL) { |
| 86 ibus = (BusIBusImpl *) g_object_new (BUS_TYPE_IBUS_IMPL, | 110 ibus = (BusIBusImpl *) g_object_new (BUS_TYPE_IBUS_IMPL, |
| 87 "path", IBUS_PATH_IBUS, | 111 "path", IBUS_PATH_IBUS, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 bus_ibus_impl_set_hotkey (ibus, hotkey, value); | 180 bus_ibus_impl_set_hotkey (ibus, hotkey, value); |
| 157 if (value == NULL) { | 181 if (value == NULL) { |
| 158 ibus_hotkey_profile_add_hotkey (ibus->hotkey_profile, | 182 ibus_hotkey_profile_add_hotkey (ibus->hotkey_profile, |
| 159 IBUS_space, | 183 IBUS_space, |
| 160 IBUS_CONTROL_MASK, | 184 IBUS_CONTROL_MASK, |
| 161 hotkey); | 185 hotkey); |
| 162 } | 186 } |
| 163 } | 187 } |
| 164 | 188 |
| 165 static void | 189 static void |
| 166 bus_ibus_impl_set_next_engine (BusIBusImpl *ibus, | 190 bus_ibus_impl_set_next_engine_in_menu (BusIBusImpl *ibus, |
| 167 GValue *value) | 191 GValue *value) |
| 168 { | 192 { |
| 169 GQuark hotkey = g_quark_from_static_string ("next-engine"); | 193 GQuark hotkey = g_quark_from_static_string ("next-engine-in-menu"); |
| 170 bus_ibus_impl_set_hotkey (ibus, hotkey, value); | 194 bus_ibus_impl_set_hotkey (ibus, hotkey, value); |
| 171 } | 195 } |
| 172 | 196 |
| 173 static void | 197 static void |
| 174 bus_ibus_impl_set_prev_engine (BusIBusImpl *ibus, | 198 bus_ibus_impl_set_previous_engine (BusIBusImpl *ibus, |
| 175 GValue *value) | 199 GValue *value) |
| 176 { | 200 { |
| 177 GQuark hotkey = g_quark_from_static_string ("prev-engine"); | 201 GQuark hotkey = g_quark_from_static_string ("previous-engine"); |
| 178 bus_ibus_impl_set_hotkey (ibus, hotkey, value); | 202 bus_ibus_impl_set_hotkey (ibus, hotkey, value); |
| 179 } | 203 } |
| 180 | 204 |
| 181 static void | 205 static void |
| 182 bus_ibus_impl_set_preload_engines (BusIBusImpl *ibus, | 206 bus_ibus_impl_set_preload_engines (BusIBusImpl *ibus, |
| 183 GValue *value) | 207 GValue *value) |
| 184 { | 208 { |
| 185 GList *engine_list = NULL; | 209 GList *engine_list = NULL; |
| 186 | 210 |
| 187 g_list_foreach (ibus->engine_list, (GFunc) g_object_unref, NULL); | 211 g_list_foreach (ibus->engine_list, (GFunc) g_object_unref, NULL); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 static void | 250 static void |
| 227 bus_ibus_impl_set_use_sys_layout (BusIBusImpl *ibus, | 251 bus_ibus_impl_set_use_sys_layout (BusIBusImpl *ibus, |
| 228 GValue *value) | 252 GValue *value) |
| 229 { | 253 { |
| 230 if (value != NULL && G_VALUE_TYPE (value) == G_TYPE_BOOLEAN) { | 254 if (value != NULL && G_VALUE_TYPE (value) == G_TYPE_BOOLEAN) { |
| 231 ibus->use_sys_layout = g_value_get_boolean (value); | 255 ibus->use_sys_layout = g_value_get_boolean (value); |
| 232 } | 256 } |
| 233 } | 257 } |
| 234 | 258 |
| 235 static void | 259 static void |
| 236 bus_ibus_impl_set_embed_preedit_text (BusIBusImpl *ibus, | 260 bus_ibus_impl_set_embed_preedit_text (BusIBusImpl *ibus, |
| 237 » » » » » » » GValue
*value){ | 261 GValue *value) |
| 262 { |
| 238 if (value != NULL && G_VALUE_TYPE (value) == G_TYPE_BOOLEAN) { | 263 if (value != NULL && G_VALUE_TYPE (value) == G_TYPE_BOOLEAN) { |
| 239 ibus->embed_preedit_text = g_value_get_boolean (value); | 264 ibus->embed_preedit_text = g_value_get_boolean (value); |
| 240 } | 265 } |
| 241 | |
| 242 } | 266 } |
| 243 | 267 |
| 244 static void | 268 static void |
| 269 bus_ibus_impl_set_enable_by_default (BusIBusImpl *ibus, |
| 270 GValue *value) |
| 271 { |
| 272 if (value != NULL && G_VALUE_TYPE (value) == G_TYPE_BOOLEAN) { |
| 273 ibus->enable_by_default = g_value_get_boolean (value); |
| 274 } |
| 275 } |
| 276 |
| 277 static void |
| 245 bus_ibus_impl_set_use_global_engine (BusIBusImpl *ibus, | 278 bus_ibus_impl_set_use_global_engine (BusIBusImpl *ibus, |
| 246 GValue *value) | 279 GValue *value) |
| 247 { | 280 { |
| 248 gboolean new_value; | 281 gboolean new_value; |
| 249 | 282 |
| 250 if (value == NULL || G_VALUE_TYPE (value) != G_TYPE_BOOLEAN) { | 283 if (value == NULL || G_VALUE_TYPE (value) != G_TYPE_BOOLEAN) { |
| 251 return; | 284 return; |
| 252 } | 285 } |
| 253 | 286 |
| 254 new_value = g_value_get_boolean (value); | 287 new_value = g_value_get_boolean (value); |
| 255 if (ibus->use_global_engine == new_value) { | 288 if (ibus->use_global_engine == new_value) { |
| 256 return; | 289 return; |
| 257 } | 290 } |
| 258 | 291 |
| 259 if (new_value == TRUE) { | 292 if (new_value == TRUE) { |
| 260 BusEngineProxy *engine; | 293 BusEngineProxy *engine; |
| 261 /* turn on use_global_engine option */ | 294 /* turn on use_global_engine option */ |
| 262 ibus->use_global_engine = TRUE; | 295 ibus->use_global_engine = TRUE; |
| 263 engine = ibus->focused_context != NULL ? | 296 engine = ibus->focused_context != NULL ? |
| 264 bus_input_context_get_engine (ibus->focused_context) : NULL; | 297 bus_input_context_get_engine (ibus->focused_context) : NULL; |
| 265 if (engine) { | 298 if (engine) { |
| 266 bus_ibus_impl_set_global_engine (ibus, engine); | 299 bus_ibus_impl_set_global_engine (ibus, engine); |
| 267 } | 300 } |
| 268 } | 301 } |
| 269 else { | 302 else { |
| 270 /* turn off use_global_engine option */ | 303 /* turn off use_global_engine option */ |
| 271 bus_ibus_impl_set_global_engine (ibus, NULL); | 304 bus_ibus_impl_set_global_engine (ibus, NULL); |
| 272 ibus->use_global_engine = FALSE; | 305 ibus->use_global_engine = FALSE; |
| 306 |
| 307 g_free (ibus->global_previous_engine_name); |
| 273 } | 308 } |
| 274 } | 309 } |
| 275 | 310 |
| 276 static gint | 311 static gint |
| 277 _engine_desc_cmp (IBusEngineDesc *desc1, | 312 _engine_desc_cmp (IBusEngineDesc *desc1, |
| 278 IBusEngineDesc *desc2) | 313 IBusEngineDesc *desc2) |
| 279 { | 314 { |
| 280 return - ((gint) desc1->rank) + ((gint) desc2->rank); | 315 return - ((gint) desc1->rank) + ((gint) desc2->rank); |
| 281 } | 316 } |
| 282 | 317 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 | 383 |
| 349 gint i; | 384 gint i; |
| 350 GValue value = { 0 }; | 385 GValue value = { 0 }; |
| 351 | 386 |
| 352 const static struct { | 387 const static struct { |
| 353 gchar *section; | 388 gchar *section; |
| 354 gchar *key; | 389 gchar *key; |
| 355 void ( *func) (BusIBusImpl *, GValue *); | 390 void ( *func) (BusIBusImpl *, GValue *); |
| 356 } entries [] = { | 391 } entries [] = { |
| 357 { "general/hotkey", "trigger", bus_ibus_impl_set_trigger }, | 392 { "general/hotkey", "trigger", bus_ibus_impl_set_trigger }, |
| 358 { "general/hotkey", "next_engine", bus_ibus_impl_set_next_engine }, | 393 { "general/hotkey", "next_engine_in_menu", bus_ibus_impl_set_next_engine
_in_menu }, |
| 359 { "general/hotkey", "prev_engine", bus_ibus_impl_set_prev_engine }, | 394 { "general/hotkey", "previous_engine", bus_ibus_impl_set_previous_engine
}, |
| 360 { "general", "preload_engines", bus_ibus_impl_set_preload_engines }, | 395 { "general", "preload_engines", bus_ibus_impl_set_preload_engines }, |
| 361 { "general", "use_system_keyboard_layout", bus_ibus_impl_set_use_sys_lay
out }, | 396 { "general", "use_system_keyboard_layout", bus_ibus_impl_set_use_sys_lay
out }, |
| 362 { "general", "use_global_engine", bus_ibus_impl_set_use_global_engine }, | 397 { "general", "use_global_engine", bus_ibus_impl_set_use_global_engine }, |
| 363 { "general", "embed_preedit_text", bus_ibus_impl_set_embed_preedit_text
}, | 398 { "general", "embed_preedit_text", bus_ibus_impl_set_embed_preedit_text
}, |
| 399 { "general", "enable_by_default", bus_ibus_impl_set_enable_by_default }, |
| 364 }; | 400 }; |
| 365 | 401 |
| 366 for (i = 0; i < G_N_ELEMENTS (entries); i++) { | 402 for (i = 0; i < G_N_ELEMENTS (entries); i++) { |
| 367 if (ibus->config != NULL && | 403 if (ibus->config != NULL && |
| 368 ibus_config_get_value (ibus->config, | 404 ibus_config_get_value (ibus->config, |
| 369 entries[i].section, | 405 entries[i].section, |
| 370 entries[i].key, | 406 entries[i].key, |
| 371 &value)) { | 407 &value)) { |
| 372 entries[i].func (ibus, &value); | 408 entries[i].func (ibus, &value); |
| 373 g_value_unset (&value); | 409 g_value_unset (&value); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 391 g_assert (value); | 427 g_assert (value); |
| 392 g_assert (BUS_IS_IBUS_IMPL (ibus)); | 428 g_assert (BUS_IS_IBUS_IMPL (ibus)); |
| 393 | 429 |
| 394 gint i; | 430 gint i; |
| 395 | 431 |
| 396 const static struct { | 432 const static struct { |
| 397 gchar *section; | 433 gchar *section; |
| 398 gchar *key; | 434 gchar *key; |
| 399 void ( *func) (BusIBusImpl *, GValue *); | 435 void ( *func) (BusIBusImpl *, GValue *); |
| 400 } entries [] = { | 436 } entries [] = { |
| 401 { "general/hotkey", "trigger", bus_ibus_impl_set_trigger }, | 437 { "general/hotkey", "trigger", bus_ibus_impl_set_trigger }, |
| 402 { "general/hotkey", "next_engine", bus_ibus_impl_set_next_engine }, | 438 { "general/hotkey", "next_engine_in_menu", bus_ibus_impl_set_next_engine
_in_menu }, |
| 403 { "general/hotkey", "prev_engine", bus_ibus_impl_set_prev_engine }, | 439 { "general/hotkey", "previous_engine", bus_ibus_impl_set_previous_engine
}, |
| 404 { "general", "preload_engines", bus_ibus_impl_set_preload_engines }, | 440 { "general", "preload_engines", bus_ibus_impl_set_preload_engines }, |
| 405 { "general", "use_system_keyboard_layout", bus_ibus_impl_set_use_sys_lay
out }, | 441 { "general", "use_system_keyboard_layout", bus_ibus_impl_set_use_sys_lay
out }, |
| 406 { "general", "use_global_engine", bus_ibus_impl_set_use_global_engine }, | 442 { "general", "use_global_engine", bus_ibus_impl_set_use_global_engine }, |
| 407 { "general", "embed_preedit_text", bus_ibus_impl_set_embed_preedit_text
}, | 443 { "general", "embed_preedit_text", bus_ibus_impl_set_embed_preedit_text
}, |
| 444 { "general", "enable_by_default", bus_ibus_impl_set_enable_by_default }, |
| 408 }; | 445 }; |
| 409 | 446 |
| 410 for (i = 0; i < G_N_ELEMENTS (entries); i++) { | 447 for (i = 0; i < G_N_ELEMENTS (entries); i++) { |
| 411 if (g_strcmp0 (entries[i].section, section) == 0 && | 448 if (g_strcmp0 (entries[i].section, section) == 0 && |
| 412 g_strcmp0 (entries[i].key, key) == 0) { | 449 g_strcmp0 (entries[i].key, key) == 0) { |
| 413 entries[i].func (ibus, value); | 450 entries[i].func (ibus, value); |
| 414 break; | 451 break; |
| 415 } | 452 } |
| 416 } | 453 } |
| 417 } | 454 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 #ifdef G_THREADS_ENABLED | 581 #ifdef G_THREADS_ENABLED |
| 545 extern gint g_monitor_timeout; | 582 extern gint g_monitor_timeout; |
| 546 if (g_monitor_timeout != 0) { | 583 if (g_monitor_timeout != 0) { |
| 547 bus_registry_start_monitor_changes (ibus->registry); | 584 bus_registry_start_monitor_changes (ibus->registry); |
| 548 } | 585 } |
| 549 #endif | 586 #endif |
| 550 | 587 |
| 551 ibus->hotkey_profile = ibus_hotkey_profile_new (); | 588 ibus->hotkey_profile = ibus_hotkey_profile_new (); |
| 552 ibus->keymap = ibus_keymap_get ("us"); | 589 ibus->keymap = ibus_keymap_get ("us"); |
| 553 | 590 |
| 554 ibus->use_sys_layout = FALSE; | 591 ibus->use_sys_layout = TRUE; |
| 555 ibus->embed_preedit_text = TRUE; | 592 ibus->embed_preedit_text = TRUE; |
| 556 ibus->use_global_engine = FALSE; | 593 ibus->enable_by_default = TRUE; |
| 594 ibus->use_global_engine = TRUE; |
| 557 ibus->global_engine = NULL; | 595 ibus->global_engine = NULL; |
| 596 ibus->global_previous_engine_name = NULL; |
| 558 | 597 |
| 559 bus_ibus_impl_reload_config (ibus); | 598 bus_ibus_impl_reload_config (ibus); |
| 560 | 599 |
| 561 g_signal_connect (BUS_DEFAULT_DBUS, | 600 g_signal_connect (BUS_DEFAULT_DBUS, |
| 562 "name-owner-changed", | 601 "name-owner-changed", |
| 563 G_CALLBACK (_dbus_name_owner_changed_cb), | 602 G_CALLBACK (_dbus_name_owner_changed_cb), |
| 564 ibus); | 603 ibus); |
| 565 } | 604 } |
| 566 | 605 |
| 567 static void | 606 static void |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 if (ibus->keymap != NULL) { | 662 if (ibus->keymap != NULL) { |
| 624 g_object_unref (ibus->keymap); | 663 g_object_unref (ibus->keymap); |
| 625 ibus->keymap = NULL; | 664 ibus->keymap = NULL; |
| 626 } | 665 } |
| 627 | 666 |
| 628 if (ibus->global_engine) { | 667 if (ibus->global_engine) { |
| 629 g_object_unref (ibus->global_engine); | 668 g_object_unref (ibus->global_engine); |
| 630 ibus->global_engine = NULL; | 669 ibus->global_engine = NULL; |
| 631 } | 670 } |
| 632 | 671 |
| 672 g_free (ibus->global_previous_engine_name); |
| 673 |
| 633 bus_server_quit (BUS_DEFAULT_SERVER); | 674 bus_server_quit (BUS_DEFAULT_SERVER); |
| 634 ibus_object_destroy ((IBusObject *) BUS_DEFAULT_SERVER); | 675 ibus_object_destroy ((IBusObject *) BUS_DEFAULT_SERVER); |
| 635 IBUS_OBJECT_CLASS(bus_ibus_impl_parent_class)->destroy (IBUS_OBJECT (ibus)); | 676 IBUS_OBJECT_CLASS(bus_ibus_impl_parent_class)->destroy (IBUS_OBJECT (ibus)); |
| 636 } | 677 } |
| 637 | 678 |
| 638 /* introspectable interface */ | 679 /* introspectable interface */ |
| 639 static IBusMessage * | 680 static IBusMessage * |
| 640 _ibus_introspect (BusIBusImpl *ibus, | 681 _ibus_introspect (BusIBusImpl *ibus, |
| 641 IBusMessage *message, | 682 IBusMessage *message, |
| 642 BusConnection *connection) | 683 BusConnection *connection) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 669 " <method name=\"ListActiveEngines\">\n" | 710 " <method name=\"ListActiveEngines\">\n" |
| 670 " <arg name=\"engines\" direction=\"out\" type=\"av\"/>\n" | 711 " <arg name=\"engines\" direction=\"out\" type=\"av\"/>\n" |
| 671 " </method>\n" | 712 " </method>\n" |
| 672 " <method name=\"Exit\">\n" | 713 " <method name=\"Exit\">\n" |
| 673 " <arg name=\"restart\" direction=\"in\" type=\"b\"/>\n" | 714 " <arg name=\"restart\" direction=\"in\" type=\"b\"/>\n" |
| 674 " </method>\n" | 715 " </method>\n" |
| 675 " <method name=\"Ping\">\n" | 716 " <method name=\"Ping\">\n" |
| 676 " <arg name=\"data\" direction=\"in\" type=\"v\"/>\n" | 717 " <arg name=\"data\" direction=\"in\" type=\"v\"/>\n" |
| 677 " <arg name=\"data\" direction=\"out\" type=\"v\"/>\n" | 718 " <arg name=\"data\" direction=\"out\" type=\"v\"/>\n" |
| 678 " </method>\n" | 719 " </method>\n" |
| 720 " <method name=\"GetUseSysLayout\">\n" |
| 721 " <arg name=\"enable\" direction=\"out\" type=\"b\"/>\n" |
| 722 " </method>\n" |
| 679 " <signal name=\"RegistryChanged\">\n" | 723 " <signal name=\"RegistryChanged\">\n" |
| 680 " </signal>\n" | 724 " </signal>\n" |
| 681 " </interface>\n" | 725 " </interface>\n" |
| 682 "</node>\n"; | 726 "</node>\n"; |
| 683 | 727 |
| 684 IBusMessage *reply_message; | 728 IBusMessage *reply_message; |
| 685 reply_message = ibus_message_new_method_return (message); | 729 reply_message = ibus_message_new_method_return (message); |
| 686 ibus_message_append_args (reply_message, | 730 ibus_message_append_args (reply_message, |
| 687 G_TYPE_STRING, &introspect, | 731 G_TYPE_STRING, &introspect, |
| 688 G_TYPE_INVALID); | 732 G_TYPE_INVALID); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 gchar *engine_name, | 830 gchar *engine_name, |
| 787 BusIBusImpl *ibus) | 831 BusIBusImpl *ibus) |
| 788 { | 832 { |
| 789 IBusEngineDesc *engine_desc = NULL; | 833 IBusEngineDesc *engine_desc = NULL; |
| 790 BusEngineProxy *engine; | 834 BusEngineProxy *engine; |
| 791 | 835 |
| 792 /* context should has focus before request an engine */ | 836 /* context should has focus before request an engine */ |
| 793 g_return_if_fail (bus_input_context_has_focus (context)); | 837 g_return_if_fail (bus_input_context_has_focus (context)); |
| 794 | 838 |
| 795 if (engine_name == NULL || engine_name[0] == '\0') { | 839 if (engine_name == NULL || engine_name[0] == '\0') { |
| 840 /* Use global engine if possible. */ |
| 841 if (ibus->use_global_engine) { |
| 842 if (ibus->global_engine) { |
| 843 bus_ibus_impl_set_context_engine (ibus, context, ibus->global_en
gine); |
| 844 return; |
| 845 } |
| 846 else { |
| 847 engine_name = bus_ibus_impl_load_global_engine_name_from_config
(ibus); |
| 848 if (engine_name) { |
| 849 engine_desc = _find_engine_desc_by_name (ibus, engine_name); |
| 850 g_free (engine_name); |
| 851 } |
| 852 } |
| 853 } |
| 796 /* request default engine */ | 854 /* request default engine */ |
| 797 if (ibus->register_engine_list) { | 855 if (!engine_desc) { |
| 798 engine_desc = (IBusEngineDesc *)ibus->register_engine_list->data; | 856 if (ibus->register_engine_list) { |
| 799 } | 857 engine_desc = (IBusEngineDesc *)ibus->register_engine_list->data
; |
| 800 else if (ibus->engine_list) { | 858 } |
| 801 engine_desc = (IBusEngineDesc *)ibus->engine_list->data; | 859 else if (ibus->engine_list) { |
| 802 } | 860 engine_desc = (IBusEngineDesc *)ibus->engine_list->data; |
| 861 } |
| 862 } |
| 803 } | 863 } |
| 804 else { | 864 else { |
| 805 /* request engine by name */ | 865 /* request engine by name */ |
| 806 engine_desc = _find_engine_desc_by_name (ibus, engine_name); | 866 engine_desc = _find_engine_desc_by_name (ibus, engine_name); |
| 807 } | 867 } |
| 808 | 868 |
| 809 if (engine_desc != NULL) { | 869 if (engine_desc != NULL) { |
| 810 engine = bus_ibus_impl_create_engine (engine_desc); | 870 engine = bus_ibus_impl_create_engine (engine_desc); |
| 811 if (engine != NULL) { | 871 if (engine != NULL) { |
| 812 bus_input_context_set_engine (context, engine); | 872 bus_ibus_impl_set_context_engine (ibus, context, engine); |
| 813 } | 873 } |
| 814 } | 874 } |
| 815 } | 875 } |
| 816 | 876 |
| 817 static void | 877 static void |
| 818 _context_request_next_engine_cb (BusInputContext *context, | 878 bus_ibus_impl_context_request_next_engine_in_menu (BusIBusImpl *ibus, |
| 819 BusIBusImpl *ibus) | 879 BusInputContext *context) |
| 820 { | 880 { |
| 821 BusEngineProxy *engine; | 881 BusEngineProxy *engine; |
| 822 IBusEngineDesc *desc; | 882 IBusEngineDesc *desc; |
| 823 IBusEngineDesc *next_desc = NULL; | 883 IBusEngineDesc *next_desc = NULL; |
| 824 GList *p; | 884 GList *p; |
| 825 | 885 |
| 826 engine = bus_input_context_get_engine (context); | 886 engine = bus_input_context_get_engine (context); |
| 827 if (engine == NULL) { | 887 if (engine == NULL) { |
| 828 _context_request_engine_cb (context, NULL, ibus); | 888 _context_request_engine_cb (context, NULL, ibus); |
| 829 return; | 889 return; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 850 next_desc = (IBusEngineDesc *)ibus->register_engine_list->data; | 910 next_desc = (IBusEngineDesc *)ibus->register_engine_list->data; |
| 851 } | 911 } |
| 852 else if (ibus->engine_list) { | 912 else if (ibus->engine_list) { |
| 853 next_desc = (IBusEngineDesc *)ibus->engine_list->data; | 913 next_desc = (IBusEngineDesc *)ibus->engine_list->data; |
| 854 } | 914 } |
| 855 } | 915 } |
| 856 | 916 |
| 857 if (next_desc != NULL) { | 917 if (next_desc != NULL) { |
| 858 engine = bus_ibus_impl_create_engine (next_desc); | 918 engine = bus_ibus_impl_create_engine (next_desc); |
| 859 if (engine != NULL) { | 919 if (engine != NULL) { |
| 860 bus_input_context_set_engine (context, engine); | 920 bus_ibus_impl_set_context_engine (ibus, context, engine); |
| 861 } | 921 } |
| 862 } | 922 } |
| 863 } | 923 } |
| 864 | 924 |
| 865 static void | 925 static void |
| 866 _context_request_prev_engine_cb (BusInputContext *context, | 926 bus_ibus_impl_context_request_previous_engine (BusIBusImpl *ibus, |
| 867 BusIBusImpl *ibus) | 927 BusInputContext *context) |
| 868 { | 928 { |
| 929 gchar *engine_name = NULL; |
| 930 if (!ibus->use_global_engine) { |
| 931 engine_name = (gchar *) g_object_get_data (G_OBJECT (context), "previous
-engine-name"); |
| 932 } |
| 933 else { |
| 934 if (!ibus->global_previous_engine_name) { |
| 935 ibus->global_previous_engine_name = bus_ibus_impl_load_global_previo
us_engine_name_from_config (ibus); |
| 936 } |
| 937 engine_name = ibus->global_previous_engine_name; |
| 938 } |
| 869 | 939 |
| 940 _context_request_engine_cb (context, engine_name, ibus); |
| 870 } | 941 } |
| 871 | 942 |
| 872 static void | 943 static void |
| 873 _global_engine_destroy_cb (BusEngineProxy *engine, | 944 _global_engine_destroy_cb (BusEngineProxy *engine, |
| 874 BusIBusImpl *ibus) | 945 BusIBusImpl *ibus) |
| 875 { | 946 { |
| 876 if (ibus->global_engine != engine) { | 947 if (ibus->global_engine != engine) { |
| 877 return; | 948 return; |
| 878 } | 949 } |
| 879 | 950 |
| 880 g_signal_handlers_disconnect_by_func (ibus->global_engine, | 951 g_signal_handlers_disconnect_by_func (ibus->global_engine, |
| 881 G_CALLBACK (_global_engine_destroy_cb), ibus); | 952 G_CALLBACK (_global_engine_destroy_cb), ibus); |
| 882 g_object_unref (ibus->global_engine); | 953 g_object_unref (ibus->global_engine); |
| 883 ibus->global_engine = NULL; | 954 ibus->global_engine = NULL; |
| 884 } | 955 } |
| 885 | 956 |
| 886 static void | 957 static void |
| 887 bus_ibus_impl_set_global_engine (BusIBusImpl *ibus, | 958 bus_ibus_impl_set_global_engine (BusIBusImpl *ibus, |
| 888 BusEngineProxy *engine) | 959 BusEngineProxy *engine) |
| 889 { | 960 { |
| 890 g_assert (ibus->use_global_engine == TRUE); | 961 g_assert (ibus->use_global_engine == TRUE); |
| 891 | 962 |
| 892 if (ibus->global_engine == engine) { | 963 if (ibus->global_engine == engine) { |
| 893 return; | 964 return; |
| 894 } | 965 } |
| 895 | 966 |
| 967 g_free (ibus->global_previous_engine_name); |
| 968 ibus->global_previous_engine_name = NULL; |
| 896 if (ibus->global_engine) { | 969 if (ibus->global_engine) { |
| 970 /* Save the current global engine's name as previous engine. */ |
| 971 ibus->global_previous_engine_name = g_strdup (bus_engine_proxy_get_desc
(ibus->global_engine)->name); |
| 972 |
| 897 ibus_object_destroy ((IBusObject *)ibus->global_engine); | 973 ibus_object_destroy ((IBusObject *)ibus->global_engine); |
| 898 /* global_engine should be NULL */ | 974 /* global_engine should be NULL */ |
| 899 g_assert (ibus->global_engine == NULL); | 975 g_assert (ibus->global_engine == NULL); |
| 900 } | 976 } |
| 901 | 977 |
| 902 if (engine != NULL && !IBUS_OBJECT_DESTROYED (engine)) { | 978 if (engine != NULL && !IBUS_OBJECT_DESTROYED (engine)) { |
| 903 g_object_ref (engine); | 979 g_object_ref (engine); |
| 904 ibus->global_engine = engine; | 980 ibus->global_engine = engine; |
| 905 g_signal_connect (ibus->global_engine, "destroy", | 981 g_signal_connect (ibus->global_engine, "destroy", |
| 906 G_CALLBACK (_global_engine_destroy_cb), ibus); | 982 G_CALLBACK (_global_engine_destroy_cb), ibus); |
| 907 } | 983 } |
| 984 |
| 985 bus_ibus_impl_save_global_engine_name_to_config (ibus); |
| 986 bus_ibus_impl_save_global_previous_engine_name_to_config (ibus); |
| 908 } | 987 } |
| 909 | 988 |
| 910 static void | 989 static void |
| 990 bus_ibus_impl_set_context_engine (BusIBusImpl *ibus, |
| 991 BusInputContext *context, |
| 992 BusEngineProxy *engine) { |
| 993 g_object_set_data (G_OBJECT (context), "previous-engine-name", NULL); |
| 994 |
| 995 /* If use_global_engine is disabled, then we need to save the previous engine |
| 996 * of each input context. */ |
| 997 if (!ibus->use_global_engine) { |
| 998 BusEngineProxy *previous_engine = bus_input_context_get_engine (context); |
| 999 if (previous_engine) { |
| 1000 g_object_set_data_full (G_OBJECT (context), "previous-engine-name", |
| 1001 g_strdup (bus_engine_proxy_get_desc (previous_
engine)->name), |
| 1002 g_free); |
| 1003 } |
| 1004 } |
| 1005 |
| 1006 bus_input_context_set_engine (context, engine); |
| 1007 } |
| 1008 |
| 1009 static void |
| 911 _context_engine_changed_cb (BusInputContext *context, | 1010 _context_engine_changed_cb (BusInputContext *context, |
| 912 BusIBusImpl *ibus) | 1011 BusIBusImpl *ibus) |
| 913 { | 1012 { |
| 914 BusEngineProxy *engine; | 1013 BusEngineProxy *engine; |
| 915 | 1014 |
| 916 if (context != ibus->focused_context || | 1015 if (context != ibus->focused_context || !ibus->use_global_engine) { |
| 917 ibus->use_global_engine != TRUE) { | |
| 918 return; | 1016 return; |
| 919 } | 1017 } |
| 920 | 1018 |
| 921 engine = bus_input_context_get_engine (context); | 1019 engine = bus_input_context_get_engine (context); |
| 922 if (engine != NULL) { | 1020 if (engine != NULL) { |
| 923 /* only set global engine if engine is not NULL */ | 1021 /* only set global engine if engine is not NULL */ |
| 924 bus_ibus_impl_set_global_engine (ibus, engine); | 1022 bus_ibus_impl_set_global_engine (ibus, engine); |
| 925 } | 1023 } |
| 926 } | 1024 } |
| 927 | 1025 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 945 | 1043 |
| 946 ibus->focused_context = NULL; | 1044 ibus->focused_context = NULL; |
| 947 | 1045 |
| 948 if (ibus->panel != NULL) { | 1046 if (ibus->panel != NULL) { |
| 949 bus_panel_proxy_focus_out (ibus->panel, context); | 1047 bus_panel_proxy_focus_out (ibus->panel, context); |
| 950 } | 1048 } |
| 951 | 1049 |
| 952 /* If the use_global_engine option is enabled, | 1050 /* If the use_global_engine option is enabled, |
| 953 * the global engine shoule be detached from the focused context. */ | 1051 * the global engine shoule be detached from the focused context. */ |
| 954 if (ibus->use_global_engine) { | 1052 if (ibus->use_global_engine) { |
| 955 bus_input_context_set_engine (context, NULL); | 1053 bus_ibus_impl_set_context_engine (ibus, context, NULL); |
| 956 } | 1054 } |
| 957 | 1055 |
| 958 g_object_unref (context); | 1056 g_object_unref (context); |
| 959 } | 1057 } |
| 960 | 1058 |
| 961 static void | 1059 static void |
| 962 _context_focus_in_cb (BusInputContext *context, | 1060 _context_focus_in_cb (BusInputContext *context, |
| 963 BusIBusImpl *ibus) | 1061 BusIBusImpl *ibus) |
| 964 { | 1062 { |
| 965 g_assert (BUS_IS_IBUS_IMPL (ibus)); | 1063 g_assert (BUS_IS_IBUS_IMPL (ibus)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 981 bus_input_context_focus_out (ibus->focused_context); | 1079 bus_input_context_focus_out (ibus->focused_context); |
| 982 g_assert (ibus->focused_context == NULL); | 1080 g_assert (ibus->focused_context == NULL); |
| 983 } | 1081 } |
| 984 | 1082 |
| 985 /* If the use_global_engine option is enabled, then we need: | 1083 /* If the use_global_engine option is enabled, then we need: |
| 986 * - Switch the context to use the global engine or save the context's | 1084 * - Switch the context to use the global engine or save the context's |
| 987 * existing engine as global engine. | 1085 * existing engine as global engine. |
| 988 * - Set the context's enabled state according to the saved state. | 1086 * - Set the context's enabled state according to the saved state. |
| 989 * Note: we get this signal only if the context supports IBUS_CAP_FOCUS. */ | 1087 * Note: we get this signal only if the context supports IBUS_CAP_FOCUS. */ |
| 990 if (ibus->use_global_engine) { | 1088 if (ibus->use_global_engine) { |
| 991 bus_input_context_set_engine (context, ibus->global_engine); | 1089 if (!ibus->global_engine) { |
| 992 if (ibus->global_engine && | 1090 bus_ibus_impl_set_global_engine (ibus, bus_input_context_get_engine
(context)); |
| 993 bus_engine_proxy_is_enabled (ibus->global_engine)) { | 1091 } |
| 994 bus_input_context_enable (context); | 1092 else { |
| 1093 bus_ibus_impl_set_context_engine (ibus, context, ibus->global_engine
); |
| 1094 if (ibus->global_engine && bus_engine_proxy_is_enabled (ibus->global
_engine)) { |
| 1095 bus_input_context_enable (context); |
| 1096 } |
| 995 } | 1097 } |
| 996 } | 1098 } |
| 997 | 1099 |
| 998 if (ibus->panel != NULL) { | 1100 if (ibus->panel != NULL) { |
| 999 bus_panel_proxy_focus_in (ibus->panel, context); | 1101 bus_panel_proxy_focus_in (ibus->panel, context); |
| 1000 } | 1102 } |
| 1001 | 1103 |
| 1002 g_object_ref (context); | 1104 g_object_ref (context); |
| 1003 ibus->focused_context = context; | 1105 ibus->focused_context = context; |
| 1004 } | 1106 } |
| 1005 | 1107 |
| 1006 static void | 1108 static void |
| 1007 _context_destroy_cb (BusInputContext *context, | 1109 _context_destroy_cb (BusInputContext *context, |
| 1008 BusIBusImpl *ibus) | 1110 BusIBusImpl *ibus) |
| 1009 { | 1111 { |
| 1010 g_assert (BUS_IS_IBUS_IMPL (ibus)); | 1112 g_assert (BUS_IS_IBUS_IMPL (ibus)); |
| 1011 g_assert (BUS_IS_INPUT_CONTEXT (context)); | 1113 g_assert (BUS_IS_INPUT_CONTEXT (context)); |
| 1012 | 1114 |
| 1013 if (context == ibus->focused_context) { | 1115 if (context == ibus->focused_context) { |
| 1014 /* focus out context */ | 1116 /* focus out context */ |
| 1015 bus_input_context_focus_out (ibus->focused_context); | 1117 bus_input_context_focus_out (ibus->focused_context); |
| 1016 g_assert (ibus->focused_context == NULL); | 1118 g_assert (ibus->focused_context == NULL); |
| 1017 } | 1119 } |
| 1018 | 1120 |
| 1019 ibus->contexts = g_list_remove (ibus->contexts, context); | 1121 ibus->contexts = g_list_remove (ibus->contexts, context); |
| 1020 g_object_unref (context); | 1122 g_object_unref (context); |
| 1021 } | 1123 } |
| 1022 | 1124 |
| 1023 #if 0 | |
| 1024 static void | |
| 1025 _context_enabled_cb (BusInputContext *context, | |
| 1026 BusIBusImpl *ibus) | |
| 1027 { | |
| 1028 } | |
| 1029 | |
| 1030 static void | |
| 1031 _context_disabled_cb (BusInputContext *context, | |
| 1032 BusIBusImpl *ibus) | |
| 1033 { | |
| 1034 } | |
| 1035 #endif | |
| 1036 | |
| 1037 static IBusMessage * | 1125 static IBusMessage * |
| 1038 _ibus_create_input_context (BusIBusImpl *ibus, | 1126 _ibus_create_input_context (BusIBusImpl *ibus, |
| 1039 IBusMessage *message, | 1127 IBusMessage *message, |
| 1040 BusConnection *connection) | 1128 BusConnection *connection) |
| 1041 { | 1129 { |
| 1042 g_assert (BUS_IS_IBUS_IMPL (ibus)); | 1130 g_assert (BUS_IS_IBUS_IMPL (ibus)); |
| 1043 g_assert (message != NULL); | 1131 g_assert (message != NULL); |
| 1044 g_assert (BUS_IS_CONNECTION (connection)); | 1132 g_assert (BUS_IS_CONNECTION (connection)); |
| 1045 | 1133 |
| 1046 gint i; | 1134 gint i; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1063 | 1151 |
| 1064 context = bus_input_context_new (connection, client); | 1152 context = bus_input_context_new (connection, client); |
| 1065 g_object_ref_sink (context); | 1153 g_object_ref_sink (context); |
| 1066 ibus->contexts = g_list_append (ibus->contexts, context); | 1154 ibus->contexts = g_list_append (ibus->contexts, context); |
| 1067 | 1155 |
| 1068 static const struct { | 1156 static const struct { |
| 1069 gchar *name; | 1157 gchar *name; |
| 1070 GCallback callback; | 1158 GCallback callback; |
| 1071 } signals [] = { | 1159 } signals [] = { |
| 1072 { "request-engine", G_CALLBACK (_context_request_engine_cb) }, | 1160 { "request-engine", G_CALLBACK (_context_request_engine_cb) }, |
| 1073 { "request-next-engine", G_CALLBACK (_context_request_next_engine_cb) }, | |
| 1074 { "request-prev-engine", G_CALLBACK (_context_request_prev_engine_cb) }, | |
| 1075 { "engine-changed", G_CALLBACK (_context_engine_changed_cb) }, | 1161 { "engine-changed", G_CALLBACK (_context_engine_changed_cb) }, |
| 1076 { "focus-in", G_CALLBACK (_context_focus_in_cb) }, | 1162 { "focus-in", G_CALLBACK (_context_focus_in_cb) }, |
| 1077 { "focus-out", G_CALLBACK (_context_focus_out_cb) }, | 1163 { "focus-out", G_CALLBACK (_context_focus_out_cb) }, |
| 1078 { "destroy", G_CALLBACK (_context_destroy_cb) }, | 1164 { "destroy", G_CALLBACK (_context_destroy_cb) }, |
| 1079 #if 0 | |
| 1080 { "enabled", G_CALLBACK (_context_enabled_cb) }, | |
| 1081 { "disabled", G_CALLBACK (_context_disabled_cb) }, | |
| 1082 #endif | |
| 1083 }; | 1165 }; |
| 1084 | 1166 |
| 1085 for (i = 0; i < G_N_ELEMENTS (signals); i++) { | 1167 for (i = 0; i < G_N_ELEMENTS (signals); i++) { |
| 1086 g_signal_connect (context, | 1168 g_signal_connect (context, |
| 1087 signals[i].name, | 1169 signals[i].name, |
| 1088 signals[i].callback, | 1170 signals[i].callback, |
| 1089 ibus); | 1171 ibus); |
| 1090 } | 1172 } |
| 1091 | 1173 |
| 1174 if (ibus->enable_by_default) { |
| 1175 bus_input_context_enable (context); |
| 1176 } |
| 1177 |
| 1092 path = ibus_service_get_path ((IBusService *) context); | 1178 path = ibus_service_get_path ((IBusService *) context); |
| 1093 reply = ibus_message_new_method_return (message); | 1179 reply = ibus_message_new_method_return (message); |
| 1094 ibus_message_append_args (reply, | 1180 ibus_message_append_args (reply, |
| 1095 IBUS_TYPE_OBJECT_PATH, &path, | 1181 IBUS_TYPE_OBJECT_PATH, &path, |
| 1096 G_TYPE_INVALID); | 1182 G_TYPE_INVALID); |
| 1097 | 1183 |
| 1098 bus_dbus_impl_register_object (BUS_DEFAULT_DBUS, | 1184 bus_dbus_impl_register_object (BUS_DEFAULT_DBUS, |
| 1099 (IBusService *)context); | 1185 (IBusService *)context); |
| 1100 return reply; | 1186 return reply; |
| 1101 } | 1187 } |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 reply = ibus_message_new_method_return (message); | 1423 reply = ibus_message_new_method_return (message); |
| 1338 | 1424 |
| 1339 ibus_message_iter_init (message, &src); | 1425 ibus_message_iter_init (message, &src); |
| 1340 ibus_message_iter_init_append (reply, &dst); | 1426 ibus_message_iter_init_append (reply, &dst); |
| 1341 | 1427 |
| 1342 ibus_message_iter_copy_data (&dst, &src); | 1428 ibus_message_iter_copy_data (&dst, &src); |
| 1343 | 1429 |
| 1344 return reply; | 1430 return reply; |
| 1345 } | 1431 } |
| 1346 | 1432 |
| 1433 static IBusMessage * |
| 1434 _ibus_get_use_sys_layout (BusIBusImpl *ibus, |
| 1435 IBusMessage *message, |
| 1436 BusConnection *connection) |
| 1437 { |
| 1438 IBusMessage *reply; |
| 1439 IBusMessageIter src, dst; |
| 1440 |
| 1441 reply = ibus_message_new_method_return (message); |
| 1442 ibus_message_append_args (reply, |
| 1443 G_TYPE_BOOLEAN, &ibus->use_sys_layout, |
| 1444 G_TYPE_INVALID); |
| 1445 |
| 1446 return reply; |
| 1447 } |
| 1448 |
| 1347 static gboolean | 1449 static gboolean |
| 1348 bus_ibus_impl_ibus_message (BusIBusImpl *ibus, | 1450 bus_ibus_impl_ibus_message (BusIBusImpl *ibus, |
| 1349 BusConnection *connection, | 1451 BusConnection *connection, |
| 1350 IBusMessage *message) | 1452 IBusMessage *message) |
| 1351 { | 1453 { |
| 1352 g_assert (BUS_IS_IBUS_IMPL (ibus)); | 1454 g_assert (BUS_IS_IBUS_IMPL (ibus)); |
| 1353 g_assert (BUS_IS_CONNECTION (connection)); | 1455 g_assert (BUS_IS_CONNECTION (connection)); |
| 1354 g_assert (message != NULL); | 1456 g_assert (message != NULL); |
| 1355 | 1457 |
| 1356 gint i; | 1458 gint i; |
| 1357 IBusMessage *reply_message = NULL; | 1459 IBusMessage *reply_message = NULL; |
| 1358 | 1460 |
| 1359 static const struct { | 1461 static const struct { |
| 1360 const gchar *interface; | 1462 const gchar *interface; |
| 1361 const gchar *name; | 1463 const gchar *name; |
| 1362 IBusMessage *(* handler) (BusIBusImpl *, IBusMessage *, BusConnection *)
; | 1464 IBusMessage *(* handler) (BusIBusImpl *, IBusMessage *, BusConnection *)
; |
| 1363 } handlers[] = { | 1465 } handlers[] = { |
| 1364 /* Introspectable interface */ | 1466 /* Introspectable interface */ |
| 1365 { DBUS_INTERFACE_INTROSPECTABLE, | 1467 { DBUS_INTERFACE_INTROSPECTABLE, |
| 1366 "Introspect", _ibus_introspect }, | 1468 "Introspect", _ibus_introspect }, |
| 1367 /* IBus interface */ | 1469 /* IBus interface */ |
| 1368 { IBUS_INTERFACE_IBUS, "GetAddress", _ibus_get_address }, | 1470 { IBUS_INTERFACE_IBUS, "GetAddress", _ibus_get_address }, |
| 1369 { IBUS_INTERFACE_IBUS, "CreateInputContext", _ibus_create_input_conte
xt }, | 1471 { IBUS_INTERFACE_IBUS, "CreateInputContext", _ibus_create_input_conte
xt }, |
| 1370 { IBUS_INTERFACE_IBUS, "CurrentInputContext", _ibus_current_input_cont
ext }, | 1472 { IBUS_INTERFACE_IBUS, "CurrentInputContext", _ibus_current_input_cont
ext }, |
| 1371 { IBUS_INTERFACE_IBUS, "RegisterComponent", _ibus_register_component
}, | 1473 { IBUS_INTERFACE_IBUS, "RegisterComponent", _ibus_register_component
}, |
| 1372 { IBUS_INTERFACE_IBUS, "ListEngines", _ibus_list_engines }, | 1474 { IBUS_INTERFACE_IBUS, "ListEngines", _ibus_list_engines }, |
| 1373 { IBUS_INTERFACE_IBUS, "ListActiveEngines", _ibus_list_active_engine
s }, | 1475 { IBUS_INTERFACE_IBUS, "ListActiveEngines", _ibus_list_active_engine
s }, |
| 1374 { IBUS_INTERFACE_IBUS, "Exit", _ibus_exit }, | 1476 { IBUS_INTERFACE_IBUS, "Exit", _ibus_exit }, |
| 1375 { IBUS_INTERFACE_IBUS, "Ping", _ibus_ping }, | 1477 { IBUS_INTERFACE_IBUS, "Ping", _ibus_ping }, |
| 1478 { IBUS_INTERFACE_IBUS, "GetUseSysLayout", _ibus_get_use_sys_layout
}, |
| 1376 }; | 1479 }; |
| 1377 | 1480 |
| 1378 ibus_message_set_sender (message, bus_connection_get_unique_name (connection
)); | 1481 ibus_message_set_sender (message, bus_connection_get_unique_name (connection
)); |
| 1379 ibus_message_set_destination (message, DBUS_SERVICE_DBUS); | 1482 ibus_message_set_destination (message, DBUS_SERVICE_DBUS); |
| 1380 | 1483 |
| 1381 if (ibus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_CALL) { | 1484 if (ibus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_CALL) { |
| 1382 for (i = 0; i < G_N_ELEMENTS (handlers); i++) { | 1485 for (i = 0; i < G_N_ELEMENTS (handlers); i++) { |
| 1383 if (ibus_message_is_method_call (message, | 1486 if (ibus_message_is_method_call (message, |
| 1384 handlers[i].interface, | 1487 handlers[i].interface, |
| 1385 handlers[i].name)) { | 1488 handlers[i].name)) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 "RegistryChanged"); | 1561 "RegistryChanged"); |
| 1459 ibus_message_append_args (message, | 1562 ibus_message_append_args (message, |
| 1460 G_TYPE_INVALID); | 1563 G_TYPE_INVALID); |
| 1461 ibus_message_set_sender (message, IBUS_SERVICE_IBUS); | 1564 ibus_message_set_sender (message, IBUS_SERVICE_IBUS); |
| 1462 | 1565 |
| 1463 bus_dbus_impl_dispatch_message_by_rule (BUS_DEFAULT_DBUS, message, NULL); | 1566 bus_dbus_impl_dispatch_message_by_rule (BUS_DEFAULT_DBUS, message, NULL); |
| 1464 | 1567 |
| 1465 ibus_message_unref (message); | 1568 ibus_message_unref (message); |
| 1466 | 1569 |
| 1467 } | 1570 } |
| 1571 |
| 1572 |
| 1573 gboolean |
| 1574 bus_ibus_impl_filter_keyboard_shortcuts (BusIBusImpl *ibus, |
| 1575 BusInputContext *context, |
| 1576 guint keyval, |
| 1577 guint modifiers, |
| 1578 guint prev_keyval, |
| 1579 guint prev_modifiers) |
| 1580 { |
| 1581 static GQuark trigger = 0; |
| 1582 static GQuark next = 0; |
| 1583 static GQuark previous = 0; |
| 1584 |
| 1585 if (trigger == 0) { |
| 1586 trigger = g_quark_from_static_string ("trigger"); |
| 1587 next = g_quark_from_static_string ("next-engine-in-menu"); |
| 1588 previous = g_quark_from_static_string ("previous-engine"); |
| 1589 } |
| 1590 |
| 1591 GQuark event = ibus_hotkey_profile_filter_key_event (ibus->hotkey_profile, |
| 1592 keyval, |
| 1593 modifiers, |
| 1594 prev_keyval, |
| 1595 prev_modifiers, |
| 1596 0); |
| 1597 |
| 1598 if (event == trigger) { |
| 1599 gboolean enabled = bus_input_context_is_enabled (context); |
| 1600 |
| 1601 if (context->enabled) { |
| 1602 bus_input_context_disable (context); |
| 1603 } |
| 1604 else { |
| 1605 bus_input_context_enable (context); |
| 1606 } |
| 1607 |
| 1608 return (enabled != bus_input_context_is_enabled (context)); |
| 1609 } |
| 1610 if (event == next) { |
| 1611 bus_ibus_impl_context_request_next_engine_in_menu (ibus, context); |
| 1612 return TRUE; |
| 1613 } |
| 1614 if (event == previous) { |
| 1615 bus_ibus_impl_context_request_previous_engine (ibus, context); |
| 1616 return TRUE; |
| 1617 } |
| 1618 return FALSE; |
| 1619 } |
| 1620 |
| 1621 static gchar* |
| 1622 bus_ibus_impl_load_global_engine_name_from_config (BusIBusImpl *ibus) |
| 1623 { |
| 1624 GValue value = { 0 }; |
| 1625 gchar *global_engine_name = NULL; |
| 1626 |
| 1627 g_assert (IBUS_IS_CONFIG (ibus->config)); |
| 1628 |
| 1629 if (ibus_config_get_value (ibus->config, "general", "global_engine", &value)
&& |
| 1630 G_VALUE_TYPE (&value) == G_TYPE_STRING) { |
| 1631 global_engine_name = g_value_dup_string (&value); |
| 1632 g_value_unset (&value); |
| 1633 } |
| 1634 |
| 1635 return global_engine_name; |
| 1636 } |
| 1637 |
| 1638 static void |
| 1639 bus_ibus_impl_save_global_engine_name_to_config (BusIBusImpl *ibus) |
| 1640 { |
| 1641 g_assert (IBUS_IS_CONFIG (ibus->config)); |
| 1642 |
| 1643 if (ibus->use_global_engine && ibus->global_engine) { |
| 1644 GValue value = { 0 }; |
| 1645 g_value_init (&value, G_TYPE_STRING); |
| 1646 g_value_set_static_string (&value, bus_engine_proxy_get_desc (ibus->glob
al_engine)->name); |
| 1647 |
| 1648 ibus_config_set_value (ibus->config, "general", "global_engine", &value)
; |
| 1649 g_value_unset (&value); |
| 1650 } |
| 1651 } |
| 1652 |
| 1653 static gchar* |
| 1654 bus_ibus_impl_load_global_previous_engine_name_from_config (BusIBusImpl *ibus) |
| 1655 { |
| 1656 GValue value = { 0 }; |
| 1657 gchar *global_previous_engine_name = NULL; |
| 1658 |
| 1659 g_assert (IBUS_IS_CONFIG (ibus->config)); |
| 1660 |
| 1661 if (ibus_config_get_value (ibus->config, "general", "global_previous_engine"
, &value) && |
| 1662 G_VALUE_TYPE (&value) == G_TYPE_STRING) { |
| 1663 global_previous_engine_name = g_value_dup_string (&value); |
| 1664 g_value_unset (&value); |
| 1665 } |
| 1666 |
| 1667 return global_previous_engine_name; |
| 1668 } |
| 1669 |
| 1670 static void |
| 1671 bus_ibus_impl_save_global_previous_engine_name_to_config (BusIBusImpl *ibus) |
| 1672 { |
| 1673 g_assert (IBUS_IS_CONFIG (ibus->config)); |
| 1674 |
| 1675 if (ibus->use_global_engine && ibus->global_previous_engine_name) { |
| 1676 GValue value = { 0 }; |
| 1677 g_value_init (&value, G_TYPE_STRING); |
| 1678 g_value_set_static_string (&value, ibus->global_previous_engine_name); |
| 1679 |
| 1680 ibus_config_set_value (ibus->config, "general", "global_previous_engine"
, &value); |
| 1681 g_value_unset (&value); |
| 1682 } |
| 1683 } |
| OLD | NEW |