Make sure that the Capture/Start menue item will always use the
[obnox/wireshark/wip.git] / gtk / main_welcome.c
index c457da3d905d766228902fd1670a3377a87325e6..c1d19e33d042f9012d6d0eab35ada052fe7b7e4a 100644 (file)
@@ -96,6 +96,10 @@ static GtkWidget *if_view = NULL;
 
 static GSList *status_messages = NULL;
 
+#ifdef USE_THREADS
+static GMutex *recent_mtx = NULL;
+#endif
+
 /* The "scroll box dynamic" is a (complicated) pseudo widget to */
 /* place a vertically list of widgets in (currently the interfaces and recent files). */
 /* Once this list get's higher than a specified amount, */
@@ -329,7 +333,8 @@ welcome_header_new(void)
 
     header_lb = gtk_label_new(NULL);
     welcome_header_set_message(NULL);
-    gtk_misc_set_alignment (GTK_MISC(header_lb), 0.0f, 0.5f);
+    gtk_label_set_selectable(GTK_LABEL(header_lb), TRUE);
+    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);
@@ -432,10 +437,137 @@ welcome_filename_link_press_cb(GtkWidget *widget _U_, GdkEventButton *event _U_,
     return FALSE;
 }
 
+typedef struct _recent_item_status {
+    gchar     *filename;
+    GtkWidget *label;
+    GObject   *menu_item;
+    GString   *str;
+    gboolean   stat_done;
+    int        err;
+    guint      timer;
+} recent_item_status;
+
+/*
+ * Fetch the status of a file.
+ * This function might be called as a thread. We can't use any drawing
+ * routines here: http://developer.gnome.org/gdk/2.24/gdk-Threads.html
+ */
+static void *get_recent_item_status(void *data)
+{
+    recent_item_status *ri_stat = (recent_item_status *) data;
+    ws_statb64 stat_buf;
+    int err;
+
+    if (!ri_stat) {
+        return NULL;
+    }
+
+    /*
+     * Add file size. We use binary prefixes instead of IEC because that's what
+     * most OSes use.
+     */
+    err = ws_stat64(ri_stat->filename, &stat_buf);
+#ifdef USE_THREADS
+    g_mutex_lock(recent_mtx);
+#endif
+    ri_stat->err = err;
+    if(err == 0) {
+        if (stat_buf.st_size/1024/1024/1024 > 10) {
+            g_string_append_printf(ri_stat->str, " (%" G_GINT64_MODIFIER "d GB)", (gint64) (stat_buf.st_size/1024/1024/1024));
+        } else if (stat_buf.st_size/1024/1024 > 10) {
+            g_string_append_printf(ri_stat->str, " (%" G_GINT64_MODIFIER "d MB)", (gint64) (stat_buf.st_size/1024/1024));
+        } else if (stat_buf.st_size/1024 > 10) {
+            g_string_append_printf(ri_stat->str, " (%" G_GINT64_MODIFIER "d KB)", (gint64) (stat_buf.st_size/1024));
+        } else {
+            g_string_append_printf(ri_stat->str, " (%" G_GINT64_MODIFIER "d Bytes)", (gint64) (stat_buf.st_size));
+        }
+        /* pango format string */
+        g_string_prepend(ri_stat->str, "<span foreground='blue'>");
+        g_string_append(ri_stat->str, "</span>");
+    } else {
+        g_string_append(ri_stat->str, " [not found]");
+    }
+
+    if (!ri_stat->label) { /* The widget went away while we were busy. */
+       g_free(ri_stat->filename);
+       g_string_free(ri_stat->str, TRUE);
+       g_free(ri_stat);
+    } else {
+        ri_stat->stat_done = TRUE;
+    }
+#ifdef USE_THREADS
+    g_mutex_unlock(recent_mtx);
+#endif
+
+    return NULL;
+}
+
+/* Timeout callback for recent items */
+static gboolean
+update_recent_items(gpointer data)
+{
+    recent_item_status *ri_stat = (recent_item_status *) data;
+    gboolean again = TRUE;
+
+    if (!ri_stat) {
+        return FALSE;
+    }
+
+#ifdef USE_THREADS
+    g_mutex_lock(recent_mtx);
+#endif
+    if (ri_stat->stat_done) {
+        again = FALSE;
+        gtk_label_set_markup(GTK_LABEL(ri_stat->label), ri_stat->str->str);
+       if (ri_stat->err == 0) {
+           gtk_widget_set_sensitive(ri_stat->label, TRUE);
+#ifdef MAIN_MENU_USE_UIMANAGER
+           gtk_action_set_sensitive((GtkAction *) ri_stat->menu_item, TRUE);
+#else
+           gtk_widget_set_sensitive(GTK_WIDGET(ri_stat->menu_item), TRUE);
+#endif
+       }
+        ri_stat->timer = 0;
+    }
+    /* Else append some sort of Unicode or ASCII animation to the label? */
+#ifdef USE_THREADS
+    g_mutex_unlock(recent_mtx);
+#endif
+    return again;
+}
+
+static void welcome_filename_destroy_cb(GtkWidget *w _U_, gpointer data) {
+    recent_item_status *ri_stat = (recent_item_status *) data;
+
+    if (!ri_stat) {
+       return;
+    }
+
+#ifdef USE_THREADS
+    g_mutex_lock(recent_mtx);
+#endif
+    if (ri_stat->timer) {
+       g_source_remove(ri_stat->timer);
+       ri_stat->timer = 0;
+    }
+
+    g_object_unref(ri_stat->menu_item);
+
+    if (ri_stat->stat_done) {
+       g_free(ri_stat->filename);
+       g_string_free(ri_stat->str, TRUE);
+       g_free(ri_stat);
+    } else {
+        ri_stat->label = NULL;
+    }
+#ifdef USE_THREADS
+    g_mutex_unlock(recent_mtx);
+#endif
+}
 
 /* create a "file link widget" */
 static GtkWidget *
-welcome_filename_link_new(const gchar *filename, GtkWidget **label)
+welcome_filename_link_new(const gchar *filename, GtkWidget **label, GObject *menu_item)
 {
     GtkWidget   *w;
     GtkWidget   *eb;
@@ -444,10 +576,9 @@ welcome_filename_link_new(const gchar *filename, GtkWidget **label)
     glong        uni_len;
     gsize        uni_start, uni_end;
     const glong  max = 60;
-    int          err;
-    ws_statb64   stat_buf;
+    recent_item_status *ri_stat;
 
-       /* filename */
+    /* filename */
     str = g_string_new(filename);
     uni_len = g_utf8_strlen(str->str, str->len);
 
@@ -462,54 +593,43 @@ welcome_filename_link_new(const gchar *filename, GtkWidget **label)
     /* escape the possibly shortened filename before adding pango language */
     str_escaped=g_markup_escape_text(str->str, -1);
     g_string_free(str, TRUE);
-    str=g_string_new(str_escaped);
-    g_free(str_escaped);
-
-    /*
-     * Add file size. We use binary prefixes instead of IEC because that's what
-     * most OSes use.
-     */
-    err = ws_stat64(filename, &stat_buf);
-    if(err == 0) {
-        if (stat_buf.st_size/1024/1024/1024 > 10) {
-            g_string_append_printf(str, " (%" G_GINT64_MODIFIER "d GB)", (gint64) (stat_buf.st_size/1024/1024/1024));
-        } else if (stat_buf.st_size/1024/1024 > 10) {
-            g_string_append_printf(str, " (%" G_GINT64_MODIFIER "d MB)", (gint64) (stat_buf.st_size/1024/1024));
-        } else if (stat_buf.st_size/1024 > 10) {
-            g_string_append_printf(str, " (%" G_GINT64_MODIFIER "d KB)", (gint64) (stat_buf.st_size/1024));
-        } else {
-            g_string_append_printf(str, " (%" G_GINT64_MODIFIER "d Bytes)", (gint64) (stat_buf.st_size));
-        }
-    } else {
-        g_string_append(str, " [not found]");
-    }
-
-    /* pango format string */
-    if(err == 0) {
-        g_string_prepend(str, "<span foreground='blue'>");
-        g_string_append(str, "</span>");
-    }
 
     /* label */
-    w = gtk_label_new(str->str);
+    w = gtk_label_new(str_escaped);
     *label = w;
-    gtk_label_set_markup(GTK_LABEL(w), str->str);
     gtk_misc_set_padding(GTK_MISC(w), 5, 2);
+    gtk_misc_set_alignment (GTK_MISC(w), 0.0f, 0.0f);
+    gtk_widget_set_sensitive(w, FALSE);
+
+    ri_stat = g_malloc(sizeof(recent_item_status));
+    ri_stat->filename = g_strdup(filename);
+    ri_stat->label = w;
+    ri_stat->menu_item = menu_item;
+    ri_stat->str = g_string_new(str_escaped);
+    ri_stat->stat_done = FALSE;
+    ri_stat->timer = 0;
+    g_object_ref(G_OBJECT(menu_item));
+    g_signal_connect(w, "destroy", G_CALLBACK(welcome_filename_destroy_cb), ri_stat);
+    g_free(str_escaped);
+
+#ifdef USE_THREADS
+    g_thread_create(get_recent_item_status, ri_stat, FALSE, NULL);
+    ri_stat->timer = g_timeout_add(200, update_recent_items, ri_stat);
+#else
+    get_recent_item_status(ri_stat);
+    update_recent_items(ri_stat);
+#endif
 
     /* event box */
     eb = gtk_event_box_new();
+    gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_item_idle_bg);
     gtk_container_add(GTK_CONTAINER(eb), w);
-       gtk_widget_set_tooltip_text(eb, filename);
-       if(err != 0) {
-        gtk_widget_set_sensitive(w, FALSE);
-    }
+    gtk_widget_set_tooltip_text(eb, filename);
 
     g_signal_connect(eb, "enter-notify-event", G_CALLBACK(welcome_item_enter_cb), w);
     g_signal_connect(eb, "leave-notify-event", G_CALLBACK(welcome_item_leave_cb), w);
     g_signal_connect(eb, "button-press-event", G_CALLBACK(welcome_filename_link_press_cb), (gchar *) filename);
 
-    g_string_free(str, TRUE);
-
     return eb;
 }
 
@@ -540,16 +660,14 @@ main_welcome_reset_recent_capture_files(void)
 
 /* add a new file to the list of recent files */
 void
-main_welcome_add_recent_capture_files(const char *widget_cf_name)
+main_welcome_add_recent_capture_file(const char *widget_cf_name, GObject *menu_item)
 {
     GtkWidget *w;
     GtkWidget *child_box;
     GtkWidget *label;
 
 
-    w = welcome_filename_link_new(widget_cf_name, &label);
-    gtk_widget_modify_bg(w, GTK_STATE_NORMAL, &topic_item_idle_bg);
-    gtk_misc_set_alignment (GTK_MISC(label), 0.0f, 0.0f);
+    w = welcome_filename_link_new(widget_cf_name, &label, menu_item);
     child_box = scroll_box_dynamic_add(welcome_file_panel_vb);
     gtk_box_pack_start(GTK_BOX(child_box), w, FALSE, FALSE, 0);
     gtk_widget_show_all(w);
@@ -564,21 +682,109 @@ static gboolean select_current_ifaces(GtkTreeModel  *model,
 {
     guint i;
     gchar *if_name;
-    
+    gboolean found = FALSE;
+
     GtkTreeSelection *selection = (GtkTreeSelection *)userdata;
-    gtk_tree_model_get (model, iter, 2, &if_name, -1);
-    if (global_capture_opts.ifaces->len > 0) {
-        for (i = 0; i < global_capture_opts.ifaces->len; i++) {
-            if (strcmp(g_array_index(global_capture_opts.ifaces, interface_options, i).name, if_name) == 0) {
-                gtk_tree_selection_select_iter(selection, iter);
-                break;
-            }
+    gtk_tree_model_get (model, iter, IFACE_NAME, &if_name, -1);
+    for (i = 0; i < global_capture_opts.ifaces->len; i++) {
+        if (strcmp(g_array_index(global_capture_opts.ifaces, interface_options, i).name, if_name) == 0) {
+            gtk_tree_selection_select_iter(selection, iter);
+            found = TRUE;
+            break;
         }
     }
+    if (!found) {
+        gtk_tree_selection_unselect_iter(selection, iter);
+    }
     return FALSE;
 }
+
+gboolean on_selection_changed(GtkTreeSelection *selection _U_,
+                              GtkTreeModel *model,
+                              GtkTreePath *path,
+                              gboolean path_currently_selected,
+                              gpointer data _U_)
+{
+    GtkTreeIter  iter;
+    gchar *if_name;
+    interface_options interface_opts;
+    guint i;
+    cap_settings_t    cap_settings;
+    gboolean found = FALSE;
+    
+    gtk_tree_model_get_iter (model, &iter, path);
+    gtk_tree_model_get (model, &iter, IFACE_NAME, &if_name, -1);
+    for (i = 0; i < global_capture_opts.ifaces->len; i++) {
+        if (strcmp(g_array_index(global_capture_opts.ifaces, interface_options, i).name, if_name) == 0) {
+            found = TRUE;
+            if (path_currently_selected) {
+                interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, i);
+                global_capture_opts.ifaces = g_array_remove_index(global_capture_opts.ifaces, i);
+                g_free(interface_opts.name);
+                g_free(interface_opts.descr);
+                g_free(interface_opts.cfilter);
+#ifdef HAVE_PCAP_REMOTE
+                g_free(interface_opts.remote_host);
+                g_free(interface_opts.remote_port);
+                g_free(interface_opts.auth_username);
+                g_free(interface_opts.auth_password);
+#endif
+                break;
+            }
+        } 
+    } 
+    if (!found && !path_currently_selected) {
+        interface_opts.name = g_strdup(if_name);
+        interface_opts.descr = get_interface_descriptive_name(interface_opts.name);
+        interface_opts.linktype = capture_dev_user_linktype_find(interface_opts.name);
+        interface_opts.cfilter = g_strdup(global_capture_opts.default_options.cfilter);
+        interface_opts.has_snaplen = global_capture_opts.default_options.has_snaplen;
+        interface_opts.snaplen = global_capture_opts.default_options.snaplen;
+        cap_settings = capture_get_cap_settings (interface_opts.name);;
+        interface_opts.promisc_mode = global_capture_opts.default_options.promisc_mode;
+#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
+        interface_opts.buffer_size =  global_capture_opts.default_options.buffer_size;
+#endif
+        interface_opts.monitor_mode = cap_settings.monitor_mode;
+#ifdef HAVE_PCAP_REMOTE
+        interface_opts.src_type = global_capture_opts.default_options.src_type;
+        interface_opts.remote_host = g_strdup(global_capture_opts.default_options.remote_host);
+        interface_opts.remote_port = g_strdup(global_capture_opts.default_options.remote_port);
+        interface_opts.auth_type = global_capture_opts.default_options.auth_type;
+        interface_opts.auth_username = g_strdup(global_capture_opts.default_options.auth_username);
+        interface_opts.auth_password = g_strdup(global_capture_opts.default_options.auth_password);
+        interface_opts.datatx_udp = global_capture_opts.default_options.datatx_udp;
+        interface_opts.nocap_rpcap = global_capture_opts.default_options.nocap_rpcap;
+        interface_opts.nocap_local = global_capture_opts.default_options.nocap_local;
+#endif
+#ifdef HAVE_PCAP_SETSAMPLING
+        interface_opts.sampling_method = global_capture_opts.default_options.sampling_method;
+        interface_opts.sampling_param  = global_capture_opts.default_options.sampling_param;
+#endif
+        g_array_append_val(global_capture_opts.ifaces, interface_opts);
+    }
+    return TRUE;
+}
 #endif
 
+void
+select_ifaces(void)
+{
+#ifdef HAVE_LIBPCAP
+    GtkWidget        *view;
+    GtkTreeModel     *model;
+    GtkTreeSelection *entry;
+
+    if (global_capture_opts.ifaces->len > 0) {
+        view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
+        model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
+        entry = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
+        gtk_tree_model_foreach(GTK_TREE_MODEL(model), select_current_ifaces, (gpointer) entry);
+        gtk_widget_grab_focus(view);
+    }
+#endif
+}
+
 /* list the interfaces */
 void
 welcome_if_tree_load(void)
@@ -609,7 +815,7 @@ welcome_if_tree_load(void)
         view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
         entry = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
         gtk_tree_selection_unselect_all(entry);
-        store = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
+        store = gtk_list_store_new(NUMCOLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
         /* List the interfaces */
         for (curr = g_list_first(if_list); curr; curr = g_list_next(curr)) {
             if_info = curr->data;
@@ -634,12 +840,12 @@ welcome_if_tree_load(void)
                 user_descr = g_strdup_printf("%s (%s)", comment, if_info->name);
                 g_free (comment);
 #endif
-                gtk_list_store_set(store, &iter, 0, gtk_image_get_pixbuf(GTK_IMAGE(icon)), 1, user_descr, 2, if_info->name, -1);
+                gtk_list_store_set(store, &iter, ICON, gtk_image_get_pixbuf(GTK_IMAGE(icon)), IFACE_DESCR, user_descr, IFACE_NAME, if_info->name, -1);
                 g_free (user_descr);
             } else if (if_info->description) {
-                gtk_list_store_set (store, &iter, 0, gtk_image_get_pixbuf(GTK_IMAGE(icon)), 1, if_info->description, 2, if_info->name, -1);
+                gtk_list_store_set (store, &iter, ICON, gtk_image_get_pixbuf(GTK_IMAGE(icon)), IFACE_DESCR, if_info->description, IFACE_NAME, if_info->name, -1);
             } else {
-                gtk_list_store_set (store, &iter, 0, gtk_image_get_pixbuf(GTK_IMAGE(icon)), 1, if_info->name, 2, if_info->name, -1);
+                gtk_list_store_set (store, &iter, ICON, gtk_image_get_pixbuf(GTK_IMAGE(icon)), IFACE_DESCR, if_info->name, IFACE_NAME, if_info->name, -1);
             }
         }
         gtk_tree_view_set_model(GTK_TREE_VIEW(if_view), GTK_TREE_MODEL (store));
@@ -647,6 +853,7 @@ welcome_if_tree_load(void)
             gtk_tree_model_foreach(GTK_TREE_MODEL(store), select_current_ifaces, (gpointer) entry);
             gtk_widget_grab_focus(view);
         }
+        gtk_tree_selection_set_select_function(entry, on_selection_changed, NULL, NULL);
     }
     free_interface_list(if_list);
 #endif  /* HAVE_LIBPCAP */
@@ -694,8 +901,8 @@ static void make_selections_array(GtkTreeModel  *model,
   int               err;
   if_info_t        *if_info;
 
-  gtk_tree_model_get (model, iter, 2, &if_name, -1);
+  gtk_tree_model_get (model, iter, IFACE_NAME, &if_name, -1);
+
   if_list = capture_interface_list(&err, NULL);
   if_list = g_list_sort (if_list, if_list_comparator_alph);
   if (g_list_length(if_list) > 0) {
@@ -755,11 +962,18 @@ static void capture_if_start(GtkWidget *w _U_, gpointer data _U_)
   view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
   entry = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
   len = gtk_tree_selection_count_selected_rows(entry);
-  if (!entry || len==0) {
+  if (!entry || len == 0) {
     simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
       "You didn't specify an interface on which to capture packets.");
     return;
   }
+#ifndef USE_THREADS
+  if (len > 1) {
+    simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+      "You specified multiple interfaces for capturing which this version of Wireshark doesn't support.");
+    return;
+  }
+#endif
   while (global_capture_opts.ifaces->len > 0) {
     interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, 0);
     global_capture_opts.ifaces = g_array_remove_index(global_capture_opts.ifaces, 0);
@@ -788,7 +1002,7 @@ static void capture_if_start(GtkWidget *w _U_, gpointer data _U_)
 #endif
   capture_start_cb(NULL, NULL);
 }
-    
+
 void capture_if_cb_prep(GtkWidget *w _U_, gpointer d _U_)
 {
   GtkTreeSelection *entry;
@@ -902,42 +1116,50 @@ welcome_new(void)
             "Same as Capture/Interfaces menu or toolbar item",
             welcome_button_callback_helper, capture_if_cb_prep);
         gtk_box_pack_start(GTK_BOX(topic_to_fill), item_hb, FALSE, FALSE, 5);
-   
+
         swindow = gtk_scrolled_window_new (NULL, NULL);
         gtk_widget_set_size_request(swindow, FALSE, 100);
         gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swindow), GTK_SHADOW_IN);
         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-  
+
         if_view = gtk_tree_view_new ();
         g_object_set(GTK_OBJECT(if_view), "headers-visible", FALSE, NULL);
         g_object_set_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES, if_view);
         renderer = gtk_cell_renderer_pixbuf_new();
         column = gtk_tree_view_column_new_with_attributes ("",
                                                GTK_CELL_RENDERER(renderer),
-                                               "pixbuf", 0,
+                                               "pixbuf", ICON,
                                                NULL);
         gtk_tree_view_append_column(GTK_TREE_VIEW(if_view), column);
         renderer = gtk_cell_renderer_text_new();
         column = gtk_tree_view_column_new_with_attributes ("",
                                                GTK_CELL_RENDERER(renderer),
-                                               "text", 1,
+                                               "text", IFACE_DESCR,
                                                NULL);
         gtk_tree_view_append_column(GTK_TREE_VIEW(if_view), column);
         gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(if_view), 0), TRUE);
         renderer = gtk_cell_renderer_text_new();
         column = gtk_tree_view_column_new_with_attributes ("",
                                                GTK_CELL_RENDERER(renderer),
-                                               "text", 2,
+                                               "text", IFACE_NAME,
                                                NULL);
         gtk_tree_view_append_column(GTK_TREE_VIEW(if_view), column);
         gtk_tree_view_column_set_visible(column, FALSE);
         selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(if_view));
         gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
+#ifdef USE_THREADS
         item_hb = welcome_button(WIRESHARK_STOCK_CAPTURE_START,
             "Start",
             "Choose one or more interfaces to capture from, then <b>Start</b>",
             "Same as Capture/Interfaces with default options",
             (welcome_button_callback_t)capture_if_start, (gpointer)if_view);
+#else
+        item_hb = welcome_button(WIRESHARK_STOCK_CAPTURE_START,
+            "Start",
+            "Choose exactly one interface to capture from, then <b>Start</b>",
+            "Same as Capture/Interfaces with default options",
+            (welcome_button_callback_t)capture_if_start, (gpointer)if_view);
+#endif
         gtk_box_pack_start(GTK_BOX(topic_to_fill), item_hb, FALSE, FALSE, 5);
         welcome_if_tree_load();
         gtk_container_add (GTK_CONTAINER (swindow), if_view);
@@ -973,7 +1195,7 @@ welcome_new(void)
         gtk_misc_set_alignment (GTK_MISC(w), 0.0f, 0.0f);
         gtk_box_pack_start(GTK_BOX(topic_to_fill), w, FALSE, FALSE, 5);
     }
-    
+
     free_interface_list(if_list);
 
     /* capture help topic */
@@ -1104,6 +1326,9 @@ welcome_new(void)
                                           welcome_eb);
     gtk_widget_show_all(welcome_scrollw);
 
+#ifdef USE_THREADS
+    recent_mtx = g_mutex_new();
+#endif
+
     return welcome_scrollw;
 }
-