Revive iok patch.

This commit is contained in:
Daiki Ueno 2011-09-02 12:02:57 +09:00
parent 52a761fa09
commit 74c5abeda0
7 changed files with 1212 additions and 60 deletions

View File

@ -1,7 +1,7 @@
From e37bcc53f1d145e10974fb0bb91802d735921fcd Mon Sep 17 00:00:00 2001 From e37bcc53f1d145e10974fb0bb91802d735921fcd Mon Sep 17 00:00:00 2001
From: Daiki Ueno <ueno@unixuser.org> From: Daiki Ueno <ueno@unixuser.org>
Date: Wed, 31 Aug 2011 11:44:46 +0900 Date: Wed, 31 Aug 2011 11:44:46 +0900
Subject: [PATCH 1/5] Update the format of default.xml to allow override. Subject: [PATCH 1/6] Update the format of default.xml to allow override.
This patch allows value inheritance from the previous matches. This patch allows value inheritance from the previous matches.
With the new format: With the new format:

102
ibus-m17n-iok.patch Normal file
View File

@ -0,0 +1,102 @@
From 240931f8433ffa9de0c78a862e0d5e0aad93953d Mon Sep 17 00:00:00 2001
From: Daiki Ueno <ueno@unixuser.org>
Date: Fri, 2 Sep 2011 11:27:02 +0900
Subject: [PATCH 6/6] Apply iok patch from fedora.
---
src/engine.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/src/engine.c b/src/engine.c
index 1e6bd1b..f23d982 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -26,6 +26,7 @@ struct _IBusM17NEngine {
IBusProperty *setup_prop;
#endif /* HAVE_SETUP */
IBusProperty *virtkbd_prop;
+ IBusProperty *show_iok_prop;
IBusPropList *prop_list;
};
@@ -40,6 +41,7 @@ struct _IBusM17NEngineClass {
gint lookup_table_orientation;
gchar *virtual_keyboard;
gboolean virtual_keyboard_enabled;
+ gboolean use_iok;
MInputMethod *im;
};
@@ -254,6 +256,9 @@ ibus_m17n_engine_class_init (IBusM17NEngineClass *klass)
}
engine_name = g_strdup_printf ("m17n:%s:%s", lang, name);
klass->config_section = g_strdup_printf ("engine/M17N/%s/%s", lang, name);
+ /* whether to use iok - maybe good to move this to default.xml */
+ klass->use_iok = g_strcmp0 (name, "inscript") == 0 ||
+ g_strcmp0 (name, "inscript2") == 0;
g_free (lang);
g_free (name);
@@ -412,6 +417,22 @@ ibus_m17n_engine_init (IBusM17NEngine *m17n)
klass->virtual_keyboard != NULL)
ibus_property_set_visible (m17n->virtkbd_prop, TRUE);
+ label = ibus_text_new_from_string ("iok");
+ m17n->show_iok_prop = ibus_property_new ("iok",
+ PROP_TYPE_NORMAL,
+ label,
+ "/usr/share/pixmaps/iok.xpm",
+ label,
+ TRUE,
+ FALSE,
+ 0,
+ NULL);
+ g_object_ref_sink (m17n->show_iok_prop);
+ ibus_prop_list_append (m17n->prop_list, m17n->show_iok_prop);
+
+ if (klass->use_iok && !klass->virtual_keyboard_enabled)
+ ibus_property_set_visible (m17n->show_iok_prop, TRUE);
+
m17n->table = ibus_lookup_table_new (9, 0, TRUE, TRUE);
g_object_ref_sink (m17n->table);
m17n->context = NULL;
@@ -502,6 +523,11 @@ ibus_m17n_engine_destroy (IBusM17NEngine *m17n)
m17n->virtkbd_prop = NULL;
}
+ if (m17n->show_iok_prop) {
+ g_object_unref (m17n->show_iok_prop);
+ m17n->show_iok_prop = NULL;
+ }
+
if (m17n->table) {
g_object_unref (m17n->table);
m17n->table = NULL;
@@ -842,6 +868,24 @@ ibus_m17n_engine_property_activate (IBusEngine *engine,
}
#endif /* HAVE_EEKBOARD */
+ if (g_strcmp0 (prop_name, "iok") == 0) {
+ const gchar *engine_name;
+ gchar *lang = NULL, *name = NULL;
+
+ engine_name = ibus_engine_get_name ((IBusEngine *) m17n);
+ if (ibus_m17n_scan_engine_name (engine_name, &lang, &name)) {
+ gchar *iok;
+
+ iok = g_strdup_printf ("/usr/bin/iok -n %s", lang);
+ g_debug ("keymap name = %s,prop_name=%s, prop_state=%d",
+ engine_name, prop_name, prop_state);
+ g_spawn_command_line_async(iok, NULL);
+ g_free (iok);
+ }
+ g_free (lang);
+ g_free (name);
+ }
+
parent_class->property_activate (engine, prop_name, prop_state);
}
--
1.7.6.1

View File

@ -0,0 +1,843 @@
From bd48b1f5c71ab849e1d2c78fd069a92d37426dc3 Mon Sep 17 00:00:00 2001
From: Daiki Ueno <ueno@unixuser.org>
Date: Thu, 1 Sep 2011 18:48:41 +0900
Subject: [PATCH 2/6] Refactor setup.c.
---
src/ibus-m17n-preferences.ui | 3 +-
src/setup.c | 663 +++++++++++++++++++++++-------------------
2 files changed, 362 insertions(+), 304 deletions(-)
diff --git a/src/ibus-m17n-preferences.ui b/src/ibus-m17n-preferences.ui
index 6f6ace7..a46ab49 100644
--- a/src/ibus-m17n-preferences.ui
+++ b/src/ibus-m17n-preferences.ui
@@ -263,9 +263,10 @@
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<child>
- <object class="GtkTreeView" id="treeviewMimConfig">
+ <object class="GtkTreeView" id="treeview_mim_config">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="has_tooltip">True</property>
<property name="enable_grid_lines">both</property>
</object>
</child>
diff --git a/src/setup.c b/src/setup.c
index aba0e92..30386df 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -17,19 +17,24 @@ enum {
NUM_COLS
};
-struct _ConfigContext {
- IBusConfig *config;
- MSymbol language;
- MSymbol name;
- GtkListStore *store;
- gchar *section;
+struct _SetupDialog {
+ GtkWidget *dialog;
+ GtkWidget *combobox_underline;
+ GtkWidget *combobox_orientation;
+ GtkWidget *checkbutton_foreground;
GtkWidget *colorbutton_foreground;
+ GtkWidget *checkbutton_background;
GtkWidget *colorbutton_background;
+ GtkWidget *treeview;
+ GtkListStore *store;
-};
-typedef struct _ConfigContext ConfigContext;
+ gchar *lang;
+ gchar *name;
-static IBusConfig *config = NULL;
+ IBusConfig *config;
+ gchar *section;
+};
+typedef struct _SetupDialog SetupDialog;
static gchar *opt_name = NULL;
static const GOptionEntry options[] = {
@@ -38,17 +43,8 @@ static const GOptionEntry options[] = {
{NULL}
};
-void
-ibus_m17n_init (IBusBus *bus)
-{
- config = ibus_bus_get_config (bus);
- if (config)
- g_object_ref_sink (config);
- ibus_m17n_init_common ();
-}
-
static gchar *
-format_value (MPlist *plist)
+format_m17n_value (MPlist *plist)
{
if (mplist_key (plist) == Msymbol)
return g_strdup (msymbol_name ((MSymbol) mplist_value (plist)));
@@ -64,7 +60,7 @@ format_value (MPlist *plist)
}
static MPlist *
-parse_value (MPlist *plist, gchar *text)
+parse_m17n_value (MPlist *plist, gchar *text)
{
MPlist *value;
@@ -100,7 +96,7 @@ parse_value (MPlist *plist, gchar *text)
}
static void
-insert_items (GtkListStore *store, MSymbol language, MSymbol name)
+insert_m17n_items (GtkListStore *store, MSymbol language, MSymbol name)
{
MPlist *plist;
@@ -109,8 +105,8 @@ insert_items (GtkListStore *store, MSymbol language, MSymbol name)
for (; plist && mplist_key (plist) == Mplist; plist = mplist_next (plist)) {
GtkTreeIter iter;
MSymbol key;
- MPlist *p, *value;
- gchar *description;
+ MPlist *p, *mvalue;
+ gchar *description, *value;
p = mplist_value (plist);
key = mplist_value (p); /* name */
@@ -118,15 +114,17 @@ insert_items (GtkListStore *store, MSymbol language, MSymbol name)
p = mplist_next (p); /* description */
description = ibus_m17n_mtext_to_utf8 ((MText *) mplist_value (p));
p = mplist_next (p); /* status */
- value = mplist_next (p);
+ mvalue = mplist_next (p);
+ value = format_m17n_value (mvalue);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
COLUMN_KEY, msymbol_name (key),
COLUMN_DESCRIPTION, description,
- COLUMN_VALUE, format_value (value),
+ COLUMN_VALUE, value,
-1);
g_free (description);
+ g_free (value);
}
}
@@ -163,95 +161,238 @@ on_edited (GtkCellRendererText *cell,
gchar *new_text,
gpointer data)
{
- ConfigContext *context = data;
- GtkTreeModel *model = GTK_TREE_MODEL (context->store);
+ SetupDialog *dialog = data;
+ GtkTreeModel *model = GTK_TREE_MODEL (dialog->store);
GtkTreeIter iter;
GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
- MPlist *plist, *p, *value;
- gchar *key;
gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_model_get (model, &iter, COLUMN_KEY, &key, -1);
- plist = minput_get_variable (context->language, context->name,
- msymbol (key));
- if (!plist)
- goto fail;
+ gtk_list_store_set (dialog->store, &iter,
+ COLUMN_VALUE, new_text,
+ -1);
+ gtk_tree_path_free (path);
+}
- p = mplist_next (mplist_next (mplist_next (mplist_value (plist))));
- if (!p)
- goto fail;
+static void
+toggle_colorbutton_sensitive (GtkToggleButton *togglebutton,
+ GtkWidget *colorbutton)
+{
+ if (gtk_toggle_button_get_active (togglebutton))
+ gtk_widget_set_sensitive (colorbutton, TRUE);
+ else
+ gtk_widget_set_sensitive (colorbutton, FALSE);
+}
- value = parse_value (p, new_text);
- if (!value)
- goto fail;
+static void
+on_foreground_toggled (GtkToggleButton *togglebutton,
+ gpointer user_data)
+{
+ SetupDialog *dialog = user_data;
+ toggle_colorbutton_sensitive (togglebutton, dialog->colorbutton_foreground);
+}
- if (minput_config_variable (context->language, context->name,
- msymbol (key), value) != 0)
- goto fail;
+static void
+on_background_toggled (GtkToggleButton *togglebutton,
+ gpointer user_data)
+{
+ SetupDialog *dialog = user_data;
+ toggle_colorbutton_sensitive (togglebutton, dialog->colorbutton_background);
+}
- if (minput_save_config () != 1)
- goto fail;
+static gint
+get_combo_box_index_by_value (GtkComboBox *combobox, gint value)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gint index;
- gtk_list_store_set (context->store, &iter,
- COLUMN_VALUE, new_text,
- -1);
+ index = 0;
+ model = gtk_combo_box_get_model (combobox);
+ if (!gtk_tree_model_get_iter_first (model, &iter))
+ return -1;
- fail:
- gtk_tree_path_free (path);
+ do {
+ gint _value;
+ gtk_tree_model_get (model, &iter, COLUMN_VALUE, &_value, -1);
+ if (_value == value)
+ return index;
+ index++;
+ } while (gtk_tree_model_iter_next (model, &iter));
+ return -1;
}
static void
-color_to_gdk (guint color, GdkColor *color_gdk)
+_gdk_color_from_uint (guint color, GdkColor *color_gdk)
{
- memset (color_gdk, 0, sizeof *color_gdk);
+ color_gdk->pixel = 0;
color_gdk->red = (color >> 8) & 0xFF00;
color_gdk->green = color & 0xFF00;
color_gdk->blue = (color & 0xFF) << 8;
}
static void
-set_color (ConfigContext *context, const gchar *name, GdkColor *color)
+setup_dialog_load_config (SetupDialog *dialog)
{
- gchar buf[8];
+ gchar *color;
+ gboolean bvalue;
+ gint ivalue;
+ GdkColor cvalue;
+ GtkCellRenderer *renderer;
+ gint index;
- if (color)
- sprintf (buf, "#%02X%02X%02X",
- (color->red & 0xFF00) >> 8,
- (color->green & 0xFF00) >> 8,
- (color->blue & 0xFF00) >> 8);
- else
- strcpy (buf, "none");
- ibus_m17n_config_set_string (config, context->section, name, buf);
+ /* General -> Pre-edit Appearance */
+ /* foreground color of pre-edit buffer */
+ bvalue = FALSE;
+ _gdk_color_from_uint (PREEDIT_FOREGROUND, &cvalue);
+ if (ibus_m17n_config_get_string (dialog->config,
+ dialog->section,
+ "preedit_foreground",
+ &color)) {
+ if (g_strcmp0 (color, "none") != 0 && gdk_color_parse (color, &cvalue))
+ bvalue = TRUE;
+ g_free (color);
+ }
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(dialog->checkbutton_foreground),
+ bvalue);
+ g_signal_connect (dialog->checkbutton_foreground, "toggled",
+ G_CALLBACK(on_foreground_toggled),
+ dialog);
+ gtk_widget_set_sensitive (dialog->colorbutton_foreground,
+ bvalue);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON(dialog->colorbutton_foreground),
+ &cvalue);
+
+ /* background color of pre-edit buffer */
+ bvalue = FALSE;
+ _gdk_color_from_uint (PREEDIT_BACKGROUND, &cvalue);
+ if (ibus_m17n_config_get_string (dialog->config,
+ dialog->section,
+ "preedit_background",
+ &color)) {
+ if (g_strcmp0 (color, "none") != 0 && gdk_color_parse (color, &cvalue))
+ bvalue = TRUE;
+ g_free (color);
+ }
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(dialog->checkbutton_background),
+ bvalue);
+ g_signal_connect (dialog->checkbutton_background, "toggled",
+ G_CALLBACK(on_background_toggled),
+ dialog);
+ gtk_widget_set_sensitive (dialog->colorbutton_background,
+ bvalue);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON(dialog->colorbutton_background),
+ &cvalue);
+
+ /* underline of pre-edit buffer */
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(dialog->combobox_underline),
+ renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT(dialog->combobox_underline),
+ renderer, "text", 0, NULL);
+ if (!ibus_m17n_config_get_int (dialog->config,
+ dialog->section,
+ "preedit_underline",
+ &ivalue))
+ ivalue = IBUS_ATTR_UNDERLINE_NONE;
+
+ index = get_combo_box_index_by_value
+ (GTK_COMBO_BOX(dialog->combobox_underline),
+ ivalue);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(dialog->combobox_underline),
+ index);
+
+ /* General -> Other */
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(dialog->combobox_orientation),
+ renderer, TRUE);
+ gtk_cell_layout_set_attributes
+ (GTK_CELL_LAYOUT(dialog->combobox_orientation),
+ renderer, "text", 0, NULL);
+ if (!ibus_m17n_config_get_int (dialog->config,
+ dialog->section,
+ "lookup_table_orientation",
+ &ivalue))
+ ivalue = IBUS_ORIENTATION_SYSTEM;
+
+ index = get_combo_box_index_by_value
+ (GTK_COMBO_BOX(dialog->combobox_orientation),
+ ivalue);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(dialog->combobox_orientation),
+ index);
+
+ /* Advanced -> m17n-lib configuration */
+ dialog->store = gtk_list_store_new (NUM_COLS,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
+ insert_m17n_items (dialog->store,
+ msymbol (dialog->lang),
+ msymbol (dialog->name));
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW(dialog->treeview),
+ GTK_TREE_MODEL (dialog->store));
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_insert_column_with_attributes
+ (GTK_TREE_VIEW (dialog->treeview), -1,
+ "Key",
+ renderer,
+ "text", COLUMN_KEY,
+ NULL);
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_insert_column_with_attributes
+ (GTK_TREE_VIEW (dialog->treeview), -1,
+ "Value",
+ renderer,
+ "text", COLUMN_VALUE,
+ NULL);
+ g_object_set (renderer, "editable", TRUE, NULL);
+ g_signal_connect (renderer, "edited", G_CALLBACK(on_edited), dialog);
+
+ g_signal_connect (dialog->treeview, "query-tooltip",
+ G_CALLBACK(on_query_tooltip), NULL);
}
-static void
-on_foreground_color_set (GtkColorButton *widget,
- gpointer user_data)
+static gchar *
+_gdk_color_to_string (GdkColor *color)
{
- ConfigContext *context = user_data;
- GdkColor color;
-
- gtk_color_button_get_color (GTK_COLOR_BUTTON(widget), &color);
- set_color (context, "preedit_foreground", &color);
+ g_strdup_printf ("#%02X%02X%02X",
+ (color->red & 0xFF00) >> 8,
+ (color->green & 0xFF00) >> 8,
+ (color->blue & 0xFF00) >> 8);
}
static void
-on_background_color_set (GtkColorButton *widget,
- gpointer user_data)
+save_color (SetupDialog *dialog,
+ GtkToggleButton *togglebutton,
+ GtkColorButton *colorbutton,
+ const gchar *name)
{
- ConfigContext *context = user_data;
- GdkColor color;
-
- gtk_color_button_get_color (GTK_COLOR_BUTTON(widget), &color);
- set_color (context, "preedit_background", &color);
+ if (gtk_toggle_button_get_active (togglebutton)) {
+ GdkColor color;
+ gchar *svalue;
+
+ gtk_color_button_get_color (colorbutton, &color);
+ svalue = _gdk_color_to_string (&color);
+ ibus_m17n_config_set_string (dialog->config,
+ dialog->section,
+ name,
+ svalue);
+ g_free (svalue);
+ } else
+ ibus_m17n_config_set_string (dialog->config,
+ dialog->section,
+ name,
+ "none");
}
static void
-on_underline_changed (GtkComboBox *combo,
- gpointer user_data)
+save_choice (SetupDialog *dialog,
+ GtkComboBox *combo,
+ const gchar *name)
{
- ConfigContext *context = user_data;
GtkTreeModel *model;
GtkTreeIter iter;
gint active;
@@ -260,123 +401,164 @@ on_underline_changed (GtkComboBox *combo,
gtk_combo_box_get_active_iter (combo, &iter);
gtk_tree_model_get (model, &iter, COLUMN_VALUE, &active, -1);
- ibus_m17n_config_set_int (config,
- context->section,
- "preedit_underline",
- active);
+ ibus_m17n_config_set_int (dialog->config, dialog->section, name, active);
}
-static void
-on_orientation_changed (GtkComboBox *combo,
- gpointer user_data)
+static gboolean
+save_m17n_options (SetupDialog *dialog)
{
- ConfigContext *context = user_data;
- GtkTreeModel *model;
+ GtkTreeModel *model = GTK_TREE_MODEL (dialog->store);
GtkTreeIter iter;
- gint active;
+ MPlist *plist, *p, *mvalue = NULL;
+ MSymbol lang, name;
+ gchar *key = NULL, *value = NULL;
+ gboolean retval = TRUE;
- 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);
+ if (!gtk_tree_model_get_iter_first (model, &iter))
+ return;
- ibus_m17n_config_set_int (config,
- context->section,
- "lookup_table_orientation",
- active);
-}
+ lang = msymbol (dialog->lang);
+ name = msymbol (dialog->name);
-static void
-toggle_color (ConfigContext *context,
- GtkToggleButton *togglebutton,
- GtkWidget *colorbutton,
- const gchar *name)
-{
- GdkColor color;
+ do {
+ gtk_tree_model_get (model, &iter,
+ COLUMN_KEY, &key,
+ COLUMN_VALUE, &value,
+ -1);
- if (gtk_toggle_button_get_active (togglebutton)) {
- gtk_widget_set_sensitive (colorbutton, TRUE);
- gtk_color_button_get_color (GTK_COLOR_BUTTON(colorbutton), &color);
- set_color (context, name, &color);
- } else {
- gtk_widget_set_sensitive (colorbutton, FALSE);
- gtk_color_button_get_color (GTK_COLOR_BUTTON(colorbutton), &color);
- set_color (context, name, NULL);
- }
+ plist = minput_get_variable (lang, name, msymbol (key));
+ if (!plist) {
+ retval = FALSE;
+ break;
+ }
+
+ p = mplist_next (mplist_next (mplist_next (mplist_value (plist))));
+ if (!p) {
+ retval = FALSE;
+ break;
+ }
+
+ mvalue = parse_m17n_value (p, value);
+ if (!mvalue) {
+ retval = FALSE;
+ break;
+ }
+
+ if (minput_config_variable (lang, name, msymbol (key), mvalue) != 0) {
+ retval = FALSE;
+ break;
+ }
+
+ if (mvalue)
+ m17n_object_unref (mvalue);
+ g_free (key);
+ g_free (value);
+ mvalue = NULL;
+ key = NULL;
+ value = NULL;
+ } while (gtk_tree_model_iter_next (model, &iter));
+
+ if (retval && minput_save_config () != 1)
+ retval = FALSE;
+
+ if (mvalue)
+ m17n_object_unref (mvalue);
+ g_free (key);
+ g_free (value);
+
+ return retval;
}
static void
-on_foreground_toggled (GtkToggleButton *togglebutton,
- gpointer user_data)
+setup_dialog_save_config (SetupDialog *dialog)
{
- ConfigContext *context = user_data;
-
- toggle_color (context,
- togglebutton,
- context->colorbutton_foreground,
- "preedit_foreground");
+ save_color (dialog,
+ GTK_TOGGLE_BUTTON(dialog->checkbutton_foreground),
+ GTK_COLOR_BUTTON(dialog->colorbutton_foreground),
+ "preedit_foreground");
+ save_color (dialog,
+ GTK_TOGGLE_BUTTON(dialog->checkbutton_background),
+ GTK_COLOR_BUTTON(dialog->colorbutton_background),
+ "preedit_background");
+ save_choice (dialog,
+ GTK_COMBO_BOX(dialog->combobox_underline),
+ "preedit_underline");
+ save_choice (dialog,
+ GTK_COMBO_BOX(dialog->combobox_orientation),
+ "lookup_table_orientation");
+ save_m17n_options (dialog);
}
-static void
-on_background_toggled (GtkToggleButton *togglebutton,
- gpointer user_data)
+static SetupDialog *
+setup_dialog_new (IBusConfig *config,
+ const gchar *lang,
+ const gchar *name)
{
- ConfigContext *context = user_data;
+ GtkBuilder *builder;
+ SetupDialog *dialog;
+ GObject *object;
+ GError *error;
+
+ dialog = g_slice_new0 (SetupDialog);
+ dialog->config = g_object_ref_sink (config);
+ dialog->lang = g_strdup (lang);
+ dialog->name = g_strdup (name);
+ dialog->section = g_strdup_printf ("engine/M17N/%s/%s", lang, name);
+
+ builder = gtk_builder_new ();
+ gtk_builder_set_translation_domain (builder, "ibus-m17n");
+
+ error = NULL;
+ gtk_builder_add_from_file (builder,
+ SETUPDIR "/ibus-m17n-preferences.ui",
+ &error);
+ g_assert_no_error (error);
+
+ object = gtk_builder_get_object (builder, "dialog");
+ dialog->dialog = GTK_WIDGET(object);
+ object = gtk_builder_get_object (builder, "checkbutton_foreground");
+ dialog->checkbutton_foreground = GTK_WIDGET(object);
+ object = gtk_builder_get_object (builder, "colorbutton_foreground");
+ dialog->colorbutton_foreground = GTK_WIDGET(object);
+ object = gtk_builder_get_object (builder, "checkbutton_background");
+ dialog->checkbutton_background = GTK_WIDGET(object);
+ object = gtk_builder_get_object (builder, "colorbutton_background");
+ dialog->colorbutton_background = GTK_WIDGET(object);
+ object = gtk_builder_get_object (builder, "combobox_underline");
+ dialog->combobox_underline = GTK_WIDGET(object);
+ object = gtk_builder_get_object (builder, "combobox_orientation");
+ dialog->combobox_orientation = GTK_WIDGET(object);
+ object = gtk_builder_get_object (builder, "treeview_mim_config");
+ dialog->treeview = GTK_WIDGET(object);
- toggle_color (context,
- togglebutton,
- context->colorbutton_background,
- "preedit_background");
+ return dialog;
}
-static gint
-get_combo_box_index_by_value (GtkComboBox *combobox, gint value)
+static void
+setup_dialog_free (SetupDialog *dialog)
{
- GtkTreeModel *model;
- GtkTreeIter iter;
- gint index;
+ gtk_widget_destroy (dialog->dialog);
- index = 0;
- model = gtk_combo_box_get_model (combobox);
- if (!gtk_tree_model_get_iter_first (model, &iter))
- return -1;
+ g_free (dialog->lang);
+ g_free (dialog->name);
- do {
- gint _value;
- gtk_tree_model_get (model, &iter, COLUMN_VALUE, &_value, -1);
- if (_value == value)
- return index;
- index++;
- } while (gtk_tree_model_iter_next (model, &iter));
- return -1;
+ g_free (dialog->section);
+ g_object_unref (dialog->store);
+ g_slice_free (SetupDialog, dialog);
}
static void
start (const gchar *engine_name)
{
IBusBus *bus;
- gchar **strv, *lang, *name;
- GtkBuilder *builder;
- GtkWidget *dialog;
- GtkWidget *combobox_underline, *combobox_orientation;
- GtkWidget *checkbutton_foreground, *checkbutton_background;
- GtkWidget *treeview;
- GtkListStore *store;
+ IBusConfig *config;
+ gchar **strv, *lang, *name, *section;
+ SetupDialog *dialog;
GObject *object;
GError *error = NULL;
- GtkCellRenderer *renderer;
- ConfigContext context;
- gchar *color;
- gboolean is_foreground_set, is_background_set;
- GdkColor foreground, background;
- gint underline;
- gint orientation;
- gint index;
ibus_init ();
-
- bus = ibus_bus_new ();
- //g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL);
- ibus_m17n_init (bus);
+ ibus_m17n_init_common ();
strv = g_strsplit (engine_name, ":", 3);
@@ -386,150 +568,25 @@ start (const gchar *engine_name)
lang = strv[1];
name = strv[2];
- config = ibus_bus_get_config (bus);
- context.section = g_strdup_printf ("engine/M17N/%s/%s", lang, name);
-
- builder = gtk_builder_new ();
- gtk_builder_set_translation_domain (builder, "ibus-m17n");
- gtk_builder_add_from_file (builder,
- SETUPDIR "/ibus-m17n-preferences.ui",
- &error);
- object = gtk_builder_get_object (builder, "dialog");
- dialog = GTK_WIDGET(object);
- object = gtk_builder_get_object (builder, "checkbutton_foreground");
- checkbutton_foreground = GTK_WIDGET(object);
- object = gtk_builder_get_object (builder, "colorbutton_foreground");
- context.colorbutton_foreground = GTK_WIDGET(object);
- object = gtk_builder_get_object (builder, "checkbutton_background");
- checkbutton_background = GTK_WIDGET(object);
- object = gtk_builder_get_object (builder, "colorbutton_background");
- context.colorbutton_background = GTK_WIDGET(object);
- object = gtk_builder_get_object (builder, "combobox_underline");
- combobox_underline = GTK_WIDGET(object);
- object = gtk_builder_get_object (builder, "combobox_orientation");
- combobox_orientation = GTK_WIDGET(object);
- object = gtk_builder_get_object (builder, "treeviewMimConfig");
- treeview = GTK_WIDGET(object);
-
- /* General -> Pre-edit Appearance */
- /* foreground color of pre-edit buffer */
- is_foreground_set = FALSE;
- color_to_gdk (PREEDIT_FOREGROUND, &foreground);
- if (ibus_m17n_config_get_string (config,
- context.section,
- "preedit_foreground",
- &color)) {
- if (g_strcmp0 (color, "none") != 0 &&
- gdk_color_parse (color, &foreground))
- is_foreground_set = TRUE;
- g_free (color);
- }
+ bus = ibus_bus_new ();
+ //g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(checkbutton_foreground),
- is_foreground_set);
- g_signal_connect (checkbutton_foreground, "toggled",
- G_CALLBACK(on_foreground_toggled),
- &context);
- gtk_widget_set_sensitive (context.colorbutton_foreground,
- is_foreground_set);
- gtk_color_button_set_color
- (GTK_COLOR_BUTTON(context.colorbutton_foreground),
- &foreground);
- g_signal_connect (context.colorbutton_foreground, "color-set",
- G_CALLBACK(on_foreground_color_set), &context);
+ config = ibus_bus_get_config (bus);
+ dialog = setup_dialog_new (config, lang, name);
-
- /* background color of pre-edit buffer */
- is_background_set = FALSE;
- color_to_gdk (PREEDIT_BACKGROUND, &background);
- if (ibus_m17n_config_get_string (config,
- context.section,
- "preedit_background",
- &color)) {
- if (g_strcmp0 (color, "none") != 0 &&
- gdk_color_parse (color, &background))
- is_background_set = TRUE;
- g_debug ("preedit_background %d", is_background_set);
- g_free (color);
- }
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(checkbutton_background),
- is_background_set);
- g_signal_connect (checkbutton_background, "toggled",
- G_CALLBACK(on_background_toggled),
- &context);
- gtk_widget_set_sensitive (context.colorbutton_background,
- is_background_set);
- gtk_color_button_set_color
- (GTK_COLOR_BUTTON(context.colorbutton_background),
- &background);
- g_signal_connect (context.colorbutton_background, "color-set",
- G_CALLBACK(on_background_color_set), &context);
+ g_strfreev (strv);
- /* underline of pre-edit buffer */
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(combobox_underline),
- renderer, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT(combobox_underline),
- renderer, "text", 0, NULL);
- if (!ibus_m17n_config_get_int (config,
- context.section,
- "preedit_underline",
- &underline))
- underline = IBUS_ATTR_UNDERLINE_NONE;
+ setup_dialog_load_config (dialog);
- index = get_combo_box_index_by_value (GTK_COMBO_BOX(combobox_underline),
- underline);
- gtk_combo_box_set_active (GTK_COMBO_BOX(combobox_underline), index);
- g_signal_connect (combobox_underline, "changed",
- G_CALLBACK(on_underline_changed), &context);
+ gtk_widget_show_all (dialog->dialog);
+ gtk_dialog_run (GTK_DIALOG(dialog->dialog));
- /* General -> Other */
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(combobox_orientation),
- renderer, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT(combobox_orientation),
- renderer, "text", 0, NULL);
- if (!ibus_m17n_config_get_int (config,
- context.section,
- "lookup_table_orientation",
- &orientation))
- orientation = IBUS_ORIENTATION_SYSTEM;
-
- index = get_combo_box_index_by_value (GTK_COMBO_BOX(combobox_orientation),
- orientation);
- gtk_combo_box_set_active (GTK_COMBO_BOX(combobox_orientation), index);
- g_signal_connect (combobox_orientation, "changed",
- G_CALLBACK(on_orientation_changed), &context);
+ setup_dialog_save_config (dialog);
+ setup_dialog_free (dialog);
- /* Advanced -> m17n-lib configuration */
- store = gtk_list_store_new (NUM_COLS,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING);
- insert_items (store, msymbol (lang), msymbol (name));
-
- gtk_tree_view_set_model (GTK_TREE_VIEW(treeview), GTK_TREE_MODEL (store));
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), -1,
- "Key",
- gtk_cell_renderer_text_new (),
- "text", COLUMN_KEY, NULL);
- g_object_set (treeview, "has-tooltip", TRUE, NULL);
- g_signal_connect (treeview, "query-tooltip", G_CALLBACK(on_query_tooltip),
- NULL);
-
- context.language = msymbol (lang);
- context.name = msymbol (name);
- context.store = store;
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), -1,
- "Value",
- renderer,
- "text", COLUMN_VALUE, NULL);
- g_object_set (renderer, "editable", TRUE, NULL);
- g_signal_connect (renderer, "edited", G_CALLBACK(on_edited), &context);
+ g_object_unref (bus);
- gtk_widget_show_all (dialog);
- gtk_dialog_run (GTK_DIALOG(dialog));
+ M17N_FINI ();
}
int
--
1.7.6.1

View File

@ -1,18 +1,20 @@
From 1bde900422ed9ed7f06962404d5e689b297ad0b2 Mon Sep 17 00:00:00 2001 From 5ec645b395e81cd804f50e5bcd6c21e92d257fbe Mon Sep 17 00:00:00 2001
From: Daiki Ueno <ueno@unixuser.org> From: Daiki Ueno <ueno@unixuser.org>
Date: Wed, 31 Aug 2011 18:28:48 +0900 Date: Wed, 31 Aug 2011 18:28:48 +0900
Subject: [PATCH 5/5] Support virtual keyboard. Subject: [PATCH 5/6] Support virtual keyboard.
--- ---
configure.ac | 17 ++++ configure.ac | 17 +++
src/Makefile.am | 7 ++ src/Makefile.am | 7 ++
src/default.xml.in.in | 111 +++++++++++++++++++++++ src/default.xml.in.in | 111 ++++++++++++++++++++
src/engine.c | 40 +++++++++ src/engine.c | 66 ++++++++++++
src/m17nutil.c | 10 ++- src/ibus-m17n-preferences.ui | 16 +++
src/m17nutil.h | 3 + src/m17nutil.c | 59 +++++++++++-
src/virtkbd.c | 233 +++++++++++++++++++++++++++++++++++++++++++++++++ src/m17nutil.h | 11 ++
src/virtkbd.h | 31 +++++++ src/setup.c | 26 +++++
8 files changed, 451 insertions(+), 1 deletions(-) src/virtkbd.c | 233 ++++++++++++++++++++++++++++++++++++++++++
src/virtkbd.h | 31 ++++++
10 files changed, 576 insertions(+), 1 deletions(-)
create mode 100644 src/virtkbd.c create mode 100644 src/virtkbd.c
create mode 100644 src/virtkbd.h create mode 100644 src/virtkbd.h
@ -195,7 +197,7 @@ index 8192878..47053ae 100644
+ </engine> + </engine>
</engines> </engines>
diff --git a/src/engine.c b/src/engine.c diff --git a/src/engine.c b/src/engine.c
index dcff0c7..c8378a3 100644 index dcff0c7..1e6bd1b 100644
--- a/src/engine.c --- a/src/engine.c
+++ b/src/engine.c +++ b/src/engine.c
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
@ -220,24 +222,39 @@ index dcff0c7..c8378a3 100644
IBusPropList *prop_list; IBusPropList *prop_list;
}; };
@@ -34,6 +38,7 @@ struct _IBusM17NEngineClass { @@ -34,6 +38,8 @@ struct _IBusM17NEngineClass {
guint preedit_background; guint preedit_background;
gint preedit_underline; gint preedit_underline;
gint lookup_table_orientation; gint lookup_table_orientation;
+ gchar *virtual_keyboard; + gchar *virtual_keyboard;
+ gboolean virtual_keyboard_enabled;
MInputMethod *im; MInputMethod *im;
}; };
@@ -290,6 +295,8 @@ ibus_m17n_engine_class_init (IBusM17NEngineClass *klass) @@ -256,6 +262,7 @@ ibus_m17n_engine_class_init (IBusM17NEngineClass *klass)
klass->preedit_background = INVALID_COLOR;
klass->preedit_underline = IBUS_ATTR_UNDERLINE_NONE;
klass->lookup_table_orientation = IBUS_ORIENTATION_SYSTEM;
+ klass->virtual_keyboard_enabled = FALSE;
engine_config = ibus_m17n_get_engine_config (engine_name);
g_free (engine_name);
@@ -290,6 +297,14 @@ ibus_m17n_engine_class_init (IBusM17NEngineClass *klass)
&klass->lookup_table_orientation)) &klass->lookup_table_orientation))
klass->lookup_table_orientation = IBUS_ORIENTATION_SYSTEM; klass->lookup_table_orientation = IBUS_ORIENTATION_SYSTEM;
+ if (!ibus_m17n_config_get_boolean (config,
+ klass->config_section,
+ "virtual_keyboard_enabled",
+ &klass->virtual_keyboard_enabled))
+ klass->virtual_keyboard_enabled = FALSE;
+
+ klass->virtual_keyboard = engine_config->virtual_keyboard; + klass->virtual_keyboard = engine_config->virtual_keyboard;
+ +
ibus_m17n_engine_config_free (engine_config); ibus_m17n_engine_config_free (engine_config);
g_signal_connect (config, "value-changed", g_signal_connect (config, "value-changed",
@@ -346,6 +353,7 @@ ibus_m17n_engine_init (IBusM17NEngine *m17n) @@ -346,6 +361,7 @@ ibus_m17n_engine_init (IBusM17NEngine *m17n)
{ {
IBusText* label; IBusText* label;
IBusText* tooltip; IBusText* tooltip;
@ -245,11 +262,10 @@ index dcff0c7..c8378a3 100644
m17n->prop_list = ibus_prop_list_new (); m17n->prop_list = ibus_prop_list_new ();
g_object_ref_sink (m17n->prop_list); g_object_ref_sink (m17n->prop_list);
@@ -378,6 +386,22 @@ ibus_m17n_engine_init (IBusM17NEngine *m17n) @@ -378,6 +394,24 @@ ibus_m17n_engine_init (IBusM17NEngine *m17n)
ibus_prop_list_append (m17n->prop_list, m17n->setup_prop); ibus_prop_list_append (m17n->prop_list, m17n->setup_prop);
#endif /* HAVE_SETUP */ #endif /* HAVE_SETUP */
+ if (klass->virtual_keyboard != NULL) {
+ label = ibus_text_new_from_string ("On-screen Keyboard"); + label = ibus_text_new_from_string ("On-screen Keyboard");
+ tooltip = ibus_text_new_from_string ("Show on-screen keyboard"); + tooltip = ibus_text_new_from_string ("Show on-screen keyboard");
+ m17n->virtkbd_prop = ibus_property_new ("virtual-keyboard", + m17n->virtkbd_prop = ibus_property_new ("virtual-keyboard",
@ -258,26 +274,32 @@ index dcff0c7..c8378a3 100644
+ "input-keyboard", + "input-keyboard",
+ tooltip, + tooltip,
+ TRUE, + TRUE,
+ TRUE, + FALSE,
+ PROP_STATE_UNCHECKED, + PROP_STATE_UNCHECKED,
+ NULL); + NULL);
+ g_object_ref_sink (m17n->virtkbd_prop); + g_object_ref_sink (m17n->virtkbd_prop);
+ ibus_prop_list_append (m17n->prop_list, m17n->virtkbd_prop); + ibus_prop_list_append (m17n->prop_list, m17n->virtkbd_prop);
+ } +
+ if (klass->virtual_keyboard_enabled &&
+ klass->virtual_keyboard != NULL)
+ ibus_property_set_visible (m17n->virtkbd_prop, TRUE);
+ +
m17n->table = ibus_lookup_table_new (9, 0, TRUE, TRUE); m17n->table = ibus_lookup_table_new (9, 0, TRUE, TRUE);
g_object_ref_sink (m17n->table); g_object_ref_sink (m17n->table);
m17n->context = NULL; m17n->context = NULL;
@@ -439,6 +463,8 @@ ibus_m17n_engine_constructor (GType type, @@ -463,6 +497,11 @@ ibus_m17n_engine_destroy (IBusM17NEngine *m17n)
} }
#endif /* HAVE_SETUP */
m17n->context = minput_create_ic (klass->im, m17n); + if (m17n->virtkbd_prop) {
+ m17n->virtkbd = ibus_m17n_virtual_keyboard_new ((IBusEngine *)m17n, + g_object_unref (m17n->virtkbd_prop);
+ klass->virtual_keyboard); + m17n->virtkbd_prop = NULL;
+ }
return (GObject *) m17n; +
} if (m17n->table) {
@@ -473,6 +499,11 @@ ibus_m17n_engine_destroy (IBusM17NEngine *m17n) g_object_unref (m17n->table);
m17n->table = NULL;
@@ -473,6 +512,11 @@ ibus_m17n_engine_destroy (IBusM17NEngine *m17n)
m17n->context = NULL; m17n->context = NULL;
} }
@ -289,38 +311,85 @@ index dcff0c7..c8378a3 100644
IBUS_OBJECT_CLASS (parent_class)->destroy ((IBusObject *)m17n); IBUS_OBJECT_CLASS (parent_class)->destroy ((IBusObject *)m17n);
} }
@@ -705,6 +736,8 @@ ibus_m17n_engine_enable (IBusEngine *engine) @@ -705,6 +749,9 @@ ibus_m17n_engine_enable (IBusEngine *engine)
input context that we will use surrounding-text. */ input context that we will use surrounding-text. */
ibus_engine_get_surrounding_text (engine, NULL, NULL, NULL); ibus_engine_get_surrounding_text (engine, NULL, NULL, NULL);
#endif /* HAVE_IBUS_ENGINE_GET_SURROUNDING_TEXT */ #endif /* HAVE_IBUS_ENGINE_GET_SURROUNDING_TEXT */
+ +
+ if (m17n->virtkbd)
+ ibus_m17n_virtual_keyboard_enable (m17n->virtkbd); + ibus_m17n_virtual_keyboard_enable (m17n->virtkbd);
} }
static void static void
@@ -714,6 +747,8 @@ ibus_m17n_engine_disable (IBusEngine *engine) @@ -714,6 +761,9 @@ ibus_m17n_engine_disable (IBusEngine *engine)
ibus_m17n_engine_focus_out (engine); ibus_m17n_engine_focus_out (engine);
parent_class->disable (engine); parent_class->disable (engine);
+ +
+ if (m17n->virtkbd)
+ ibus_m17n_virtual_keyboard_disable (m17n->virtkbd); + ibus_m17n_virtual_keyboard_disable (m17n->virtkbd);
} }
static void static void
@@ -776,6 +811,11 @@ ibus_m17n_engine_property_activate (IBusEngine *engine, @@ -776,6 +826,22 @@ ibus_m17n_engine_property_activate (IBusEngine *engine,
} }
#endif /* HAVE_SETUP */ #endif /* HAVE_SETUP */
+#ifdef HAVE_EEKBOARD +#ifdef HAVE_EEKBOARD
+ if (g_strcmp0 (prop_name, "virtual-keyboard") == 0) + if (g_strcmp0 (prop_name, "virtual-keyboard") == 0) {
+ /* virtual keyboard is not initialized until a user activates
+ the "virtual-keyboard" prop for the first time */
+ if (m17n->virtkbd == NULL) {
+ IBusM17NEngineClass *klass =
+ (IBusM17NEngineClass *) G_OBJECT_GET_CLASS (m17n);
+
+ m17n->virtkbd =
+ ibus_m17n_virtual_keyboard_new ((IBusEngine *)m17n,
+ klass->virtual_keyboard);
+ }
+ ibus_m17n_virtual_keyboard_toggle_display (m17n->virtkbd); + ibus_m17n_virtual_keyboard_toggle_display (m17n->virtkbd);
+ }
+#endif /* HAVE_EEKBOARD */ +#endif /* HAVE_EEKBOARD */
+ +
parent_class->property_activate (engine, prop_name, prop_state); parent_class->property_activate (engine, prop_name, prop_state);
} }
diff --git a/src/ibus-m17n-preferences.ui b/src/ibus-m17n-preferences.ui
index a46ab49..bca034d 100644
--- a/src/ibus-m17n-preferences.ui
+++ b/src/ibus-m17n-preferences.ui
@@ -192,6 +192,7 @@
<child>
<object class="GtkTable" id="table2">
<property name="visible">True</property>
+ <property name="n_rows">2</property>
<property name="n_columns">2</property>
<child>
<object class="GtkLabel" id="label9">
@@ -210,6 +211,21 @@
<property name="right_attach">2</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton_virtkbd">
+ <property name="label" translatable="yes">Enable Virtual Keyboard</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
</object>
</child>
</object>
diff --git a/src/m17nutil.c b/src/m17nutil.c diff --git a/src/m17nutil.c b/src/m17nutil.c
index 94a6891..a4e4b09 100644 index 94a6891..2143e54 100644
--- a/src/m17nutil.c --- a/src/m17nutil.c
+++ b/src/m17nutil.c +++ b/src/m17nutil.c
@@ -18,7 +18,8 @@ typedef enum { @@ -18,7 +18,8 @@ typedef enum {
@ -354,8 +423,61 @@ index 94a6891..a4e4b09 100644
g_warning ("<engine> element contains invalid element <%s>", g_warning ("<engine> element contains invalid element <%s>",
sub_node->name); sub_node->name);
} }
@@ -494,3 +502,52 @@ ibus_m17n_config_get_int (IBusConfig *config,
return FALSE;
#endif /* !IBUS_CHECK_VERSION(1,3,99) */
}
+
+void
+ibus_m17n_config_set_boolean (IBusConfig *config,
+ const gchar *section,
+ const gchar *name,
+ gboolean value)
+{
+#if IBUS_CHECK_VERSION(1,3,99)
+ ibus_config_set_value (config, section, name, g_variant_new_boolean (value));
+#else
+ GValue v = { 0 };
+
+ g_value_init (&v, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&v, value);
+ ibus_config_set_value (config, section, name, &v);
+#endif /* !IBUS_CHECK_VERSION(1,3,99) */
+}
+
+gboolean
+ibus_m17n_config_get_boolean (IBusConfig *config,
+ const gchar *section,
+ const gchar *name,
+ gboolean *result)
+{
+#if IBUS_CHECK_VERSION(1,3,99)
+ GVariant *value = NULL;
+
+ g_return_val_if_fail (result != NULL, FALSE);
+
+ value = ibus_config_get_value (config, section, name);
+ if (value) {
+ *result = g_variant_get_boolean (value);
+ g_variant_unref (value);
+ return TRUE;
+ }
+ return FALSE;
+#else
+ GValue value = { 0 };
+
+ g_return_val_if_fail (result != NULL, FALSE);
+
+ if (ibus_config_get_value (config, section, name, &value)) {
+ *result = g_value_get_boolean (&value);
+ g_value_unset (&value);
+ return TRUE;
+ }
+ return FALSE;
+#endif /* !IBUS_CHECK_VERSION(1,3,99) */
+}
diff --git a/src/m17nutil.h b/src/m17nutil.h diff --git a/src/m17nutil.h b/src/m17nutil.h
index 21b1bb9..f138c8b 100644 index 21b1bb9..9c3fca8 100644
--- a/src/m17nutil.h --- a/src/m17nutil.h
+++ b/src/m17nutil.h +++ b/src/m17nutil.h
@@ -25,6 +25,9 @@ struct _IBusM17NEngineConfig { @@ -25,6 +25,9 @@ struct _IBusM17NEngineConfig {
@ -368,6 +490,84 @@ index 21b1bb9..f138c8b 100644
}; };
typedef struct _IBusM17NEngineConfig IBusM17NEngineConfig; typedef struct _IBusM17NEngineConfig IBusM17NEngineConfig;
@@ -56,4 +59,12 @@ gboolean ibus_m17n_config_get_int (IBusConfig *config,
const gchar *section,
const gchar *name,
gint *result);
+void ibus_m17n_config_set_boolean (IBusConfig *config,
+ const gchar *section,
+ const gchar *name,
+ gboolean value);
+gboolean ibus_m17n_config_get_boolean (IBusConfig *config,
+ const gchar *section,
+ const gchar *name,
+ gboolean *result);
#endif
diff --git a/src/setup.c b/src/setup.c
index 30386df..1c534d6 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -25,6 +25,7 @@ struct _SetupDialog {
GtkWidget *colorbutton_foreground;
GtkWidget *checkbutton_background;
GtkWidget *colorbutton_background;
+ GtkWidget *checkbutton_virtkbd;
GtkWidget *treeview;
GtkListStore *store;
@@ -322,6 +323,15 @@ setup_dialog_load_config (SetupDialog *dialog)
gtk_combo_box_set_active (GTK_COMBO_BOX(dialog->combobox_orientation),
index);
+ if (!ibus_m17n_config_get_boolean (dialog->config,
+ dialog->section,
+ "virtual_keyboard_enabled",
+ &bvalue))
+ bvalue = FALSE;
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(dialog->checkbutton_virtkbd),
+ bvalue);
+
/* Advanced -> m17n-lib configuration */
dialog->store = gtk_list_store_new (NUM_COLS,
G_TYPE_STRING,
@@ -404,6 +414,17 @@ save_choice (SetupDialog *dialog,
ibus_m17n_config_set_int (dialog->config, dialog->section, name, active);
}
+static void
+save_toggle (SetupDialog *dialog,
+ GtkToggleButton *togglebutton,
+ const gchar *name)
+{
+ ibus_m17n_config_set_boolean (dialog->config,
+ dialog->section,
+ name,
+ gtk_toggle_button_get_active (togglebutton));
+}
+
static gboolean
save_m17n_options (SetupDialog *dialog)
{
@@ -486,6 +507,9 @@ setup_dialog_save_config (SetupDialog *dialog)
save_choice (dialog,
GTK_COMBO_BOX(dialog->combobox_orientation),
"lookup_table_orientation");
+ save_toggle (dialog,
+ GTK_TOGGLE_BUTTON(dialog->checkbutton_virtkbd),
+ "virtual_keyboard_enabled");
save_m17n_options (dialog);
}
@@ -528,6 +552,8 @@ setup_dialog_new (IBusConfig *config,
dialog->combobox_underline = GTK_WIDGET(object);
object = gtk_builder_get_object (builder, "combobox_orientation");
dialog->combobox_orientation = GTK_WIDGET(object);
+ object = gtk_builder_get_object (builder, "checkbutton_virtkbd");
+ dialog->checkbutton_virtkbd = GTK_WIDGET(object);
object = gtk_builder_get_object (builder, "treeview_mim_config");
dialog->treeview = GTK_WIDGET(object);
diff --git a/src/virtkbd.c b/src/virtkbd.c diff --git a/src/virtkbd.c b/src/virtkbd.c
new file mode 100644 new file mode 100644
index 0000000..9baf971 index 0000000..9baf971

View File

@ -1,7 +1,7 @@
From 0cc2abaab50e6668e525da093ef12ed0277d5c21 Mon Sep 17 00:00:00 2001 From 0cc2abaab50e6668e525da093ef12ed0277d5c21 Mon Sep 17 00:00:00 2001
From: Daiki Ueno <ueno@unixuser.org> From: Daiki Ueno <ueno@unixuser.org>
Date: Mon, 8 Aug 2011 09:59:28 +0900 Date: Mon, 8 Aug 2011 09:59:28 +0900
Subject: [PATCH 3/5] Set XKB layout option via default.xml. Subject: [PATCH 3/6] Set XKB layout option via default.xml.
--- ---
src/default.xml.in.in | 9 +++++++++ src/default.xml.in.in | 9 +++++++++

View File

@ -1,7 +1,7 @@
From 4cad5fe6e36be9cbfe0d50f683b489e9202c7d53 Mon Sep 17 00:00:00 2001 From 4cad5fe6e36be9cbfe0d50f683b489e9202c7d53 Mon Sep 17 00:00:00 2001
From: Daiki Ueno <ueno@unixuser.org> From: Daiki Ueno <ueno@unixuser.org>
Date: Wed, 31 Aug 2011 11:44:46 +0900 Date: Wed, 31 Aug 2011 11:44:46 +0900
Subject: [PATCH 4/5] Supply hotkeys and symbol in engine desc. Subject: [PATCH 4/6] Supply hotkeys and symbol in engine desc.
--- ---
configure.ac | 3 + configure.ac | 3 +
@ -29,8 +29,8 @@ index 927d382..23102c4 100644
AC_CONFIG_FILES([ po/Makefile.in AC_CONFIG_FILES([ po/Makefile.in
diff --git a/m4/.gitignore b/m4/.gitignore diff --git a/m4/.gitignore b/m4/.gitignore
index 0f4126c..e28d185 100644 index 0f4126c..e28d185 100644
--- a/m4/.gitignore #--- a/m4/.gitignore
+++ b/m4/.gitignore #+++ b/m4/.gitignore
@@ -1 +1,3 @@ @@ -1 +1,3 @@
*.m4 *.m4
+!ibus.m4 +!ibus.m4

View File

@ -17,7 +17,7 @@
Name: ibus-m17n Name: ibus-m17n
Version: 1.3.3 Version: 1.3.3
Release: 1%{?dist} Release: 2%{?dist}
Summary: The M17N engine for IBus platform Summary: The M17N engine for IBus platform
License: GPLv2+ License: GPLv2+
Group: System Environment/Libraries Group: System Environment/Libraries
@ -26,9 +26,11 @@ Source0: http://ibus.googlecode.com/files/%{name}-%{version}.tar.gz
#Patch0: ibus-m17n-HEAD.patch #Patch0: ibus-m17n-HEAD.patch
Patch1: ibus-m17n-default-xml-override.patch Patch1: ibus-m17n-default-xml-override.patch
Patch2: ibus-m17n-xkb-options.patch Patch2: ibus-m17n-setup-refactor.patch
Patch3: ibus-m17n-xx-icon-symbol.patch Patch3: ibus-m17n-xkb-options.patch
Patch4: ibus-m17n-virtkbd.patch Patch4: ibus-m17n-xx-icon-symbol.patch
Patch5: ibus-m17n-virtkbd.patch
Patch6: ibus-m17n-iok.patch
# The following BR is for autogen and not necessary when packging # The following BR is for autogen and not necessary when packging
# released tarballs. # released tarballs.
@ -58,11 +60,13 @@ the input table maps from m17n-db.
%setup -q %setup -q
#patch0 -p1 -b .HEAD #patch0 -p1 -b .HEAD
%patch1 -p1 -b .default-xml-override %patch1 -p1 -b .default-xml-override
%patch2 -p1 -b .xkb-options %patch2 -p1 -b .setup-refactor
%patch3 -p1 -b .xkb-options
# do not apply patch to m4/.gitignore # do not apply patch to m4/.gitignore
sed -i 's!^[-+][-+][-+] .*/m4/\.gitignore!#\0!' %PATCH3 sed -i 's!^[-+][-+][-+] .*/m4/\.gitignore!#\0!' %PATCH4
%patch3 -p1 -b .xx-icon-symbol %patch4 -p1 -b .xx-icon-symbol
%patch4 -p1 -b .virtkbd %patch5 -p1 -b .virtkbd
%patch6 -p1 -b .iok
NOCONFIGURE=1 ./autogen.sh NOCONFIGURE=1 ./autogen.sh
%build %build
@ -84,6 +88,9 @@ make DESTDIR=${RPM_BUILD_ROOT} install
%{_datadir}/ibus/component/* %{_datadir}/ibus/component/*
%changelog %changelog
* Fri Sep 2 2011 Daiki Ueno <dueno@redhat.com> - 1.3.3-2
- Revive iok patch.
* Thu Sep 1 2011 Daiki Ueno <dueno@redhat.com> - 1.3.3-1 * Thu Sep 1 2011 Daiki Ueno <dueno@redhat.com> - 1.3.3-1
- New upstream release. - New upstream release.
- Add ibus-m17n-default-xml-override.patch. - Add ibus-m17n-default-xml-override.patch.