Add the ability to push and pop messages in to and out of the welcome
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 29 Apr 2009 22:42:33 +0000 (22:42 +0000)
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 29 Apr 2009 22:42:33 +0000 (22:42 +0000)
screen header, similar to the status bar. Hide the welcome body if the
message stack length is > 0.  Use this to display the "Waiting for
capture input data..." message when we're capturing from a pipe. This
lets the user know what's going on and keeps them from clicking on a
welcome screen item while we're waiting for data to arrive.  You can see
this in action by running

   (sleep 5; cat /path/to/a/capture) | wireshark -k -i -

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

gtk/main_statusbar.c
gtk/main_welcome.c
gtk/main_welcome.h

index def851b0dcc162d2c9aa4343ac9e911cfc95d907..a29b327f69046025095edf8144f96ef61ff8b2eb 100644 (file)
@@ -54,6 +54,7 @@
 #include "gtk/gtkglobals.h"
 #include "gtk/expert_comp_dlg.h"
 #include "gtk/profile_dlg.h"
 #include "gtk/gtkglobals.h"
 #include "gtk/expert_comp_dlg.h"
 #include "gtk/profile_dlg.h"
+#include "gtk/main_welcome.h"
 
 #include "../image/expert_error.xpm"
 #include "../image/expert_warn.xpm"
 
 #include "../image/expert_error.xpm"
 #include "../image/expert_warn.xpm"
@@ -571,7 +572,9 @@ statusbar_cf_file_read_finished_cb(capture_file *cf)
 static void
 statusbar_capture_prepared_cb(capture_options *capture_opts _U_)
 {
 static void
 statusbar_capture_prepared_cb(capture_options *capture_opts _U_)
 {
-    statusbar_push_file_msg(" Waiting for capture input data ...");
+    gchar *msg = " Waiting for capture input data ...";
+    statusbar_push_file_msg(msg);
+    welcome_header_push_msg(msg);
 }
 
 static void
 }
 
 static void
@@ -581,6 +584,7 @@ statusbar_capture_update_started_cb(capture_options *capture_opts)
 
 
     statusbar_pop_file_msg();
 
 
     statusbar_pop_file_msg();
+    welcome_header_pop_msg();
 
     if(capture_opts->iface) {
         capture_msg = g_strdup_printf(" %s: <live capture in progress> to file: %s",
 
     if(capture_opts->iface) {
         capture_msg = g_strdup_printf(" %s: <live capture in progress> to file: %s",
index be34643c90c9149234e55b1cae3dd0b7e3467fe2..c48eb6863d37bf60577b4056f521bbd60800d0d0 100644 (file)
@@ -67,7 +67,8 @@
 /* XXX */
 extern gint if_list_comparator_alph (const void *first_arg, const void *second_arg);
 
 /* XXX */
 extern gint if_list_comparator_alph (const void *first_arg, const void *second_arg);
 
-
+static GtkWidget *welcome_hb = NULL;
+static GtkWidget *header_lb = NULL;
 static GdkColor header_bar_bg;
 static GdkColor topic_header_bg;
 static GdkColor topic_content_bg;
 static GdkColor header_bar_bg;
 static GdkColor topic_header_bg;
 static GdkColor topic_content_bg;
@@ -79,6 +80,7 @@ static GtkWidget *welcome_file_panel_vb = NULL;
 static GtkWidget *welcome_if_panel_vb = NULL;
 #endif
 
 static GtkWidget *welcome_if_panel_vb = NULL;
 #endif
 
+static GSList *status_messages = NULL;
 
 /* The "scroll box dynamic" is a (complicated) pseudo widget to */
 /* place a vertically list of widgets in (currently the interfaces and recent files). */
 
 /* The "scroll box dynamic" is a (complicated) pseudo widget to */
 /* place a vertically list of widgets in (currently the interfaces and recent files). */
@@ -245,6 +247,34 @@ welcome_button(const gchar *stock_item,
     return eb;
 }
 
     return eb;
 }
 
+static void
+welcome_header_set_message(gchar *msg) {
+    GString *message;
+    time_t secs = time(NULL);
+    struct tm *now = localtime(&secs);
+    
+    message = g_string_new("<span weight=\"bold\" size=\"x-large\" foreground=\"black\">");
+    
+    if (msg) {
+       g_string_append(message, msg);
+    } else { /* Use our default header */
+       if ((now->tm_mon == 3 && now->tm_mday == 1) || (now->tm_mon == 6 && now->tm_mday == 14)) {
+           g_string_append(message, "Sniffing the glue that holds the Internet together");
+       } else {
+           g_string_append(message, prefs.gui_start_title);
+       }
+    
+       if (prefs.gui_version_in_start_page) {
+           g_string_append_printf(message, "</span>\n<span size=\"large\" foreground=\"black\">Version " VERSION "%s",
+                                  wireshark_svnversion);
+       }
+    }
+
+    g_string_append(message, "</span>");
+
+    gtk_label_set_markup(GTK_LABEL(header_lb), message->str);
+    g_string_free(message, TRUE);
+}
 
 /* create the banner "above our heads" */
 static GtkWidget *
 
 /* create the banner "above our heads" */
 static GtkWidget *
@@ -254,10 +284,6 @@ welcome_header_new(void)
     GtkWidget *item_hb;
     GtkWidget *eb;
     GtkWidget *icon;
     GtkWidget *item_hb;
     GtkWidget *eb;
     GtkWidget *icon;
-    GString *message;
-    GtkWidget *w;
-    time_t secs = time(NULL);
-    struct tm *now = localtime(&secs);
 
     item_vb = gtk_vbox_new(FALSE, 0);
 
 
     item_vb = gtk_vbox_new(FALSE, 0);
 
@@ -272,30 +298,46 @@ welcome_header_new(void)
     icon = xpm_to_widget_from_parent(top_level, wssplash_xpm);
     gtk_box_pack_start(GTK_BOX(item_hb), icon, FALSE, FALSE, 10);
 
     icon = xpm_to_widget_from_parent(top_level, wssplash_xpm);
     gtk_box_pack_start(GTK_BOX(item_hb), icon, FALSE, FALSE, 10);
 
-    message = g_string_new("<span weight=\"bold\" size=\"x-large\" foreground=\"black\">");
-    if ((now->tm_mon == 3 && now->tm_mday == 1) || (now->tm_mon == 6 && now->tm_mday == 14)) {
-        g_string_append(message, "Sniffing the glue that holds the Internet together");
-    } else {
-        g_string_append(message, prefs.gui_start_title);
-    }
-    g_string_append(message, "</span>");
-
-    if (prefs.gui_version_in_start_page) {
-        g_string_append_printf(message, "\n<span size=\"large\" foreground=\"black\">Version " VERSION "%s</span>",
-                               wireshark_svnversion);
-    }
-
-    w = gtk_label_new(message->str);
-    gtk_label_set_markup(GTK_LABEL(w), message->str);
-    g_string_free(message, TRUE);
-    gtk_misc_set_alignment (GTK_MISC(w), 0.0f, 0.5f);
-    gtk_box_pack_start(GTK_BOX(item_hb), w, TRUE, TRUE, 5);
+    header_lb = gtk_label_new(NULL);
+    welcome_header_set_message(NULL);
+    gtk_misc_set_alignment (GTK_MISC(header_lb), 0.0f, 0.5f);
+    gtk_box_pack_start(GTK_BOX(item_hb), header_lb, TRUE, TRUE, 5);
 
     gtk_widget_show_all(eb);
 
     return eb;
 }
 
 
     gtk_widget_show_all(eb);
 
     return eb;
 }
 
+void
+welcome_header_push_msg(gchar *msg) {
+    gchar *msg_copy = g_strdup(msg);
+    
+    status_messages = g_slist_append(status_messages, msg_copy);
+    
+    welcome_header_set_message(msg_copy);
+    
+    gtk_widget_hide(welcome_hb);
+}
+
+void
+welcome_header_pop_msg() {
+    gchar *msg = NULL;    
+
+    if (status_messages) {
+       g_free(status_messages->data);
+        status_messages = g_slist_delete_link(status_messages, status_messages);
+    }
+    
+    if (status_messages) {
+       msg = status_messages->data;
+    }
+
+    welcome_header_set_message(msg);
+    
+    if (!status_messages) {
+        gtk_widget_show(welcome_hb);
+    }
+}
 
 /* create a "topic header widget" */
 static GtkWidget *
 
 /* create a "topic header widget" */
 static GtkWidget *
@@ -643,7 +685,6 @@ welcome_new(void)
 {
     GtkWidget *welcome_scrollw;
     GtkWidget *welcome_vb;
 {
     GtkWidget *welcome_scrollw;
     GtkWidget *welcome_vb;
-    GtkWidget *welcome_hb;
     GtkWidget *column_vb;
     GtkWidget *item_hb;
     GtkWidget *w;
     GtkWidget *column_vb;
     GtkWidget *item_hb;
     GtkWidget *w;
index b646428465bd94eb7aca4c06eac0314f6766209c..f8894690951cfdbf6113e15555028d5b09cd0c23 100644 (file)
@@ -37,5 +37,19 @@ void main_welcome_add_recent_capture_files(const char *widget_cf_name);
 /* reload the list of interfaces */
 void welcome_if_panel_reload(void);
 
 /* reload the list of interfaces */
 void welcome_if_panel_reload(void);
 
+/** Push a status message into the welcome screen header similar to
+ *  statusbar_push_*_msg(). This hides everything under the header.
+ *  If msg is dynamically allocated, it is up to the caller to free
+ *  it. If msg is NULL, the default message will be shown.
+ *
+ * @param msg The message
+ */
+void welcome_header_push_msg(gchar *msg);
+
+/** Pop a status message from the welcome screen. If there are no
+ *  messages on the stack, the default message and the main columns
+ *  will be shown.
+ */
+void welcome_header_pop_msg();
 
 #endif /* __MAIN_WELCOME_H__ */
 
 #endif /* __MAIN_WELCOME_H__ */