Example #1
0
void
ibus_rime_load_settings(IBusConfig* config)
{
  //g_debug("ibus_rime_load_settings");
  GVariant* value;

  value = ibus_config_get_value(config, "engine/Rime", "embed_preedit_text");
  if (!value) {
    value = ibus_config_get_value(config, "general", "embed_preedit_text");
  }
  if (value && g_variant_classify(value) == G_VARIANT_CLASS_BOOLEAN) {
    g_ibus_rime_settings.embed_preedit_text = g_variant_get_boolean(value);
  }

  value = ibus_config_get_value(config, "engine/Rime", "lookup_table_orientation");
  if (!value) {
    value = ibus_config_get_value(config, "panel", "lookup_table_orientation");
  }
  if (value && g_variant_classify(value) == G_VARIANT_CLASS_INT32) {
    g_ibus_rime_settings.lookup_table_orientation = g_variant_get_int32(value);
  }

  value = ibus_config_get_value(config, "engine/Rime", "color_scheme");
  if (value && g_variant_classify(value) == G_VARIANT_CLASS_STRING) {
    ibus_rime_select_color_scheme(g_variant_get_string(value, NULL));
  }
}
GValue *ibus_config_backend_read_value(MkdgBackend * backend,
                                       GValue * value,
                                       const gchar * section,
                                       const gchar * key, gpointer userData)
{
    IBusConfig *config = (IBusConfig *) backend->config;
    gchar confSection[KEY_BUFFER_SIZE];

    to_real_section(confSection, backend, section);
    printf("confSection=%s\n", confSection);
#if IBUS_CHECK_VERSION(1, 4, 0)
    GVariant *gVar = ibus_config_get_value(config, confSection,
                                           key);

    if (gVar == NULL) {
        return NULL;
    }
    g_variant_ref_sink(gVar);
    mkdg_g_variant_to_g_value(gVar, value);
    g_variant_unref(gVar);
    return value;
#else
    return ibus_config_get_value(config, confSection, key, value);
#endif
}
Example #3
0
void
ibus_hangul_init (IBusBus *bus)
{
    GVariant* value;

    hanja_table = hanja_table_load (NULL);

    symbol_table = hanja_table_load (IBUSHANGUL_DATADIR "/data/symbol.txt");

    config = ibus_bus_get_config (bus);
    if (config)
        g_object_ref_sink (config);

    hangul_keyboard = g_string_new_len ("2", 8);
    value = ibus_config_get_value (config, "engine/Hangul",
                                         "HangulKeyboard");
    if (value != NULL) {
        const gchar* str = g_variant_get_string (value, NULL);
        g_string_assign (hangul_keyboard, str);
        g_variant_unref(value);
    }

    hanja_key_list_init(&hanja_keys);

    value = ibus_config_get_value (config, "engine/Hangul",
                                         "HanjaKeys");
    if (value != NULL) {
        const gchar* str = g_variant_get_string (value, NULL);
        hanja_key_list_set_from_string(&hanja_keys, str);
        g_variant_unref(value);
    } else {
	hanja_key_list_append(&hanja_keys, IBUS_Hangul_Hanja, 0);
	hanja_key_list_append(&hanja_keys, IBUS_F9, 0);
    }

    value = ibus_config_get_value (config, "engine/Hangul",
                                         "WordCommit");
    if (value != NULL) {
        word_commit = g_variant_get_boolean (value);
        g_variant_unref(value);
    }

    value = ibus_config_get_value (config, "engine/Hangul", "AutoReorder");
    if (value != NULL) {
        auto_reorder = g_variant_get_boolean (value);
        g_variant_unref (value);
    }

    keymap = ibus_keymap_get("us");
}
Example #4
0
void
ibus_rime_config_value_changed_cb(IBusConfig* config,
                                  const gchar* section,
                                  const gchar* name,
                                  GVariant* value,
                                  gpointer unused)
{
  //g_debug("ibus_rime_config_value_changed_cb [%s/%s]", section, name);
  if (!strcmp("general", section)) {
    if (!strcmp("embed_preedit_text", name) &&
        value && g_variant_classify(value) == G_VARIANT_CLASS_BOOLEAN) {
      g_ibus_rime_settings.embed_preedit_text = g_variant_get_boolean(value);
      return;
    }
  }
  else if (!strcmp("panel", section)) {
    if (!strcmp("lookup_table_orientation", name) &&
        value && g_variant_classify(value) == G_VARIANT_CLASS_INT32) {
      g_ibus_rime_settings.lookup_table_orientation = g_variant_get_int32(value);
      return;
    }
  }
  else if (!strcmp("engine/Rime", section)) {
    if (!strcmp("embed_preedit_text", name) &&
        value && g_variant_classify(value) == G_VARIANT_CLASS_BOOLEAN) {
      GVariant* overridden = ibus_config_get_value(config, "engine/Rime", "embed_preedit_text");
      if (!overridden) {
        g_ibus_rime_settings.embed_preedit_text = g_variant_get_boolean(value);
      }
      return;
    }
    if (!strcmp("lookup_table_orientation", name) &&
        value && g_variant_classify(value) == G_VARIANT_CLASS_INT32) {
      GVariant* overridden = ibus_config_get_value(config, "engine/Rime", "lookup_table_orientation");
      if (!overridden) {
        g_ibus_rime_settings.lookup_table_orientation = g_variant_get_int32(value);
      }
      return;
    }
    if (!strcmp("color_scheme", name) &&
        value && g_variant_classify(value) == G_VARIANT_CLASS_STRING) {
      ibus_rime_select_color_scheme(g_variant_get_string(value, NULL));
      return;
    }
  }
}
Example #5
0
File: main.c Project: KDE/kimtoy
static gboolean
x11_fd_dispatch(GSource* source, GSourceFunc callback, gpointer user_data)
{
    Display *dpy = ((x11_source_t*)source)->dpy;

    XEvent e;

    while (XPending(dpy))
    {

        XNextEvent(dpy, &e);
        if (e.type == KeyPress)
        {
//             g_print("KeyPress!!!\n");

            static const gchar *names[64] = {0};
            names[0] = "xkb:us::eng";

            static int inited = 0;
            if (!inited)
            {
                IBusConfig *config = ibus_bus_get_config (bus);
                GVariant *engines = ibus_config_get_value (config, "general", "preload-engines");
                if (!engines)
                    continue;

                int i = 1;

                GVariantIter iter;
                GVariant *child;
                g_variant_iter_init (&iter, engines);
                while ((child = g_variant_iter_next_value (&iter)) != NULL) {
                    const gchar *engine_name = g_variant_get_string (child, NULL);
//                     g_print("engine_name %s\n", engine_name);
                    names[i] = engine_name;
                    i++;
                    g_variant_unref (child);
                }

                inited = 1;
            }

            static int n = 0;
            n = n==0? 1 : 0;
            ibus_bus_set_global_engine(bus, names[n]);
        }

    }

    return TRUE;
}