diff --git a/common/utils/itti_analyzer/libui/ui_callbacks.c b/common/utils/itti_analyzer/libui/ui_callbacks.c index fd95c54e260e34378e732478edbc39afbbca0fcf..10f01fec0054fc32ec7d0b8f5be4c8582f968e6b 100644 --- a/common/utils/itti_analyzer/libui/ui_callbacks.c +++ b/common/utils/itti_analyzer/libui/ui_callbacks.c @@ -67,9 +67,9 @@ gboolean ui_callback_on_save_filters(GtkWidget *widget, gpointer data) gboolean ui_callback_on_about(GtkWidget *widget, gpointer data) { #if defined(PACKAGE_STRING) - ui_notification_dialog (GTK_MESSAGE_INFO, "about", "%s", PACKAGE_STRING); + ui_notification_dialog (GTK_MESSAGE_INFO, "about", "Eurecom %s", PACKAGE_STRING); #else - ui_notification_dialog (GTK_MESSAGE_INFO, "about", "itti_analyzer"); + ui_notification_dialog (GTK_MESSAGE_INFO, "about", "Eurecom itti_analyzer"); #endif return TRUE; diff --git a/common/utils/itti_analyzer/libui/ui_main_screen.h b/common/utils/itti_analyzer/libui/ui_main_screen.h index c9b91f8d9eaffa1825fda8bcfd158bf7eda4182e..0bef97e7a0b868715c589351a0535e7c636861d0 100644 --- a/common/utils/itti_analyzer/libui/ui_main_screen.h +++ b/common/utils/itti_analyzer/libui/ui_main_screen.h @@ -10,6 +10,7 @@ typedef struct { GtkWidget *port_entry; char *port_entry_init; + GtkWidget *progressbar_window; GtkWidget *progressbar; GtkWidget *signalslist; ui_text_view_t *text_view; diff --git a/common/utils/itti_analyzer/libui/ui_notifications.c b/common/utils/itti_analyzer/libui/ui_notifications.c index 7b1bbe86000d29bcb57e3ad3114df02f6ef5d9be..947d6cfd67785e3b5c551f265a2b8f7e6b56f270 100644 --- a/common/utils/itti_analyzer/libui/ui_notifications.c +++ b/common/utils/itti_analyzer/libui/ui_notifications.c @@ -3,6 +3,8 @@ #include <stdint.h> #include <stdarg.h> +#include <sys/stat.h> + #include <gtk/gtk.h> #include "itti_types.h" @@ -88,9 +90,24 @@ int ui_messages_read(char *filename) else { itti_socket_header_t message_header; + struct stat st; + int size; + double read_fraction = 0.f; + + if (stat(filename, &st) < 0) { + ui_notification_dialog (GTK_MESSAGE_ERROR, "get file length", + "Failed to retrieve length for file \"%s\": %s", + filename, + g_strerror (errno)); + result = RC_FAIL; + } + size = st.st_size; ui_callback_signal_clear_list (NULL, NULL); + /* Initialize the progress bar */ + ui_progress_bar_set_fraction(0); + do { read_data = read (source, &message_header, sizeof(itti_socket_header_t)); @@ -105,6 +122,8 @@ int ui_messages_read(char *filename) if (read_data > 0) { + read_fraction += (double)read_data / size; + input_data_length = message_header.message_size - sizeof(itti_socket_header_t); g_debug ("%x, %x ,%x", message_header.message_type, message_header.message_size, input_data_length); @@ -122,6 +141,8 @@ int ui_messages_read(char *filename) result = RC_FAIL; break; } + + read_fraction += (double)input_data_length / size; } switch (message_header.message_type) @@ -146,6 +167,7 @@ int ui_messages_read(char *filename) if (read_messages % 100 == 0) { + ui_progress_bar_set_fraction(read_fraction); ui_gtk_flush_events (); } break; @@ -179,6 +201,8 @@ int ui_messages_read(char *filename) ui_set_title ("\"%s\"", basename); } + ui_progress_bar_terminate(); + g_message("Read %d messages (%d to display) from file \"%s\"\n", read_messages, ui_tree_view_get_filtered_number(), filename); close (source); @@ -317,27 +341,41 @@ int ui_filters_save_file_chooser(void) int ui_progress_bar_set_fraction(double fraction) { -// /* If not exist instantiate */ -// if (!ui_main_data.progressbar) { -// ui_main_data.progressbar = gtk_progress_bar_new(); -// } -// -// gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ui_main_data.progressbar), fraction); -// -// gtk_widget_show(ui_main_data.progressbar); -// -// gtk_main_iteration(); + /* If not exist instantiate */ + if (!ui_main_data.progressbar && !ui_main_data.progressbar_window) { + ui_main_data.progressbar_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + + /* Set the window at center of window */ + gtk_window_set_position(GTK_WINDOW(ui_main_data.progressbar_window), GTK_WIN_POS_CENTER); + gtk_window_set_title(GTK_WINDOW(ui_main_data.progressbar_window), "Processing"); + + gtk_container_set_border_width(GTK_CONTAINER (ui_main_data.progressbar_window), 10); + + ui_main_data.progressbar = gtk_progress_bar_new(); + + gtk_container_add (GTK_CONTAINER (ui_main_data.progressbar_window), + ui_main_data.progressbar); + gtk_widget_show_all (ui_main_data.progressbar_window); + } + + gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ui_main_data.progressbar), fraction); + +// ui_gtk_flush_events(); return RC_OK; } int ui_progress_bar_terminate(void) { -// if (!ui_main_data.progressbar) -// return RC_FAIL; -// -// gtk_widget_destroy(ui_main_data.progressbar); -// ui_main_data.progressbar = NULL; + if (ui_main_data.progressbar) { + gtk_widget_destroy(ui_main_data.progressbar); + } + if (ui_main_data.progressbar_window) { + gtk_widget_destroy(ui_main_data.progressbar_window); + } + + ui_main_data.progressbar = NULL; + ui_main_data.progressbar_window = NULL; return RC_OK; }