diff options
author | stig <stig@f5534014-38df-0310-8fa8-9805f1628bb7> | 2010-05-06 10:32:59 +0000 |
---|---|---|
committer | stig <stig@f5534014-38df-0310-8fa8-9805f1628bb7> | 2010-05-06 10:32:59 +0000 |
commit | d6bf3385ee65d287c35376b32bfd4a0cf105fd11 (patch) | |
tree | dd115ea922b4ddb9753879203b72ca647eb667eb /gtk | |
parent | 1845d0bf1c990f8d3b2c2a0cac285199bb9ea789 (diff) |
Added an option to display seconds as hours, minutes and seconds
in the packet list, on this format: "1h 2m 3.456s".
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@32683 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/main.c | 14 | ||||
-rw-r--r-- | gtk/menus.c | 45 | ||||
-rw-r--r-- | gtk/recent.c | 13 | ||||
-rw-r--r-- | gtk/recent.h | 1 |
4 files changed, 72 insertions, 1 deletions
diff --git a/gtk/main.c b/gtk/main.c index 7fb82e6144..09a6af2949 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -2018,7 +2018,7 @@ main(int argc, char *argv[]) #endif #endif -#define OPTSTRING_INIT "a:b:c:C:Df:g:Hhi:jJ:kK:lLm:nN:o:P:pQr:R:Ss:t:vw:X:y:z:" +#define OPTSTRING_INIT "a:b:c:C:Df:g:Hhi:jJ:kK:lLm:nN:o:P:pQr:R:Ss:t:T:vw:X:y:z:" #if defined HAVE_LIBPCAP && defined _WIN32 #define OPTSTRING_WIN32 "B:" @@ -2542,6 +2542,17 @@ main(int argc, char *argv[]) exit(1); } break; + case 'T': /* Seconds type */ + if (strcmp(optarg, "s") == 0) + timestamp_set_seconds_type(TS_SECONDS_DEFAULT); + else if (strcmp(optarg, "hms") == 0) + timestamp_set_seconds_type(TS_SECONDS_HOUR_MIN_SEC); + else { + cmdarg_err("Invalid seconds type \"%s\"", optarg); + cmdarg_err_cont("It must be \"s\" for seconds or \"hms\" for hours, minutes and seconds."); + exit(1); + } + break; case 'X': /* ext ops were already processed just ignore them this time*/ break; @@ -3615,6 +3626,7 @@ void change_configuration_profile (const gchar *profile_name) rf_path, strerror(rf_open_errno)); } timestamp_set_type (recent.gui_time_format); + timestamp_set_seconds_type (recent.gui_seconds_format); color_filters_enable(recent.packet_list_colorize); prefs_to_capture_opts(); diff --git a/gtk/menus.c b/gtk/menus.c index aafcea8875..911f95d5dc 100644 --- a/gtk/menus.c +++ b/gtk/menus.c @@ -132,6 +132,7 @@ static void set_menu_sensitivity (GtkItemFactory *, const gchar *, gint); static void show_hide_cb(GtkWidget *w, gpointer data, gint action); static void timestamp_format_cb(GtkWidget *w, gpointer d, gint action); static void timestamp_precision_cb(GtkWidget *w, gpointer d, gint action); +static void timestamp_seconds_time_cb(GtkWidget *w, gpointer d, gint action); static void name_resolution_cb(GtkWidget *w, gpointer d, gint action); #ifdef HAVE_LIBPCAP static void auto_scroll_live_cb(GtkWidget *w, gpointer d); @@ -590,6 +591,8 @@ static GtkItemFactoryEntry menu_items[] = TS_PREC_FIXED_USEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,}, {"/View/Time Display Format/Nanoseconds: 0.123456789", NULL, GTK_MENU_FUNC(timestamp_precision_cb), TS_PREC_FIXED_NSEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,}, + {"/View/Time Display Format/<separator>", NULL, NULL, 0, "<Separator>", NULL,}, + {"/View/Time Display Format/Display Seconds with hours and minutes", "<alt><control>0", GTK_MENU_FUNC(timestamp_seconds_time_cb), 0, "<CheckItem>", NULL,}, {"/View/Name Resol_ution", NULL, NULL, 0, "<Branch>", NULL,}, {"/View/Name Resolution/_Resolve Name", NULL, GTK_MENU_FUNC(resolve_name_cb), 0, NULL, NULL,}, {"/View/Name Resolution/<separator>", NULL, NULL, 0, "<Separator>", NULL,}, @@ -2164,6 +2167,24 @@ timestamp_precision_cb(GtkWidget *w _U_, gpointer d _U_, gint action) } } +static void +timestamp_seconds_time_cb(GtkWidget *w, gpointer d _U_, gint action _U_) +{ + if (GTK_CHECK_MENU_ITEM(w)->active) { + recent.gui_seconds_format = TS_SECONDS_HOUR_MIN_SEC; + } else { + recent.gui_seconds_format = TS_SECONDS_DEFAULT; + } + timestamp_set_seconds_type (recent.gui_seconds_format); + +#ifdef NEW_PACKET_LIST + /* This call adjusts column width */ + cf_timestamp_auto_precision(&cfile); + new_packet_list_queue_draw(); +#else + cf_change_time_formats(&cfile); +#endif +} void menu_name_resolution_changed(void) @@ -2369,6 +2390,30 @@ menu_recent_read_finished(void) { gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE); + /* don't change the seconds format, if we had a command line value */ + if (timestamp_get_seconds_type() != TS_SECONDS_NOT_SET) { + recent.gui_seconds_format = timestamp_get_seconds_type(); + } + + menu = gtk_item_factory_get_widget(main_menu_factory, + "/View/Time Display Format/Display Seconds with hours and minutes"); + switch (recent.gui_seconds_format) { + case TS_SECONDS_DEFAULT: + recent.gui_seconds_format = -1; + /* set_active will not trigger the callback when deactivating an inactive item! */ + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE); + break; + case TS_SECONDS_HOUR_MIN_SEC: + recent.gui_seconds_format = -1; + /* set_active will not trigger the callback when activating an active item! */ + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE); + break; + default: + g_assert_not_reached(); + } + menu_colorize_changed(recent.packet_list_colorize); switch (recent.gui_bytes_view) { diff --git a/gtk/recent.c b/gtk/recent.c index bb062d7325..54509e3ef4 100644 --- a/gtk/recent.c +++ b/gtk/recent.c @@ -70,6 +70,7 @@ #define RECENT_KEY_PACKET_LIST_COLORIZE "gui.packet_list_colorize" #define RECENT_GUI_TIME_FORMAT "gui.time_format" #define RECENT_GUI_TIME_PRECISION "gui.time_precision" +#define RECENT_GUI_SECONDS_FORMAT "gui.seconds_format" #define RECENT_GUI_ZOOM_LEVEL "gui.zoom_level" #define RECENT_GUI_BYTES_VIEW "gui.bytes_view" #define RECENT_GUI_GEOMETRY_MAIN_X "gui.geometry_main_x" @@ -99,6 +100,9 @@ static const char *ts_type_text[] = static const char *ts_precision_text[] = { "AUTO", "SEC", "DSEC", "CSEC", "MSEC", "USEC", "NSEC", NULL }; +static const char *ts_seconds_text[] = + { "SECONDS", "HOUR_MIN_SEC", NULL }; + /* Takes an string and a pointer to an array of strings, and a default int value. * The array must be terminated by a NULL string. If the string is found in the array * of strings, the index of that string in the array is returned. Otherwise, the @@ -358,6 +362,11 @@ write_profile_recent(void) fprintf(rf, RECENT_GUI_TIME_PRECISION ": %s\n", ts_precision_text[recent.gui_time_precision]); + fprintf(rf, "\n# Seconds display format.\n"); + fprintf(rf, "# One of: SECONDS, HOUR_MIN_SEC\n"); + fprintf(rf, RECENT_GUI_SECONDS_FORMAT ": %s\n", + ts_seconds_text[recent.gui_seconds_format]); + fprintf(rf, "\n# Zoom level.\n"); fprintf(rf, "# A decimal number.\n"); fprintf(rf, RECENT_GUI_ZOOM_LEVEL ": %d\n", @@ -603,6 +612,9 @@ read_set_recent_pair_static(gchar *key, gchar *value, void *private_data _U_) } else if (strcmp(key, RECENT_GUI_TIME_PRECISION) == 0) { recent.gui_time_precision = find_index_from_string_array(value, ts_precision_text, TS_PREC_AUTO); + } else if (strcmp(key, RECENT_GUI_SECONDS_FORMAT) == 0) { + recent.gui_seconds_format = + find_index_from_string_array(value, ts_seconds_text, TS_SECONDS_DEFAULT); } else if (strcmp(key, RECENT_GUI_ZOOM_LEVEL) == 0) { num = strtol(value, &p, 0); if (p == value || *p != '\0') @@ -848,6 +860,7 @@ recent_read_profile_static(char **rf_path_return, int *rf_errno_return) recent.packet_list_colorize = TRUE; recent.gui_time_format = TS_RELATIVE; recent.gui_time_precision = TS_PREC_AUTO; + recent.gui_seconds_format = TS_SECONDS_DEFAULT; recent.gui_zoom_level = 0; recent.gui_bytes_view = 0; diff --git a/gtk/recent.h b/gtk/recent.h index 9ef7191934..c7b58c14f2 100644 --- a/gtk/recent.h +++ b/gtk/recent.h @@ -65,6 +65,7 @@ typedef struct recent_settings_tag { gboolean packet_list_colorize; gint gui_time_format; gint gui_time_precision; + gint gui_seconds_format; gint gui_zoom_level; gint gui_bytes_view; |