Commit 58b5876a authored by Cedric Roux's avatar Cedric Roux

- Added progress bar when reading messages file

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4366 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent e02b0875
...@@ -67,9 +67,9 @@ gboolean ui_callback_on_save_filters(GtkWidget *widget, gpointer data) ...@@ -67,9 +67,9 @@ gboolean ui_callback_on_save_filters(GtkWidget *widget, gpointer data)
gboolean ui_callback_on_about(GtkWidget *widget, gpointer data) gboolean ui_callback_on_about(GtkWidget *widget, gpointer data)
{ {
#if defined(PACKAGE_STRING) #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 #else
ui_notification_dialog (GTK_MESSAGE_INFO, "about", "itti_analyzer"); ui_notification_dialog (GTK_MESSAGE_INFO, "about", "Eurecom itti_analyzer");
#endif #endif
return TRUE; return TRUE;
......
...@@ -10,6 +10,7 @@ typedef struct { ...@@ -10,6 +10,7 @@ typedef struct {
GtkWidget *port_entry; GtkWidget *port_entry;
char *port_entry_init; char *port_entry_init;
GtkWidget *progressbar_window;
GtkWidget *progressbar; GtkWidget *progressbar;
GtkWidget *signalslist; GtkWidget *signalslist;
ui_text_view_t *text_view; ui_text_view_t *text_view;
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
#include <stdint.h> #include <stdint.h>
#include <stdarg.h> #include <stdarg.h>
#include <sys/stat.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "itti_types.h" #include "itti_types.h"
...@@ -88,9 +90,24 @@ int ui_messages_read(char *filename) ...@@ -88,9 +90,24 @@ int ui_messages_read(char *filename)
else else
{ {
itti_socket_header_t message_header; 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); ui_callback_signal_clear_list (NULL, NULL);
/* Initialize the progress bar */
ui_progress_bar_set_fraction(0);
do do
{ {
read_data = read (source, &message_header, sizeof(itti_socket_header_t)); read_data = read (source, &message_header, sizeof(itti_socket_header_t));
...@@ -105,6 +122,8 @@ int ui_messages_read(char *filename) ...@@ -105,6 +122,8 @@ int ui_messages_read(char *filename)
if (read_data > 0) if (read_data > 0)
{ {
read_fraction += (double)read_data / size;
input_data_length = message_header.message_size - sizeof(itti_socket_header_t); 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); 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) ...@@ -122,6 +141,8 @@ int ui_messages_read(char *filename)
result = RC_FAIL; result = RC_FAIL;
break; break;
} }
read_fraction += (double)input_data_length / size;
} }
switch (message_header.message_type) switch (message_header.message_type)
...@@ -146,6 +167,7 @@ int ui_messages_read(char *filename) ...@@ -146,6 +167,7 @@ int ui_messages_read(char *filename)
if (read_messages % 100 == 0) if (read_messages % 100 == 0)
{ {
ui_progress_bar_set_fraction(read_fraction);
ui_gtk_flush_events (); ui_gtk_flush_events ();
} }
break; break;
...@@ -179,6 +201,8 @@ int ui_messages_read(char *filename) ...@@ -179,6 +201,8 @@ int ui_messages_read(char *filename)
ui_set_title ("\"%s\"", basename); 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); g_message("Read %d messages (%d to display) from file \"%s\"\n", read_messages, ui_tree_view_get_filtered_number(), filename);
close (source); close (source);
...@@ -317,27 +341,41 @@ int ui_filters_save_file_chooser(void) ...@@ -317,27 +341,41 @@ int ui_filters_save_file_chooser(void)
int ui_progress_bar_set_fraction(double fraction) int ui_progress_bar_set_fraction(double fraction)
{ {
// /* If not exist instantiate */ /* If not exist instantiate */
// if (!ui_main_data.progressbar) { if (!ui_main_data.progressbar && !ui_main_data.progressbar_window) {
// ui_main_data.progressbar = gtk_progress_bar_new(); ui_main_data.progressbar_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
// }
// /* Set the window at center of window */
// gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ui_main_data.progressbar), fraction); 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_widget_show(ui_main_data.progressbar);
// gtk_container_set_border_width(GTK_CONTAINER (ui_main_data.progressbar_window), 10);
// gtk_main_iteration();
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; return RC_OK;
} }
int ui_progress_bar_terminate(void) int ui_progress_bar_terminate(void)
{ {
// if (!ui_main_data.progressbar) if (ui_main_data.progressbar) {
// return RC_FAIL; gtk_widget_destroy(ui_main_data.progressbar);
// }
// gtk_widget_destroy(ui_main_data.progressbar); if (ui_main_data.progressbar_window) {
// ui_main_data.progressbar = NULL; gtk_widget_destroy(ui_main_data.progressbar_window);
}
ui_main_data.progressbar = NULL;
ui_main_data.progressbar_window = NULL;
return RC_OK; return RC_OK;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment