diff options
author | Peng Huang <shawn.p.huang@gmail.com> | 2010-07-23 11:41:44 +0800 |
---|---|---|
committer | Peng Huang <shawn.p.huang@gmail.com> | 2010-07-30 17:54:32 +0800 |
commit | 3609568f318b0d6ae831d0d4eb2a24398f81531f (patch) | |
tree | 4e5cb9bac96c22db87790c3340ce7fa7cc65ce60 | |
parent | d400b92229e7c03d7a893bc8ed33382c933e32d3 (diff) | |
download | ibus-3609568f318b0d6ae831d0d4eb2a24398f81531f.tar.gz |
Add memcomf/main.cc
-rw-r--r-- | memconf/main.cc | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/memconf/main.cc b/memconf/main.cc new file mode 100644 index 00000000..b2c6c837 --- /dev/null +++ b/memconf/main.cc @@ -0,0 +1,65 @@ +/* vim:set et sts=4: */ + +#include <ibus.h> +#include <stdlib.h> +#include <locale.h> +#include "config.h" + +static IBusBus *bus = NULL; +static IBusConfigGConf *config = NULL; + +/* options */ +static gboolean ibus = FALSE; +static gboolean verbose = FALSE; + +static const GOptionEntry entries[] = +{ + { "ibus", 'i', 0, G_OPTION_ARG_NONE, &ibus, "component is executed by ibus", NULL }, + { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "verbose", NULL }, + { NULL }, +}; + + +static void +ibus_disconnected_cb (IBusBus *bus, + gpointer user_data) +{ + g_debug ("bus disconnected"); + ibus_quit (); +} + +static void +ibus_gconf_start (void) +{ + ibus_init (); + bus = ibus_bus_new (); + if (!ibus_bus_is_connected (bus)) { + exit (-1); + } + g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL); + config = ibus_config_gconf_new (ibus_bus_get_connection (bus)); + ibus_bus_request_name (bus, IBUS_SERVICE_CONFIG, 0); + ibus_main (); +} + +int +main (gint argc, gchar **argv) +{ + GError *error = NULL; + GOptionContext *context; + + setlocale (LC_ALL, ""); + + context = g_option_context_new ("- ibus gconf component"); + + g_option_context_add_main_entries (context, entries, "ibus-gconf"); + + if (!g_option_context_parse (context, &argc, &argv, &error)) { + g_print ("Option parsing failed: %s\n", error->message); + exit (-1); + } + + ibus_gconf_start (); + + return 0; +} |