GtkWidget *clear;
GtkWidget *add;
GtkWidget *view;
+ GtkWidget *default_;
+ GtkWidget *revert;
GtkWidget *delete;
+ GtkWidget *status;
};
enum KeyMaskBit {
}
}
-gboolean
+static gboolean
key_pressed_cb (GtkEntry *entry, GdkEventKey *event, gpointer data)
{
guint c;
return TRUE;
}
-gboolean
+static gboolean
key_released_cb (GtkEntry *entry, GdkEventKey *event, gpointer data)
{
guint c;
}
static void
+update_widgets (struct BindingWidgets *bw)
+{
+ MSymbol 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), _("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"));
+ }
+}
+
+static void
clear_cb (GtkButton *button, gpointer data)
{
struct BindingWidgets *bw = data;
gtk_list_store_set (store, &iter, 0, mplist_value (last), -1);
update_binding_store (bw->view);
clear_cb (NULL, bw);
- gtk_widget_set_sensitive (bw->clear, FALSE);
- gtk_widget_set_sensitive (bw->add, FALSE);
+ update_widgets (bw);
}
static GtkWidget *
CONFIG_COMMAND (empty);
m17n_object_unref (empty);
update_binding_store (bw->view);
+ update_widgets (bw);
}
static void *
CONFIG_COMMAND (NULL);
update_binding_store (bw->view);
+ update_widgets (bw);
}
static void
m17n_object_unref (new);
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
update_binding_store (bw->view);
- gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
+ update_widgets (bw);
}
static GtkWidget *
create_deleting_section (struct BindingWidgets *bw)
{
GtkListStore *store;
- GtkWidget *scrolled, *default_, *revert, *delete, *hbox, *vbox;
+ GtkWidget *scrolled, *hbox, *vbox;
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
GtkTreeIter iter;
gtk_tree_view_column_set_cell_data_func
(column, renderer, keyseq_render_function, NULL, NULL);
- default_ = gtk_button_new_from_stock (_("_Default"));
- g_signal_connect (G_OBJECT (default_), "clicked",
+ bw->default_ = gtk_button_new_from_stock (_("_Default"));
+ g_signal_connect (G_OBJECT (bw->default_), "clicked",
G_CALLBACK (default_cb), bw);
- revert = gtk_button_new_from_stock (GTK_STOCK_REVERT_TO_SAVED);
- g_signal_connect (G_OBJECT (revert), "clicked",
+ bw->revert = gtk_button_new_from_stock (GTK_STOCK_REVERT_TO_SAVED);
+ g_signal_connect (G_OBJECT (bw->revert), "clicked",
G_CALLBACK (revert_cb), bw);
bw->delete = gtk_button_new_from_stock (GTK_STOCK_DELETE);
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), default_);
- gtk_container_add (GTK_CONTAINER (hbox), revert);
+ gtk_container_add (GTK_CONTAINER (hbox), bw->default_);
+ gtk_container_add (GTK_CONTAINER (hbox), bw->revert);
gtk_container_add (GTK_CONTAINER (hbox), bw->delete);
gtk_container_add (GTK_CONTAINER (vbox), hbox);
gchar *status_str;
status = CURRENT_STATUS;
- if (status == Mnil || status == Minherited)
- status_str = _("default");
+ if (status == Mconfigured)
+ status_str = _("modified");
else if (status == Mcustomized)
status_str = _("customized");
else
- status_str = _("modified");
+ status_str = _("default");
gtk_list_store_set (store, iter, 1, status_str, -1);
}
{
GtkTreeModel *model;
GtkTreeIter iter;
- GtkWidget *dialog;
+ GtkWidget *dialog, *vbox;
struct BindingWidgets bw;
gchar *command;
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
NULL));
+
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
create_adding_section (&bw));
+
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
create_deleting_section (&bw));
+ bw.status = gtk_label_new (NULL);
+ vbox = gtk_vbox_new (FALSE, 12);
+ gtk_container_add (GTK_CONTAINER (vbox), bw.status);
+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox);
+
+ update_widgets (&bw);
gtk_widget_show_all (dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_tree_model_get_iter (model, &iter, path);
}
GtkWidget *
-create_command_entries (GtkTooltips *tip, MSymbol lang, MSymbol name)
+create_command_list (GtkTooltips *tip, MSymbol lang, MSymbol name)
{
GtkListStore *store;
GtkWidget *view;
(current_lang, current_name, current_variable))))))
#define CURRENT_STATUS \
- (mplist_next \
+ (mplist_value \
(mplist_next \
- (mplist_value \
- (minput_get_variable \
- (current_lang, current_name, current_variable)))))
+ (mplist_next \
+ (mplist_value \
+ (minput_get_variable \
+ (current_lang, current_name, current_variable))))))
#define CONFIG_VARIABLE(plist) \
minput_config_variable (current_lang, current_name, current_variable, \
/* type of widget */
enum WidgetType wtype;
+
+ /* default button */
+ GtkWidget *default_;
+
+ /* revert button */
+ GtkWidget *revert;
+
+ /* apply button */
+ GtkWidget *apply;
+
+ /* status label */
+ GtkWidget *status;
};
static MSymbol current_lang, current_name, current_variable;
static void
+update_controller (struct ControllerInfo *ci)
+{
+ MPlist *plist;
+ MSymbol key, status;
+ void *value;
+
+ status = CURRENT_STATUS;
+ if (status == Mconfigured)
+ {
+ gtk_widget_set_sensitive (ci->default_, TRUE);
+ gtk_widget_set_sensitive (ci->revert, TRUE);
+ gtk_widget_set_sensitive (ci->apply, FALSE);
+ gtk_label_set_text (GTK_LABEL (ci->status), _("Status : modified"));
+ }
+ else if (status == Mcustomized)
+ {
+ gtk_widget_set_sensitive (ci->default_, TRUE);
+ gtk_widget_set_sensitive (ci->revert, FALSE);
+ gtk_widget_set_sensitive (ci->apply, FALSE);
+ gtk_label_set_text (GTK_LABEL (ci->status), _("Status : customized"));
+ }
+ else
+ {
+ gtk_widget_set_sensitive (ci->default_, FALSE);
+ gtk_widget_set_sensitive (ci->revert, FALSE);
+ gtk_widget_set_sensitive (ci->apply, FALSE);
+ gtk_label_set_text (GTK_LABEL (ci->status), _("Status : default"));
+ }
+
+ plist = CURRENT_VALUE;
+ /* plist == (value [valid-value ...]) */
+ key = mplist_key (plist);
+ value = mplist_value (plist);
+
+ if (ci->wtype == ENTRY_WIDGET)
+ {
+ if (key == Msymbol)
+ gtk_entry_set_text (GTK_ENTRY (ci->widget),
+ msymbol_name ((MSymbol) value));
+ else if (key == Mtext)
+ /* Fixme : Assuming the return value is in UTF-8 */
+ gtk_entry_set_text (GTK_ENTRY (ci->widget),
+ mtext_data ((MText *) value,
+ NULL, NULL, NULL, NULL));
+ else
+ {
+ gchar buf[32];
+ g_snprintf (buf, sizeof (buf), "%d", (gint) value);
+ gtk_entry_set_text (GTK_ENTRY (ci->widget), buf);
+ }
+ }
+ else if (ci->wtype == COMBO_BOX_WIDGET)
+ {
+ gint i;
+
+ for (i = 0, plist = mplist_next (plist);
+ plist && mplist_key (plist) == key;
+ i++, plist = mplist_next (plist))
+ if (mplist_value (plist) == value)
+ break;
+ gtk_combo_box_set_active (GTK_COMBO_BOX (ci->widget), i);
+ }
+ else
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (ci->widget),
+ (gdouble) (int) value);
+}
+
+static void
entry_cb (GtkEntry *entry, gpointer data)
{
const gchar *text = gtk_entry_get_text (entry);
gtk_editable_set_position (GTK_EDITABLE (entry), -1);
}
m17n_object_unref (plist);
+ update_controller (ci);
}
static void
CONFIG_VARIABLE (plist);
}
m17n_object_unref (plist);
+ update_controller (ci);
}
static void
(void *) gtk_spin_button_get_value_as_int (spin));
CONFIG_VARIABLE (plist);
m17n_object_unref (plist);
+ update_controller (ci);
}
enum
MSymbol status;
gchar *value_str, *status_str, buf[32];
- plist = CURRENT_STATUS;
- /* plist == (status value [valid-value ...]) */
- status = mplist_value (plist);
- if (status == Mnil || status == Minherited)
- status_str = _("default");
+ status = CURRENT_STATUS;
+ if (status == Mconfigured)
+ status_str = _("modified");
else if (status == Mcustomized)
status_str = _("customized");
else
- status_str = _("modified");
+ status_str = _("default");
- plist = mplist_next (plist);
+ plist = CURRENT_VALUE;
/* plist == (value [valid-value ...]) */
if (mplist_key (plist) == Msymbol)
value_str = msymbol_name ((MSymbol) mplist_value (plist));
-1);
}
+static gboolean
+key_pressed_cb (GtkEntry *entry, GdkEventKey *event, gpointer data)
+{
+ struct ControllerInfo *ci = data;
+
+ gtk_widget_set_sensitive (ci->default_, TRUE);
+ gtk_widget_set_sensitive (ci->revert, TRUE);
+ gtk_widget_set_sensitive (ci->apply, TRUE);
+ return FALSE;
+}
+
static GtkWidget *
create_widget (struct ControllerInfo *ci)
{
gtk_editable_set_editable (GTK_EDITABLE (ci->widget), TRUE);
g_signal_connect (G_OBJECT (ci->widget), "activate",
G_CALLBACK (entry_cb), ci);
+ g_signal_connect (G_OBJECT (ci->widget), "key-press-event",
+ G_CALLBACK (key_pressed_cb), ci);
}
}
else if (ci->vtype == Mtext)
gtk_editable_set_editable (GTK_EDITABLE (ci->widget), TRUE);
g_signal_connect (G_OBJECT (ci->widget), "activate",
G_CALLBACK (entry_cb), ci);
+ g_signal_connect (G_OBJECT (ci->widget), "key-press-event",
+ G_CALLBACK (key_pressed_cb), ci);
}
}
else if (ci->vtype == Minteger)
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (ci->widget), TRUE);
gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (ci->widget),
GTK_UPDATE_IF_VALID);
+ g_signal_connect (G_OBJECT (ci->widget), "activate",
+ G_CALLBACK (entry_cb), ci);
g_signal_connect (G_OBJECT (ci->widget), "value_changed",
G_CALLBACK (spin_cb), ci);
+ g_signal_connect (G_OBJECT (ci->widget), "key-press-event",
+ G_CALLBACK (key_pressed_cb), ci);
}
else
{
gtk_editable_set_editable (GTK_EDITABLE (ci->widget), TRUE);
g_signal_connect (G_OBJECT (ci->widget), "activate",
G_CALLBACK (entry_cb), ci);
+ g_signal_connect (G_OBJECT (ci->widget), "key-press-event",
+ G_CALLBACK (key_pressed_cb), ci);
}
}
- else
+ else /* should never come here */
{
ci->widget = gtk_entry_new ();
ci->wtype = ENTRY_WIDGET;
gtk_editable_set_editable (GTK_EDITABLE (ci->widget), TRUE);
g_signal_connect (G_OBJECT (ci->widget), "activate",
G_CALLBACK (entry_cb), ci);
+ g_signal_connect (G_OBJECT (ci->widget), "key-press-event",
+ G_CALLBACK (key_pressed_cb), ci);
}
return ci->widget;
}
-static void
-update_controller (struct ControllerInfo *ci)
-{
- MPlist *plist;
- MSymbol key;
- void *value;
-
- plist = CURRENT_VALUE;
- /* plist == (value [valid-value ...]) */
- key = mplist_key (plist);
- value = mplist_value (plist);
-
- if (ci->wtype == ENTRY_WIDGET)
- {
- if (key == Msymbol)
- gtk_entry_set_text (GTK_ENTRY (ci->widget),
- msymbol_name ((MSymbol) value));
- else if (key == Mtext)
- /* Fixme : Assuming the return value is in UTF-8 */
- gtk_entry_set_text (GTK_ENTRY (ci->widget),
- mtext_data ((MText *) value,
- NULL, NULL, NULL, NULL));
- else
- {
- gchar buf[32];
- g_snprintf (buf, sizeof (buf), "%d", (gint) value);
- gtk_entry_set_text (GTK_ENTRY (ci->widget), buf);
- }
- }
- else if (ci->wtype == COMBO_BOX_WIDGET)
- {
- gint i;
-
- for (i = 0, plist = mplist_next (plist);
- plist && mplist_key (plist) == key;
- i++, plist = mplist_next (plist))
- if (mplist_value (plist) == value)
- break;
- gtk_combo_box_set_active (GTK_COMBO_BOX (ci->widget), i);
- }
- else
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (ci->widget),
- (gdouble) (int) value);
-}
-
static void *
default_cb (GtkButton *button, gpointer data)
{
MPlist *empty = mplist ();
+ struct ControllerInfo *ci = data;
CONFIG_VARIABLE (empty);
m17n_object_unref (empty);
- update_controller ((struct ControllerInfo *) data);
+ update_controller (ci);
}
static void *
revert_cb (GtkButton *button, gpointer data)
{
+ struct ControllerInfo *ci = data;
+
CONFIG_VARIABLE (NULL);
- update_controller ((struct ControllerInfo *) data);
+ update_controller (ci);
}
static void *
if (ci->wtype == ENTRY_WIDGET)
entry_cb (GTK_ENTRY (ci->widget), ci);
+ update_controller (ci);
}
static void
{
GtkTreeModel *model;
GtkTreeIter iter;
- GtkWidget *dialog, *default_, *revert, *apply, *hbox, *vbox;
+ GtkWidget *dialog, *hbox, *vbox;
struct ControllerInfo ci;
gchar *variable;
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
NULL));
- default_ = gtk_button_new_from_stock (_("_Default"));
- g_signal_connect (G_OBJECT (default_), "clicked",
+ ci.default_ = gtk_button_new_from_stock (_("_Default"));
+ g_signal_connect (G_OBJECT (ci.default_), "clicked",
G_CALLBACK (default_cb), &ci);
- revert = gtk_button_new_from_stock (GTK_STOCK_REVERT_TO_SAVED);
- g_signal_connect (G_OBJECT (revert), "clicked",
+ ci.revert = gtk_button_new_from_stock (GTK_STOCK_REVERT_TO_SAVED);
+ g_signal_connect (G_OBJECT (ci.revert), "clicked",
G_CALLBACK (revert_cb), &ci);
- apply = gtk_button_new_from_stock (GTK_STOCK_APPLY);
- g_signal_connect (G_OBJECT (apply), "clicked",
+ ci.apply = gtk_button_new_from_stock (GTK_STOCK_APPLY);
+ g_signal_connect (G_OBJECT (ci.apply), "clicked",
G_CALLBACK (apply_cb), &ci);
+ ci.status = gtk_label_new (NULL);
+
vbox = gtk_vbox_new (FALSE, 6);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox);
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), default_);
- gtk_container_add (GTK_CONTAINER (hbox), revert);
- gtk_container_add (GTK_CONTAINER (hbox), apply);
+ gtk_container_add (GTK_CONTAINER (hbox), ci.default_);
+ gtk_container_add (GTK_CONTAINER (hbox), ci.revert);
+ gtk_container_add (GTK_CONTAINER (hbox), ci.apply);
gtk_container_add (GTK_CONTAINER (vbox), hbox);
+
+ gtk_container_add (GTK_CONTAINER (vbox), ci.status);
+ update_controller (&ci);
gtk_widget_show_all (dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_tree_model_get_iter (model, &iter, path);
}
GtkWidget *
-create_variable_entries (GtkTooltips *tip, MSymbol lang, MSymbol name)
+create_variable_list (GtkTooltips *tip, MSymbol lang, MSymbol name)
{
GtkListStore *store;
GtkWidget *view;