Commit bb84c46c authored by winckel's avatar winckel

Added handling of message read abort when closing windows.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4862 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 0b31d140
......@@ -164,6 +164,12 @@ void ui_set_title(const char *fmt, ...)
gtk_window_set_title (GTK_WINDOW(ui_main_data.window), title);
}
void ui_main_window_destroy (void)
{
ui_progressbar_window_destroy();
gtk_main_quit();
}
int ui_gtk_initialize(int argc, char *argv[])
{
GtkWidget *vbox;
......@@ -190,7 +196,7 @@ int ui_gtk_initialize(int argc, char *argv[])
gtk_container_add (GTK_CONTAINER(ui_main_data.window), vbox);
/* Assign the destroy event */
g_signal_connect(ui_main_data.window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect(ui_main_data.window, "destroy", ui_main_window_destroy, NULL);
/* Show the application window */
gtk_widget_show_all (ui_main_data.window);
......
......@@ -63,6 +63,8 @@ void ui_gtk_parse_arg(int argc, char *argv[]);
void ui_set_title(const char *fmt, ...);
void ui_main_window_destroy (void);
int ui_gtk_initialize(int argc, char *argv[]);
void ui_gtk_flush_events(void);
......
......@@ -99,7 +99,7 @@ int ui_menu_bar_create(GtkWidget *vbox)
quit = gtk_menu_item_new_with_mnemonic ("_Quit");
gtk_widget_add_accelerator (quit, "activate", accel_group, GDK_KEY_q, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
gtk_menu_shell_append (GTK_MENU_SHELL(filters_menu), quit);
g_signal_connect(G_OBJECT(quit), "activate", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(G_OBJECT(quit), "activate", ui_main_window_destroy, NULL);
}
}
......
......@@ -31,6 +31,7 @@ static const itti_message_types_t itti_dump_message_type_end = ITTI_DUMP_MESS
static gboolean chooser_running;
static FILE *messages_file;
static uint32_t message_number;
static gboolean ui_abort;
int ui_disable_connect_button(void)
{
......@@ -126,6 +127,7 @@ int ui_messages_read(char *file_name)
ui_main_data.follow_last = TRUE;
/* Initialize the progress bar */
ui_abort = FALSE;
ui_progress_bar_set_fraction (0);
do
......@@ -261,7 +263,7 @@ int ui_messages_read(char *file_name)
break;
}
}
} while (read_data > 0);
} while ((ui_abort == FALSE) && (read_data > 0));
if (read_messages > 0)
{
......@@ -561,28 +563,41 @@ int ui_filters_save_file_chooser(void)
return result;
}
void ui_progressbar_window_destroy (void)
{
ui_abort = TRUE;
ui_progress_bar_terminate();
}
int ui_progress_bar_set_fraction(double fraction)
{
/* If not exist instantiate */
if (!ui_main_data.progressbar && !ui_main_data.progressbar_window)
if (ui_abort == FALSE)
{
ui_main_data.progressbar_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
/* 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");
/* 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);
gtk_container_set_border_width (GTK_CONTAINER (ui_main_data.progressbar_window), 10);
ui_main_data.progressbar = gtk_progress_bar_new ();
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_container_add (GTK_CONTAINER (ui_main_data.progressbar_window), ui_main_data.progressbar);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(ui_main_data.progressbar), fraction);
/* Assign the destroy event */
g_signal_connect(ui_main_data.progressbar_window, "destroy", ui_progressbar_window_destroy, NULL);
// ui_gtk_flush_events();
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;
}
......@@ -592,14 +607,13 @@ int ui_progress_bar_terminate(void)
if (ui_main_data.progressbar)
{
gtk_widget_destroy (ui_main_data.progressbar);
ui_main_data.progressbar = NULL;
}
if (ui_main_data.progressbar_window)
{
gtk_widget_destroy (ui_main_data.progressbar_window);
ui_main_data.progressbar_window = NULL;
}
ui_main_data.progressbar = NULL;
ui_main_data.progressbar_window = NULL;
return RC_OK;
}
......@@ -17,6 +17,8 @@ int ui_filters_open_file_chooser(void);
int ui_filters_save_file_chooser(void);
void ui_progressbar_window_destroy(void);
int ui_progress_bar_set_fraction(double fraction);
int ui_progress_bar_terminate(void);
......
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