From: ntakahas Date: Mon, 7 May 2007 10:54:26 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: REL-0-9-0~14 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4519c7b2963a2347987d2e9ea815c0b1c46acb1a;p=m17n%2Fm17n-im-config.git *** empty log message *** --- diff --git a/src/mim-config.c b/src/mim-config.c index 84feb29..a1dcc08 100644 --- a/src/mim-config.c +++ b/src/mim-config.c @@ -453,7 +453,7 @@ struct ConfigControl /* minput_config_variable or minput_config_command. */ int (*config) (MSymbol, MSymbol, MSymbol, MPlist *); /* If non-NULL, a function to call before finishing a dialog. */ - int (*config_on_ok) (struct ConfigControl *control); + gboolean (*config_on_ok) (struct ConfigControl *control); /* Widget showing the current data (value or key bindings) */ GtkWidget *data; @@ -525,31 +525,33 @@ struct VariableControl control->config (control->lang, control->name, control->item, \ (plist)) +static MPlist *entry_keyseq; + static void -update_widgets (struct ConfigControl *control) +update_status (struct ConfigControl *control) { MSymbol status = CURRENT_STATUS; if (status == Mconfigured) { - gtk_widget_set_sensitive (control->default_, TRUE); - gtk_widget_set_sensitive (control->revert, TRUE); gtk_label_set_text (GTK_LABEL (control->status), mim_status_str[MIM_STATUS_MODIFIED]); + gtk_widget_set_sensitive (control->default_, TRUE); + gtk_widget_set_sensitive (control->revert, TRUE); } else if (status == Mcustomized) { - gtk_widget_set_sensitive (control->default_, TRUE); - gtk_widget_set_sensitive (control->revert, FALSE); gtk_label_set_text (GTK_LABEL (control->status), mim_status_str[MIM_STATUS_CUSTOMIZED]); + gtk_widget_set_sensitive (control->default_, TRUE); + gtk_widget_set_sensitive (control->revert, FALSE); } else { - gtk_widget_set_sensitive (control->default_, FALSE); - gtk_widget_set_sensitive (control->revert, FALSE); gtk_label_set_text (GTK_LABEL (control->status), mim_status_str[MIM_STATUS_DEFAULT]); + gtk_widget_set_sensitive (control->default_, FALSE); + gtk_widget_set_sensitive (control->revert, FALSE); } } @@ -578,7 +580,7 @@ default_cb (GtkButton *button, gpointer data) CONFIG_DATA (empty); m17n_object_unref (empty); control->update_data (control); - update_widgets (control); + update_status (control); control->config_on_ok = NULL; } @@ -589,7 +591,7 @@ revert_cb (GtkButton *button, gpointer data) CONFIG_DATA (NULL); control->update_data (control); - update_widgets (control); + update_status (control); control->config_on_ok = NULL; } @@ -607,6 +609,8 @@ ok_cb (GtkButton *button, gpointer data) } control->config_on_ok = NULL; } + if (control->config == minput_config_command) + m17n_object_unref (entry_keyseq); gtk_dialog_response (GTK_DIALOG (gtk_widget_get_toplevel (GTK_WIDGET (button))), GTK_RESPONSE_OK); @@ -671,17 +675,17 @@ item_activated_cb (GtkTreeView *parent, GtkTreePath *path, gtk_tree_model_get (model, &iter, CONFIG_COL_ITEM, &item, -1); control->item = msymbol (item); - dialog = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (dialog), msymbol_name (control->item)); - gtk_window_set_transient_for - (GTK_WINDOW (dialog), - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (parent)))); - gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE); + dialog = (gtk_dialog_new_with_buttons + (msymbol_name (control->item), + GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (parent))), + GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, + NULL)); gtk_button_box_set_layout (GTK_BUTTON_BOX (GTK_DIALOG (dialog)->action_area), GTK_BUTTONBOX_EDGE); + gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); hbox = gtk_hbox_new (FALSE, 12); - gtk_container_set_border_width (GTK_CONTAINER (hbox), 12); + gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); label = gtk_label_new (_("Status")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); label = gtk_label_new (": "); @@ -704,13 +708,12 @@ item_activated_cb (GtkTreeView *parent, GtkTreePath *path, control->setup_dialog (dialog, control); - update_widgets (control); + update_status (control); gtk_widget_show_all (dialog); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_tree_model_get_iter (model, &iter, path); set_list_element (GTK_LIST_STORE (model), &iter, control, NULL); gtk_widget_destroy (dialog); - /*m17n_object_unref (entry_keyseq);*/ } @@ -779,9 +782,10 @@ config_im (GtkTreeView *tree, MSymbol lang, MSymbol name) GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL)); gtk_widget_set_size_request (dialog, 500, 300); + gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); vbox = gtk_vbox_new (FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER(vbox), 10); + gtk_container_set_border_width (GTK_CONTAINER(vbox), 5); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox); notebook = gtk_notebook_new (); @@ -1002,7 +1006,7 @@ variable_setup_dialog (GtkWidget *dialog, struct ConfigControl *control) { MPlist *plist; void *value; - GtkWidget *hbox; + GtkWidget *hbox, *vbox; plist = CURRENT_DATA; VARIABLE_CONTROL (control)->vtype = mplist_key (plist); @@ -1016,8 +1020,6 @@ variable_setup_dialog (GtkWidget *dialog, struct ConfigControl *control) gint i, nth; control->data = gtk_combo_box_new_text (); - g_signal_connect (GTK_OBJECT (control->data), "changed", - G_CALLBACK (changed_cb), control); VARIABLE_CONTROL (control)->wtype = COMBO_BOX_WIDGET; for (i = 0; mplist_key (plist) == Msymbol; plist = mplist_next (plist), i++) @@ -1029,17 +1031,19 @@ variable_setup_dialog (GtkWidget *dialog, struct ConfigControl *control) msymbol_name ((MSymbol) mplist_value (plist))); } gtk_combo_box_set_active (GTK_COMBO_BOX (control->data), nth); + g_signal_connect (GTK_OBJECT (control->data), "changed", + G_CALLBACK (changed_cb), control); } else { control->data = gtk_entry_new (); + VARIABLE_CONTROL (control)->wtype = ENTRY_WIDGET; + gtk_entry_set_text (GTK_ENTRY (control->data), msymbol_name (value)); + gtk_editable_set_editable (GTK_EDITABLE (control->data), TRUE); g_signal_connect (GTK_OBJECT (control->data), "changed", G_CALLBACK (changed_cb), control); g_signal_connect (GTK_OBJECT (control->data), "activate", G_CALLBACK (ok_cb), control); - VARIABLE_CONTROL (control)->wtype = ENTRY_WIDGET; - gtk_entry_set_text (GTK_ENTRY (control->data), msymbol_name (value)); - gtk_editable_set_editable (GTK_EDITABLE (control->data), TRUE); } } else if (VARIABLE_CONTROL (control)->vtype == Mtext) @@ -1149,10 +1153,12 @@ variable_setup_dialog (GtkWidget *dialog, struct ConfigControl *control) gtk_box_set_spacing (GTK_BOX (hbox), 6); gtk_container_add (GTK_CONTAINER (hbox), control->default_); gtk_container_add (GTK_CONTAINER (hbox), control->revert); + vbox = gtk_vbox_new (FALSE, 12); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); + gtk_box_pack_start (GTK_BOX (vbox), control->data, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), - control->data, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), - hbox, FALSE, FALSE, 0); + vbox, FALSE, FALSE, 0); } @@ -1191,7 +1197,7 @@ delete_cb (GtkButton *button, gpointer data) CONFIG_DATA (new); m17n_object_unref (new); control->update_data (control); - update_widgets (control); + update_status (control); } static GtkWidget * @@ -1242,8 +1248,8 @@ create_deleting_section (struct ConfigControl *control) g_signal_connect (G_OBJECT (cmd_control->delete), "clicked", G_CALLBACK (delete_cb), control); - vbox = gtk_vbox_new (FALSE, 12); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); + vbox = gtk_vbox_new (FALSE, 5); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); hbox = gtk_hbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 6); @@ -1263,7 +1269,6 @@ create_deleting_section (struct ConfigControl *control) } static unsigned modifier_state = 0; -static MPlist *entry_keyseq; enum KeyMaskBit { META_MASK_BIT = 1, @@ -1421,7 +1426,8 @@ add_cb (GtkButton *button, gpointer data) CONFIG_DATA (new); m17n_object_unref (new); control->update_data (control); - update_widgets (control); + update_status (control); + clear_cb (NULL, control); } static GtkWidget * @@ -1449,7 +1455,7 @@ create_adding_section (struct ConfigControl *control) g_signal_connect (G_OBJECT (cmd_control->add), "clicked", G_CALLBACK (add_cb), cmd_control); - vbox = gtk_vbox_new (FALSE, 12); + vbox = gtk_vbox_new (FALSE, 5); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); hbox = gtk_hbox_new (FALSE, 6);