From 0a99282e75946fa133080610d451323e418d1a30 Mon Sep 17 00:00:00 2001 From: ntakahas Date: Fri, 27 Apr 2007 12:37:47 +0000 Subject: [PATCH] *** empty log message *** --- src/command.c | 69 +++++++++++++++++++++---- src/variable.c | 153 +++++++++++++++++++++++++++++++------------------------- 2 files changed, 143 insertions(+), 79 deletions(-) diff --git a/src/command.c b/src/command.c index ccf85c9..d0168f8 100644 --- a/src/command.c +++ b/src/command.c @@ -214,19 +214,16 @@ update_widgets (struct BindingWidgets *bw) { gtk_widget_set_sensitive (bw->default_, TRUE); gtk_widget_set_sensitive (bw->revert, TRUE); - gtk_label_set_text (GTK_LABEL (bw->status), _("Status : modified")); } else if (status == Mcustomized) { gtk_widget_set_sensitive (bw->default_, TRUE); gtk_widget_set_sensitive (bw->revert, FALSE); - gtk_label_set_text (GTK_LABEL (bw->status), _("Status : customized")); } else { gtk_widget_set_sensitive (bw->default_, FALSE); gtk_widget_set_sensitive (bw->revert, FALSE); - gtk_label_set_text (GTK_LABEL (bw->status), _("Status : default")); } } @@ -281,7 +278,9 @@ add_cb (GtkButton *button, gpointer data) gtk_list_store_set (store, &iter, 0, mplist_value (last), -1); update_binding_store (bw->view); clear_cb (NULL, bw); - update_widgets (bw); + gtk_widget_set_sensitive (bw->default_, TRUE); + gtk_widget_set_sensitive (bw->revert, TRUE); + gtk_label_set_text (GTK_LABEL (bw->status), _("modified")); } static GtkWidget * @@ -370,7 +369,17 @@ default_cb (GtkButton *button, gpointer data) CONFIG_COMMAND (empty); m17n_object_unref (empty); update_binding_store (bw->view); - update_widgets (bw); + gtk_widget_set_sensitive (bw->default_, FALSE); + if (CURRENT_STATUS == Mconfigured) + { + gtk_widget_set_sensitive (bw->revert, TRUE); + gtk_label_set_text (GTK_LABEL (bw->status), _("modified")); + } + else + { + gtk_widget_set_sensitive (bw->revert, FALSE); + gtk_label_set_text (GTK_LABEL (bw->status), _("default")); + } } static void * @@ -380,7 +389,17 @@ revert_cb (GtkButton *button, gpointer data) CONFIG_COMMAND (NULL); update_binding_store (bw->view); - update_widgets (bw); + gtk_widget_set_sensitive (bw->revert, FALSE); + if (CURRENT_STATUS == Mnil) + { + gtk_widget_set_sensitive (bw->default_, FALSE); + gtk_label_set_text (GTK_LABEL (bw->status), _("default")); + } + else + { + gtk_widget_set_sensitive (bw->default_, TRUE); + gtk_label_set_text (GTK_LABEL (bw->status), _("customized")); + } } static void @@ -407,6 +426,9 @@ delete_cb (GtkButton *button, gpointer data) gtk_list_store_remove (GTK_LIST_STORE (model), &iter); update_binding_store (bw->view); update_widgets (bw); + gtk_widget_set_sensitive (bw->default_, TRUE); + gtk_widget_set_sensitive (bw->revert, TRUE); + gtk_label_set_text (GTK_LABEL (bw->status), _("modified")); } static GtkWidget * @@ -501,7 +523,8 @@ activated_cb (GtkTreeView *parent, GtkTreePath *path, { GtkTreeModel *model; GtkTreeIter iter; - GtkWidget *dialog, *vbox, *hbox; + GtkWidget *dialog, *label, *vbox, *hbox; + MSymbol status; struct BindingWidgets bw; gchar *command; @@ -526,13 +549,37 @@ activated_cb (GtkTreeView *parent, GtkTreePath *path, vbox = gtk_vbox_new (FALSE, 12); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox); + hbox = gtk_hbox_new (FALSE, 6); - bw.status = gtk_label_new (NULL); - gtk_box_pack_start (GTK_BOX (hbox), bw.status, FALSE, FALSE, 6); gtk_container_add (GTK_CONTAINER (vbox), hbox); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox); - update_widgets (&bw); + label = gtk_label_new (_("Status : ")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + + bw.status = gtk_label_new (NULL); + gtk_box_pack_start (GTK_BOX (hbox), bw.status, FALSE, FALSE, 0); + + status = CURRENT_STATUS; + if (status == Mconfigured) + { + gtk_widget_set_sensitive (bw.default_, TRUE); + gtk_widget_set_sensitive (bw.revert, TRUE); + gtk_label_set_text (GTK_LABEL (bw.status), _("modified")); + } + else if (status == Mcustomized) + { + gtk_widget_set_sensitive (bw.default_, TRUE); + gtk_widget_set_sensitive (bw.revert, FALSE); + gtk_label_set_text (GTK_LABEL (bw.status), _("customized")); + } + else + { + gtk_widget_set_sensitive (bw.default_, FALSE); + gtk_widget_set_sensitive (bw.revert, FALSE); + gtk_label_set_text (GTK_LABEL (bw.status), _("default")); + } + gtk_widget_show_all (dialog); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_tree_model_get_iter (model, &iter, path); diff --git a/src/variable.c b/src/variable.c index e1a97f9..cfc66c1 100644 --- a/src/variable.c +++ b/src/variable.c @@ -15,7 +15,7 @@ (minput_get_variable \ (current_lang, current_name, current_variable)))))) -#define CURRENT_STATUS \ +#define CURRENT_STATUS \ (mplist_value \ (mplist_next \ (mplist_next \ @@ -45,6 +45,9 @@ struct ControllerInfo /* type of widget */ enum WidgetType wtype; + /* whether minput_config_variable () should be called on ok button */ + gboolean need_config; + /* default button */ GtkWidget *default_; @@ -64,7 +67,7 @@ struct ControllerInfo static MSymbol current_lang, current_name, current_variable; static void -update_status (struct ControllerInfo *ci) +update_widget (struct ControllerInfo *ci) { MPlist *plist; MSymbol key, status; @@ -106,26 +109,50 @@ update_status (struct ControllerInfo *ci) else /* ci->wtype == SPIN_BUTTON_WIDGET */ gtk_spin_button_set_value (GTK_SPIN_BUTTON (ci->widget), (gdouble) (int) value); +} - status = CURRENT_STATUS; - if (status == Mconfigured) +static void * +default_cb (GtkButton *button, gpointer data) +{ + MPlist *empty = mplist (); + struct ControllerInfo *ci = data; + + CONFIG_VARIABLE (empty); + m17n_object_unref (empty); + update_widget (ci); + gtk_widget_set_sensitive (ci->default_, FALSE); + if (CURRENT_STATUS == Mconfigured) { - gtk_widget_set_sensitive (ci->default_, TRUE); gtk_widget_set_sensitive (ci->revert, TRUE); - gtk_label_set_text (GTK_LABEL (ci->status), _("Status : modified")); + gtk_label_set_text (GTK_LABEL (ci->status), _("modified")); } - else if (status == Mcustomized) + else { - gtk_widget_set_sensitive (ci->default_, TRUE); gtk_widget_set_sensitive (ci->revert, FALSE); - gtk_label_set_text (GTK_LABEL (ci->status), _("Status : customized")); + gtk_label_set_text (GTK_LABEL (ci->status), _("default")); } - else + ci->need_config = FALSE; +} + +static void * +revert_cb (GtkButton *button, gpointer data) +{ + struct ControllerInfo *ci = data; + + CONFIG_VARIABLE (NULL); + update_widget (ci); + gtk_widget_set_sensitive (ci->revert, FALSE); + if (CURRENT_STATUS == Mnil) { gtk_widget_set_sensitive (ci->default_, FALSE); - gtk_widget_set_sensitive (ci->revert, FALSE); - gtk_label_set_text (GTK_LABEL (ci->status), _("Status : default")); + gtk_label_set_text (GTK_LABEL (ci->status), _("default")); } + else + { + gtk_widget_set_sensitive (ci->default_, TRUE); + gtk_label_set_text (GTK_LABEL (ci->status), _("customized")); + } + ci->need_config = FALSE; } static gboolean @@ -171,7 +198,6 @@ config_with_entry (struct ControllerInfo *ci) _("The value must be an integer.")); gtk_dialog_run (GTK_DIALOG (msg)); gtk_widget_destroy (msg); - update_status (ci); ret = FALSE; } } @@ -180,7 +206,7 @@ config_with_entry (struct ControllerInfo *ci) return ret; } -static void +static gboolean config_with_combo (struct ControllerInfo *ci) { gchar *text = gtk_combo_box_get_active_text (GTK_COMBO_BOX (ci->widget)); @@ -209,19 +235,21 @@ config_with_combo (struct ControllerInfo *ci) CONFIG_VARIABLE (plist); } m17n_object_unref (plist); - update_status (ci); + return TRUE; } -static void +static gboolean config_with_spin (struct ControllerInfo *ci) { - MPlist *plist = mplist (); gint i; i = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ci->widget)); + MPlist *plist = mplist (); + mplist_add (plist, Minteger, (void *) i); CONFIG_VARIABLE (plist); m17n_object_unref (plist); + return TRUE; } static void * @@ -229,53 +257,32 @@ ok_cb (GtkButton *button, gpointer data) { struct ControllerInfo *ci = data; - if (! strcmp (gtk_label_get_text (GTK_LABEL (ci->status)), - "Status : modified")) + if (ci->need_config) { if (ci->wtype == ENTRY_WIDGET) { if (config_with_entry (ci)) gtk_dialog_response (GTK_DIALOG (ci->dialog), GTK_RESPONSE_OK); else - update_status (ci); + revert_cb (NULL, ci); } else if (ci->wtype == COMBO_BOX_WIDGET) { - config_with_combo (ci); + config_with_combo (ci); /* always returns true */ gtk_dialog_response (GTK_DIALOG (ci->dialog), GTK_RESPONSE_OK); } else /* ci->wtype == SPIN_BUTTON */ { - config_with_spin (ci); + config_with_spin (ci); /* always returns true */ gtk_dialog_response (GTK_DIALOG (ci->dialog), GTK_RESPONSE_OK); } } - else /* default or customized */ + else gtk_dialog_response (GTK_DIALOG (ci->dialog), GTK_RESPONSE_OK); } -static void * -default_cb (GtkButton *button, gpointer data) -{ - MPlist *empty = mplist (); - struct ControllerInfo *ci = data; - - CONFIG_VARIABLE (empty); - m17n_object_unref (empty); - update_status (ci); -} - -static void * -revert_cb (GtkButton *button, gpointer data) -{ - struct ControllerInfo *ci = data; - - CONFIG_VARIABLE (NULL); - update_status (ci); -} - static void changed_cb (GtkEntry *entry, gpointer data) { @@ -283,18 +290,8 @@ changed_cb (GtkEntry *entry, gpointer data) gtk_widget_set_sensitive (ci->default_, TRUE); gtk_widget_set_sensitive (ci->revert, TRUE); - gtk_label_set_text (GTK_LABEL (ci->status), _("Status : modified")); -} - -static gboolean -value_changed_cb (GtkWidget *widget, gpointer data) -{ - struct ControllerInfo *ci = data; - - gtk_widget_set_sensitive (ci->default_, TRUE); - gtk_widget_set_sensitive (ci->revert, TRUE); - gtk_label_set_text (GTK_LABEL (ci->status), _("Status : modified")); - return FALSE; + gtk_label_set_text (GTK_LABEL (ci->status), _("modified")); + ci->need_config = TRUE; } enum @@ -360,7 +357,7 @@ create_widget (struct ControllerInfo *ci) ci->widget = gtk_combo_box_new_text (); g_signal_connect (GTK_OBJECT (ci->widget), "changed", - G_CALLBACK (value_changed_cb), ci); + G_CALLBACK (changed_cb), ci); ci->wtype = COMBO_BOX_WIDGET; for (i = 0; plist && mplist_key (plist) == Msymbol; plist = mplist_next (plist), i++) @@ -391,7 +388,7 @@ create_widget (struct ControllerInfo *ci) ci->widget = gtk_combo_box_new_text (); g_signal_connect (GTK_OBJECT (ci->widget), "changed", - G_CALLBACK (value_changed_cb), ci); + G_CALLBACK (changed_cb), ci); ci->wtype = COMBO_BOX_WIDGET; for (i = 0; plist && mplist_key (plist) == Mtext; plist = mplist_next (plist), i++) @@ -427,7 +424,7 @@ create_widget (struct ControllerInfo *ci) ci->widget = gtk_combo_box_new_text (); g_signal_connect (GTK_OBJECT (ci->widget), "changed", - G_CALLBACK (value_changed_cb), ci); + G_CALLBACK (changed_cb), ci); ci->wtype = COMBO_BOX_WIDGET; for (i = 0; plist && mplist_key (plist) == Minteger; plist = mplist_next (plist), i++) @@ -453,8 +450,6 @@ create_widget (struct ControllerInfo *ci) adj = gtk_adjustment_new ((gdouble) (int) value, lower, upper, 1.0, 10.0, 0); ci->widget = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 0, 0); - g_signal_connect (GTK_OBJECT (ci->widget), "value-changed", - G_CALLBACK (value_changed_cb), ci); g_signal_connect (GTK_OBJECT (ci->widget), "changed", G_CALLBACK (changed_cb), ci); ci->wtype = SPIN_BUTTON_WIDGET; @@ -485,7 +480,8 @@ activated_cb (GtkTreeView *parent, GtkTreePath *path, { GtkTreeModel *model; GtkTreeIter iter; - GtkWidget *hbox, *vbox; + GtkWidget *label, *hbox, *vbox; + MSymbol status; struct ControllerInfo ci; gchar *variable; @@ -509,12 +505,15 @@ activated_cb (GtkTreeView *parent, GtkTreePath *path, g_signal_connect (G_OBJECT (ci.revert), "clicked", G_CALLBACK (revert_cb), &ci); + label = gtk_label_new (_("Status : ")); ci.status = gtk_label_new (NULL); ci.ok = gtk_button_new_from_stock (GTK_STOCK_OK); g_signal_connect (G_OBJECT (ci.ok), "clicked", G_CALLBACK (ok_cb), &ci); + ci.need_config = FALSE; + vbox = gtk_vbox_new (FALSE, 12); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (ci.dialog)->vbox), vbox); @@ -529,16 +528,34 @@ activated_cb (GtkTreeView *parent, GtkTreePath *path, gtk_container_add (GTK_CONTAINER (vbox), hbox); hbox = gtk_hbox_new (FALSE, 6); - gtk_box_pack_start (GTK_BOX (hbox), ci.status, FALSE, FALSE, 6); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), ci.status, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (vbox), hbox); - hbox = gtk_hbutton_box_new (); - gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END); - gtk_box_set_spacing (GTK_BOX (hbox), 6); - gtk_container_add (GTK_CONTAINER (hbox), ci.ok); - gtk_container_add (GTK_CONTAINER (vbox), hbox); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (ci.dialog)->action_area), + ci.ok); - update_status (&ci); + update_widget (&ci); + status = CURRENT_STATUS; + if (status == Mconfigured) + { + gtk_widget_set_sensitive (ci.default_, TRUE); + gtk_widget_set_sensitive (ci.revert, TRUE); + gtk_label_set_text (GTK_LABEL (ci.status), _("modified")); + } + else if (status == Mcustomized) + { + gtk_widget_set_sensitive (ci.default_, TRUE); + gtk_widget_set_sensitive (ci.revert, FALSE); + gtk_label_set_text (GTK_LABEL (ci.status), _("customized")); + } + else + { + gtk_widget_set_sensitive (ci.default_, FALSE); + gtk_widget_set_sensitive (ci.revert, FALSE); + gtk_label_set_text (GTK_LABEL (ci.status), _("default")); + } + gtk_widget_show_all (ci.dialog); gtk_dialog_run (GTK_DIALOG (ci.dialog)); gtk_tree_model_get_iter (model, &iter, path); -- 1.7.10.4