From 3d5adb652c0f466680e49697723eeff0f54cbccc Mon Sep 17 00:00:00 2001 From: ntakahas Date: Wed, 2 May 2007 11:02:19 +0000 Subject: [PATCH] *** empty log message *** --- src/command.c | 53 +++++++++++++++++++++++++++++++++++++++++----- src/variable.c | 64 +++++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 98 insertions(+), 19 deletions(-) diff --git a/src/command.c b/src/command.c index d0168f8..49d1ad8 100644 --- a/src/command.c +++ b/src/command.c @@ -25,6 +25,15 @@ (minput_get_command \ (current_lang, current_name, current_command)))))) +#define CURRENT_DESCRIPTION \ + (mtext_data \ + (mplist_value \ + (mplist_next \ + (mplist_value \ + (minput_get_command \ + (current_lang, current_name, current_command)))), \ + NULL, NULL, NULL, NULL)) + #define CONFIG_COMMAND(plist) \ minput_config_command (current_lang, current_name, current_command, \ (plist)) @@ -45,13 +54,13 @@ static MSymbol current_lang, current_name, current_command; struct BindingWidgets { - GtkWidget *entry; - GtkWidget *clear; - GtkWidget *add; GtkWidget *view; GtkWidget *default_; GtkWidget *revert; GtkWidget *delete; + GtkWidget *entry; + GtkWidget *clear; + GtkWidget *add; GtkWidget *status; }; @@ -501,6 +510,22 @@ create_deleting_section (struct BindingWidgets *bw) return vbox; } +static void * +help_cb (GtkButton *button, gpointer data) +{ + struct BindingWidgets *bw = data; + GtkWidget *msg; + + msg = gtk_message_dialog_new (GTK_WINDOW + (gtk_widget_get_toplevel (bw->view)), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_CLOSE, + CURRENT_DESCRIPTION); + gtk_dialog_run (GTK_DIALOG (msg)); + gtk_widget_destroy (msg); +} + static void set_status (GtkListStore *store, GtkTreeIter *iter) { @@ -523,7 +548,7 @@ activated_cb (GtkTreeView *parent, GtkTreePath *path, { GtkTreeModel *model; GtkTreeIter iter; - GtkWidget *dialog, *label, *vbox, *hbox; + GtkWidget *dialog, *label, *help, *vbox, *hbox; MSymbol status; struct BindingWidgets bw; gchar *command; @@ -534,12 +559,30 @@ activated_cb (GtkTreeView *parent, GtkTreePath *path, gtk_tree_model_get (model, &iter, 0, &command, -1); current_command = msymbol (command); + /* dialog = (gtk_dialog_new_with_buttons (command, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (parent))), - GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, + GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL)); + */ + dialog = gtk_dialog_new (); + gtk_window_set_title (GTK_WINDOW (dialog), command); + 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); + gtk_button_box_set_layout (GTK_BUTTON_BOX (GTK_DIALOG (dialog)->action_area), + GTK_BUTTONBOX_EDGE); + + help = gtk_button_new_from_stock (GTK_STOCK_HELP); + g_signal_connect (G_OBJECT (help), "clicked", + G_CALLBACK (help_cb), &bw); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), + help, FALSE, FALSE, 0); + + gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, GTK_RESPONSE_OK); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), create_deleting_section (&bw)); diff --git a/src/variable.c b/src/variable.c index 8e1f524..313744c 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 \ @@ -23,6 +23,15 @@ (minput_get_variable \ (current_lang, current_name, current_variable)))))) +#define CURRENT_DESCRIPTION \ + (mtext_data \ + (mplist_value \ + (mplist_next \ + (mplist_value \ + (minput_get_variable \ + (current_lang, current_name, current_variable)))), \ + NULL, NULL, NULL, NULL)) + #define CONFIG_VARIABLE(plist) \ minput_config_variable (current_lang, current_name, current_variable, \ (plist)) @@ -57,9 +66,6 @@ struct ControllerInfo /* status label */ GtkWidget *status; - /* ok button */ - GtkWidget *ok; - /* dialog itself */ GtkWidget *dialog; }; @@ -191,7 +197,7 @@ config_with_entry (struct ControllerInfo *ci) GtkWidget *msg; msg = gtk_message_dialog_new (GTK_WINDOW - (gtk_widget_get_toplevel (ci->widget)), + (gtk_widget_get_toplevel (ci->dialog)), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, @@ -375,6 +381,8 @@ create_widget (struct ControllerInfo *ci) ci->widget = gtk_entry_new (); g_signal_connect (GTK_OBJECT (ci->widget), "changed", G_CALLBACK (changed_cb), ci); + g_signal_connect (GTK_OBJECT (ci->widget), "activate", + G_CALLBACK (ok_cb), ci); ci->wtype = ENTRY_WIDGET; gtk_entry_set_text (GTK_ENTRY (ci->widget), msymbol_name (value)); gtk_editable_set_editable (GTK_EDITABLE (ci->widget), TRUE); @@ -409,6 +417,8 @@ create_widget (struct ControllerInfo *ci) ci->widget = gtk_entry_new (); g_signal_connect (GTK_OBJECT (ci->widget), "changed", G_CALLBACK (changed_cb), ci); + g_signal_connect (GTK_OBJECT (ci->widget), "activate", + G_CALLBACK (ok_cb), ci); ci->wtype = ENTRY_WIDGET; /* Fixme : Assuming the return value is in UTF-8 */ gtk_entry_set_text (GTK_ENTRY (ci->widget), @@ -464,6 +474,8 @@ create_widget (struct ControllerInfo *ci) ci->widget = gtk_entry_new (); g_signal_connect (GTK_OBJECT (ci->widget), "changed", G_CALLBACK (changed_cb), ci); + g_signal_connect (GTK_OBJECT (ci->widget), "activate", + G_CALLBACK (ok_cb), ci); ci->wtype = ENTRY_WIDGET; g_snprintf (buf, sizeof (buf), "%d", (gint) value); gtk_entry_set_text (GTK_ENTRY (ci->widget), buf); @@ -473,14 +485,30 @@ create_widget (struct ControllerInfo *ci) return ci->widget; } + +static void * +help_cb (GtkButton *button, gpointer data) +{ + struct ControllerInfo *ci = data; + GtkWidget *msg; + + msg = gtk_message_dialog_new (GTK_WINDOW + (gtk_widget_get_toplevel (ci->dialog)), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_CLOSE, + CURRENT_DESCRIPTION); + gtk_dialog_run (GTK_DIALOG (msg)); + gtk_widget_destroy (msg); +} static void -activated_cb (GtkTreeView *parent, GtkTreePath *path, - GtkTreeViewColumn *col, gpointer data) +row_activated_cb (GtkTreeView *parent, GtkTreePath *path, + GtkTreeViewColumn *col, gpointer data) { GtkTreeModel *model; GtkTreeIter iter; - GtkWidget *label, *hbox, *vbox; + GtkWidget *label, *ok, *help, *hbox, *vbox; MSymbol status; struct ControllerInfo ci; gchar *variable; @@ -494,7 +522,7 @@ activated_cb (GtkTreeView *parent, GtkTreePath *path, ci.dialog = (gtk_dialog_new_with_buttons (variable, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (parent))), - GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, + GTK_DIALOG_DESTROY_WITH_PARENT, NULL)); ci.default_ = gtk_button_new_from_stock (_("_Default")); @@ -508,10 +536,14 @@ activated_cb (GtkTreeView *parent, GtkTreePath *path, 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", + ok = gtk_button_new_from_stock (GTK_STOCK_OK); + g_signal_connect (G_OBJECT (ok), "clicked", G_CALLBACK (ok_cb), &ci); + help = gtk_button_new_from_stock (GTK_STOCK_HELP); + g_signal_connect (G_OBJECT (help), "clicked", + G_CALLBACK (help_cb), &ci); + 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); @@ -519,7 +551,6 @@ activated_cb (GtkTreeView *parent, GtkTreePath *path, gtk_container_add (GTK_CONTAINER (vbox), create_widget (&ci)); 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.default_); gtk_container_add (GTK_CONTAINER (hbox), ci.revert); @@ -530,8 +561,13 @@ activated_cb (GtkTreeView *parent, GtkTreePath *path, gtk_box_pack_start (GTK_BOX (hbox), ci.status, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (vbox), hbox); + gtk_button_box_set_layout + (GTK_BUTTON_BOX (GTK_DIALOG (ci.dialog)->action_area), + GTK_BUTTONBOX_EDGE); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (ci.dialog)->action_area), + help); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (ci.dialog)->action_area), - ci.ok); + ok); status = CURRENT_STATUS; if (status == Mconfigured) @@ -641,6 +677,6 @@ create_variable_list (MSymbol lang, MSymbol name) VCOL_STATUS, NULL); g_signal_connect (G_OBJECT (view), "row-activated", - G_CALLBACK (activated_cb), NULL); + G_CALLBACK (row_activated_cb), NULL); return view; } -- 1.7.10.4