5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #include <epan/prefs.h>
37 #include "capture-pcap-util.h"
38 #include "capture_opts.h"
39 #include "capture_ui_utils.h"
42 #include <wsutil/file_util.h>
44 #include "ui/recent.h"
45 #include "ui/simple_dialog.h"
47 #include "ui/gtk/gui_utils.h"
48 #include "ui/gtk/color_utils.h"
49 #include "ui/gtk/gtkglobals.h"
50 #include "ui/gtk/main.h"
51 #include "ui/gtk/menus.h"
52 #include "ui/gtk/main_welcome.h"
53 #include "ui/gtk/help_dlg.h"
54 #include "ui/gtk/capture_file_dlg.h"
55 #include "ui/gtk/stock_icons.h"
56 #include "ui/gtk/utf8_entities.h"
58 #include "ui/gtk/capture_dlg.h"
59 #include "ui/gtk/capture_if_dlg.h"
60 #include "ui/gtk/capture_globals.h"
61 #if GTK_CHECK_VERSION(2,18,0)
62 #include "ui/gtk/webbrowser.h"
64 #endif /* HAVE_LIBPCAP */
65 #include "../../image/wssplash-dev.xpm"
66 #include "../version_info.h"
75 #include "airpcap_loader.h"
76 #include "airpcap_gui_utils.h"
78 #if defined(HAVE_PCAP_REMOTE)
79 #include "ui/gtk/remote_icons.h"
83 static GtkWidget *welcome_hb = NULL;
84 static GtkWidget *header_lb = NULL;
85 /* Foreground colors are set using Pango markup */
86 #if GTK_CHECK_VERSION(3,0,0)
87 static GdkRGBA rgba_welcome_bg = {0.901, 0.901, 0.901, 1.0 };
88 static GdkRGBA rgba_header_bar_bg = { 0.094, 0.360, 0.792, 1.0 };
89 static GdkRGBA rgba_topic_header_bg = { 0.004, 0.224, 0.745, 1.0 };
90 static GdkRGBA rgba_topic_content_bg = { 1, 1, 1, 1.0 };
91 static GdkRGBA rgba_topic_item_idle_bg;
92 static GdkRGBA rgba_topic_item_entered_bg = { 0.827, 0.847, 0.854, 1.0 };
94 static GdkColor welcome_bg = { 0, 0xe6e6, 0xe6e6, 0xe6e6 };
95 static GdkColor header_bar_bg = { 0, 0x1818, 0x5c5c, 0xcaca };
96 static GdkColor topic_header_bg = { 0, 0x0101, 0x3939, 0xbebe };
97 static GdkColor topic_content_bg = { 0, 0xffff, 0xffff, 0xffff };
98 static GdkColor topic_item_idle_bg;
99 static GdkColor topic_item_entered_bg = { 0, 0xd3d3, 0xd8d8, 0xdada };
101 static GtkWidget *welcome_file_panel_vb = NULL;
103 static GtkWidget *if_view = NULL;
104 static GtkWidget *swindow;
107 static GSList *status_messages = NULL;
109 static GMutex *recent_mtx;
112 static void capture_if_start(GtkWidget *w _U_, gpointer data _U_);
113 #if GTK_CHECK_VERSION(2,18,0)
114 static gboolean activate_link_cb(GtkLabel *label _U_, gchar *uri, gpointer user_data _U_);
118 /* The "scroll box dynamic" is a (complicated) pseudo widget to */
119 /* place a vertically list of widgets in (currently the interfaces and recent files). */
120 /* Once this list get's higher than a specified amount, */
121 /* it is moved into a scrolled_window. */
122 /* This is all complicated, the scrolled window is a bit ugly, */
123 /* the sizes might not be the same on all systems, ... */
124 /* ... but that's the best what we currently have */
125 #define SCROLL_BOX_CHILD_BOX "ScrollBoxDynamic_ChildBox"
126 #define SCROLL_BOX_MAX_CHILDS "ScrollBoxDynamic_MaxChilds"
127 #define SCROLL_BOX_SCROLLW_Y_SIZE "ScrollBoxDynamic_Scrollw_Y_Size"
128 #define SCROLL_BOX_SCROLLW "ScrollBoxDynamic_Scrollw"
129 #define TREE_VIEW_INTERFACES "TreeViewInterfaces"
130 #define CAPTURE_VIEW "CaptureView"
131 #define CAPTURE_LABEL "CaptureLabel"
132 #define CAPTURE_HB_BOX_INTERFACE_LIST "CaptureHorizontalBoxInterfaceList"
133 #define CAPTURE_HB_BOX_START "CaptureHorizontalBoxStart"
134 #define CAPTURE_HB_BOX_CAPTURE "CaptureHorizontalBoxCapture"
138 scroll_box_dynamic_new(GtkWidget *child_box, guint max_childs, guint scrollw_y_size) {
139 GtkWidget * parent_box;
142 parent_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
143 gtk_box_pack_start(GTK_BOX(parent_box), GTK_WIDGET(child_box), TRUE, TRUE, 0);
144 g_object_set_data(G_OBJECT(parent_box), SCROLL_BOX_CHILD_BOX, child_box);
145 g_object_set_data(G_OBJECT(parent_box), SCROLL_BOX_MAX_CHILDS, GINT_TO_POINTER(max_childs));
146 g_object_set_data(G_OBJECT(parent_box), SCROLL_BOX_SCROLLW_Y_SIZE, GINT_TO_POINTER(scrollw_y_size));
147 gtk_widget_show_all(parent_box);
154 scroll_box_dynamic_add(GtkWidget *parent_box)
156 GtkWidget *child_box;
160 guint scrollw_y_size;
163 child_box = g_object_get_data(G_OBJECT(parent_box), SCROLL_BOX_CHILD_BOX);
164 max_cnt = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(parent_box), SCROLL_BOX_MAX_CHILDS));
166 /* get the current number of children */
167 childs = gtk_container_get_children(GTK_CONTAINER(child_box));
168 curr_cnt = g_list_length(childs);
171 /* have we just reached the max? */
172 if(curr_cnt == max_cnt) {
173 /* create the scrolled window */
174 /* XXX - there's no way to get rid of the shadow frame - except for creating an own widget :-( */
175 scrollw = scrolled_window_new(NULL, NULL);
176 scrollw_y_size = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(parent_box), SCROLL_BOX_SCROLLW_Y_SIZE));
177 gtk_widget_set_size_request(scrollw, -1, scrollw_y_size);
179 g_object_set_data(G_OBJECT(parent_box), SCROLL_BOX_SCROLLW, scrollw);
180 gtk_box_pack_start(GTK_BOX(parent_box), scrollw, TRUE, TRUE, 0);
182 /* move child_box from parent_box into scrolled window */
183 g_object_ref(child_box);
184 gtk_container_remove(GTK_CONTAINER(parent_box), child_box);
185 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollw),
187 gtk_widget_show_all(scrollw);
195 scroll_box_dynamic_reset(GtkWidget *parent_box)
197 GtkWidget *child_box, *scrollw;
200 child_box = g_object_get_data(G_OBJECT(parent_box), SCROLL_BOX_CHILD_BOX);
201 scrollw = g_object_get_data(G_OBJECT(parent_box), SCROLL_BOX_SCROLLW);
203 if(scrollw != NULL) {
204 /* move the child_box back from scrolled window into the parent_box */
205 g_object_ref(child_box);
206 gtk_container_remove(GTK_CONTAINER(parent_box), scrollw);
207 g_object_set_data(G_OBJECT(parent_box), SCROLL_BOX_SCROLLW, NULL);
208 gtk_box_pack_start(GTK_BOX(parent_box), child_box, TRUE, TRUE, 0);
215 /* mouse entered this widget - change background color */
217 welcome_item_enter_cb(GtkWidget *eb, GdkEventCrossing *event _U_, gpointer user_data _U_)
219 #if GTK_CHECK_VERSION(3,0,0)
220 gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_item_entered_bg);
222 gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_item_entered_bg);
228 /* mouse has left this widget - change background color */
230 welcome_item_leave_cb(GtkWidget *eb, GdkEventCrossing *event _U_, gpointer user_data _U_)
232 #if GTK_CHECK_VERSION(3,0,0)
233 gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_item_idle_bg);
235 gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_item_idle_bg);
241 typedef gboolean (*welcome_button_callback_t) (GtkWidget *widget,
242 GdkEventButton *event,
245 /* create a "button widget" */
247 welcome_button(const gchar *stock_item,
248 const gchar *title, const gchar *subtitle, const gchar *tooltip,
249 welcome_button_callback_t welcome_button_callback, gpointer welcome_button_callback_data)
251 GtkWidget *eb, *w, *item_hb, *text_vb;
252 gchar *formatted_text;
254 item_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1, FALSE);
256 /* event box (for background color and events) */
257 eb = gtk_event_box_new();
258 gtk_container_add(GTK_CONTAINER(eb), item_hb);
259 #if GTK_CHECK_VERSION(3,0,0)
260 gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_item_idle_bg);
262 gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_item_idle_bg);
264 if(tooltip != NULL) {
265 gtk_widget_set_tooltip_text(eb, tooltip);
268 g_signal_connect(eb, "enter-notify-event", G_CALLBACK(welcome_item_enter_cb), NULL);
269 g_signal_connect(eb, "leave-notify-event", G_CALLBACK(welcome_item_leave_cb), NULL);
270 g_signal_connect(eb, "button-release-event", G_CALLBACK(welcome_button_callback), welcome_button_callback_data);
273 w = gtk_image_new_from_stock(stock_item, GTK_ICON_SIZE_LARGE_TOOLBAR);
274 gtk_box_pack_start(GTK_BOX(item_hb), w, FALSE, FALSE, 5);
276 text_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
279 w = gtk_label_new(title);
280 gtk_misc_set_alignment (GTK_MISC(w), 0.0f, 0.5f);
281 formatted_text = g_strdup_printf("<span weight=\"bold\" size=\"x-large\" foreground=\"black\">%s</span>", title);
282 gtk_label_set_markup(GTK_LABEL(w), formatted_text);
283 g_free(formatted_text);
284 gtk_box_pack_start(GTK_BOX(text_vb), w, FALSE, FALSE, 1);
287 w = gtk_label_new(subtitle);
288 gtk_misc_set_alignment (GTK_MISC(w), 0.0f, 0.5f);
289 formatted_text = g_strdup_printf("<span size=\"small\" foreground=\"black\">%s</span>", subtitle);
290 gtk_label_set_markup(GTK_LABEL(w), formatted_text);
291 g_free(formatted_text);
292 gtk_box_pack_start(GTK_BOX(text_vb), w, FALSE, FALSE, 1);
294 gtk_box_pack_start(GTK_BOX(item_hb), text_vb, TRUE, TRUE, 5);
300 /* Hack to handle welcome-button "button-release-event" callback */
301 /* 1. Dispatch to desired actual callback */
302 /* 2. Return TRUE for the event callback. */
303 /* user_data: actual (no arg) callback fcn to be invoked. */
305 welcome_button_callback_helper(GtkWidget *w, GdkEventButton *event _U_, gpointer user_data)
307 void (*funct)(GtkWidget *, gpointer) = user_data;
314 welcome_header_set_message(gchar *msg) {
316 time_t secs = time(NULL);
317 struct tm *now = localtime(&secs);
319 message = g_string_new("<span weight=\"bold\" size=\"x-large\" foreground=\"white\">");
322 g_string_append(message, msg);
323 } else { /* Use our default header */
324 if ((now->tm_mon == 3 && now->tm_mday == 1) || (now->tm_mon == 6 && now->tm_mday == 14)) {
325 g_string_append(message, "Sniffing the glue that holds the Internet together");
327 g_string_append(message, prefs.gui_start_title);
330 if (prefs.gui_version_in_start_page) {
331 g_string_append_printf(message, "</span>\n<span size=\"large\" foreground=\"white\">Version " VERSION "%s",
332 wireshark_svnversion);
336 g_string_append(message, "</span>");
338 gtk_label_set_markup(GTK_LABEL(header_lb), message->str);
339 g_string_free(message, TRUE);
343 /* create the banner "above our heads" */
345 welcome_header_new(void)
352 item_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
355 eb = gtk_event_box_new();
356 gtk_container_add(GTK_CONTAINER(eb), item_vb);
357 #if GTK_CHECK_VERSION(3,0,0)
358 gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_header_bar_bg);
360 gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &header_bar_bg);
362 item_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
363 gtk_box_pack_start(GTK_BOX(item_vb), item_hb, FALSE, FALSE, 10);
365 /*icon = xpm_to_widget_from_parent(top_level, wssplash_xpm);*/
366 icon = xpm_to_widget(wssplash_xpm);
367 gtk_box_pack_start(GTK_BOX(item_hb), icon, FALSE, FALSE, 10);
369 header_lb = gtk_label_new(NULL);
370 welcome_header_set_message(NULL);
371 gtk_label_set_selectable(GTK_LABEL(header_lb), TRUE);
372 gtk_misc_set_alignment(GTK_MISC(header_lb), 0.0f, 0.5f);
373 gtk_box_pack_start(GTK_BOX(item_hb), header_lb, TRUE, TRUE, 5);
375 gtk_widget_show_all(eb);
382 welcome_header_push_msg(const gchar *msg) {
383 gchar *msg_copy = g_strdup(msg);
385 status_messages = g_slist_append(status_messages, msg_copy);
387 welcome_header_set_message(msg_copy);
389 gtk_widget_hide(welcome_hb);
394 welcome_header_pop_msg(void) {
397 if (status_messages) {
398 g_free(status_messages->data);
399 status_messages = g_slist_delete_link(status_messages, status_messages);
402 if (status_messages) {
403 msg = status_messages->data;
406 welcome_header_set_message(msg);
408 if (!status_messages) {
409 gtk_widget_show(welcome_hb);
414 /* create a "topic header widget" */
416 welcome_topic_header_new(const char *header)
420 gchar *formatted_message;
423 w = gtk_label_new(header);
424 formatted_message = g_strdup_printf("<span weight=\"bold\" size=\"x-large\" foreground=\"white\">%s</span>", header);
425 gtk_label_set_markup(GTK_LABEL(w), formatted_message);
426 g_free(formatted_message);
429 eb = gtk_event_box_new();
430 gtk_container_add(GTK_CONTAINER(eb), w);
431 #if GTK_CHECK_VERSION(3,0,0)
432 gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_header_bg);
434 gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_header_bg);
440 /* create a "topic widget" */
442 welcome_topic_new(const char *header, GtkWidget **to_fill)
445 GtkWidget *layout_vb;
447 GtkWidget *topic_header;
450 topic_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
452 topic_header = welcome_topic_header_new(header);
453 gtk_box_pack_start(GTK_BOX(topic_vb), topic_header, FALSE, FALSE, 0);
455 layout_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 5, FALSE);
456 gtk_container_set_border_width(GTK_CONTAINER(layout_vb), 10);
457 gtk_box_pack_start(GTK_BOX(topic_vb), layout_vb, FALSE, FALSE, 0);
459 /* colorize vbox (we need an event box for this!) */
460 topic_eb = gtk_event_box_new();
461 gtk_container_add(GTK_CONTAINER(topic_eb), topic_vb);
462 #if GTK_CHECK_VERSION(3,0,0)
463 gtk_widget_override_background_color(topic_eb, GTK_STATE_NORMAL, &rgba_topic_content_bg);
465 gtk_widget_modify_bg(topic_eb, GTK_STATE_NORMAL, &topic_content_bg);
467 *to_fill = layout_vb;
473 /* a file link was pressed */
475 welcome_filename_link_press_cb(GtkWidget *widget _U_, GdkEventButton *event _U_, gpointer data)
477 menu_open_filename(data);
482 typedef struct _recent_item_status {
490 } recent_item_status;
493 * Fetch the status of a file.
494 * This function might be called as a thread. We can't use any drawing
495 * routines here: http://developer.gnome.org/gdk/2.24/gdk-Threads.html
497 static void *get_recent_item_status(void *data)
499 recent_item_status *ri_stat = (recent_item_status *) data;
508 * Add file size. We use binary prefixes instead of IEC because that's what
511 err = ws_stat64(ri_stat->filename, &stat_buf);
512 g_mutex_lock(recent_mtx);
515 if (stat_buf.st_size/1024/1024/1024 > 10) {
516 g_string_append_printf(ri_stat->str, " (%" G_GINT64_MODIFIER "d GB)", (gint64) (stat_buf.st_size/1024/1024/1024));
517 } else if (stat_buf.st_size/1024/1024 > 10) {
518 g_string_append_printf(ri_stat->str, " (%" G_GINT64_MODIFIER "d MB)", (gint64) (stat_buf.st_size/1024/1024));
519 } else if (stat_buf.st_size/1024 > 10) {
520 g_string_append_printf(ri_stat->str, " (%" G_GINT64_MODIFIER "d KB)", (gint64) (stat_buf.st_size/1024));
522 g_string_append_printf(ri_stat->str, " (%" G_GINT64_MODIFIER "d Bytes)", (gint64) (stat_buf.st_size));
524 /* pango format string */
525 g_string_prepend(ri_stat->str, "<span foreground='blue'>");
526 g_string_append(ri_stat->str, "</span>");
528 g_string_append(ri_stat->str, " [not found]");
531 if (!ri_stat->label) { /* The widget went away while we were busy. */
532 g_free(ri_stat->filename);
533 g_string_free(ri_stat->str, TRUE);
536 ri_stat->stat_done = TRUE;
538 g_mutex_unlock(recent_mtx);
543 /* Timeout callback for recent items */
545 update_recent_items(gpointer data)
547 recent_item_status *ri_stat = (recent_item_status *) data;
548 gboolean again = TRUE;
554 g_mutex_lock(recent_mtx);
555 if (ri_stat->stat_done) {
557 gtk_label_set_markup(GTK_LABEL(ri_stat->label), ri_stat->str->str);
558 if (ri_stat->err == 0) {
559 gtk_widget_set_sensitive(ri_stat->label, TRUE);
560 gtk_action_set_sensitive((GtkAction *) ri_stat->menu_item, TRUE);
564 /* Else append some sort of Unicode or ASCII animation to the label? */
565 g_mutex_unlock(recent_mtx);
569 static void welcome_filename_destroy_cb(GtkWidget *w _U_, gpointer data) {
570 recent_item_status *ri_stat = (recent_item_status *) data;
576 g_mutex_lock(recent_mtx);
577 if (ri_stat->timer) {
578 g_source_remove(ri_stat->timer);
582 g_object_unref(ri_stat->menu_item);
584 if (ri_stat->stat_done) {
585 g_free(ri_stat->filename);
586 g_string_free(ri_stat->str, TRUE);
589 ri_stat->label = NULL;
591 g_mutex_unlock(recent_mtx);
594 /* create a "file link widget" */
596 welcome_filename_link_new(const gchar *filename, GtkWidget **label, GObject *menu_item)
603 gsize uni_start, uni_end;
604 const glong max = 60;
605 recent_item_status *ri_stat;
608 str = g_string_new(filename);
609 uni_len = g_utf8_strlen(str->str, str->len);
611 /* cut max filename length */
613 uni_start = g_utf8_offset_to_pointer(str->str, 20) - str->str;
614 uni_end = g_utf8_offset_to_pointer(str->str, uni_len - max) - str->str;
615 g_string_erase(str, uni_start, uni_end);
616 g_string_insert(str, uni_start, " " UTF8_HORIZONTAL_ELLIPSIS " ");
619 /* escape the possibly shortened filename before adding pango language */
620 str_escaped=g_markup_escape_text(str->str, -1);
621 g_string_free(str, TRUE);
624 w = gtk_label_new(str_escaped);
626 gtk_misc_set_padding(GTK_MISC(w), 5, 2);
627 gtk_misc_set_alignment (GTK_MISC(w), 0.0f, 0.0f);
628 gtk_widget_set_sensitive(w, FALSE);
630 ri_stat = g_malloc(sizeof(recent_item_status));
631 ri_stat->filename = g_strdup(filename);
633 ri_stat->menu_item = menu_item;
634 ri_stat->str = g_string_new(str_escaped);
635 ri_stat->stat_done = FALSE;
637 g_object_ref(G_OBJECT(menu_item));
638 g_signal_connect(w, "destroy", G_CALLBACK(welcome_filename_destroy_cb), ri_stat);
641 #if GLIB_CHECK_VERSION(2,31,0)
642 /* XXX - Add the filename here? */
643 g_thread_new("Recent item status", get_recent_item_status, ri_stat);
645 g_thread_create(get_recent_item_status, ri_stat, FALSE, NULL);
647 ri_stat->timer = g_timeout_add(200, update_recent_items, ri_stat);
650 eb = gtk_event_box_new();
651 #if GTK_CHECK_VERSION(3,0,0)
652 gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_item_idle_bg);
654 gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_item_idle_bg);
656 gtk_container_add(GTK_CONTAINER(eb), w);
657 gtk_widget_set_tooltip_text(eb, filename);
659 g_signal_connect(eb, "enter-notify-event", G_CALLBACK(welcome_item_enter_cb), w);
660 g_signal_connect(eb, "leave-notify-event", G_CALLBACK(welcome_item_leave_cb), w);
661 g_signal_connect(eb, "button-press-event", G_CALLBACK(welcome_filename_link_press_cb), (gchar *) filename);
667 /* reset the list of recent files */
669 main_welcome_reset_recent_capture_files(void)
671 GtkWidget *child_box;
673 GList* child_list_item;
676 if(welcome_file_panel_vb) {
677 child_box = scroll_box_dynamic_reset(welcome_file_panel_vb);
678 child_list = gtk_container_get_children(GTK_CONTAINER(child_box));
679 child_list_item = child_list;
681 while(child_list_item) {
682 gtk_container_remove(GTK_CONTAINER(child_box), child_list_item->data);
683 child_list_item = g_list_next(child_list_item);
686 g_list_free(child_list);
691 /* add a new file to the list of recent files */
693 main_welcome_add_recent_capture_file(const char *widget_cf_name, GObject *menu_item)
696 GtkWidget *child_box;
700 w = welcome_filename_link_new(widget_cf_name, &label, menu_item);
701 child_box = scroll_box_dynamic_add(welcome_file_panel_vb);
702 gtk_box_pack_start(GTK_BOX(child_box), w, FALSE, FALSE, 0);
703 gtk_widget_show_all(w);
704 gtk_widget_show_all(child_box);
708 static gboolean select_current_ifaces(GtkTreeModel *model,
717 GtkTreeSelection *selection = (GtkTreeSelection *)userdata;
719 gtk_tree_model_get (model, iter, IFACE_NAME, &if_name, -1);
720 for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
721 device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
722 if (strcmp(device.name, if_name) == 0) {
723 if (device.selected && !gtk_tree_selection_path_is_selected(selection, path)) {
724 gtk_tree_selection_select_iter(selection, iter);
726 gtk_tree_selection_unselect_iter(selection, iter);
734 gboolean on_selection_changed(GtkTreeSelection *selection _U_,
737 gboolean path_currently_selected,
745 gtk_tree_model_get_iter (model, &iter, path);
746 gtk_tree_model_get (model, &iter, IFACE_NAME, &if_name, -1);
747 for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
748 device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
749 if (strcmp(device.name, if_name) == 0) {
750 if (!device.locked) {
751 if (path_currently_selected) {
752 if (device.selected) {
753 device.selected = FALSE;
754 device.locked = TRUE;
755 global_capture_opts.num_selected--;
758 if (!device.selected) {
759 device.selected = TRUE;
760 device.locked = TRUE;
761 global_capture_opts.num_selected++;
764 global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
765 g_array_insert_val(global_capture_opts.all_ifaces, i, device);
767 if (capture_dlg_window_present()) {
768 enable_selected_interface(g_strdup(if_name), device.selected);
770 if (interfaces_dialog_window_present()) {
771 update_selected_interface(g_strdup(if_name));
773 device.locked = FALSE;
774 global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
775 g_array_insert_val(global_capture_opts.all_ifaces, i, device);
783 static gboolean activate_ifaces(GtkTreeModel *model,
784 GtkTreePath *path _U_,
790 GtkTreeSelection *selection;
791 selected_name_t *entry = (selected_name_t *)userdata;
793 view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
794 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
795 gtk_tree_model_get (model, iter, IFACE_NAME, &if_name, -1);
796 if (strcmp(if_name, entry->name) == 0) {
797 if (entry->activate) {
798 gtk_tree_selection_select_iter(selection, iter);
800 gtk_tree_selection_unselect_iter(selection, iter);
807 void change_interface_selection(gchar* name, gboolean activate)
811 selected_name_t entry;
813 view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
814 model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
815 entry.name = g_strdup(name);
816 entry.activate = activate;
817 gtk_tree_model_foreach(GTK_TREE_MODEL(model), (GtkTreeModelForeachFunc)(activate_ifaces), (gpointer) &entry);
820 void change_selection_for_all(gboolean enable)
824 for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
825 change_interface_selection(g_array_index(global_capture_opts.all_ifaces, interface_t, i).name, enable);
836 GtkTreeSelection *entry;
838 if (global_capture_opts.num_selected > 0 && swindow) {
839 view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
840 model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
841 entry = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
842 gtk_tree_model_foreach(GTK_TREE_MODEL(model), select_current_ifaces, (gpointer) entry);
843 gtk_widget_grab_focus(view);
850 change_interface_name(gchar *oldname, guint index)
856 GtkTreeSelection *entry;
859 view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
860 entry = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
861 model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
863 device = g_array_index(global_capture_opts.all_ifaces, interface_t, index);
864 if (gtk_tree_model_get_iter_first (model, &iter)) {
866 gtk_tree_model_get(model, &iter, IFACE_NAME, &optname, -1);
867 if (strcmp(optname, oldname) == 0) {
868 gtk_list_store_set(GTK_LIST_STORE(model), &iter, ICON, gtk_image_get_pixbuf(GTK_IMAGE(capture_get_if_icon(&device))), IFACE_DESCR, device.display_name, IFACE_NAME, device.name, -1);
869 if (device.selected) {
870 gtk_tree_selection_select_iter(entry, &iter);
874 } while (gtk_tree_model_iter_next(model, &iter));
880 #ifdef HAVE_PCAP_REMOTE
882 add_interface_to_list(guint index)
884 GtkWidget *view, *icon;
891 device = g_array_index(global_capture_opts.all_ifaces, interface_t, index);
892 icon = pixbuf_to_widget(remote_sat_pb_data);
893 view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
894 model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
895 size = gtk_tree_model_iter_n_children(model, NULL);
896 lines = g_strdup_printf("%d", size-1);
897 if (gtk_tree_model_get_iter_from_string(model, &iter, lines)) {
898 gtk_list_store_append (GTK_LIST_STORE(model), &iter);
899 gtk_list_store_set(GTK_LIST_STORE(model), &iter, ICON, gtk_image_get_pixbuf(GTK_IMAGE(icon)), IFACE_DESCR, device.display_name, IFACE_NAME, device.name, -1);
906 clear_capture_box(void)
910 item_hb = g_object_get_data(G_OBJECT(welcome_hb), CAPTURE_HB_BOX_INTERFACE_LIST);
912 gtk_widget_destroy(item_hb);
914 item_hb = g_object_get_data(G_OBJECT(welcome_hb), CAPTURE_HB_BOX_START);
916 gtk_widget_destroy(item_hb);
918 item_hb = g_object_get_data(G_OBJECT(welcome_hb), CAPTURE_HB_BOX_CAPTURE);
920 gtk_widget_destroy(item_hb);
923 gtk_widget_destroy(swindow);
930 update_capture_box(void)
933 GtkListStore *store = NULL;
935 GtkTreeSelection *entry;
937 gboolean changed = FALSE;
939 entry = gtk_tree_view_get_selection(GTK_TREE_VIEW(if_view));
940 gtk_tree_selection_unselect_all(GTK_TREE_SELECTION(entry));
941 store = gtk_list_store_new(NUMCOLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
943 gtk_list_store_clear(store);
944 gtk_tree_view_set_model(GTK_TREE_VIEW(if_view), GTK_TREE_MODEL (store));
945 for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
946 device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
947 if (!device.hidden) {
948 gtk_list_store_append (store, &iter);
949 gtk_list_store_set (store, &iter, ICON, gtk_image_get_pixbuf(GTK_IMAGE(capture_get_if_icon(&device))), IFACE_DESCR, device.display_name, IFACE_NAME, device.name, -1);
950 if (device.selected) {
951 gtk_tree_selection_select_iter(entry, &iter);
956 gtk_tree_selection_set_select_function(GTK_TREE_SELECTION(entry), on_selection_changed, (gpointer)&changed, NULL);
959 static void fill_capture_box(void)
961 GtkWidget *box_to_fill;
962 GtkWidget *item_hb_interface_list, *item_hb_capture, *item_hb_start, *label, *w;
966 GtkTreeSelection *selection;
967 GtkCellRenderer *renderer;
968 GtkTreeViewColumn *column;
970 gchar *label_text, *err_str;
973 DWORD chimney_enabled = 0;
974 DWORD ce_size = sizeof(chimney_enabled);
977 label = g_object_get_data(G_OBJECT(welcome_hb), CAPTURE_LABEL);
979 gtk_widget_destroy(label);
981 box_to_fill = g_object_get_data(G_OBJECT(welcome_hb), CAPTURE_VIEW);
982 if (global_capture_opts.all_ifaces->len > 0) {
983 item_hb_interface_list = welcome_button(WIRESHARK_STOCK_CAPTURE_INTERFACES,
985 "Live list of the capture interfaces\n(counts incoming packets)",
986 "Same as Capture/Interfaces menu or toolbar item",
987 welcome_button_callback_helper, capture_if_cb);
988 gtk_box_pack_start(GTK_BOX(box_to_fill), item_hb_interface_list, FALSE, FALSE, 5);
989 swindow = gtk_scrolled_window_new (NULL, NULL);
990 gtk_widget_set_size_request(swindow, FALSE, 100);
991 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swindow), GTK_SHADOW_IN);
992 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
993 g_object_set_data(G_OBJECT(welcome_hb), CAPTURE_HB_BOX_INTERFACE_LIST, item_hb_interface_list);
995 if_view = gtk_tree_view_new ();
996 g_object_set(G_OBJECT(if_view), "headers-visible", FALSE, NULL);
997 g_signal_connect(if_view, "row-activated", G_CALLBACK(options_interface_cb), (gpointer)welcome_hb);
998 g_object_set_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES, if_view);
999 column = gtk_tree_view_column_new();
1000 renderer = gtk_cell_renderer_pixbuf_new();
1001 gtk_tree_view_column_pack_start(column, renderer, FALSE);
1002 gtk_tree_view_column_set_attributes(column, renderer, "pixbuf", ICON, NULL);
1003 renderer = gtk_cell_renderer_text_new();
1004 gtk_tree_view_column_pack_start(column, renderer, TRUE);
1005 gtk_tree_view_column_set_attributes(column, renderer, "text", IFACE_DESCR, NULL);
1006 gtk_tree_view_append_column(GTK_TREE_VIEW(if_view), column);
1007 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(if_view), 0), TRUE);
1008 renderer = gtk_cell_renderer_text_new();
1009 column = gtk_tree_view_column_new_with_attributes ("",
1010 GTK_CELL_RENDERER(renderer),
1013 gtk_tree_view_append_column(GTK_TREE_VIEW(if_view), column);
1014 gtk_tree_view_column_set_visible(column, FALSE);
1015 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(if_view));
1016 gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
1017 item_hb_start = welcome_button(WIRESHARK_STOCK_CAPTURE_START,
1019 "Choose one or more interfaces to capture from, then <b>Start</b>",
1020 "Same as Capture/Interfaces with default options",
1021 (welcome_button_callback_t)capture_if_start, (gpointer)if_view);
1022 gtk_box_pack_start(GTK_BOX(box_to_fill), item_hb_start, FALSE, FALSE, 5);
1023 update_capture_box();
1024 gtk_container_add (GTK_CONTAINER (swindow), if_view);
1025 gtk_container_add(GTK_CONTAINER(box_to_fill), swindow);
1026 g_object_set_data(G_OBJECT(welcome_hb), CAPTURE_HB_BOX_START, item_hb_start);
1028 item_hb_capture = welcome_button(WIRESHARK_STOCK_CAPTURE_OPTIONS,
1030 "Start a capture with detailed options",
1031 "Same as Capture/Options menu or toolbar item",
1032 welcome_button_callback_helper, capture_prep_cb);
1033 gtk_box_pack_start(GTK_BOX(box_to_fill), item_hb_capture, FALSE, FALSE, 5);
1034 g_object_set_data(G_OBJECT(welcome_hb), CAPTURE_HB_BOX_CAPTURE, item_hb_capture);
1036 /* Check for chimney offloading */
1037 reg_ret = RegQueryValueEx(HKEY_LOCAL_MACHINE,
1038 _T("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\EnableTCPChimney"),
1039 NULL, NULL, (LPBYTE) &chimney_enabled, &ce_size);
1040 if (reg_ret == ERROR_SUCCESS && chimney_enabled) {
1041 item_hb = welcome_button(WIRESHARK_STOCK_WIKI,
1042 "Offloading Detected",
1043 "TCP Chimney offloading is enabled. You \nmight not capture much data.",
1044 topic_online_url(ONLINEPAGE_CHIMNEY),
1045 topic_menu_cb, GINT_TO_POINTER(ONLINEPAGE_CHIMNEY));
1046 gtk_box_pack_start(GTK_BOX(box_to_fill), item_hb_capture, FALSE, FALSE, 5);
1051 clear_capture_box();
1053 capture_interface_list(&error, &err_str);
1056 case CANT_GET_INTERFACE_LIST:
1057 label_text = g_strdup_printf("No interface can be used for capturing in "
1058 "this system with the current configuration.\n\n"
1061 "See Capture Help below for details.",
1065 case NO_INTERFACES_FOUND:
1066 label_text = g_strdup("No interface can be used for capturing in "
1067 "this system with the current configuration.\n"
1069 "See Capture Help below for details.");
1072 case DONT_HAVE_PCAP:
1073 label_text = g_strdup("WinPcap doesn't appear to be installed. "
1074 "In order to capture packets, WinPcap "
1075 "must be installed; see\n"
1077 #if GTK_CHECK_VERSION(2,18,0)
1078 " <a href=\"http://www.winpcap.org/\">http://www.winpcap.org/</a>\n"
1080 " http://www.winpcap.org/\n"
1083 "or the mirror at\n"
1085 #if GTK_CHECK_VERSION(2,18,0)
1086 " <a href=\"http://www.mirrors.wiretapped.net/security/packet-capture/winpcap/\">http://www.mirrors.wiretapped.net/security/packet-capture/winpcap/</a>\n"
1088 " http://www.mirrors.wiretapped.net/security/packet-capture/winpcap/\n"
1091 "or the mirror at\n"
1093 #if GTK_CHECK_VERSION(2,18,0)
1094 " <a href=\"http://winpcap.cs.pu.edu.tw/\">http://winpcap.cs.pu.edu.tw/</a>\n"
1096 " http://winpcap.cs.pu.edu.tw/\n"
1099 "for a downloadable version of WinPcap "
1100 "and for instructions on how to install "
1105 label_text = g_strdup_printf("Error = %d; this \"can't happen\".", error);
1108 if (err_str != NULL)
1110 w = gtk_label_new(label_text);
1111 gtk_label_set_markup(GTK_LABEL(w), label_text);
1112 gtk_label_set_line_wrap(GTK_LABEL(w), TRUE);
1113 g_free (label_text);
1114 gtk_misc_set_alignment (GTK_MISC(w), 0.0f, 0.0f);
1115 gtk_box_pack_start(GTK_BOX(box_to_fill), w, FALSE, FALSE, 5);
1116 #if GTK_CHECK_VERSION(2,18,0)
1117 g_signal_connect(w, "activate-link", G_CALLBACK(activate_link_cb), NULL);
1119 g_object_set_data(G_OBJECT(welcome_hb), CAPTURE_LABEL, w);
1122 #endif /* HAVE_LIBPCAP */
1125 /* reload the list of interfaces */
1127 welcome_if_panel_reload(void)
1131 /* If we have a list of interfaces, and if the current interface
1132 list is non-empty, just update the interface list. Otherwise,
1133 create it (as we didn't have it) or destroy it (as we won't
1135 if (if_view && swindow && global_capture_opts.all_ifaces->len > 0) {
1136 update_capture_box();
1140 gtk_widget_show_all(welcome_hb);
1142 #endif /* HAVE_LIBPCAP */
1146 static void capture_if_start(GtkWidget *w _U_, gpointer data _U_)
1152 if (global_capture_opts.num_selected == 0) {
1153 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
1154 "You didn't specify an interface on which to capture packets.");
1158 /* XXX - remove this? */
1159 if (global_capture_opts.save_file) {
1160 g_free(global_capture_opts.save_file);
1161 global_capture_opts.save_file = NULL;
1163 #ifdef HAVE_AIRPCAP /* TODO: don't let it depend on interface_opts */
1164 for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
1165 device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
1166 airpcap_if_active = get_airpcap_if_from_name(airpcap_if_list, device.name);
1167 airpcap_if_selected = airpcap_if_active;
1168 if (airpcap_if_selected) {
1172 if (airpcap_if_active)
1173 airpcap_set_toolbar_start_capture(airpcap_if_active);
1175 capture_start_cb(NULL, NULL);
1180 #if GTK_CHECK_VERSION(2,18,0)
1182 activate_link_cb(GtkLabel *label _U_, gchar *uri, gpointer user_data _U_)
1184 return browser_open_url(uri);
1189 /* create the welcome page */
1193 GtkWidget *welcome_scrollw;
1194 GtkWidget *welcome_eb;
1195 GtkWidget *welcome_vb;
1196 GtkWidget *column_vb;
1200 GtkWidget *topic_vb;
1201 GtkWidget *topic_to_fill;
1202 GtkWidget *topic_capture_to_fill;
1204 GtkWidget *file_child_box;
1206 DWORD chimney_enabled = 0;
1207 DWORD ce_size = sizeof(chimney_enabled);
1209 /* prepare colors */
1211 /* Allocating color isn't necessary? */
1213 /* "page" background */
1214 get_color(&welcome_bg);
1216 /* header bar background color */
1217 get_color(&header_bar_bg);
1219 /* topic header background color */
1220 get_color(&topic_header_bg);
1222 /* topic content background color */
1223 get_color(&topic_content_bg);
1225 #if GTK_CHECK_VERSION(3,0,0)
1226 rgba_topic_item_idle_bg = rgba_topic_content_bg;
1228 topic_item_idle_bg = topic_content_bg;
1231 /* Allocating collor isn't necessary? */
1232 /* topic item entered color */
1233 get_color(&topic_item_entered_bg);
1235 welcome_scrollw = scrolled_window_new(NULL, NULL);
1237 welcome_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
1239 welcome_eb = gtk_event_box_new();
1240 gtk_container_add(GTK_CONTAINER(welcome_eb), welcome_vb);
1241 #if GTK_CHECK_VERSION(3,0,0)
1242 gtk_widget_override_background_color(welcome_eb, GTK_STATE_NORMAL, &rgba_welcome_bg);
1244 gtk_widget_modify_bg(welcome_eb, GTK_STATE_NORMAL, &welcome_bg);
1247 header = welcome_header_new();
1248 gtk_box_pack_start(GTK_BOX(welcome_vb), header, FALSE, FALSE, 0);
1251 welcome_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10, FALSE);
1252 gtk_container_set_border_width(GTK_CONTAINER(welcome_hb), 10);
1253 gtk_box_pack_start(GTK_BOX(welcome_vb), welcome_hb, TRUE, TRUE, 0);
1256 /* column capture */
1257 column_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 10, FALSE);
1258 #if GTK_CHECK_VERSION(3,0,0)
1259 gtk_widget_override_background_color(column_vb, GTK_STATE_NORMAL, &rgba_welcome_bg);
1261 gtk_widget_modify_bg(column_vb, GTK_STATE_NORMAL, &welcome_bg);
1263 gtk_box_pack_start(GTK_BOX(welcome_hb), column_vb, TRUE, TRUE, 0);
1266 topic_vb = welcome_topic_new("Capture", &topic_capture_to_fill);
1267 gtk_box_pack_start(GTK_BOX(column_vb), topic_vb, TRUE, TRUE, 0);
1268 g_object_set_data(G_OBJECT(welcome_hb), CAPTURE_VIEW, topic_capture_to_fill);
1271 fill_in_local_interfaces(&global_capture_opts);
1274 /* capture help topic */
1275 topic_vb = welcome_topic_new("Capture Help", &topic_to_fill);
1276 gtk_box_pack_start(GTK_BOX(column_vb), topic_vb, TRUE, TRUE, 0);
1278 item_hb = welcome_button(WIRESHARK_STOCK_WIKI,
1280 "Step by step to a successful capture setup",
1281 topic_online_url(ONLINEPAGE_CAPTURE_SETUP),
1282 topic_menu_cb, GINT_TO_POINTER(ONLINEPAGE_CAPTURE_SETUP));
1283 gtk_box_pack_start(GTK_BOX(topic_to_fill), item_hb, FALSE, FALSE, 5);
1285 item_hb = welcome_button(WIRESHARK_STOCK_WIKI,
1287 "Specific information for capturing on:\nEthernet, WLAN, ...",
1288 topic_online_url(ONLINEPAGE_NETWORK_MEDIA),
1289 topic_menu_cb, GINT_TO_POINTER(ONLINEPAGE_NETWORK_MEDIA));
1290 gtk_box_pack_start(GTK_BOX(topic_to_fill), item_hb, FALSE, FALSE, 5);
1292 label_text = g_strdup("<span foreground=\"black\">Capturing is not compiled into\nthis version of Wireshark!</span>");
1293 w = gtk_label_new(label_text);
1294 gtk_label_set_markup(GTK_LABEL(w), label_text);
1295 g_free (label_text);
1296 gtk_misc_set_alignment (GTK_MISC(w), 0.0f, 0.0f);
1297 gtk_box_pack_start(GTK_BOX(topic_capture_to_fill), w, FALSE, FALSE, 5);
1298 #endif /* HAVE_LIBPCAP */
1300 /* fill bottom space */
1301 w = gtk_label_new("");
1302 gtk_box_pack_start(GTK_BOX(topic_capture_to_fill), w, TRUE, TRUE, 0);
1306 topic_vb = welcome_topic_new("Files", &topic_to_fill);
1307 gtk_box_pack_start(GTK_BOX(welcome_hb), topic_vb, TRUE, TRUE, 0);
1309 item_hb = welcome_button(GTK_STOCK_OPEN,
1311 "Open a previously captured file",
1312 "Same as File/Open menu or toolbar item",
1313 welcome_button_callback_helper, file_open_cmd_cb);
1314 gtk_box_pack_start(GTK_BOX(topic_to_fill), item_hb, FALSE, FALSE, 5);
1316 /* prepare list of recent files (will be filled in later) */
1317 label_text = g_strdup("<span foreground=\"black\">Open Recent:</span>");
1318 w = gtk_label_new(label_text);
1319 gtk_label_set_markup(GTK_LABEL(w), label_text);
1320 g_free (label_text);
1321 gtk_misc_set_alignment (GTK_MISC(w), 0.0f, 0.0f);
1322 gtk_box_pack_start(GTK_BOX(topic_to_fill), w, FALSE, FALSE, 5);
1324 file_child_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 1, FALSE);
1325 /* 17 file items or 300 pixels height is about the size */
1326 /* that still fits on a screen of about 1000*700 */
1327 welcome_file_panel_vb = scroll_box_dynamic_new(GTK_WIDGET(file_child_box), 17, 300);
1328 gtk_box_pack_start(GTK_BOX(topic_to_fill), welcome_file_panel_vb, FALSE, FALSE, 0);
1330 item_hb = welcome_button(WIRESHARK_STOCK_WIKI,
1332 "A rich assortment of example capture files on the wiki",
1333 topic_online_url(ONLINEPAGE_SAMPLE_CAPTURES),
1334 topic_menu_cb, GINT_TO_POINTER(ONLINEPAGE_SAMPLE_CAPTURES));
1335 gtk_box_pack_start(GTK_BOX(topic_to_fill), item_hb, FALSE, FALSE, 5);
1337 /* fill bottom space */
1338 w = gtk_label_new("");
1339 gtk_box_pack_start(GTK_BOX(topic_to_fill), w, TRUE, TRUE, 0);
1343 column_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 10, FALSE);
1344 gtk_box_pack_start(GTK_BOX(welcome_hb), column_vb, TRUE, TRUE, 0);
1347 topic_vb = welcome_topic_new("Online", &topic_to_fill);
1348 gtk_box_pack_start(GTK_BOX(column_vb), topic_vb, TRUE, TRUE, 0);
1350 item_hb = welcome_button(GTK_STOCK_HOME,
1352 "Visit the project's website",
1353 topic_online_url(ONLINEPAGE_HOME),
1354 topic_menu_cb, GINT_TO_POINTER(ONLINEPAGE_HOME));
1355 gtk_box_pack_start(GTK_BOX(topic_to_fill), item_hb, FALSE, FALSE, 5);
1358 item_hb = welcome_button(GTK_STOCK_HELP,
1361 "(local version, if installed)",
1362 "Locally installed (if installed) otherwise online version",
1363 topic_menu_cb, GINT_TO_POINTER(HELP_CONTENT));
1365 item_hb = welcome_button(GTK_STOCK_HELP,
1369 topic_online_url(ONLINEPAGE_USERGUIDE),
1370 topic_menu_cb, GINT_TO_POINTER(ONLINEPAGE_USERGUIDE));
1372 gtk_box_pack_start(GTK_BOX(topic_to_fill), item_hb, FALSE, FALSE, 5);
1374 item_hb = welcome_button(WIRESHARK_STOCK_WIKI,
1376 "Work with Wireshark as securely as possible",
1377 topic_online_url(ONLINEPAGE_SECURITY),
1378 topic_menu_cb, GINT_TO_POINTER(ONLINEPAGE_SECURITY));
1379 gtk_box_pack_start(GTK_BOX(topic_to_fill), item_hb, FALSE, FALSE, 5);
1382 /* XXX - add this, once the Windows update functionality is implemented */
1384 topic_vb = welcome_topic_new("Updates", &topic_to_fill);
1385 gtk_box_pack_start(GTK_BOX(column_vb), topic_vb, TRUE, TRUE, 0);
1387 label_text = g_strdup("<span foreground=\"black\">No updates available!</span>");
1388 w = gtk_label_new(label_text);
1389 gtk_label_set_markup(GTK_LABEL(w), label_text);
1390 g_free (label_text);
1391 gtk_box_pack_start(GTK_BOX(topic_to_fill), w, TRUE, TRUE, 0);
1396 gtk_widget_show_all(welcome_eb);
1398 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(welcome_scrollw),
1400 gtk_widget_show_all(welcome_scrollw);
1402 #if GLIB_CHECK_VERSION(2,31,0)
1403 recent_mtx = g_malloc(sizeof(GMutex));
1404 g_mutex_init(recent_mtx);
1406 recent_mtx = g_mutex_new();
1409 return welcome_scrollw;
1412 GtkWidget* get_welcome_window(void)