Popup a menu with configuration profiles instead of the profile dlg
[obnox/wireshark/wip.git] / gtk / main_statusbar.c
1 /* main_statusbar.c
2  *
3  * $Id$
4  *
5  * Wireshark - Network traffic analyzer
6  * By Gerald Combs <gerald@wireshark.org>
7  * Copyright 1998 Gerald Combs
8  *
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29
30 #ifdef HAVE_UNISTD_H
31 #include <unistd.h>
32 #endif
33
34 #include <gtk/gtk.h>
35
36 #include <epan/epan.h>
37 #include <epan/filesystem.h>
38 #include <epan/epan_dissect.h>
39 #include <epan/expert.h>
40 #include <epan/prefs.h>
41
42 #include "../cfile.h"
43 #include "../file.h"
44 #include "../capture_opts.h"
45 #include "../capture_ui_utils.h"
46
47 #include "gtk/recent.h"
48 #include "gtk/main.h"
49 #include "gtk/main_statusbar.h"
50 #include "gtk/gui_utils.h"
51 #include "gtk/gtkglobals.h"
52 #include "gtk/expert_comp_dlg.h"
53 #include "gtk/profile_dlg.h"
54
55 #include "../image/expert_error.xpm"
56 #include "../image/expert_warn.xpm"
57 #include "../image/expert_note.xpm"
58 #include "../image/expert_chat.xpm"
59 #include "../image/expert_none.xpm"
60
61 /*
62  * The order below defines the priority of info bar contexts.
63  */
64 typedef enum {
65     STATUS_LEVEL_MAIN,
66     STATUS_LEVEL_FILE,
67     STATUS_LEVEL_FILTER,
68     STATUS_LEVEL_HELP,
69     NUM_STATUS_LEVELS
70 } status_level_e;
71
72
73 #ifdef HAVE_LIBPCAP
74 #define DEF_READY_MESSAGE " Ready to load or capture"
75 #else
76 #define DEF_READY_MESSAGE " Ready to load file"
77 #endif
78
79
80 GtkWidget    *status_pane_left, *status_pane_right;
81 GtkWidget    *info_bar, *packets_bar, *profile_bar, *profile_bar_event;
82 GtkWidget    *expert_info_error, *expert_info_warn, *expert_info_note;
83 GtkWidget    *expert_info_chat, *expert_info_none;
84
85 static guint        main_ctx, file_ctx, help_ctx, filter_ctx, packets_ctx, profile_ctx;
86 static guint        status_levels[NUM_STATUS_LEVELS];
87 static gchar        *packets_str = NULL;
88 static gchar        *profile_str = NULL;
89
90
91 static void info_bar_new(void);
92 static void packets_bar_new(void);
93 static void profile_bar_new(void);
94 static void status_expert_new(void);
95
96
97
98 /*
99  * Push a message referring to file access onto the statusbar.
100  */
101 static void
102 statusbar_push_file_msg(const gchar *msg)
103 {
104     int i;
105
106     /*g_warning("statusbar_push: %s", msg);*/
107     for (i = STATUS_LEVEL_FILE + 1; i < NUM_STATUS_LEVELS; i++) {
108         if (status_levels[i])
109             return;
110     }
111     status_levels[STATUS_LEVEL_FILE]++;
112     gtk_statusbar_push(GTK_STATUSBAR(info_bar), file_ctx, msg);
113 }
114
115 /*
116  * Pop a message referring to file access off the statusbar.
117  */
118 static void
119 statusbar_pop_file_msg(void)
120 {
121     /*g_warning("statusbar_pop");*/
122     if (status_levels[STATUS_LEVEL_FILE] > 0) {
123         status_levels[STATUS_LEVEL_FILE]--;
124     }
125     gtk_statusbar_pop(GTK_STATUSBAR(info_bar), file_ctx);
126 }
127
128 /*
129  * Push a message referring to the currently-selected field onto the statusbar.
130  */
131 void
132 statusbar_push_field_msg(const gchar *msg)
133 {
134     int i;
135
136     for (i = STATUS_LEVEL_HELP + 1; i < NUM_STATUS_LEVELS; i++) {
137         if (status_levels[i])
138             return;
139     }
140     status_levels[STATUS_LEVEL_HELP]++;
141
142     gtk_statusbar_push(GTK_STATUSBAR(info_bar), help_ctx, msg);
143 }
144
145 /*
146  * Pop a message referring to the currently-selected field off the statusbar.
147  */
148 void
149 statusbar_pop_field_msg(void)
150 {
151     if (status_levels[STATUS_LEVEL_HELP] > 0) {
152         status_levels[STATUS_LEVEL_HELP]--;
153     }
154     gtk_statusbar_pop(GTK_STATUSBAR(info_bar), help_ctx);
155 }
156
157 /*
158  * Push a message referring to the current filter onto the statusbar.
159  */
160 void
161 statusbar_push_filter_msg(const gchar *msg)
162 {
163     int i;
164
165     for (i = STATUS_LEVEL_FILTER + 1; i < NUM_STATUS_LEVELS; i++) {
166         if (status_levels[i])
167             return;
168     }
169     status_levels[STATUS_LEVEL_FILTER]++;
170
171     gtk_statusbar_push(GTK_STATUSBAR(info_bar), filter_ctx, msg);
172 }
173
174 /*
175  * Pop a message referring to the current filter off the statusbar.
176  */
177 void
178 statusbar_pop_filter_msg(void)
179 {
180     if (status_levels[STATUS_LEVEL_FILTER] > 0) {
181         status_levels[STATUS_LEVEL_FILTER]--;
182     }
183     gtk_statusbar_pop(GTK_STATUSBAR(info_bar), filter_ctx);
184 }
185
186
187 GtkWidget *
188 statusbar_new(void)
189 {
190     GtkWidget *status_hbox;
191
192     /* Sstatus hbox */
193     status_hbox = gtk_hbox_new(FALSE, 1);
194     gtk_container_border_width(GTK_CONTAINER(status_hbox), 0);
195
196     /* info (main) statusbar */
197     info_bar_new();
198
199     /* packets statusbar */
200     packets_bar_new();
201
202     /* profile statusbar */
203     profile_bar_new();
204
205     /* expert info indicator */
206     status_expert_new();
207
208     /* Pane for the statusbar */
209     status_pane_left = gtk_hpaned_new();
210     gtk_widget_show(status_pane_left);
211     status_pane_right = gtk_hpaned_new();
212     gtk_widget_show(status_pane_right);
213
214     return status_hbox;
215 }
216
217 void
218 statusbar_load_window_geometry(void)
219 {
220     if (recent.has_gui_geometry_status_pane && recent.gui_geometry_status_pane_left)
221         gtk_paned_set_position(GTK_PANED(status_pane_left), recent.gui_geometry_status_pane_left);
222     if (recent.has_gui_geometry_status_pane && recent.gui_geometry_status_pane_right)
223         gtk_paned_set_position(GTK_PANED(status_pane_right), recent.gui_geometry_status_pane_right);
224 }
225
226 void
227 statusbar_save_window_geometry(void)
228 {
229     recent.gui_geometry_status_pane_left    = gtk_paned_get_position(GTK_PANED(status_pane_left));
230     recent.gui_geometry_status_pane_right   = gtk_paned_get_position(GTK_PANED(status_pane_right));
231 }
232
233
234 /*
235  * Helper for statusbar_widgets_emptying()
236  */
237 static void
238 foreach_remove_a_child(GtkWidget *widget, gpointer data) {
239     gtk_container_remove(GTK_CONTAINER(data), widget);
240 }
241
242 void
243 statusbar_widgets_emptying(GtkWidget *statusbar)
244 {
245     gtk_widget_ref(info_bar);
246     gtk_widget_ref(packets_bar);
247     gtk_widget_ref(profile_bar);
248     gtk_widget_ref(profile_bar_event);
249     gtk_widget_ref(status_pane_left);
250     gtk_widget_ref(status_pane_right);
251     gtk_widget_ref(expert_info_error);
252     gtk_widget_ref(expert_info_warn);
253     gtk_widget_ref(expert_info_note);
254     gtk_widget_ref(expert_info_chat);
255     gtk_widget_ref(expert_info_none);
256
257     /* empty all containers participating */
258     gtk_container_foreach(GTK_CONTAINER(statusbar),     foreach_remove_a_child, statusbar);
259     gtk_container_foreach(GTK_CONTAINER(status_pane_left),   foreach_remove_a_child, status_pane_left);
260     gtk_container_foreach(GTK_CONTAINER(status_pane_right),   foreach_remove_a_child, status_pane_right);
261 }
262
263 void
264 statusbar_widgets_pack(GtkWidget *statusbar)
265 {
266     gtk_box_pack_start(GTK_BOX(statusbar), expert_info_error, FALSE, FALSE, 0);
267     gtk_box_pack_start(GTK_BOX(statusbar), expert_info_warn, FALSE, FALSE, 0);
268     gtk_box_pack_start(GTK_BOX(statusbar), expert_info_note, FALSE, FALSE, 0);
269     gtk_box_pack_start(GTK_BOX(statusbar), expert_info_chat, FALSE, FALSE, 0);
270     gtk_box_pack_start(GTK_BOX(statusbar), expert_info_none, FALSE, FALSE, 0);
271     gtk_box_pack_start(GTK_BOX(statusbar), status_pane_left, TRUE, TRUE, 0);
272     gtk_paned_pack1(GTK_PANED(status_pane_left), info_bar, FALSE, FALSE);
273     gtk_paned_pack2(GTK_PANED(status_pane_left), status_pane_right, TRUE, FALSE);
274     gtk_paned_pack1(GTK_PANED(status_pane_right), packets_bar, TRUE, FALSE);
275     gtk_paned_pack2(GTK_PANED(status_pane_right), profile_bar_event, FALSE, FALSE);
276 }
277
278 void
279 statusbar_widgets_show_or_hide(GtkWidget *statusbar)
280 {
281     /*
282      * Show the status hbox if either:
283      *
284      *    1) we're showing the filter toolbar and we want it in the status
285      *       line
286      *
287      * or
288      *
289      *    2) we're showing the status bar.
290      */
291     if ((recent.filter_toolbar_show && prefs.filter_toolbar_show_in_statusbar) ||
292          recent.statusbar_show) {
293         gtk_widget_show(statusbar);
294     } else {
295         gtk_widget_hide(statusbar);
296     }
297
298     if (recent.statusbar_show) {
299         gtk_widget_show(status_pane_left);
300     } else {
301         gtk_widget_hide(status_pane_left);
302     }
303 }
304
305
306 static void
307 info_bar_new(void)
308 {
309     int i;
310
311     /* tip: tooltips don't work on statusbars! */
312     info_bar = gtk_statusbar_new();
313     main_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(info_bar), "main");
314     file_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(info_bar), "file");
315     help_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(info_bar), "help");
316     filter_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(info_bar), "filter");
317     gtk_statusbar_set_has_resize_grip(GTK_STATUSBAR(info_bar), FALSE);
318     gtk_statusbar_push(GTK_STATUSBAR(info_bar), main_ctx, DEF_READY_MESSAGE);
319
320     for (i = 0; i < NUM_STATUS_LEVELS; i++) {
321         status_levels[i] = 0;
322     }
323
324     gtk_widget_show(info_bar);
325 }
326
327 static void
328 packets_bar_new(void)
329 {
330     /* tip: tooltips don't work on statusbars! */
331     packets_bar = gtk_statusbar_new();
332     packets_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(packets_bar), "packets");
333     packets_bar_update();
334     gtk_statusbar_set_has_resize_grip(GTK_STATUSBAR(packets_bar), FALSE);
335
336     gtk_widget_show(packets_bar);
337 }
338
339 static void
340 profile_bar_new(void)
341 {
342     GtkTooltips   *tooltips;
343
344     tooltips = gtk_tooltips_new();
345
346     profile_bar_event = gtk_event_box_new();
347     profile_bar = gtk_statusbar_new();
348     gtk_container_add(GTK_CONTAINER(profile_bar_event), profile_bar);
349     g_signal_connect(profile_bar_event, "button_press_event", G_CALLBACK(profile_show_popup_cb), NULL);
350     profile_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(profile_bar), "profile");
351     gtk_tooltips_set_tip (tooltips, profile_bar_event,
352                           "Click to change configuration profile", NULL);
353     profile_bar_update();
354
355     gtk_widget_show(profile_bar);
356     gtk_widget_show(profile_bar_event);
357 }
358
359
360 /*
361  * update the packets statusbar to the current values
362  */
363 void 
364 packets_bar_update(void)
365 {
366
367     if(packets_bar) {
368         /* remove old status */
369         if(packets_str) {
370             g_free(packets_str);
371             gtk_statusbar_pop(GTK_STATUSBAR(packets_bar), packets_ctx);
372         }
373
374         /* do we have any packets? */
375         if(cfile.count) {
376             if(cfile.drops_known) {
377                 packets_str = g_strdup_printf(" Packets: %u Displayed: %u Marked: %u Dropped: %u",
378                     cfile.count, cfile.displayed_count, cfile.marked_count, cfile.drops);
379             } else {
380                 packets_str = g_strdup_printf(" Packets: %u Displayed: %u Marked: %u",
381                     cfile.count, cfile.displayed_count, cfile.marked_count);
382             }
383         } else {
384             packets_str = g_strdup(" No Packets");
385         }
386         gtk_statusbar_push(GTK_STATUSBAR(packets_bar), packets_ctx, packets_str);
387     }
388 }
389
390 /*
391  * update the packets statusbar to the current values
392  */
393 void
394 profile_bar_update(void)
395 {
396     if (profile_bar) {
397         /* remove old status */
398         if(profile_str) {
399             g_free(profile_str);
400             gtk_statusbar_pop(GTK_STATUSBAR(profile_bar), profile_ctx);
401         }
402
403         profile_str = g_strdup_printf (" Profile: %s", get_profile_name ());
404
405         gtk_statusbar_push(GTK_STATUSBAR(profile_bar), profile_ctx, profile_str);
406     }
407 }
408
409
410 static void
411 status_expert_new(void)
412 {
413     GtkWidget *expert_image;
414     GtkTooltips   *tooltips;
415
416     tooltips = gtk_tooltips_new();
417
418     expert_image = xpm_to_widget_from_parent(top_level, expert_error_xpm);
419     gtk_tooltips_set_tip(tooltips, expert_image, "ERROR is the highest expert info level", NULL);
420     gtk_widget_show(expert_image);
421     expert_info_error = gtk_event_box_new();
422     gtk_container_add(GTK_CONTAINER(expert_info_error), expert_image);
423     g_signal_connect(expert_info_error, "button_press_event", G_CALLBACK(expert_comp_dlg_cb), NULL);
424
425     expert_image = xpm_to_widget_from_parent(top_level, expert_warn_xpm);
426     gtk_tooltips_set_tip(tooltips, expert_image, "WARNING is the highest expert info level", NULL);
427     gtk_widget_show(expert_image);
428     expert_info_warn = gtk_event_box_new();
429     gtk_container_add(GTK_CONTAINER(expert_info_warn), expert_image);
430     g_signal_connect(expert_info_warn, "button_press_event", G_CALLBACK(expert_comp_dlg_cb), NULL);
431
432     expert_image = xpm_to_widget_from_parent(top_level, expert_note_xpm);
433     gtk_tooltips_set_tip(tooltips, expert_image, "NOTE is the highest expert info level", NULL);
434     gtk_widget_show(expert_image);
435     expert_info_note = gtk_event_box_new();
436     gtk_container_add(GTK_CONTAINER(expert_info_note), expert_image);
437     g_signal_connect(expert_info_note, "button_press_event", G_CALLBACK(expert_comp_dlg_cb), NULL);
438
439     expert_image = xpm_to_widget_from_parent(top_level, expert_chat_xpm);
440     gtk_tooltips_set_tip(tooltips, expert_image, "CHAT is the highest expert info level", NULL);
441     gtk_widget_show(expert_image);
442     expert_info_chat = gtk_event_box_new();
443     gtk_container_add(GTK_CONTAINER(expert_info_chat), expert_image);
444     g_signal_connect(expert_info_chat, "button_press_event", G_CALLBACK(expert_comp_dlg_cb), NULL);
445
446     expert_image = xpm_to_widget_from_parent(top_level, expert_none_xpm);
447     gtk_tooltips_set_tip(tooltips, expert_image, "No expert info", NULL);
448     gtk_widget_show(expert_image);
449     expert_info_none = gtk_event_box_new();
450     gtk_container_add(GTK_CONTAINER(expert_info_none), expert_image);
451     g_signal_connect(expert_info_none, "button_press_event", G_CALLBACK(expert_comp_dlg_cb), NULL);
452     gtk_widget_show(expert_info_none);
453 }
454
455 static void
456 status_expert_hide(void)
457 {
458     /* reset expert info indicator */
459     gtk_widget_hide(expert_info_error);
460     gtk_widget_hide(expert_info_warn);
461     gtk_widget_hide(expert_info_note);
462     gtk_widget_hide(expert_info_chat);
463     gtk_widget_hide(expert_info_none);
464 }
465
466 static void
467 status_expert_update(void)
468 {
469     status_expert_hide();
470
471     switch(expert_get_highest_severity()) {
472         case(PI_ERROR):
473         gtk_widget_show(expert_info_error);
474         break;
475         case(PI_WARN):
476         gtk_widget_show(expert_info_warn);
477         break;
478         case(PI_NOTE):
479         gtk_widget_show(expert_info_note);
480         break;
481         case(PI_CHAT):
482         gtk_widget_show(expert_info_chat);
483         break;
484         default:
485         gtk_widget_show(expert_info_none);
486         break;
487     }
488 }
489
490 static void
491 statusbar_set_filename(const char *file_name, gint64 file_length, nstime_t *file_elapsed_time)
492 {
493   gchar       *size_str;
494   gchar       *status_msg;
495
496   /* expert info indicator */
497   status_expert_update();
498
499   /* statusbar */
500   /* convert file size */
501   if (file_length/1024/1024 > 10) {
502     size_str = g_strdup_printf("%" G_GINT64_MODIFIER "d MB", file_length/1024/1024);
503   } else if (file_length/1024 > 10) {
504     size_str = g_strdup_printf("%" G_GINT64_MODIFIER "d KB", file_length/1024);
505   } else {
506     size_str = g_strdup_printf("%" G_GINT64_MODIFIER "d Bytes", file_length);
507   }
508
509   status_msg = g_strdup_printf(" File: \"%s\" %s %02lu:%02lu:%02lu",
510     (file_name) ? file_name : "", size_str,
511     (long)file_elapsed_time->secs/3600,
512     (long)file_elapsed_time->secs%3600/60,
513     (long)file_elapsed_time->secs%60);
514   g_free(size_str);
515   statusbar_push_file_msg(status_msg);
516   g_free(status_msg);
517 }
518
519
520 static void
521 statusbar_cf_file_closing_cb(capture_file *cf _U_)
522 {
523     /* Clear any file-related status bar messages.
524        XXX - should be "clear *ALL* file-related status bar messages;
525        will there ever be more than one on the stack? */
526     statusbar_pop_file_msg();
527
528     /* reset expert info indicator */
529     status_expert_hide();
530     gtk_widget_show(expert_info_none);
531 }
532
533
534 static void
535 statusbar_cf_file_closed_cb(capture_file *cf _U_)
536 {
537   /* go back to "No packets" */
538   packets_bar_update();
539 }
540
541
542 static void
543 statusbar_cf_file_read_start_cb(capture_file *cf)
544 {
545   const gchar *name_ptr;
546   gchar       *load_msg;
547
548   /* Ensure we pop any previous loaded filename */
549   statusbar_pop_file_msg();
550
551   name_ptr = get_basename(cf->filename);
552
553   load_msg = g_strdup_printf(" Loading: %s", name_ptr);
554   statusbar_push_file_msg(load_msg);
555   g_free(load_msg);
556 }
557
558
559 static void
560 statusbar_cf_file_read_finished_cb(capture_file *cf)
561 {
562     statusbar_pop_file_msg();
563     statusbar_set_filename(cf->filename, cf->f_datalen, &(cf->elapsed_time));
564 }
565
566
567 #ifdef HAVE_LIBPCAP
568 static void
569 statusbar_cf_live_capture_prepared_cb(capture_options *capture_opts _U_)
570 {
571     statusbar_push_file_msg(" Waiting for capture input data ...");
572 }
573
574 static void
575 statusbar_cf_live_capture_update_started_cb(capture_options *capture_opts)
576 {
577     gchar *capture_msg;
578
579
580     statusbar_pop_file_msg();
581
582     if(capture_opts->iface) {
583         capture_msg = g_strdup_printf(" %s: <live capture in progress> to file: %s",
584                                       get_iface_description(capture_opts),
585                                       (capture_opts->save_file) ? capture_opts->save_file : "");
586     } else {
587         capture_msg = g_strdup_printf(" <live capture in progress> to file: %s",
588             (capture_opts->save_file) ? capture_opts->save_file : "");
589     }
590
591     statusbar_push_file_msg(capture_msg);
592
593     g_free(capture_msg);
594 }
595
596 static void
597 statusbar_cf_live_capture_update_continue_cb(capture_file *cf)
598 {
599     gchar *capture_msg;
600
601
602     status_expert_update();
603
604     statusbar_pop_file_msg();
605
606     if (cf->f_datalen/1024/1024 > 10) {
607         capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %" G_GINT64_MODIFIER "d MB",
608                                       get_iface_description(capture_opts),
609                                       capture_opts->save_file,
610                                       cf->f_datalen/1024/1024);
611     } else if (cf->f_datalen/1024 > 10) {
612         capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %" G_GINT64_MODIFIER "d KB",
613                                       get_iface_description(capture_opts),
614                                       capture_opts->save_file,
615                                       cf->f_datalen/1024);
616     } else {
617         capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %" G_GINT64_MODIFIER "d Bytes",
618                                       get_iface_description(capture_opts),
619                                       capture_opts->save_file,
620                                       cf->f_datalen);
621     }
622
623     statusbar_push_file_msg(capture_msg);
624 }
625
626 static void
627 statusbar_cf_live_capture_update_finished_cb(capture_file *cf)
628 {
629     /* Pop the "<live capture in progress>" message off the status bar. */
630     statusbar_pop_file_msg();
631     statusbar_set_filename(cf->filename, cf->f_datalen, &(cf->elapsed_time));
632 }
633
634 static void
635 statusbar_cf_live_capture_fixed_started_cb(capture_options *capture_opts)
636 {
637     gchar *capture_msg;
638
639
640     statusbar_pop_file_msg();
641
642     capture_msg = g_strdup_printf(" %s: <live capture in progress> to file: %s",
643                                   get_iface_description(capture_opts),
644                                   (capture_opts->save_file) ? capture_opts->save_file : "");
645
646     statusbar_push_file_msg(capture_msg);
647     gtk_statusbar_push(GTK_STATUSBAR(packets_bar), packets_ctx, " Packets: 0");
648
649     g_free(capture_msg);
650 }
651
652 static void
653 statusbar_cf_live_capture_fixed_continue_cb(capture_file *cf)
654 {
655     gchar *capture_msg;
656
657
658     gtk_statusbar_pop(GTK_STATUSBAR(packets_bar), packets_ctx);
659     capture_msg = g_strdup_printf(" Packets: %u", cf_get_packet_count(cf));
660     gtk_statusbar_push(GTK_STATUSBAR(packets_bar), packets_ctx, capture_msg);
661     g_free(capture_msg);
662 }
663
664
665 static void
666 statusbar_cf_live_capture_fixed_finished_cb(capture_file *cf _U_)
667 {
668     /* Pop the "<live capture in progress>" message off the status bar. */
669     statusbar_pop_file_msg();
670
671     /* Pop the "<capturing>" message off the status bar */
672     gtk_statusbar_pop(GTK_STATUSBAR(packets_bar), packets_ctx);
673 }
674
675 #endif /* HAVE_LIBPCAP */
676
677
678 static void
679 statusbar_cf_field_unselected_cb(capture_file *cf _U_)
680 {
681     statusbar_pop_field_msg();
682 }
683
684 static void
685 statusbar_cf_file_safe_started_cb(gchar * filename)
686 {
687     gchar        *save_msg;
688
689     save_msg = g_strdup_printf(" Saving: %s...", get_basename(filename));
690     statusbar_push_file_msg(save_msg);
691     g_free(save_msg);
692 }
693
694 static void
695 statusbar_cf_file_safe_finished_cb(gpointer data _U_)
696 {
697     /* Pop the "Saving:" message off the status bar. */
698     statusbar_pop_file_msg();
699 }
700
701 static void
702 statusbar_cf_file_safe_failed_cb(gpointer data _U_)
703 {
704     /* Pop the "Saving:" message off the status bar. */
705     statusbar_pop_file_msg();
706 }
707
708
709
710 void
711 statusbar_cf_callback(gint event, gpointer data, gpointer user_data _U_)
712 {
713     switch(event) {
714     case(cf_cb_file_closing):
715         statusbar_cf_file_closing_cb(data);
716         break;
717     case(cf_cb_file_closed):
718         statusbar_cf_file_closed_cb(data);
719         break;
720     case(cf_cb_file_read_start):
721         statusbar_cf_file_read_start_cb(data);
722         break;
723     case(cf_cb_file_read_finished):
724         statusbar_cf_file_read_finished_cb(data);
725         break;
726 #ifdef HAVE_LIBPCAP
727     case(cf_cb_live_capture_prepared):
728         statusbar_cf_live_capture_prepared_cb(data);
729         break;
730     case(cf_cb_live_capture_update_started):
731         statusbar_cf_live_capture_update_started_cb(data);
732         break;
733     case(cf_cb_live_capture_update_continue):
734         statusbar_cf_live_capture_update_continue_cb(data);
735         break;
736     case(cf_cb_live_capture_update_finished):
737         statusbar_cf_live_capture_update_finished_cb(data);
738         break;
739     case(cf_cb_live_capture_fixed_started):
740         statusbar_cf_live_capture_fixed_started_cb(data);
741         break;
742     case(cf_cb_live_capture_fixed_continue):
743         statusbar_cf_live_capture_fixed_continue_cb(data);
744         break;
745     case(cf_cb_live_capture_fixed_finished):
746         statusbar_cf_live_capture_fixed_finished_cb(data);
747         break;
748     case(cf_cb_live_capture_stopping):
749         /* Beware: this state won't be called, if the capture child
750          * closes the capturing on it's own! */
751         break;
752 #endif
753     case(cf_cb_packet_selected):
754         break;
755     case(cf_cb_packet_unselected):
756         break;
757     case(cf_cb_field_unselected):
758         statusbar_cf_field_unselected_cb(data);
759         break;
760     case(cf_cb_file_safe_started):
761         statusbar_cf_file_safe_started_cb(data);
762         break;
763     case(cf_cb_file_safe_finished):
764         statusbar_cf_file_safe_finished_cb(data);
765         break;
766     case(cf_cb_file_safe_reload_finished):
767         break;
768     case(cf_cb_file_safe_failed):
769         statusbar_cf_file_safe_failed_cb(data);
770         break;
771     default:
772         g_warning("statusbar_cf_callback: event %u unknown", event);
773         g_assert_not_reached();
774     }
775 }
776