From: handa Date: Tue, 19 Jun 2007 12:18:53 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: REL-0-9-0~3 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a6878745927661e56d45532405002b0a0d24872;p=m17n%2Fm17n-im-config.git *** empty log message *** --- diff --git a/src/m17n-im-config.h b/src/m17n-im-config.h index b93a0df..32ab6b4 100644 --- a/src/m17n-im-config.h +++ b/src/m17n-im-config.h @@ -31,6 +31,7 @@ G_BEGIN_DECLS extern GtkWidget *mim_config_new (GCallback func, gpointer data); extern gboolean mim_config_modified (GtkWidget *config); extern gboolean mim_config_revert (GtkWidget *config); +extern gboolean mim_config_default (GtkWidget *config); extern gboolean mim_config_save (GtkWidget *config); extern GtkTreeView *mim_config_get_tree_view (GtkWidget *config); diff --git a/src/main.c b/src/main.c index 01b1aad..3c1f622 100644 --- a/src/main.c +++ b/src/main.c @@ -34,6 +34,8 @@ struct CallbackArgument { /* IM configuration widget created by mim_config_new (). */ GtkWidget *config; + /* Button widget "default" */ + GtkWidget *default_; /* Button widget "revert" */ GtkWidget *revert; /* Button widget "save" */ @@ -66,6 +68,16 @@ status_changed_cb (GtkWidget *config, gpointer data) } } +/* Called when "default" button is clicked. */ +static void +default_clicked_cb (GtkButton *button, gpointer data) +{ + struct CallbackArgument *arg = data; + + mim_config_default (arg->config); + status_changed_cb (arg->config, data); +} + /* Called when "revert" button is clicked. */ static void revert_clicked_cb (GtkButton *button, gpointer data) @@ -135,7 +147,7 @@ int main (int argc, char **argv) { GtkWidget *window, *vbox, *hbox; - GtkWidget *revert, *save, *ok, *quit; + GtkWidget *default_, *revert, *save, *ok, *quit; struct CallbackArgument arg; #if ENABLE_NLS @@ -160,9 +172,9 @@ main (int argc, char **argv) || || |+-------------------------------------+| |+-hbox--------------------------------+| - || +------+ +----+ +----+ +--+|| - || |revert| |save| |quit| |ok||| - || +------+ +----+ +----+ +--+|| + ||+-------+ +------+ +----+ +----+ +--+|| + |||default| |revert| |save| |quit| |ok||| + ||+-------+ +------+ +----+ +----+ +--+|| |+-------------------------------------+| +---------------------------------------+ */ @@ -171,6 +183,7 @@ main (int argc, char **argv) gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); gtk_container_add (GTK_CONTAINER (window), vbox); + default_ = gtk_button_new_from_stock (_("_Default")); revert = gtk_button_new_from_stock (GTK_STOCK_REVERT_TO_SAVED); gtk_widget_set_sensitive (revert, FALSE); save = gtk_button_new_from_stock (GTK_STOCK_SAVE); @@ -183,6 +196,8 @@ main (int argc, char **argv) arg.config = mim_config_new (G_CALLBACK (status_changed_cb), &arg); gtk_box_pack_start (GTK_BOX (vbox), arg.config, TRUE, TRUE, 0); + g_signal_connect (G_OBJECT (default_), "clicked", + G_CALLBACK (default_clicked_cb), &arg); g_signal_connect (G_OBJECT (revert), "clicked", G_CALLBACK (revert_clicked_cb), &arg); g_signal_connect (G_OBJECT (save), "clicked", @@ -195,6 +210,7 @@ main (int argc, char **argv) hbox = gtk_hbutton_box_new (); gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END); gtk_box_set_spacing (GTK_BOX (hbox), 5); + gtk_container_add (GTK_CONTAINER (hbox), default_); gtk_container_add (GTK_CONTAINER (hbox), revert); gtk_container_add (GTK_CONTAINER (hbox), save); gtk_container_add (GTK_CONTAINER (hbox), quit); diff --git a/src/mim-config.c b/src/mim-config.c index d172924..ae19749 100644 --- a/src/mim-config.c +++ b/src/mim-config.c @@ -433,7 +433,7 @@ make_store_for_input_methods () static gboolean revert_to_saved (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, - gpointer data) + gpointer data) { enum MimStatus status; MSymbol lang, name; @@ -454,7 +454,7 @@ revert_to_saved (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, static gboolean set_as_saved (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, - gpointer data) + gpointer data) { enum MimStatus status; MSymbol lang, name; @@ -471,6 +471,28 @@ set_as_saved (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, return FALSE; } +static gboolean +reset_to_default (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, + gpointer data) +{ + enum MimStatus status; + MSymbol lang, name; + MimConfigStatus *config_status = data; + MPlist *empty = mplist (); + + gtk_tree_model_get (model, iter, COL_LANG, &lang, COL_NAME, &name, -1); + if (lang == Mnil) + return FALSE; + gtk_tree_model_get (model, iter, COL_STATUS, &status, -1); + if (status == MIM_STATUS_DEFAULT) + return FALSE; + minput_config_variable (lang, name, Mnil, empty); + minput_config_command (lang, name, Mnil, empty); + status = get_mim_status (lang, name); + update_child_row (model, iter, status, config_status, NULL); + return FALSE; +} + static int initialized = 0; static void @@ -1707,6 +1729,20 @@ mim_config_modified (GtkWidget *config) } gboolean +mim_config_default (GtkWidget *config) +{ + GtkTreeView *tree; + GtkTreeModel *model; + MimConfigStatus *config_status; + + tree = g_object_get_data (G_OBJECT (config), CONFIG_TREE_VIEW); + model = gtk_tree_view_get_model (tree); + config_status = g_object_get_data (G_OBJECT (model), CONFIG_STATUS_DATA); + gtk_tree_model_foreach (model, reset_to_default, config_status); + return TRUE; +} + +gboolean mim_config_revert (GtkWidget *config) { GtkTreeView *tree;