Move main_statusbar.h to the top-level directory; none of its routines
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 27 Nov 2010 21:50:49 +0000 (21:50 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 27 Nov 2010 21:50:49 +0000 (21:50 +0000)
use GTK+ data types, so, at least in theory, it could be implemented
atop another toolkit.

Make statusbar_push_temporary_msg() take a format string and format
arguments.  Use it instead of simple_status(), and change one call to
just take a format string and arguments rather than to take the result
of using that format string and arguments with g_strdup_printf() and
passing the result to statusbar_push_temporary_msg().

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35041 f5534014-38df-0310-8fa8-9805f1628bb7

13 files changed:
Makefile.common
file.c
gtk/Makefile.common
gtk/filter_dlg.c
gtk/find_dlg.c
gtk/main.c
gtk/main_packet_list.c
gtk/main_statusbar.c
gtk/menus.c
gtk/new_packet_list.c
gtk/simple_dialog.c
main_statusbar.h [moved from gtk/main_statusbar.h with 87% similarity]
simple_dialog.h

index 1840a24a819ea3a6ddf372bcefb005d8e1f75a90..e4345155b3aa46d0beb86f592eda4a19002d82a2 100644 (file)
@@ -167,6 +167,7 @@ wireshark_INCLUDES =        \
        g711.h  \
        globals.h       \
        log.h   \
+       main_statusbar.h        \
        merge.h \
        progress_dlg.h  \
        proto_hier_stats.h      \
diff --git a/file.c b/file.c
index 70fa701a87ae4b78b041bc1ebcbc12caeda7c6d6..c69e0ea51877738d14db5580992c228454b6d727 100644 (file)
--- a/file.c
+++ b/file.c
@@ -60,6 +60,7 @@
 #include "merge.h"
 #include "alert_box.h"
 #include "simple_dialog.h"
+#include "main_statusbar.h"
 #include "progress_dlg.h"
 #include "ui_util.h"
 #include <epan/prefs.h>
@@ -3931,12 +3932,12 @@ find_packet(capture_file *cf,
 
           if (prefs.gui_find_wrap)
           {
-              simple_status("Search reached the beginning. Continuing at end.");
+              statusbar_push_temporary_msg("Search reached the beginning. Continuing at end.");
               fdata = cf->plist_end;    /* wrap around */
           }
           else
           {
-              simple_status("Search reached the beginning.");
+              statusbar_push_temporary_msg("Search reached the beginning.");
               fdata = start_fd;        /* stay on previous packet */
           }
         }
@@ -3946,12 +3947,12 @@ find_packet(capture_file *cf,
         if (fdata == NULL) {
           if (prefs.gui_find_wrap)
           {
-              simple_status("Search reached the end. Continuing at beginning.");
+              statusbar_push_temporary_msg("Search reached the end. Continuing at beginning.");
               fdata = cf->plist_start;    /* wrap around */
           }
           else
           {
-              simple_status("Search reached the end.");
+              statusbar_push_temporary_msg("Search reached the end.");
               fdata = start_fd;     /* stay on previous packet */
           }
         }
@@ -4027,13 +4028,13 @@ cf_goto_frame(capture_file *cf, guint fnumber)
 
   if (fdata == NULL) {
     /* we didn't find a packet with that packet number */
-    simple_status("There is no packet number %u.", fnumber);
+    statusbar_push_temporary_msg("There is no packet number %u.", fnumber);
     return FALSE;   /* we failed to go to that packet */
   }
   if (!fdata->flags.passed_dfilter) {
     /* that packet currently isn't displayed */
     /* XXX - add it to the set of displayed packets? */
-    simple_status("Packet number %u isn't displayed.", fnumber);
+    statusbar_push_temporary_msg("Packet number %u isn't displayed.", fnumber);
     return FALSE;   /* we failed to go to that packet */
   }
 
index 26db07a527bbc3669fa1f8ebd78e5b1fe49ccf58..794a95530e38e7a4434bffd17a7c389909747ef9 100644 (file)
@@ -283,7 +283,6 @@ noinst_HEADERS = \
        menus.h         \
        main_packet_list.h      \
        main_proto_draw.h       \
-       main_statusbar.h                \
        main_statusbar_private.h        \
        main_toolbar.h  \
        main_welcome.h          \
index 5a3f0710455a28f3e0240d1af5b683d1711adadd..f9dcd166c04a25ae05e35eb6b27078ccbf2f5173 100644 (file)
@@ -36,9 +36,9 @@
 
 #include "../filters.h"
 #include "../simple_dialog.h"
+#include "../main_statusbar.h"
 
 #include "gtk/main.h"
-#include "gtk/main_statusbar.h"
 #include "gtk/filter_dlg.h"
 #include "gtk/dlg_utils.h"
 #include "gtk/gui_utils.h"
@@ -1351,10 +1351,8 @@ filter_te_syntax_check_cb(GtkWidget *w, gpointer user_data _U_)
                  * We're being lazy and only printing the first "problem" token.
                  * Would it be better to print all of them?
                  */
-                msg = g_strdup_printf(" \"%s\" may have unexpected results (see the User's Guide)",
+                statusbar_push_temporary_msg(" \"%s\" may have unexpected results (see the User's Guide)",
                                       (const char *) g_ptr_array_index(depr, 0));
-                statusbar_push_temporary_msg(msg);
-                g_free(msg);
             }
         } else {
             colorize_filter_te_as_valid(w);
index 8b3b7a80f1135fcdb4ce8d65b99eb034cb18f4c8..713186f4c84b4d25feb0d96d820ed8414cdce010 100644 (file)
@@ -39,6 +39,7 @@
 #include "../globals.h"
 #include "../alert_box.h"
 #include "../simple_dialog.h"
+#include "../main_statusbar.h"
 
 #include "gtk/gui_utils.h"
 #include "gtk/find_dlg.h"
@@ -590,7 +591,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
      */
     bytes = convert_string_to_hex(filter_text, &nbytes);
     if (bytes == NULL) {
-      simple_status("That's not a valid hex string.");
+      statusbar_push_temporary_msg("That's not a valid hex string.");
       return;
     }
   } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (string_rb))) {
@@ -599,7 +600,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
      * Make sure we're searching for something, first.
      */
     if (strcmp(filter_text, "") == 0) {
-      simple_status("You didn't specify any text for which to search.");
+      statusbar_push_temporary_msg("You didn't specify any text for which to search.");
       return;
     }
 
@@ -613,7 +614,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
     else if (string_type == SCS_UNICODE)
       scs_type = SCS_UNICODE;
     else {
-      simple_status("You didn't choose a valid character set.");
+      statusbar_push_temporary_msg("You didn't choose a valid character set.");
       return;
     }
     string = convert_string_case(filter_text, case_type);
@@ -630,7 +631,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
     /* Was it empty? */
     if (sfcode == NULL) {
       /* Yes - complain. */
-      simple_status("That filter doesn't test anything.");
+      statusbar_push_temporary_msg("That filter doesn't test anything.");
       return;
     }
   }
@@ -653,7 +654,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
     g_free(bytes);
     if (!found_packet) {
       /* We didn't find a packet */
-      simple_status("No packet contained those bytes.");
+      statusbar_push_temporary_msg("No packet contained those bytes.");
       return;
     }
   } else if (cfile.string) {
@@ -666,7 +667,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
       }
       if (!found_packet) {
         /* We didn't find the packet. */
-        simple_status("No packet contained that string in its dissected display.");
+        statusbar_push_temporary_msg("No packet contained that string in its dissected display.");
         return;
       }
     } else if (cfile.summary_data) {
@@ -692,7 +693,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
       }
       if (!found_packet) {
         /* We didn't find the packet. */
-        simple_status("No packet contained that string in its data.");
+        statusbar_push_temporary_msg("No packet contained that string in its data.");
         return;
       }
     }
@@ -701,7 +702,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
     dfilter_free(sfcode);
     if (!found_packet) {
       /* We didn't find a packet */
-      simple_status("No packet matched that filter.");
+      statusbar_push_temporary_msg("No packet matched that filter.");
       g_free(bytes);
       return;
     }
index 9592955fc934c946c29e2e2d71ca55d0fe6d1d45..367f249e34a9bd2cbaab8bee9d6549c891d16b99 100644 (file)
@@ -92,6 +92,7 @@
 #include "../color_filters.h"
 #include "../print.h"
 #include "../simple_dialog.h"
+#include "../main_statusbar.h"
 #include "../register.h"
 #include "../ringbuffer.h"
 #include "../ui_util.h"
 #include "gtk/menus.h"
 #include "gtk/macros_dlg.h"
 #include "gtk/main_packet_list.h"
-#include "gtk/main_statusbar.h"
 #include "gtk/main_statusbar_private.h"
 #include "gtk/main_toolbar.h"
 #include "gtk/main_welcome.h"
index fae0a0fd0deedd340b6f78f97f0c9111a3f58124..4c451340480d0d7f93b1eba0cc81ad268e539287 100644 (file)
@@ -44,6 +44,7 @@
 #include "../color_filters.h"
 #include "../ui_util.h"
 #include "../progress_dlg.h"
+#include "../main_statusbar.h"
 
 #include "gtk/gtkglobals.h"
 #include "gtk/gui_utils.h"
@@ -56,7 +57,6 @@
 #include "gtk/main.h"
 #include "gtk/menus.h"
 #include "gtk/main_packet_list.h"
-#include "gtk/main_statusbar.h"
 #include "gtk/packet_win.h"
 #include "gtk/prefs_column.h"
 #include "gtk/prefs_dlg.h"
index 5a55c4e726967fd65575584ca9eb977c43e3fb21..eae9b22b204fbe78fd03818681340cff411003fc 100644 (file)
@@ -48,7 +48,6 @@
 
 #include "gtk/recent.h"
 #include "gtk/main.h"
-#include "gtk/main_statusbar.h"
 #include "gtk/main_statusbar_private.h"
 #include "gtk/gui_utils.h"
 #include "gtk/gtkglobals.h"
@@ -59,6 +58,8 @@
 #include "gtk/keys.h"
 #include "gtk/menus.h"
 
+#include "main_statusbar.h"
+
 /*
  * The order below defines the priority of info bar contexts.
  */
@@ -231,14 +232,21 @@ statusbar_flash_temporary_msg(gpointer data _U_)
 }
 
 /*
- * Push a temporary message onto the statusbar.
+ * Push a formatted temporary message onto the statusbar.
  */
 void
-statusbar_push_temporary_msg(const gchar *msg)
+statusbar_push_temporary_msg(const gchar *msg_format, ...)
 {
+    va_list ap;
+    gchar *msg;
     guint msg_id;
 
+    va_start(ap, msg_format);
+    msg = g_strdup_vprintf(msg_format, ap);
+    va_end(ap);
+
     msg_id = gtk_statusbar_push(GTK_STATUSBAR(info_bar), main_ctx, msg);
+    g_free(msg);
 
     flash_time = TEMPORARY_FLASH_TIMEOUT - 1;
     g_timeout_add(TEMPORARY_FLASH_INTERVAL, statusbar_flash_temporary_msg, NULL);
index a2b47eea227bfe2d164d974c968b751231db3be5..cc5608d8bdc5d5108bcb72c79657d16acf1cfdcc 100644 (file)
@@ -48,6 +48,7 @@
 #include "../print.h"
 #include "../ui_util.h"
 #include "../simple_dialog.h"
+#include "../main_statusbar.h"
 #include "../color_filters.h"
 #include "../stat_menu.h"
 
@@ -456,14 +457,14 @@ goto_conversation_frame(gboolean dir)
         if( filter == NULL )
             filter = build_conversation_filter(CONV_IP,FALSE);
         if( filter == NULL ) {
-           simple_status("Unable to build conversation filter.");
+           statusbar_push_temporary_msg("Unable to build conversation filter.");
             g_free(filter);
             return;
         }
 
         if (!dfilter_compile(filter, &dfcode)) {
             /* The attempt failed; report an error. */
-            simple_status("Error compiling filter for this conversation.");
+            statusbar_push_temporary_msg("Error compiling filter for this conversation.");
             g_free(filter);
             return;
         }
@@ -472,7 +473,7 @@ goto_conversation_frame(gboolean dir)
 
         if (!found_packet) {
             /* We didn't find a packet */
-            simple_status("No previous/next packet in conversation.");
+            statusbar_push_temporary_msg("No previous/next packet in conversation.");
         }
 
         dfilter_free(dfcode);
index 29ac396bb22af863ebec1b2a352c6ab665f5e7ca..1e02768e6436c4420642f5e53b1aef6ab5592153 100644 (file)
@@ -47,6 +47,7 @@
 #include "../ui_util.h"
 #include "../progress_dlg.h"
 #include "../simple_dialog.h"
+#include "../main_statusbar.h"
 #include "epan/emem.h"
 #include "globals.h"
 #include "gtk/gtkglobals.h"
@@ -61,7 +62,6 @@
 #include "color_filters.h"
 #include "gtk/color_utils.h"
 #include "gtk/capture_file_dlg.h"
-#include "gtk/main_statusbar.h"
 #include "gtk/packet_win.h"
 #include "gtk/main.h"
 #include "gtk/prefs_column.h"
index ba1aaacd3399afe0211914bbc42abc2a3a953eda..ff7d28343a03eb1da0829c968d073c79fc2b0f43 100644 (file)
@@ -38,8 +38,6 @@
 #include "gtk/gui_utils.h"
 #include "gtk/stock_icons.h"
 
-#include "main_statusbar.h"
-
 static void simple_dialog_cancel_cb(GtkWidget *, gpointer);
 
 #define CALLBACK_FCT_KEY    "ESD_Callback_Fct"
@@ -415,21 +413,3 @@ simple_dialog_format_message(const char *msg)
     }
     return str;
 }
-
-/*
- * This doesn't create a window, but it falls into the realm of "telling the
- * user what happened" and having it here means it can be called from file.c.
- */
-void
-simple_status(const gchar *msg_format, ...)
-{
-    va_list ap;
-    gchar *msg;
-
-    va_start(ap, msg_format);
-    msg = g_strdup_vprintf(msg_format, ap);
-    va_end(ap);
-
-    statusbar_push_temporary_msg(msg);
-    g_free(msg);
-}
similarity index 87%
rename from gtk/main_statusbar.h
rename to main_statusbar.h
index 119a6fdb2693e4a2a445c7db762ff28cee77443f..6bf4d7ba7e924bfd69f05ac7daa8939b0069c8ef 100644 (file)
@@ -49,11 +49,11 @@ void statusbar_push_filter_msg(const gchar *msg);
  */
 void statusbar_pop_filter_msg(void);
 
-/** Push a temporary message onto the statusbar. The message is automatically
- * removed at a later interval.
+/** Push a formatted temporary message onto the statusbar. The message
+ * is automatically removed at a later interval.
  *
- * @param msg The message
+ * @param msg_format The format string for the message
  */
-void statusbar_push_temporary_msg(const gchar *msg);
+void statusbar_push_temporary_msg(const gchar *msg_format, ...);
 
 #endif /* __MAIN_STATUSBAR_H__ */
index 87f66791f7cf9fd6051105d5ea26d9b458f22fc9..40258cadb7cf3f404448d0144501638d2a67f859 100644 (file)
@@ -159,15 +159,6 @@ extern char *simple_dialog_format_message(const char *msg);
  */
 extern void display_queued_messages(void);
 
-/** Show a message in the status bar.
- *
- * @param msg_format Status message
- */
-extern void simple_status(const gchar *msg_format, ...)
-    G_GNUC_PRINTF(1, 2);
-
-
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */