ibus-m17n/ibus-m17n-ibus-1.4.patch

344 lines
15 KiB
Diff
Raw Normal View History

2010-12-10 07:05:05 +00:00
From c7acc11b3a8e72efb2479b3d1a6f20abb156994c Mon Sep 17 00:00:00 2001
2010-12-08 09:25:29 +00:00
From: Daiki Ueno <ueno@unixuser.org>
Date: Fri, 3 Dec 2010 17:05:45 +0900
2010-11-09 02:34:42 +00:00
Subject: [PATCH] Fix problem with ibus-1.4
---
2010-12-08 09:25:29 +00:00
src/engine.c | 58 +++++++++++++++++++++++--------------------------
2010-12-10 07:05:05 +00:00
src/m17nutil.c | 18 +++++++-------
2010-12-08 09:25:29 +00:00
src/main.c | 7 +++--
src/setup.c | 65 ++++++++++++++++++++++++++++---------------------------
2010-12-10 07:05:05 +00:00
4 files changed, 73 insertions(+), 75 deletions(-)
2010-11-09 02:34:42 +00:00
diff --git a/src/engine.c b/src/engine.c
2010-12-08 09:25:29 +00:00
index f8e7fe5..5fbe46f 100644
2010-11-09 02:34:42 +00:00
--- a/src/engine.c
+++ b/src/engine.c
2010-12-08 09:25:29 +00:00
@@ -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;
2010-11-09 02:34:42 +00:00
2010-12-08 09:25:29 +00:00
@@ -321,43 +321,39 @@ ibus_m17n_engine_class_init (IBusM17NEngineClass *klass)
engine_config = ibus_m17n_get_engine_config (engine_name);
g_free (engine_name);
2010-11-09 02:34:42 +00:00
2010-12-08 09:25:29 +00:00
- if (ibus_config_get_value (config,
- klass->config_section,
- "preedit_foreground",
- &value)) {
- const gchar *hex = g_value_get_string (&value);
2010-11-09 02:34:42 +00:00
+ if (value = ibus_config_get_value (config,
2010-12-08 09:25:29 +00:00
+ klass->config_section,
2010-11-09 02:34:42 +00:00
+ "preedit_foreground")) {
+ const gchar *hex = g_variant_get_string (value, NULL);
2010-12-08 09:25:29 +00:00
klass->preedit_foreground = ibus_m17n_parse_color (hex);
- g_value_unset (&value);
2010-11-09 02:34:42 +00:00
+ g_variant_unref (value);
2010-12-08 09:25:29 +00:00
} 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);
2010-11-09 02:34:42 +00:00
+ if (value = ibus_config_get_value (config,
2010-12-08 09:25:29 +00:00
+ klass->config_section,
2010-11-09 02:34:42 +00:00
+ "preedit_background")) {
+ const gchar *hex = g_variant_get_string (value, NULL);
2010-12-08 09:25:29 +00:00
klass->preedit_background = ibus_m17n_parse_color (hex);
- g_value_unset (&value);
2010-11-09 02:34:42 +00:00
+ g_variant_unref (value);
2010-12-08 09:25:29 +00:00
} 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);
2010-11-09 02:34:42 +00:00
+ if (value = ibus_config_get_value (config,
2010-12-08 09:25:29 +00:00
+ klass->config_section,
2010-11-09 02:34:42 +00:00
+ "preedit_underline")) {
2010-12-08 09:25:29 +00:00
+ klass->preedit_underline = g_variant_get_int32 (value);
2010-11-09 02:34:42 +00:00
+ g_variant_unref (value);
2010-12-08 09:25:29 +00:00
} 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);
2010-11-09 02:34:42 +00:00
+ if (value = ibus_config_get_value (config,
2010-12-08 09:25:29 +00:00
+ klass->config_section,
2010-11-09 02:34:42 +00:00
+ "lookup_table_orientation")) {
2010-12-08 09:25:29 +00:00
+ klass->lookup_table_orientation = g_variant_get_int32 (value);
2010-11-09 02:34:42 +00:00
+ g_variant_unref (value);
2010-12-08 09:25:29 +00:00
} 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)
2010-11-09 02:34:42 +00:00
{
2010-12-08 09:25:29 +00:00
if (g_strcmp0 (section, klass->config_section) == 0) {
2010-11-09 02:34:42 +00:00
if (g_strcmp0 (name, "preedit_foreground") == 0) {
- const gchar *hex = g_value_get_string (value);
+ const gchar *hex = g_variant_get_string (value, NULL);
2010-12-08 09:25:29 +00:00
guint color;
color = ibus_m17n_parse_color (hex);
if (color != INVALID_COLOR) {
klass->preedit_foreground = color;
}
2010-11-09 02:34:42 +00:00
} 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);
2010-12-08 09:25:29 +00:00
guint color;
color = ibus_m17n_parse_color (hex);
if (color != INVALID_COLOR) {
klass->preedit_background = color;
}
2010-11-09 02:34:42 +00:00
} else if (g_strcmp0 (name, "preedit_underline") == 0) {
2010-12-08 09:25:29 +00:00
- klass->preedit_underline = g_value_get_int (value);
+ klass->preedit_underline = g_variant_get_int32 (value);
2010-11-09 02:34:42 +00:00
} else if (g_strcmp0 (name, "lookup_table_orientation") == 0) {
2010-12-08 09:25:29 +00:00
- klass->lookup_table_orientation = g_value_get_int (value);
+ klass->lookup_table_orientation = g_variant_get_int32 (value);
2010-11-09 02:34:42 +00:00
}
}
}
diff --git a/src/m17nutil.c b/src/m17nutil.c
2010-12-10 07:05:05 +00:00
index 6d6961f..c4098c7 100644
2010-11-09 02:34:42 +00:00
--- a/src/m17nutil.c
+++ b/src/m17nutil.c
2010-12-10 07:05:05 +00:00
@@ -113,15 +113,15 @@ ibus_m17n_engine_new (MSymbol lang,
2010-11-09 02:34:42 +00:00
engine_icon = ibus_m17n_mtext_to_utf8 (icon);
engine_desc = ibus_m17n_mtext_to_utf8 (desc);
2010-12-10 07:05:05 +00:00
2010-11-09 02:34:42 +00:00
- engine = ibus_engine_desc_new (engine_name,
- engine_longname,
- engine_desc ? engine_desc : "",
- msymbol_name (lang),
- "GPL",
- "",
- engine_icon ? engine_icon : "",
- "us");
2010-12-10 07:05:05 +00:00
- engine->rank = config->rank;
2010-11-09 02:34:42 +00:00
+ 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",
2010-12-08 09:25:29 +00:00
+ "rank", config->rank,
2010-11-09 02:34:42 +00:00
+ NULL);
2010-12-08 09:25:29 +00:00
2010-11-09 02:34:42 +00:00
g_free (engine_name);
g_free (engine_longname);
diff --git a/src/main.c b/src/main.c
2010-12-08 09:25:29 +00:00
index e76898d..bba31e1 100644
2010-11-09 02:34:42 +00:00
--- a/src/main.c
+++ b/src/main.c
2010-12-08 09:25:29 +00:00
@@ -51,13 +51,14 @@ start_component (void)
2010-11-09 02:34:42 +00:00
engines = ibus_component_get_engines (component);
for (p = engines; p != NULL; p = p->next) {
IBusEngineDesc *engine = (IBusEngineDesc *)p->data;
2010-12-08 09:25:29 +00:00
- 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);
2010-11-09 02:34:42 +00:00
}
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),
--
2010-12-08 09:25:29 +00:00
1.7.3.3
2010-11-09 02:34:42 +00:00