aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/toolbar.c
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2007-12-10 03:27:40 +0000
committerBill Meier <wmeier@newsguy.com>2007-12-10 03:27:40 +0000
commitdf4f2f604e19a073ed82788653da6bf44a01d59a (patch)
tree5e833c1138b111d0dd2ffdb876bbd8e3b4dab609 /gtk/toolbar.c
parentb7d8f269b22f18e363a9e714f5009be4a7ab2601 (diff)
Fix Bug #2055: "File Save not working properly";
Change SVN #23487 patch to not use signal_connect each time the the function of the save button is changed since that results in multiple callbacks attached to the save button. Intead: associate data with the save button which species its current function. (It sure would be nice if the original problem causing the blank spot on the toolbar could be resolved; the work-around is starting to get messy). svn path=/trunk/; revision=23821
Diffstat (limited to 'gtk/toolbar.c')
-rw-r--r--gtk/toolbar.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/gtk/toolbar.c b/gtk/toolbar.c
index 963e5b0c45..45dc7fe93b 100644
--- a/gtk/toolbar.c
+++ b/gtk/toolbar.c
@@ -381,8 +381,7 @@ void set_toolbar_for_unsaved_capture_file(gboolean have_unsaved_capture_file) {
GTK_STOCK_SAVE);
gtk_tool_item_set_tooltip(save_button, tooltips,
SAVE_BUTTON_TOOLTIP_TEXT, NULL);
- g_signal_connect(save_button, "clicked",
- G_CALLBACK(file_save_cmd_cb), NULL);
+ OBJECT_SET_DATA(save_button, "save", (gpointer)TRUE);
#else /* GTK_CHECK_VERSION(2,4,0) */
gtk_widget_hide(GTK_WIDGET(save_as_button));
gtk_widget_show(GTK_WIDGET(save_button));
@@ -393,8 +392,7 @@ void set_toolbar_for_unsaved_capture_file(gboolean have_unsaved_capture_file) {
GTK_STOCK_SAVE_AS);
gtk_tool_item_set_tooltip(save_button, tooltips,
SAVE_AS_BUTTON_TOOLTIP_TEXT, NULL);
- g_signal_connect(save_button, "clicked",
- G_CALLBACK(file_save_as_cmd_cb), NULL);
+ OBJECT_SET_DATA(save_button, "save", (gpointer)FALSE);
#else /* GTK_CHECK_VERSION(2,4,0) */
gtk_widget_show(GTK_WIDGET(save_as_button));
gtk_widget_hide(GTK_WIDGET(save_button));
@@ -405,6 +403,19 @@ void set_toolbar_for_unsaved_capture_file(gboolean have_unsaved_capture_file) {
}
}
+/* fudge to call correct file_save or file_save_as fcn based upon the
+ value of the "save" key associated with the save button
+*/
+
+static void file_save_or_save_as_cmd_cb(GtkWidget *w, gpointer data) {
+ if ((gboolean)OBJECT_GET_DATA(save_button,"save")) {
+ file_save_cmd_cb(w, data);
+ }
+ else {
+ file_save_as_cmd_cb(w, data);
+ }
+}
+
/** The packet history has changed, we need to update the menu.
*
@@ -681,14 +692,23 @@ toolbar_new(void)
toolbar_item(open_button, window, main_tb,
GTK_STOCK_OPEN, tooltips, "Open a capture file...", stock_open_24_xpm, file_open_cmd_cb, NULL);
- toolbar_item(save_button, window, main_tb,
- GTK_STOCK_SAVE, tooltips, SAVE_BUTTON_TOOLTIP_TEXT, stock_save_24_xpm, file_save_cmd_cb, NULL);
-
/* Only create a separate button in GTK < 2.4. With GTK 2.4+, we will
- * just modify the save_button to read/show save or save as as needed. */
+ * just modify the save_button to read/show save or save as as needed.
+ * We'll also fudge in an object key ("save") for the save button with data which specifies
+ * whether the button is currently "save" (TRUE)or "save as" (FALSE).
+ * The fcn file_save_or_save_as_cmd_cb
+ * will then call the appropriate file_save_cmd_cb or file_save_as_cmd_cb
+ */
+
#if !GTK_CHECK_VERSION(2,4,0)
+ toolbar_item(save_button, window, main_tb,
+ GTK_STOCK_SAVE, tooltips, SAVE_BUTTON_TOOLTIP_TEXT, stock_save_24_xpm, file_save_cmd_cb, NULL);
toolbar_item(save_as_button, window, main_tb,
GTK_STOCK_SAVE_AS, tooltips, SAVE_AS_BUTTON_TOOLTIP_TEXT, stock_save_as_24_xpm, file_save_as_cmd_cb, NULL);
+#else
+ toolbar_item(save_button, window, main_tb,
+ GTK_STOCK_SAVE, tooltips, SAVE_BUTTON_TOOLTIP_TEXT, stock_save_24_xpm, file_save_or_save_as_cmd_cb, NULL);
+ OBJECT_SET_DATA(save_button, "save", (gpointer)TRUE);
#endif
toolbar_item(close_button, window, main_tb,