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