<commit_before>/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* ibus-xkb - IBus XKB
 * Copyright (C) 2011 <NAME> <<EMAIL>>
 * Copyright (C) 2011 <NAME> <<EMAIL>>
 * Copyright (C) 2011 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <ibus.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>

#ifdef ENABLE_NLS
#include <locale.h>
#endif

#include "xkbxml.h"
#include "ibusxkbxml.h"
#include "ibus-simple-engine.h"


static IBusBus *bus = NULL;
static IBusFactory *factory = NULL;
static gboolean ibus = FALSE;
static gboolean xml = FALSE;

static const GOptionEntry entries[] =
{
    { "ibus", 'i', 0, G_OPTION_ARG_NONE, &ibus, "component is executed by ibus", NULL },
    { "xml", 'x', 0, G_OPTION_ARG_NONE, &xml, "print component xml", NULL },
    { NULL },
};

static void
ibus_disconnected_cb (IBusBus  *bus,
                      gpointer  user_data)
{
    g_debug ("bus disconnected");
    ibus_quit ();
}

IBusEngine *
_factory_create_engine_cb (IBusFactory *factory,
                           const gchar *engine_name,
                           gpointer     data)
{
    IBusEngine *engine = NULL;
    gchar *object_path = NULL;
    static int id = 0;

    g_return_val_if_fail (engine_name != NULL, NULL);

    if (g_strcmp0 (engine_name, "xkb:layout:us") == 0) {
        return NULL;
    }

    object_path = g_strdup_printf ("/org/freedesktop/IBus/XKBEngine/%d",
                                   ++id);
    engine = ibus_engine_new_type (IBUS_TYPE_SIMPLE_ENGINE,
                                   engine_name,
                                   object_path,
                                   ibus_service_get_connection (IBUS_SERVICE (factory)));
    g_free (object_path);
    return engine;
}

static void
start_component (int argc, char **argv)
{
    IBusComponent *component;

    ibus_init ();

    bus = ibus_bus_new ();
    g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL);

    component = ibus_component_new ("org.freedesktop.IBus.XKB",
                                    "XKB Component",
                                    VERSION,
                                    "LGPL2.1",
                                    "<NAME> <<EMAIL>>",
                                    "http://code.google.com/p/ibus/",
                                    "",
                                    GETTEXT_PACKAGE);
    ibus_component_add_engine (component,
                               ibus_xkb_engine_desc_new ("eng",
                                                         "us",
                                                         "USA",
                                                         NULL,<commit_msg>Renamed ibus_engine_new_type to ibus_engine_new_with_type.<commit_after>/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* ibus-xkb - IBus XKB
 * Copyright (C) 2011 <NAME> <<EMAIL>>
 * Copyright (C) 2011 <NAME> <<EMAIL>>
 * Copyright (C) 2011 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <ibus.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>

#ifdef ENABLE_NLS
#include <locale.h>
#endif

#include "xkbxml.h"
#include "ibusxkbxml.h"
#include "ibus-simple-engine.h"


static IBusBus *bus = NULL;
static IBusFactory *factory = NULL;
static gboolean ibus = FALSE;
static gboolean xml = FALSE;

static const GOptionEntry entries[] =
{
    { "ibus", 'i', 0, G_OPTION_ARG_NONE, &ibus, "component is executed by ibus", NULL },
    { "xml", 'x', 0, G_OPTION_ARG_NONE, &xml, "print component xml", NULL },
    { NULL },
};

static void
ibus_disconnected_cb (IBusBus  *bus,
                      gpointer  user_data)
{
    g_debug ("bus disconnected");
    ibus_quit ();
}

IBusEngine *
_factory_create_engine_cb (IBusFactory *factory,
                           const gchar *engine_name,
                           gpointer     data)
{
    IBusEngine *engine = NULL;
    gchar *object_path = NULL;
    static int id = 0;

    g_return_val_if_fail (engine_name != NULL, NULL);

    if (g_strcmp0 (engine_name, "xkb:layout:us") == 0) {
        return NULL;
    }

    object_path = g_strdup_printf ("/org/freedesktop/IBus/XKBEngine/%d",
                                   ++id);
    engine = ibus_engine_new_with_type (IBUS_TYPE_SIMPLE_ENGINE,
                                        engine_name,
                                        object_path,
                                        ibus_service_get_connection (IBUS_SERVICE (factory)));
    g_free (object_path);
    return engine;
}

static void
start_component (int argc, char **argv)
{
    IBusComponent *component;

    ibus_init ();

    bus = ibus_bus_new ();
    g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL);

    component = ibus_component_new ("org.freedesktop.IBus.XKB",
                                    "XKB Component",
                                    VERSION,
                                    "LGPL2.1",
                                    "<NAME> <<EMAIL>>",
                                    "http://code.google.com/p/ibus/",
                                    "",
                                    GETTEXT_PACKAGE);
    ibus_component_add_engine (component,
                               ibus_xkb_engine_desc_new ("eng",
                                                         "us",
                                                         "USA",
                                                         NULL,
{'fraction_non_alphanumeric': 0.09910166833024384, 'fraction_numerical': 0.010837016968487096, 'mean_word_length': 1.8581907090464547, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3682162', 'n_tokens_mistral': 2105, 'n_tokens_neox': 1973, 'n_words': 604}