OLD | NEW |
1 /* vim:set et sts=4: */ | 1 /* vim:set et sts=4: */ |
2 /* | 2 /* |
3 * Copyright © 2009 Red Hat, Inc. All rights reserved. | 3 * Copyright © 2009 Red Hat, Inc. All rights reserved. |
4 * Copyright © 2009 Ding-Yi Chen <dchen at redhat.com> | 4 * Copyright © 2009 Ding-Yi Chen <dchen at redhat.com> |
5 * | 5 * |
6 * This file is part of the ibus-chewing Project. | 6 * This file is part of the ibus-chewing Project. |
7 * | 7 * |
8 * This program is free software; you can redistribute it and/or | 8 * This program is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU General Public License | 9 * modify it under the terms of the GNU General Public License |
10 * as published by the Free Software Foundation; either version 2 | 10 * as published by the Free Software Foundation; either version 2 |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "ibus-chewing-engine.h" | 28 #include "ibus-chewing-engine.h" |
29 #include "maker-dialog.h" | 29 #include "maker-dialog.h" |
30 | 30 |
31 MakerDialog *makerDialog=NULL; | 31 MakerDialog *makerDialog=NULL; |
32 static IBusBus *bus = NULL; | 32 static IBusBus *bus = NULL; |
33 static IBusFactory *factory = NULL; | 33 static IBusFactory *factory = NULL; |
34 | 34 |
35 /* options */ | 35 /* options */ |
36 static gboolean ibus = FALSE; | 36 static gboolean ibus = FALSE; |
37 int ibus_chewing_verbose= 0; | 37 int ibus_chewing_verbose= 0; |
| 38 IBusConfig *iConfig = NULL; |
38 | 39 |
39 static const GOptionEntry entries[] = | 40 static const GOptionEntry entries[] = |
40 { | 41 { |
41 { "ibus", 'i', 0, G_OPTION_ARG_NONE, &ibus, "component is executed by ibus",
NULL }, | 42 { "ibus", 'i', 0, G_OPTION_ARG_NONE, &ibus, "component is executed by ibus",
NULL }, |
42 { "verbose", 'v', 0, G_OPTION_ARG_INT, &ibus_chewing_verbose, | 43 { "verbose", 'v', 0, G_OPTION_ARG_INT, &ibus_chewing_verbose, |
43 "Verbose level. The higher the level, the more the debug messages.", | 44 "Verbose level. The higher the level, the more the debug messages.", |
44 "[integer]" }, | 45 "[integer]" }, |
45 { NULL }, | 46 { NULL }, |
46 }; | 47 }; |
47 | 48 |
48 | 49 |
49 static void | 50 static void |
50 ibus_disconnected_cb (IBusBus *bus, | 51 ibus_disconnected_cb (IBusBus *bus, |
51 gpointer user_data) | 52 gpointer user_data) |
52 { | 53 { |
53 g_debug ("bus disconnected"); | 54 g_debug ("bus disconnected"); |
54 ibus_quit (); | 55 ibus_quit (); |
55 } | 56 } |
56 | 57 |
57 | 58 |
58 static void | 59 static void |
59 start_component (void) | 60 start_component (void) |
60 { | 61 { |
61 bus = ibus_bus_new (); | 62 bus = ibus_bus_new (); |
62 g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NU
LL); | 63 g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NU
LL); |
| 64 iConfig = ibus_bus_get_config (bus); |
| 65 if (iConfig) |
| 66 g_object_ref_sink (iConfig); |
63 | 67 |
64 IBusConnection *iConnection=ibus_bus_get_connection (bus); | 68 IBusConnection *iConnection=ibus_bus_get_connection (bus); |
65 factory = ibus_factory_new (iConnection); | 69 factory = ibus_factory_new (iConnection); |
66 ibus_factory_add_engine (factory, "chewing", IBUS_TYPE_CHEWING_ENGINE); | 70 ibus_factory_add_engine (factory, "chewing", IBUS_TYPE_CHEWING_ENGINE); |
67 | 71 |
68 if (ibus) { | 72 if (ibus) { |
69 ibus_bus_request_name (bus, "org.freedesktop.IBus.Chewing", 0); | 73 ibus_bus_request_name (bus, "org.freedesktop.IBus.Chewing", 0); |
70 }else { | 74 }else { |
71 IBusComponent *component; | 75 IBusComponent *component; |
72 // component = ibus_component_new_from_file ( DATADIR "/ibus/component/ch
ewing.xml"); | 76 // component = ibus_component_new_from_file ( DATADIR "/ibus/component/ch
ewing.xml"); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 148 |
145 if (!g_option_context_parse (context, &argc, &argv, &error)) { | 149 if (!g_option_context_parse (context, &argc, &argv, &error)) { |
146 g_print ("Option parsing failed: %s\n", error->message); | 150 g_print ("Option parsing failed: %s\n", error->message); |
147 exit (-1); | 151 exit (-1); |
148 } | 152 } |
149 | 153 |
150 g_option_context_free (context); | 154 g_option_context_free (context); |
151 start_component (); | 155 start_component (); |
152 return 0; | 156 return 0; |
153 } | 157 } |
OLD | NEW |