344 lines
15 KiB
Diff
344 lines
15 KiB
Diff
From c7acc11b3a8e72efb2479b3d1a6f20abb156994c Mon Sep 17 00:00:00 2001
|
|
From: Daiki Ueno <ueno@unixuser.org>
|
|
Date: Fri, 3 Dec 2010 17:05:45 +0900
|
|
Subject: [PATCH] Fix problem with ibus-1.4
|
|
|
|
---
|
|
src/engine.c | 58 +++++++++++++++++++++++--------------------------
|
|
src/m17nutil.c | 18 +++++++-------
|
|
src/main.c | 7 +++--
|
|
src/setup.c | 65 ++++++++++++++++++++++++++++---------------------------
|
|
4 files changed, 73 insertions(+), 75 deletions(-)
|
|
|
|
diff --git a/src/engine.c b/src/engine.c
|
|
index f8e7fe5..5fbe46f 100644
|
|
--- a/src/engine.c
|
|
+++ b/src/engine.c
|
|
@@ -58,7 +58,7 @@ static void ibus_m17n_engine_class_finalize (IBusM17NEngineClass *klass);
|
|
static void ibus_m17n_config_value_changed (IBusConfig *config,
|
|
const gchar *section,
|
|
const gchar *name,
|
|
- GValue *value,
|
|
+ GVariant *value,
|
|
IBusM17NEngineClass *klass);
|
|
static GObject*
|
|
ibus_m17n_engine_constructor (GType type,
|
|
@@ -274,7 +274,7 @@ ibus_m17n_engine_class_init (IBusM17NEngineClass *klass)
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
IBusObjectClass *ibus_object_class = IBUS_OBJECT_CLASS (klass);
|
|
IBusEngineClass *engine_class = IBUS_ENGINE_CLASS (klass);
|
|
- GValue value = { 0 };
|
|
+ GVariant *value = NULL;
|
|
gchar *engine_name, *lang = NULL, *name = NULL;
|
|
IBusM17NEngineConfig *engine_config;
|
|
|
|
@@ -321,43 +321,39 @@ ibus_m17n_engine_class_init (IBusM17NEngineClass *klass)
|
|
engine_config = ibus_m17n_get_engine_config (engine_name);
|
|
g_free (engine_name);
|
|
|
|
- if (ibus_config_get_value (config,
|
|
- klass->config_section,
|
|
- "preedit_foreground",
|
|
- &value)) {
|
|
- const gchar *hex = g_value_get_string (&value);
|
|
+ if (value = ibus_config_get_value (config,
|
|
+ klass->config_section,
|
|
+ "preedit_foreground")) {
|
|
+ const gchar *hex = g_variant_get_string (value, NULL);
|
|
|
|
klass->preedit_foreground = ibus_m17n_parse_color (hex);
|
|
- g_value_unset (&value);
|
|
+ g_variant_unref (value);
|
|
} else if (engine_config->preedit_highlight)
|
|
klass->preedit_foreground = PREEDIT_FOREGROUND;
|
|
|
|
- if (ibus_config_get_value (config,
|
|
- klass->config_section,
|
|
- "preedit_background",
|
|
- &value)) {
|
|
- const gchar *hex = g_value_get_string (&value);
|
|
+ if (value = ibus_config_get_value (config,
|
|
+ klass->config_section,
|
|
+ "preedit_background")) {
|
|
+ const gchar *hex = g_variant_get_string (value, NULL);
|
|
|
|
klass->preedit_background = ibus_m17n_parse_color (hex);
|
|
- g_value_unset (&value);
|
|
+ g_variant_unref (value);
|
|
} else if (engine_config->preedit_highlight)
|
|
klass->preedit_background = PREEDIT_BACKGROUND;
|
|
|
|
- if (ibus_config_get_value (config,
|
|
- klass->config_section,
|
|
- "preedit_underline",
|
|
- &value)) {
|
|
- klass->preedit_underline = g_value_get_int (&value);
|
|
- g_value_unset (&value);
|
|
+ if (value = ibus_config_get_value (config,
|
|
+ klass->config_section,
|
|
+ "preedit_underline")) {
|
|
+ klass->preedit_underline = g_variant_get_int32 (value);
|
|
+ g_variant_unref (value);
|
|
} else
|
|
klass->preedit_underline = IBUS_ATTR_UNDERLINE_NONE;
|
|
|
|
- if (ibus_config_get_value (config,
|
|
- klass->config_section,
|
|
- "lookup_table_orientation",
|
|
- &value)) {
|
|
- klass->lookup_table_orientation = g_value_get_int (&value);
|
|
- g_value_unset (&value);
|
|
+ if (value = ibus_config_get_value (config,
|
|
+ klass->config_section,
|
|
+ "lookup_table_orientation")) {
|
|
+ klass->lookup_table_orientation = g_variant_get_int32 (value);
|
|
+ g_variant_unref (value);
|
|
} else
|
|
klass->lookup_table_orientation = IBUS_ORIENTATION_SYSTEM;
|
|
|
|
@@ -372,28 +368,28 @@ static void
|
|
ibus_m17n_config_value_changed (IBusConfig *config,
|
|
const gchar *section,
|
|
const gchar *name,
|
|
- GValue *value,
|
|
+ GVariant *value,
|
|
IBusM17NEngineClass *klass)
|
|
{
|
|
if (g_strcmp0 (section, klass->config_section) == 0) {
|
|
if (g_strcmp0 (name, "preedit_foreground") == 0) {
|
|
- const gchar *hex = g_value_get_string (value);
|
|
+ const gchar *hex = g_variant_get_string (value, NULL);
|
|
guint color;
|
|
color = ibus_m17n_parse_color (hex);
|
|
if (color != INVALID_COLOR) {
|
|
klass->preedit_foreground = color;
|
|
}
|
|
} else if (g_strcmp0 (name, "preedit_background") == 0) {
|
|
- const gchar *hex = g_value_get_string (value);
|
|
+ const gchar *hex = g_variant_get_string (value, NULL);
|
|
guint color;
|
|
color = ibus_m17n_parse_color (hex);
|
|
if (color != INVALID_COLOR) {
|
|
klass->preedit_background = color;
|
|
}
|
|
} else if (g_strcmp0 (name, "preedit_underline") == 0) {
|
|
- klass->preedit_underline = g_value_get_int (value);
|
|
+ klass->preedit_underline = g_variant_get_int32 (value);
|
|
} else if (g_strcmp0 (name, "lookup_table_orientation") == 0) {
|
|
- klass->lookup_table_orientation = g_value_get_int (value);
|
|
+ klass->lookup_table_orientation = g_variant_get_int32 (value);
|
|
}
|
|
}
|
|
}
|
|
diff --git a/src/m17nutil.c b/src/m17nutil.c
|
|
index 6d6961f..c4098c7 100644
|
|
--- a/src/m17nutil.c
|
|
+++ b/src/m17nutil.c
|
|
@@ -113,15 +113,15 @@ ibus_m17n_engine_new (MSymbol lang,
|
|
engine_icon = ibus_m17n_mtext_to_utf8 (icon);
|
|
engine_desc = ibus_m17n_mtext_to_utf8 (desc);
|
|
|
|
- engine = ibus_engine_desc_new (engine_name,
|
|
- engine_longname,
|
|
- engine_desc ? engine_desc : "",
|
|
- msymbol_name (lang),
|
|
- "GPL",
|
|
- "",
|
|
- engine_icon ? engine_icon : "",
|
|
- "us");
|
|
- engine->rank = config->rank;
|
|
+ engine = ibus_engine_desc_new_varargs ("name", engine_name,
|
|
+ "longname", engine_longname,
|
|
+ "description", engine_desc ? engine_desc : "",
|
|
+ "language", msymbol_name (lang),
|
|
+ "license", "GPL",
|
|
+ "icon", engine_icon ? engine_icon : "",
|
|
+ "layout", "us",
|
|
+ "rank", config->rank,
|
|
+ NULL);
|
|
|
|
g_free (engine_name);
|
|
g_free (engine_longname);
|
|
diff --git a/src/main.c b/src/main.c
|
|
index e76898d..bba31e1 100644
|
|
--- a/src/main.c
|
|
+++ b/src/main.c
|
|
@@ -51,13 +51,14 @@ start_component (void)
|
|
engines = ibus_component_get_engines (component);
|
|
for (p = engines; p != NULL; p = p->next) {
|
|
IBusEngineDesc *engine = (IBusEngineDesc *)p->data;
|
|
- GType type = ibus_m17n_engine_get_type_for_name (engine->name);
|
|
+ const gchar *engine_name = ibus_engine_desc_get_name (engine);
|
|
+ GType type = ibus_m17n_engine_get_type_for_name (engine_name);
|
|
|
|
if (type == G_TYPE_INVALID) {
|
|
- g_debug ("Can not create engine type for %s", engine->name);
|
|
+ g_debug ("Can not create engine type for %s", engine_name);
|
|
continue;
|
|
}
|
|
- ibus_factory_add_engine (factory, engine->name, type);
|
|
+ ibus_factory_add_engine (factory, engine_name, type);
|
|
}
|
|
|
|
if (ibus) {
|
|
diff --git a/src/setup.c b/src/setup.c
|
|
index 0fe6e1b..178190e 100644
|
|
--- a/src/setup.c
|
|
+++ b/src/setup.c
|
|
@@ -210,10 +210,8 @@ color_to_gdk (guint color, GdkColor *color_gdk)
|
|
static void
|
|
set_color (ConfigContext *context, const gchar *name, GdkColor *color)
|
|
{
|
|
- GValue value = { 0 };
|
|
gchar buf[8];
|
|
|
|
- g_value_init (&value, G_TYPE_STRING);
|
|
if (color)
|
|
sprintf (buf, "#%02X%02X%02X",
|
|
(color->red & 0xFF00) >> 8,
|
|
@@ -221,8 +219,10 @@ set_color (ConfigContext *context, const gchar *name, GdkColor *color)
|
|
(color->blue & 0xFF00) >> 8);
|
|
else
|
|
strcpy (buf, "none");
|
|
- g_value_set_string (&value, buf);
|
|
- ibus_config_set_value (config, context->section, name, &value);
|
|
+ ibus_config_set_value (config,
|
|
+ context->section,
|
|
+ name,
|
|
+ g_variant_new_string (buf));
|
|
}
|
|
|
|
static void
|
|
@@ -254,17 +254,16 @@ on_underline_changed (GtkComboBox *combo,
|
|
ConfigContext *context = user_data;
|
|
GtkTreeModel *model;
|
|
GtkTreeIter iter;
|
|
- GValue value = { 0 };
|
|
gint active;
|
|
|
|
model = gtk_combo_box_get_model (combo);
|
|
gtk_combo_box_get_active_iter (combo, &iter);
|
|
gtk_tree_model_get (model, &iter, COLUMN_VALUE, &active, -1);
|
|
|
|
- g_value_init (&value, G_TYPE_INT);
|
|
- g_value_set_int (&value, active);
|
|
- ibus_config_set_value (config, context->section, "preedit_underline",
|
|
- &value);
|
|
+ ibus_config_set_value (config,
|
|
+ context->section,
|
|
+ "preedit_underline",
|
|
+ g_variant_new_int32 (active));
|
|
}
|
|
|
|
static void
|
|
@@ -274,17 +273,16 @@ on_orientation_changed (GtkComboBox *combo,
|
|
ConfigContext *context = user_data;
|
|
GtkTreeModel *model;
|
|
GtkTreeIter iter;
|
|
- GValue value = { 0 };
|
|
gint active;
|
|
|
|
model = gtk_combo_box_get_model (combo);
|
|
gtk_combo_box_get_active_iter (combo, &iter);
|
|
gtk_tree_model_get (model, &iter, COLUMN_VALUE, &active, -1);
|
|
|
|
- g_value_init (&value, G_TYPE_INT);
|
|
- g_value_set_int (&value, active);
|
|
- ibus_config_set_value (config, context->section, "lookup_table_orientation",
|
|
- &value);
|
|
+ ibus_config_set_value (config,
|
|
+ context->section,
|
|
+ "lookup_table_orientation",
|
|
+ g_variant_new_int32 (active));
|
|
}
|
|
|
|
static void
|
|
@@ -367,7 +365,7 @@ start (const gchar *engine_name)
|
|
GError *error = NULL;
|
|
GtkCellRenderer *renderer;
|
|
ConfigContext context;
|
|
- GValue value = { 0 };
|
|
+ GVariant *value = NULL;
|
|
gboolean is_foreground_set, is_background_set;
|
|
GdkColor foreground, background;
|
|
gint underline;
|
|
@@ -417,15 +415,16 @@ start (const gchar *engine_name)
|
|
/* foreground color of pre-edit buffer */
|
|
is_foreground_set = FALSE;
|
|
color_to_gdk (PREEDIT_FOREGROUND, &foreground);
|
|
- if (ibus_config_get_value (config, context.section, "preedit_foreground",
|
|
- &value)) {
|
|
+ if (value = ibus_config_get_value (config,
|
|
+ context.section,
|
|
+ "preedit_foreground")) {
|
|
const gchar *color;
|
|
|
|
- color = g_value_get_string (&value);
|
|
+ color = g_variant_get_string (value, NULL);
|
|
if (g_strcmp0 (color, "none") != 0 &&
|
|
gdk_color_parse (color, &foreground))
|
|
is_foreground_set = TRUE;
|
|
- g_value_unset (&value);
|
|
+ g_variant_unref (value);
|
|
}
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(checkbutton_foreground),
|
|
@@ -445,16 +444,17 @@ start (const gchar *engine_name)
|
|
/* background color of pre-edit buffer */
|
|
is_background_set = FALSE;
|
|
color_to_gdk (PREEDIT_BACKGROUND, &background);
|
|
- if (ibus_config_get_value (config, context.section, "preedit_background",
|
|
- &value)) {
|
|
+ if (value = ibus_config_get_value (config,
|
|
+ context.section,
|
|
+ "preedit_background")) {
|
|
const gchar *color;
|
|
|
|
- color = g_value_get_string (&value);
|
|
+ color = g_variant_get_string (value, NULL);
|
|
if (g_strcmp0 (color, "none") != 0 &&
|
|
gdk_color_parse (color, &background))
|
|
is_background_set = TRUE;
|
|
g_debug ("preedit_background %d", is_background_set);
|
|
- g_value_unset (&value);
|
|
+ g_variant_unref (value);
|
|
}
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(checkbutton_background),
|
|
is_background_set);
|
|
@@ -476,10 +476,11 @@ start (const gchar *engine_name)
|
|
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT(combobox_underline),
|
|
renderer, "text", 0, NULL);
|
|
underline = IBUS_ATTR_UNDERLINE_NONE;
|
|
- if (ibus_config_get_value (config, context.section, "preedit_underline",
|
|
- &value)) {
|
|
- underline = g_value_get_int (&value);
|
|
- g_value_unset (&value);
|
|
+ if (value = ibus_config_get_value (config,
|
|
+ context.section,
|
|
+ "preedit_underline")) {
|
|
+ underline = g_variant_get_int32 (value);
|
|
+ g_variant_unref (value);
|
|
}
|
|
|
|
index = get_combo_box_index_by_value (GTK_COMBO_BOX(combobox_underline),
|
|
@@ -495,11 +496,11 @@ start (const gchar *engine_name)
|
|
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT(combobox_orientation),
|
|
renderer, "text", 0, NULL);
|
|
orientation = IBUS_ORIENTATION_SYSTEM;
|
|
- if (ibus_config_get_value (config, context.section,
|
|
- "lookup_table_orientation",
|
|
- &value)) {
|
|
- orientation = g_value_get_int (&value);
|
|
- g_value_unset (&value);
|
|
+ if (value = ibus_config_get_value (config,
|
|
+ context.section,
|
|
+ "lookup_table_orientation")) {
|
|
+ orientation = g_variant_get_int32 (value);
|
|
+ g_variant_unref (value);
|
|
}
|
|
|
|
index = get_combo_box_index_by_value (GTK_COMBO_BOX(combobox_orientation),
|
|
--
|
|
1.7.3.3
|
|
|