Blame conf/gconf/main.c

Packit 3ff832
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
Packit 3ff832
/* vim:set et sts=4: */
Packit 3ff832
Packit 3ff832
#include <ibus.h>
Packit 3ff832
#include <stdlib.h>
Packit 3ff832
#include <locale.h>
Packit 3ff832
#include "config.h"
Packit 3ff832
Packit 3ff832
static IBusBus *bus = NULL;
Packit 3ff832
static IBusConfigGConf *config = NULL;
Packit 3ff832
Packit 3ff832
/* options */
Packit 3ff832
static gboolean ibus = FALSE;
Packit 3ff832
static gboolean verbose = FALSE;
Packit 3ff832
Packit 3ff832
static const GOptionEntry entries[] =
Packit 3ff832
{
Packit 3ff832
    { "ibus", 'i', 0, G_OPTION_ARG_NONE, &ibus, "component is executed by ibus", NULL },
Packit 3ff832
    { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "verbose", NULL },
Packit 3ff832
    { NULL },
Packit 3ff832
};
Packit 3ff832
Packit 3ff832
Packit 3ff832
static void
Packit 3ff832
ibus_disconnected_cb (IBusBus  *bus,
Packit 3ff832
                      gpointer  user_data)
Packit 3ff832
{
Packit 3ff832
    ibus_quit ();
Packit 3ff832
}
Packit 3ff832
Packit 3ff832
static void
Packit 3ff832
ibus_gconf_start (void)
Packit 3ff832
{
Packit 3ff832
    ibus_init ();
Packit 3ff832
    bus = ibus_bus_new ();
Packit 3ff832
    if (!ibus_bus_is_connected (bus)) {
Packit 3ff832
        exit (-1);
Packit 3ff832
    }
Packit 3ff832
    g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL);
Packit 3ff832
    config = ibus_config_gconf_new (ibus_bus_get_connection (bus));
Packit 3ff832
    ibus_bus_request_name (bus, IBUS_SERVICE_CONFIG, 0);
Packit 3ff832
    ibus_main ();
Packit 3ff832
}
Packit 3ff832
Packit 3ff832
gint
Packit 3ff832
main (gint argc, gchar **argv)
Packit 3ff832
{
Packit 3ff832
    GError *error = NULL;
Packit 3ff832
    GOptionContext *context;
Packit 3ff832
Packit 3ff832
    setlocale (LC_ALL, "");
Packit 3ff832
Packit 3ff832
    context = g_option_context_new ("- ibus gconf component");
Packit 3ff832
Packit 3ff832
    g_option_context_add_main_entries (context, entries, "ibus-gconf");
Packit 3ff832
Packit 3ff832
    if (!g_option_context_parse (context, &argc, &argv, &error)) {
Packit 3ff832
        g_print ("Option parsing failed: %s\n", error->message);
Packit 3ff832
        g_error_free (error);
Packit 3ff832
        exit (-1);
Packit 3ff832
    }
Packit 3ff832
Packit 3ff832
    ibus_gconf_start ();
Packit 3ff832
Packit 3ff832
    return 0;
Packit 3ff832
}