Chromium Code Reviews| 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 } |
|
satorux1
2010/04/27 23:34:32
You can keep the function as-is.
| |
| 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 /* Only for backward compatibility, shall be removed later. */ |
| 359 { "general/hotkey", "prev_engine", bus_ibus_impl_set_prev_engine }, | 394 { "general/hotkey", "next_engine", bus_ibus_impl_set_next_engine_in_menu }, |
| 395 { "general/hotkey", "next_engine_in_menu", bus_ibus_impl_set_next_engine _in_menu }, | |
| 396 /* Only for backward compatibility, shall be removed later. */ | |
| 397 { "general/hotkey", "prev_engine", bus_ibus_impl_set_previous_engine }, | |
| 398 { "general/hotkey", "previous_engine", bus_ibus_impl_set_previous_engine }, | |
| 360 { "general", "preload_engines", bus_ibus_impl_set_preload_engines }, | 399 { "general", "preload_engines", bus_ibus_impl_set_preload_engines }, |
| 361 { "general", "use_system_keyboard_layout", bus_ibus_impl_set_use_sys_lay out }, | 400 { "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 }, | 401 { "general", "use_global_engine", bus_ibus_impl_set_use_global_engine }, |
| 363 { "general", "embed_preedit_text", bus_ibus_impl_set_embed_preedit_text }, | 402 { "general", "embed_preedit_text", bus_ibus_impl_set_embed_preedit_text }, |
| 403 { "general", "enable_by_default", bus_ibus_impl_set_enable_by_default }, | |
| 364 }; | 404 }; |
| 365 | 405 |
| 366 for (i = 0; i < G_N_ELEMENTS (entries); i++) { | 406 for (i = 0; i < G_N_ELEMENTS (entries); i++) { |
| 367 if (ibus->config != NULL && | 407 if (ibus->config != NULL && |
| 368 ibus_config_get_value (ibus->config, | 408 ibus_config_get_value (ibus->config, |
| 369 entries[i].section, | 409 entries[i].section, |
| 370 entries[i].key, | 410 entries[i].key, |
| 371 &value)) { | 411 &value)) { |
| 372 entries[i].func (ibus, &value); | 412 entries[i].func (ibus, &value); |
| 373 g_value_unset (&value); | 413 g_value_unset (&value); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 391 g_assert (value); | 431 g_assert (value); |
| 392 g_assert (BUS_IS_IBUS_IMPL (ibus)); | 432 g_assert (BUS_IS_IBUS_IMPL (ibus)); |
| 393 | 433 |
| 394 gint i; | 434 gint i; |
| 395 | 435 |
| 396 const static struct { | 436 const static struct { |
| 397 gchar *section; | 437 gchar *section; |
| 398 gchar *key; | 438 gchar *key; |
| 399 void ( *func) (BusIBusImpl *, GValue *); | 439 void ( *func) (BusIBusImpl *, GValue *); |
| 400 } entries [] = { | 440 } entries [] = { |
| 401 { "general/hotkey", "trigger", bus_ibus_impl_set_trigger }, | 441 { "general/hotkey", "trigger", bus_ibus_impl_set_trigger }, |
| 402 { "general/hotkey", "next_engine", bus_ibus_impl_set_next_engine }, | 442 /* Only for backward compatibility, shall be removed later. */ |
| 403 { "general/hotkey", "prev_engine", bus_ibus_impl_set_prev_engine }, | 443 { "general/hotkey", "next_engine", bus_ibus_impl_set_next_engine_in_menu }, |
| 444 { "general/hotkey", "next_engine_in_menu", bus_ibus_impl_set_next_engine _in_menu }, | |
| 445 /* Only for backward compatibility, shall be removed later. */ | |
| 446 { "general/hotkey", "prev_engine", bus_ibus_impl_set_previous_engine }, | |
| 447 { "general/hotkey", "previous_engine", bus_ibus_impl_set_previous_engine }, | |
| 404 { "general", "preload_engines", bus_ibus_impl_set_preload_engines }, | 448 { "general", "preload_engines", bus_ibus_impl_set_preload_engines }, |
| 405 { "general", "use_system_keyboard_layout", bus_ibus_impl_set_use_sys_lay out }, | 449 { "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 }, | 450 { "general", "use_global_engine", bus_ibus_impl_set_use_global_engine }, |
| 407 { "general", "embed_preedit_text", bus_ibus_impl_set_embed_preedit_text }, | 451 { "general", "embed_preedit_text", bus_ibus_impl_set_embed_preedit_text }, |
| 452 { "general", "enable_by_default", bus_ibus_impl_set_enable_by_default }, | |
| 408 }; | 453 }; |
| 409 | 454 |
| 410 for (i = 0; i < G_N_ELEMENTS (entries); i++) { | 455 for (i = 0; i < G_N_ELEMENTS (entries); i++) { |
| 411 if (g_strcmp0 (entries[i].section, section) == 0 && | 456 if (g_strcmp0 (entries[i].section, section) == 0 && |
| 412 g_strcmp0 (entries[i].key, key) == 0) { | 457 g_strcmp0 (entries[i].key, key) == 0) { |
| 413 entries[i].func (ibus, value); | 458 entries[i].func (ibus, value); |
| 414 break; | 459 break; |
| 415 } | 460 } |
| 416 } | 461 } |
| 417 } | 462 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 546 if (g_monitor_timeout != 0) { | 591 if (g_monitor_timeout != 0) { |
| 547 bus_registry_start_monitor_changes (ibus->registry); | 592 bus_registry_start_monitor_changes (ibus->registry); |
| 548 } | 593 } |
| 549 #endif | 594 #endif |
| 550 | 595 |
| 551 ibus->hotkey_profile = ibus_hotkey_profile_new (); | 596 ibus->hotkey_profile = ibus_hotkey_profile_new (); |
| 552 ibus->keymap = ibus_keymap_get ("us"); | 597 ibus->keymap = ibus_keymap_get ("us"); |
| 553 | 598 |
| 554 ibus->use_sys_layout = FALSE; | 599 ibus->use_sys_layout = FALSE; |
| 555 ibus->embed_preedit_text = TRUE; | 600 ibus->embed_preedit_text = TRUE; |
| 601 ibus->enable_by_default = FALSE; | |
| 556 ibus->use_global_engine = FALSE; | 602 ibus->use_global_engine = FALSE; |
| 557 ibus->global_engine = NULL; | 603 ibus->global_engine = NULL; |
| 604 ibus->global_previous_engine_name = NULL; | |
| 558 | 605 |
| 559 bus_ibus_impl_reload_config (ibus); | 606 bus_ibus_impl_reload_config (ibus); |
| 560 | 607 |
| 561 g_signal_connect (BUS_DEFAULT_DBUS, | 608 g_signal_connect (BUS_DEFAULT_DBUS, |
| 562 "name-owner-changed", | 609 "name-owner-changed", |
| 563 G_CALLBACK (_dbus_name_owner_changed_cb), | 610 G_CALLBACK (_dbus_name_owner_changed_cb), |
| 564 ibus); | 611 ibus); |
| 565 } | 612 } |
| 566 | 613 |
| 567 static void | 614 static void |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 623 if (ibus->keymap != NULL) { | 670 if (ibus->keymap != NULL) { |
| 624 g_object_unref (ibus->keymap); | 671 g_object_unref (ibus->keymap); |
| 625 ibus->keymap = NULL; | 672 ibus->keymap = NULL; |
| 626 } | 673 } |
| 627 | 674 |
| 628 if (ibus->global_engine) { | 675 if (ibus->global_engine) { |
| 629 g_object_unref (ibus->global_engine); | 676 g_object_unref (ibus->global_engine); |
| 630 ibus->global_engine = NULL; | 677 ibus->global_engine = NULL; |
| 631 } | 678 } |
| 632 | 679 |
| 680 g_free (ibus->global_previous_engine_name); | |
| 681 | |
| 633 bus_server_quit (BUS_DEFAULT_SERVER); | 682 bus_server_quit (BUS_DEFAULT_SERVER); |
| 634 ibus_object_destroy ((IBusObject *) BUS_DEFAULT_SERVER); | 683 ibus_object_destroy ((IBusObject *) BUS_DEFAULT_SERVER); |
| 635 IBUS_OBJECT_CLASS(bus_ibus_impl_parent_class)->destroy (IBUS_OBJECT (ibus)); | 684 IBUS_OBJECT_CLASS(bus_ibus_impl_parent_class)->destroy (IBUS_OBJECT (ibus)); |
| 636 } | 685 } |
| 637 | 686 |
| 638 /* introspectable interface */ | 687 /* introspectable interface */ |
| 639 static IBusMessage * | 688 static IBusMessage * |
| 640 _ibus_introspect (BusIBusImpl *ibus, | 689 _ibus_introspect (BusIBusImpl *ibus, |
| 641 IBusMessage *message, | 690 IBusMessage *message, |
| 642 BusConnection *connection) | 691 BusConnection *connection) |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 669 " <method name=\"ListActiveEngines\">\n" | 718 " <method name=\"ListActiveEngines\">\n" |
| 670 " <arg name=\"engines\" direction=\"out\" type=\"av\"/>\n" | 719 " <arg name=\"engines\" direction=\"out\" type=\"av\"/>\n" |
| 671 " </method>\n" | 720 " </method>\n" |
| 672 " <method name=\"Exit\">\n" | 721 " <method name=\"Exit\">\n" |
| 673 " <arg name=\"restart\" direction=\"in\" type=\"b\"/>\n" | 722 " <arg name=\"restart\" direction=\"in\" type=\"b\"/>\n" |
| 674 " </method>\n" | 723 " </method>\n" |
| 675 " <method name=\"Ping\">\n" | 724 " <method name=\"Ping\">\n" |
| 676 " <arg name=\"data\" direction=\"in\" type=\"v\"/>\n" | 725 " <arg name=\"data\" direction=\"in\" type=\"v\"/>\n" |
| 677 " <arg name=\"data\" direction=\"out\" type=\"v\"/>\n" | 726 " <arg name=\"data\" direction=\"out\" type=\"v\"/>\n" |
| 678 " </method>\n" | 727 " </method>\n" |
| 728 " <method name=\"GetUseSysLayout\">\n" | |
| 729 " <arg name=\"enable\" direction=\"out\" type=\"b\"/>\n" | |
| 730 " </method>\n" | |
| 679 " <signal name=\"RegistryChanged\">\n" | 731 " <signal name=\"RegistryChanged\">\n" |
| 680 " </signal>\n" | 732 " </signal>\n" |
| 681 " </interface>\n" | 733 " </interface>\n" |
| 682 "</node>\n"; | 734 "</node>\n"; |
| 683 | 735 |
| 684 IBusMessage *reply_message; | 736 IBusMessage *reply_message; |
| 685 reply_message = ibus_message_new_method_return (message); | 737 reply_message = ibus_message_new_method_return (message); |
| 686 ibus_message_append_args (reply_message, | 738 ibus_message_append_args (reply_message, |
| 687 G_TYPE_STRING, &introspect, | 739 G_TYPE_STRING, &introspect, |
| 688 G_TYPE_INVALID); | 740 G_TYPE_INVALID); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 786 gchar *engine_name, | 838 gchar *engine_name, |
| 787 BusIBusImpl *ibus) | 839 BusIBusImpl *ibus) |
| 788 { | 840 { |
| 789 IBusEngineDesc *engine_desc = NULL; | 841 IBusEngineDesc *engine_desc = NULL; |
| 790 BusEngineProxy *engine; | 842 BusEngineProxy *engine; |
| 791 | 843 |
| 792 /* context should has focus before request an engine */ | 844 /* context should has focus before request an engine */ |
| 793 g_return_if_fail (bus_input_context_has_focus (context)); | 845 g_return_if_fail (bus_input_context_has_focus (context)); |
| 794 | 846 |
| 795 if (engine_name == NULL || engine_name[0] == '\0') { | 847 if (engine_name == NULL || engine_name[0] == '\0') { |
| 848 /* Use global engine if possible. */ | |
| 849 if (ibus->use_global_engine) { | |
| 850 if (ibus->global_engine) { | |
| 851 bus_ibus_impl_set_context_engine (ibus, context, ibus->global_en gine); | |
| 852 return; | |
| 853 } | |
| 854 else { | |
| 855 engine_name = bus_ibus_impl_load_global_engine_name_from_config (ibus); | |
| 856 if (engine_name) { | |
| 857 engine_desc = _find_engine_desc_by_name (ibus, engine_name); | |
| 858 g_free (engine_name); | |
| 859 } | |
| 860 } | |
| 861 } | |
| 796 /* request default engine */ | 862 /* request default engine */ |
| 797 if (ibus->register_engine_list) { | 863 if (!engine_desc) { |
| 798 engine_desc = (IBusEngineDesc *)ibus->register_engine_list->data; | 864 if (ibus->register_engine_list) { |
| 799 } | 865 engine_desc = (IBusEngineDesc *)ibus->register_engine_list->data ; |
| 800 else if (ibus->engine_list) { | 866 } |
| 801 engine_desc = (IBusEngineDesc *)ibus->engine_list->data; | 867 else if (ibus->engine_list) { |
| 802 } | 868 engine_desc = (IBusEngineDesc *)ibus->engine_list->data; |
| 869 } | |
| 870 } | |
| 803 } | 871 } |
| 804 else { | 872 else { |
| 805 /* request engine by name */ | 873 /* request engine by name */ |
| 806 engine_desc = _find_engine_desc_by_name (ibus, engine_name); | 874 engine_desc = _find_engine_desc_by_name (ibus, engine_name); |
| 807 } | 875 } |
| 808 | 876 |
| 809 if (engine_desc != NULL) { | 877 if (engine_desc != NULL) { |
| 810 engine = bus_ibus_impl_create_engine (engine_desc); | 878 engine = bus_ibus_impl_create_engine (engine_desc); |
| 811 if (engine != NULL) { | 879 if (engine != NULL) { |
| 812 bus_input_context_set_engine (context, engine); | 880 bus_ibus_impl_set_context_engine (ibus, context, engine); |
| 813 } | 881 } |
| 814 } | 882 } |
| 815 } | 883 } |
| 816 | 884 |
| 817 static void | 885 static void |
| 818 _context_request_next_engine_cb (BusInputContext *context, | 886 bus_ibus_impl_context_request_next_engine_in_menu (BusIBusImpl *ibus, |
| 819 BusIBusImpl *ibus) | 887 BusInputContext *context) |
| 820 { | 888 { |
| 821 BusEngineProxy *engine; | 889 BusEngineProxy *engine; |
| 822 IBusEngineDesc *desc; | 890 IBusEngineDesc *desc; |
| 823 IBusEngineDesc *next_desc = NULL; | 891 IBusEngineDesc *next_desc = NULL; |
| 824 GList *p; | 892 GList *p; |
| 825 | 893 |
| 826 engine = bus_input_context_get_engine (context); | 894 engine = bus_input_context_get_engine (context); |
| 827 if (engine == NULL) { | 895 if (engine == NULL) { |
| 828 _context_request_engine_cb (context, NULL, ibus); | 896 _context_request_engine_cb (context, NULL, ibus); |
| 829 return; | 897 return; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 850 next_desc = (IBusEngineDesc *)ibus->register_engine_list->data; | 918 next_desc = (IBusEngineDesc *)ibus->register_engine_list->data; |
| 851 } | 919 } |
| 852 else if (ibus->engine_list) { | 920 else if (ibus->engine_list) { |
| 853 next_desc = (IBusEngineDesc *)ibus->engine_list->data; | 921 next_desc = (IBusEngineDesc *)ibus->engine_list->data; |
| 854 } | 922 } |
| 855 } | 923 } |
| 856 | 924 |
| 857 if (next_desc != NULL) { | 925 if (next_desc != NULL) { |
| 858 engine = bus_ibus_impl_create_engine (next_desc); | 926 engine = bus_ibus_impl_create_engine (next_desc); |
| 859 if (engine != NULL) { | 927 if (engine != NULL) { |
| 860 bus_input_context_set_engine (context, engine); | 928 bus_ibus_impl_set_context_engine (ibus, context, engine); |
| 861 } | 929 } |
| 862 } | 930 } |
| 863 } | 931 } |
| 864 | 932 |
| 865 static void | 933 static void |
| 866 _context_request_prev_engine_cb (BusInputContext *context, | 934 bus_ibus_impl_context_request_previous_engine (BusIBusImpl *ibus, |
| 867 BusIBusImpl *ibus) | 935 BusInputContext *context) |
| 868 { | 936 { |
| 937 gchar *engine_name = NULL; | |
| 938 if (!ibus->use_global_engine) { | |
| 939 engine_name = (gchar *) g_object_get_data (G_OBJECT (context), "previous -engine-name"); | |
| 940 } | |
| 941 else { | |
| 942 if (!ibus->global_previous_engine_name) { | |
| 943 ibus->global_previous_engine_name = bus_ibus_impl_load_global_previo us_engine_name_from_config (ibus); | |
| 944 } | |
| 945 engine_name = ibus->global_previous_engine_name; | |
| 946 } | |
| 869 | 947 |
| 948 _context_request_engine_cb (context, engine_name, ibus); | |
| 870 } | 949 } |
| 871 | 950 |
| 872 static void | 951 static void |
| 873 _global_engine_destroy_cb (BusEngineProxy *engine, | 952 _global_engine_destroy_cb (BusEngineProxy *engine, |
| 874 BusIBusImpl *ibus) | 953 BusIBusImpl *ibus) |
| 875 { | 954 { |
| 876 if (ibus->global_engine != engine) { | 955 if (ibus->global_engine != engine) { |
| 877 return; | 956 return; |
| 878 } | 957 } |
| 879 | 958 |
| 880 g_signal_handlers_disconnect_by_func (ibus->global_engine, | 959 g_signal_handlers_disconnect_by_func (ibus->global_engine, |
| 881 G_CALLBACK (_global_engine_destroy_cb), ibus); | 960 G_CALLBACK (_global_engine_destroy_cb), ibus); |
| 882 g_object_unref (ibus->global_engine); | 961 g_object_unref (ibus->global_engine); |
| 883 ibus->global_engine = NULL; | 962 ibus->global_engine = NULL; |
| 884 } | 963 } |
| 885 | 964 |
| 886 static void | 965 static void |
| 887 bus_ibus_impl_set_global_engine (BusIBusImpl *ibus, | 966 bus_ibus_impl_set_global_engine (BusIBusImpl *ibus, |
| 888 BusEngineProxy *engine) | 967 BusEngineProxy *engine) |
| 889 { | 968 { |
| 890 g_assert (ibus->use_global_engine == TRUE); | 969 g_assert (ibus->use_global_engine == TRUE); |
| 891 | 970 |
| 892 if (ibus->global_engine == engine) { | 971 if (ibus->global_engine == engine) { |
| 893 return; | 972 return; |
| 894 } | 973 } |
| 895 | 974 |
| 975 g_free (ibus->global_previous_engine_name); | |
| 976 ibus->global_previous_engine_name = NULL; | |
| 896 if (ibus->global_engine) { | 977 if (ibus->global_engine) { |
| 978 /* Save the current global engine's name as previous engine. */ | |
| 979 ibus->global_previous_engine_name = g_strdup (bus_engine_proxy_get_desc (ibus->global_engine)->name); | |
| 980 | |
| 897 ibus_object_destroy ((IBusObject *)ibus->global_engine); | 981 ibus_object_destroy ((IBusObject *)ibus->global_engine); |
| 898 /* global_engine should be NULL */ | 982 /* global_engine should be NULL */ |
| 899 g_assert (ibus->global_engine == NULL); | 983 g_assert (ibus->global_engine == NULL); |
| 900 } | 984 } |
| 901 | 985 |
| 902 if (engine != NULL && !IBUS_OBJECT_DESTROYED (engine)) { | 986 if (engine != NULL && !IBUS_OBJECT_DESTROYED (engine)) { |
| 903 g_object_ref (engine); | 987 g_object_ref (engine); |
| 904 ibus->global_engine = engine; | 988 ibus->global_engine = engine; |
| 905 g_signal_connect (ibus->global_engine, "destroy", | 989 g_signal_connect (ibus->global_engine, "destroy", |
| 906 G_CALLBACK (_global_engine_destroy_cb), ibus); | 990 G_CALLBACK (_global_engine_destroy_cb), ibus); |
| 907 } | 991 } |
| 992 | |
| 993 bus_ibus_impl_save_global_engine_name_to_config (ibus); | |
| 994 bus_ibus_impl_save_global_previous_engine_name_to_config (ibus); | |
| 908 } | 995 } |
| 909 | 996 |
| 910 static void | 997 static void |
| 998 bus_ibus_impl_set_context_engine (BusIBusImpl *ibus, | |
| 999 BusInputContext *context, | |
| 1000 BusEngineProxy *engine) { | |
| 1001 g_object_set_data (G_OBJECT (context), "previous-engine-name", NULL); | |
| 1002 | |
| 1003 /* If use_global_engine is disabled, then we need to save the previous engine | |
| 1004 * of each input context. */ | |
| 1005 if (!ibus->use_global_engine) { | |
| 1006 BusEngineProxy *previous_engine = bus_input_context_get_engine (context); | |
| 1007 if (previous_engine) { | |
| 1008 g_object_set_data_full (G_OBJECT (context), "previous-engine-name", | |
| 1009 g_strdup (bus_engine_proxy_get_desc (previous_ engine)->name), | |
| 1010 g_free); | |
| 1011 } | |
| 1012 } | |
| 1013 | |
| 1014 bus_input_context_set_engine (context, engine); | |
| 1015 } | |
| 1016 | |
| 1017 static void | |
| 911 _context_engine_changed_cb (BusInputContext *context, | 1018 _context_engine_changed_cb (BusInputContext *context, |
| 912 BusIBusImpl *ibus) | 1019 BusIBusImpl *ibus) |
| 913 { | 1020 { |
| 914 BusEngineProxy *engine; | 1021 BusEngineProxy *engine; |
| 915 | 1022 |
| 916 if (context != ibus->focused_context || | 1023 if (context != ibus->focused_context || !ibus->use_global_engine) { |
| 917 ibus->use_global_engine != TRUE) { | |
| 918 return; | 1024 return; |
| 919 } | 1025 } |
| 920 | 1026 |
| 921 engine = bus_input_context_get_engine (context); | 1027 engine = bus_input_context_get_engine (context); |
| 922 if (engine != NULL) { | 1028 if (engine != NULL) { |
| 923 /* only set global engine if engine is not NULL */ | 1029 /* only set global engine if engine is not NULL */ |
| 924 bus_ibus_impl_set_global_engine (ibus, engine); | 1030 bus_ibus_impl_set_global_engine (ibus, engine); |
| 925 } | 1031 } |
| 926 } | 1032 } |
| 927 | 1033 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 945 | 1051 |
| 946 ibus->focused_context = NULL; | 1052 ibus->focused_context = NULL; |
| 947 | 1053 |
| 948 if (ibus->panel != NULL) { | 1054 if (ibus->panel != NULL) { |
| 949 bus_panel_proxy_focus_out (ibus->panel, context); | 1055 bus_panel_proxy_focus_out (ibus->panel, context); |
| 950 } | 1056 } |
| 951 | 1057 |
| 952 /* If the use_global_engine option is enabled, | 1058 /* If the use_global_engine option is enabled, |
| 953 * the global engine shoule be detached from the focused context. */ | 1059 * the global engine shoule be detached from the focused context. */ |
| 954 if (ibus->use_global_engine) { | 1060 if (ibus->use_global_engine) { |
| 955 bus_input_context_set_engine (context, NULL); | 1061 bus_ibus_impl_set_context_engine (ibus, context, NULL); |
| 956 } | 1062 } |
| 957 | 1063 |
| 958 g_object_unref (context); | 1064 g_object_unref (context); |
| 959 } | 1065 } |
| 960 | 1066 |
| 961 static void | 1067 static void |
| 962 _context_focus_in_cb (BusInputContext *context, | 1068 _context_focus_in_cb (BusInputContext *context, |
| 963 BusIBusImpl *ibus) | 1069 BusIBusImpl *ibus) |
| 964 { | 1070 { |
| 965 g_assert (BUS_IS_IBUS_IMPL (ibus)); | 1071 g_assert (BUS_IS_IBUS_IMPL (ibus)); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 981 bus_input_context_focus_out (ibus->focused_context); | 1087 bus_input_context_focus_out (ibus->focused_context); |
| 982 g_assert (ibus->focused_context == NULL); | 1088 g_assert (ibus->focused_context == NULL); |
| 983 } | 1089 } |
| 984 | 1090 |
| 985 /* If the use_global_engine option is enabled, then we need: | 1091 /* 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 | 1092 * - Switch the context to use the global engine or save the context's |
| 987 * existing engine as global engine. | 1093 * existing engine as global engine. |
| 988 * - Set the context's enabled state according to the saved state. | 1094 * - 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. */ | 1095 * Note: we get this signal only if the context supports IBUS_CAP_FOCUS. */ |
| 990 if (ibus->use_global_engine) { | 1096 if (ibus->use_global_engine) { |
| 991 bus_input_context_set_engine (context, ibus->global_engine); | 1097 if (!ibus->global_engine) { |
| 992 if (ibus->global_engine && | 1098 bus_ibus_impl_set_global_engine (ibus, bus_input_context_get_engine (context)); |
| 993 bus_engine_proxy_is_enabled (ibus->global_engine)) { | 1099 } |
| 994 bus_input_context_enable (context); | 1100 else { |
| 1101 bus_ibus_impl_set_context_engine (ibus, context, ibus->global_engine ); | |
| 1102 if (ibus->global_engine && bus_engine_proxy_is_enabled (ibus->global _engine)) { | |
| 1103 bus_input_context_enable (context); | |
| 1104 } | |
| 995 } | 1105 } |
| 996 } | 1106 } |
| 997 | 1107 |
| 998 if (ibus->panel != NULL) { | 1108 if (ibus->panel != NULL) { |
| 999 bus_panel_proxy_focus_in (ibus->panel, context); | 1109 bus_panel_proxy_focus_in (ibus->panel, context); |
| 1000 } | 1110 } |
| 1001 | 1111 |
| 1002 g_object_ref (context); | 1112 g_object_ref (context); |
| 1003 ibus->focused_context = context; | 1113 ibus->focused_context = context; |
| 1004 } | 1114 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1063 | 1173 |
| 1064 context = bus_input_context_new (connection, client); | 1174 context = bus_input_context_new (connection, client); |
| 1065 g_object_ref_sink (context); | 1175 g_object_ref_sink (context); |
| 1066 ibus->contexts = g_list_append (ibus->contexts, context); | 1176 ibus->contexts = g_list_append (ibus->contexts, context); |
| 1067 | 1177 |
| 1068 static const struct { | 1178 static const struct { |
| 1069 gchar *name; | 1179 gchar *name; |
| 1070 GCallback callback; | 1180 GCallback callback; |
| 1071 } signals [] = { | 1181 } signals [] = { |
| 1072 { "request-engine", G_CALLBACK (_context_request_engine_cb) }, | 1182 { "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) }, | 1183 { "engine-changed", G_CALLBACK (_context_engine_changed_cb) }, |
| 1076 { "focus-in", G_CALLBACK (_context_focus_in_cb) }, | 1184 { "focus-in", G_CALLBACK (_context_focus_in_cb) }, |
| 1077 { "focus-out", G_CALLBACK (_context_focus_out_cb) }, | 1185 { "focus-out", G_CALLBACK (_context_focus_out_cb) }, |
| 1078 { "destroy", G_CALLBACK (_context_destroy_cb) }, | 1186 { "destroy", G_CALLBACK (_context_destroy_cb) }, |
| 1079 #if 0 | 1187 #if 0 |
| 1080 { "enabled", G_CALLBACK (_context_enabled_cb) }, | 1188 { "enabled", G_CALLBACK (_context_enabled_cb) }, |
| 1081 { "disabled", G_CALLBACK (_context_disabled_cb) }, | 1189 { "disabled", G_CALLBACK (_context_disabled_cb) }, |
| 1082 #endif | 1190 #endif |
| 1083 }; | 1191 }; |
| 1084 | 1192 |
| 1085 for (i = 0; i < G_N_ELEMENTS (signals); i++) { | 1193 for (i = 0; i < G_N_ELEMENTS (signals); i++) { |
| 1086 g_signal_connect (context, | 1194 g_signal_connect (context, |
| 1087 signals[i].name, | 1195 signals[i].name, |
| 1088 signals[i].callback, | 1196 signals[i].callback, |
| 1089 ibus); | 1197 ibus); |
| 1090 } | 1198 } |
| 1091 | 1199 |
| 1200 if (ibus->enable_by_default) { | |
| 1201 bus_input_context_enable (context); | |
| 1202 } | |
| 1203 | |
| 1092 path = ibus_service_get_path ((IBusService *) context); | 1204 path = ibus_service_get_path ((IBusService *) context); |
| 1093 reply = ibus_message_new_method_return (message); | 1205 reply = ibus_message_new_method_return (message); |
| 1094 ibus_message_append_args (reply, | 1206 ibus_message_append_args (reply, |
| 1095 IBUS_TYPE_OBJECT_PATH, &path, | 1207 IBUS_TYPE_OBJECT_PATH, &path, |
| 1096 G_TYPE_INVALID); | 1208 G_TYPE_INVALID); |
| 1097 | 1209 |
| 1098 bus_dbus_impl_register_object (BUS_DEFAULT_DBUS, | 1210 bus_dbus_impl_register_object (BUS_DEFAULT_DBUS, |
| 1099 (IBusService *)context); | 1211 (IBusService *)context); |
| 1100 return reply; | 1212 return reply; |
| 1101 } | 1213 } |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1337 reply = ibus_message_new_method_return (message); | 1449 reply = ibus_message_new_method_return (message); |
| 1338 | 1450 |
| 1339 ibus_message_iter_init (message, &src); | 1451 ibus_message_iter_init (message, &src); |
| 1340 ibus_message_iter_init_append (reply, &dst); | 1452 ibus_message_iter_init_append (reply, &dst); |
| 1341 | 1453 |
| 1342 ibus_message_iter_copy_data (&dst, &src); | 1454 ibus_message_iter_copy_data (&dst, &src); |
| 1343 | 1455 |
| 1344 return reply; | 1456 return reply; |
| 1345 } | 1457 } |
| 1346 | 1458 |
| 1459 static IBusMessage * | |
| 1460 _ibus_get_use_sys_layout (BusIBusImpl *ibus, | |
| 1461 IBusMessage *message, | |
| 1462 BusConnection *connection) | |
| 1463 { | |
| 1464 IBusMessage *reply; | |
| 1465 IBusMessageIter src, dst; | |
| 1466 | |
| 1467 reply = ibus_message_new_method_return (message); | |
| 1468 ibus_message_append_args (reply, | |
| 1469 G_TYPE_BOOLEAN, &ibus->use_sys_layout, | |
| 1470 G_TYPE_INVALID); | |
| 1471 | |
| 1472 return reply; | |
| 1473 } | |
| 1474 | |
| 1347 static gboolean | 1475 static gboolean |
| 1348 bus_ibus_impl_ibus_message (BusIBusImpl *ibus, | 1476 bus_ibus_impl_ibus_message (BusIBusImpl *ibus, |
| 1349 BusConnection *connection, | 1477 BusConnection *connection, |
| 1350 IBusMessage *message) | 1478 IBusMessage *message) |
| 1351 { | 1479 { |
| 1352 g_assert (BUS_IS_IBUS_IMPL (ibus)); | 1480 g_assert (BUS_IS_IBUS_IMPL (ibus)); |
| 1353 g_assert (BUS_IS_CONNECTION (connection)); | 1481 g_assert (BUS_IS_CONNECTION (connection)); |
| 1354 g_assert (message != NULL); | 1482 g_assert (message != NULL); |
| 1355 | 1483 |
| 1356 gint i; | 1484 gint i; |
| 1357 IBusMessage *reply_message = NULL; | 1485 IBusMessage *reply_message = NULL; |
| 1358 | 1486 |
| 1359 static const struct { | 1487 static const struct { |
| 1360 const gchar *interface; | 1488 const gchar *interface; |
| 1361 const gchar *name; | 1489 const gchar *name; |
| 1362 IBusMessage *(* handler) (BusIBusImpl *, IBusMessage *, BusConnection *) ; | 1490 IBusMessage *(* handler) (BusIBusImpl *, IBusMessage *, BusConnection *) ; |
| 1363 } handlers[] = { | 1491 } handlers[] = { |
| 1364 /* Introspectable interface */ | 1492 /* Introspectable interface */ |
| 1365 { DBUS_INTERFACE_INTROSPECTABLE, | 1493 { DBUS_INTERFACE_INTROSPECTABLE, |
| 1366 "Introspect", _ibus_introspect }, | 1494 "Introspect", _ibus_introspect }, |
| 1367 /* IBus interface */ | 1495 /* IBus interface */ |
| 1368 { IBUS_INTERFACE_IBUS, "GetAddress", _ibus_get_address }, | 1496 { IBUS_INTERFACE_IBUS, "GetAddress", _ibus_get_address }, |
| 1369 { IBUS_INTERFACE_IBUS, "CreateInputContext", _ibus_create_input_conte xt }, | 1497 { IBUS_INTERFACE_IBUS, "CreateInputContext", _ibus_create_input_conte xt }, |
| 1370 { IBUS_INTERFACE_IBUS, "CurrentInputContext", _ibus_current_input_cont ext }, | 1498 { IBUS_INTERFACE_IBUS, "CurrentInputContext", _ibus_current_input_cont ext }, |
| 1371 { IBUS_INTERFACE_IBUS, "RegisterComponent", _ibus_register_component }, | 1499 { IBUS_INTERFACE_IBUS, "RegisterComponent", _ibus_register_component }, |
| 1372 { IBUS_INTERFACE_IBUS, "ListEngines", _ibus_list_engines }, | 1500 { IBUS_INTERFACE_IBUS, "ListEngines", _ibus_list_engines }, |
| 1373 { IBUS_INTERFACE_IBUS, "ListActiveEngines", _ibus_list_active_engine s }, | 1501 { IBUS_INTERFACE_IBUS, "ListActiveEngines", _ibus_list_active_engine s }, |
| 1374 { IBUS_INTERFACE_IBUS, "Exit", _ibus_exit }, | 1502 { IBUS_INTERFACE_IBUS, "Exit", _ibus_exit }, |
| 1375 { IBUS_INTERFACE_IBUS, "Ping", _ibus_ping }, | 1503 { IBUS_INTERFACE_IBUS, "Ping", _ibus_ping }, |
| 1504 { IBUS_INTERFACE_IBUS, "GetUseSysLayout", _ibus_get_use_sys_layout }, | |
| 1376 }; | 1505 }; |
| 1377 | 1506 |
| 1378 ibus_message_set_sender (message, bus_connection_get_unique_name (connection )); | 1507 ibus_message_set_sender (message, bus_connection_get_unique_name (connection )); |
| 1379 ibus_message_set_destination (message, DBUS_SERVICE_DBUS); | 1508 ibus_message_set_destination (message, DBUS_SERVICE_DBUS); |
| 1380 | 1509 |
| 1381 if (ibus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_CALL) { | 1510 if (ibus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_CALL) { |
| 1382 for (i = 0; i < G_N_ELEMENTS (handlers); i++) { | 1511 for (i = 0; i < G_N_ELEMENTS (handlers); i++) { |
| 1383 if (ibus_message_is_method_call (message, | 1512 if (ibus_message_is_method_call (message, |
| 1384 handlers[i].interface, | 1513 handlers[i].interface, |
| 1385 handlers[i].name)) { | 1514 handlers[i].name)) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1458 "RegistryChanged"); | 1587 "RegistryChanged"); |
| 1459 ibus_message_append_args (message, | 1588 ibus_message_append_args (message, |
| 1460 G_TYPE_INVALID); | 1589 G_TYPE_INVALID); |
| 1461 ibus_message_set_sender (message, IBUS_SERVICE_IBUS); | 1590 ibus_message_set_sender (message, IBUS_SERVICE_IBUS); |
| 1462 | 1591 |
| 1463 bus_dbus_impl_dispatch_message_by_rule (BUS_DEFAULT_DBUS, message, NULL); | 1592 bus_dbus_impl_dispatch_message_by_rule (BUS_DEFAULT_DBUS, message, NULL); |
| 1464 | 1593 |
| 1465 ibus_message_unref (message); | 1594 ibus_message_unref (message); |
| 1466 | 1595 |
| 1467 } | 1596 } |
| 1597 | |
| 1598 | |
| 1599 gboolean | |
| 1600 bus_ibus_impl_filter_keyboard_shortcuts (BusIBusImpl *ibus, | |
| 1601 BusInputContext *context, | |
| 1602 guint keyval, | |
| 1603 guint modifiers, | |
| 1604 guint prev_keyval, | |
| 1605 guint prev_modifiers) | |
| 1606 { | |
| 1607 static GQuark trigger = 0; | |
| 1608 static GQuark next = 0; | |
| 1609 static GQuark previous = 0; | |
| 1610 | |
| 1611 if (trigger == 0) { | |
| 1612 trigger = g_quark_from_static_string ("trigger"); | |
| 1613 next = g_quark_from_static_string ("next-engine-in-menu"); | |
| 1614 previous = g_quark_from_static_string ("previous-engine"); | |
| 1615 } | |
| 1616 | |
| 1617 GQuark event = ibus_hotkey_profile_filter_key_event (ibus->hotkey_profile, | |
| 1618 keyval, | |
| 1619 modifiers, | |
| 1620 prev_keyval, | |
| 1621 prev_modifiers, | |
| 1622 0); | |
| 1623 | |
| 1624 if (event == trigger) { | |
| 1625 gboolean enabled = bus_input_context_is_enabled (context); | |
| 1626 if (enabled) { | |
| 1627 bus_input_context_disable (context); | |
| 1628 } | |
| 1629 else { | |
| 1630 bus_input_context_enable (context); | |
| 1631 } | |
| 1632 return (enabled != bus_input_context_is_enabled (context)); | |
| 1633 } | |
| 1634 if (event == next) { | |
| 1635 if (bus_input_context_is_enabled(context)) { | |
| 1636 bus_ibus_impl_context_request_next_engine_in_menu (ibus, context); | |
| 1637 } | |
| 1638 else { | |
| 1639 bus_input_context_enable (context); | |
| 1640 } | |
| 1641 return TRUE; | |
| 1642 } | |
| 1643 if (event == previous) { | |
| 1644 if (bus_input_context_is_enabled(context)) { | |
| 1645 bus_ibus_impl_context_request_previous_engine (ibus, context); | |
| 1646 } | |
| 1647 else { | |
| 1648 bus_input_context_enable (context); | |
| 1649 } | |
| 1650 return TRUE; | |
| 1651 } | |
| 1652 return FALSE; | |
| 1653 } | |
| 1654 | |
| 1655 static gchar* | |
| 1656 bus_ibus_impl_load_global_engine_name_from_config (BusIBusImpl *ibus) | |
| 1657 { | |
| 1658 GValue value = { 0 }; | |
| 1659 gchar *global_engine_name = NULL; | |
| 1660 | |
| 1661 g_assert (IBUS_IS_CONFIG (ibus->config)); | |
| 1662 | |
| 1663 if (ibus_config_get_value (ibus->config, "general", "global_engine", &value) && | |
| 1664 G_VALUE_TYPE (&value) == G_TYPE_STRING) { | |
| 1665 global_engine_name = g_value_dup_string (&value); | |
| 1666 g_value_unset (&value); | |
| 1667 } | |
| 1668 | |
| 1669 return global_engine_name; | |
| 1670 } | |
| 1671 | |
| 1672 static void | |
| 1673 bus_ibus_impl_save_global_engine_name_to_config (BusIBusImpl *ibus) | |
| 1674 { | |
| 1675 g_assert (IBUS_IS_CONFIG (ibus->config)); | |
| 1676 | |
| 1677 if (ibus->use_global_engine && ibus->global_engine) { | |
| 1678 GValue value = { 0 }; | |
| 1679 g_value_init (&value, G_TYPE_STRING); | |
| 1680 g_value_set_static_string (&value, bus_engine_proxy_get_desc (ibus->glob al_engine)->name); | |
| 1681 | |
| 1682 ibus_config_set_value (ibus->config, "general", "global_engine", &value) ; | |
| 1683 g_value_unset (&value); | |
| 1684 } | |
| 1685 } | |
| 1686 | |
| 1687 static gchar* | |
| 1688 bus_ibus_impl_load_global_previous_engine_name_from_config (BusIBusImpl *ibus) | |
| 1689 { | |
| 1690 GValue value = { 0 }; | |
| 1691 gchar *global_previous_engine_name = NULL; | |
| 1692 | |
| 1693 g_assert (IBUS_IS_CONFIG (ibus->config)); | |
| 1694 | |
| 1695 if (ibus_config_get_value (ibus->config, "general", "global_previous_engine" , &value) && | |
| 1696 G_VALUE_TYPE (&value) == G_TYPE_STRING) { | |
| 1697 global_previous_engine_name = g_value_dup_string (&value); | |
| 1698 g_value_unset (&value); | |
| 1699 } | |
| 1700 | |
| 1701 return global_previous_engine_name; | |
| 1702 } | |
| 1703 | |
| 1704 static void | |
| 1705 bus_ibus_impl_save_global_previous_engine_name_to_config (BusIBusImpl *ibus) | |
| 1706 { | |
| 1707 g_assert (IBUS_IS_CONFIG (ibus->config)); | |
| 1708 | |
| 1709 if (ibus->use_global_engine && ibus->global_previous_engine_name) { | |
| 1710 GValue value = { 0 }; | |
| 1711 g_value_init (&value, G_TYPE_STRING); | |
| 1712 g_value_set_static_string (&value, ibus->global_previous_engine_name); | |
| 1713 | |
| 1714 ibus_config_set_value (ibus->config, "general", "global_previous_engine" , &value); | |
| 1715 g_value_unset (&value); | |
| 1716 } | |
| 1717 } | |
| OLD | NEW |