{
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"));
}
}
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 *
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 *
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
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 *
{
GtkTreeModel *model;
GtkTreeIter iter;
- GtkWidget *dialog, *vbox, *hbox;
+ GtkWidget *dialog, *label, *vbox, *hbox;
+ MSymbol status;
struct BindingWidgets bw;
gchar *command;
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);
(minput_get_variable \
(current_lang, current_name, current_variable))))))
-#define CURRENT_STATUS \
+#define CURRENT_STATUS \
(mplist_value \
(mplist_next \
(mplist_next \
/* type of widget */
enum WidgetType wtype;
+ /* whether minput_config_variable () should be called on ok button */
+ gboolean need_config;
+
/* default button */
GtkWidget *default_;
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;
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
_("The value must be an integer."));
gtk_dialog_run (GTK_DIALOG (msg));
gtk_widget_destroy (msg);
- update_status (ci);
ret = FALSE;
}
}
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));
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 *
{
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)
{
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
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++)
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++)
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++)
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;
{
GtkTreeModel *model;
GtkTreeIter iter;
- GtkWidget *hbox, *vbox;
+ GtkWidget *label, *hbox, *vbox;
+ MSymbol status;
struct ControllerInfo ci;
gchar *variable;
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);
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);