Commit b681a72b authored by winckel's avatar winckel

Added a button to save all ITTI messages.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4869 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 161cde75
......@@ -58,12 +58,14 @@ gboolean ui_callback_on_open_messages(GtkWidget *widget, gpointer data)
gboolean ui_callback_on_save_messages(GtkWidget *widget, gpointer data)
{
g_message("Save messages event occurred");
gboolean filtered = (data != NULL) ? TRUE : FALSE;
g_message("Save messages event occurred %d", filtered);
if (operation_running == FALSE)
{
operation_running = TRUE;
CHECK_FCT(ui_messages_save_file_chooser());
CHECK_FCT(ui_messages_save_file_chooser(filtered));
operation_running = FALSE;
}
......
......@@ -26,6 +26,7 @@ typedef struct {
GtkToolItem *open_replay_file;
GtkToolItem *refresh_replay_file;
GtkToolItem *save_replay_file;
GtkToolItem *save_replay_file_filtered;
GtkToolItem *connect;
GtkToolItem *disconnect;
......
......@@ -37,6 +37,7 @@ int ui_menu_bar_create(GtkWidget *vbox)
GtkWidget *open_messages;
GtkWidget *reload_messages;
GtkWidget *save_messages;
GtkWidget *save_messages_filtered;
GtkWidget *goto_first_messages;
GtkWidget *goto_messages;
GtkWidget *goto_last_messages;
......@@ -81,7 +82,7 @@ int ui_menu_bar_create(GtkWidget *vbox)
(gpointer) TRUE);
save_filters = gtk_menu_item_new_with_mnemonic ("_Save filters file");
gtk_widget_add_accelerator (save_filters, "activate", accel_group, GDK_KEY_a, GDK_CONTROL_MASK,
gtk_widget_add_accelerator (save_filters, "activate", accel_group, GDK_KEY_v, GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE);
gtk_menu_shell_append (GTK_MENU_SHELL(filters_menu), save_filters);
g_signal_connect(G_OBJECT(save_filters), "activate", G_CALLBACK(ui_callback_on_save_filters), NULL);
......@@ -128,11 +129,19 @@ int ui_menu_bar_create(GtkWidget *vbox)
g_signal_connect(G_OBJECT(reload_messages), "activate", G_CALLBACK(ui_callback_on_open_messages),
(gpointer) TRUE);
save_messages = gtk_menu_item_new_with_mnemonic ("_Save messages file");
gtk_widget_add_accelerator (save_messages, "activate", accel_group, GDK_KEY_s, GDK_CONTROL_MASK,
save_messages = gtk_menu_item_new_with_mnemonic ("_Save messages file (all)");
gtk_widget_add_accelerator (save_messages, "activate", accel_group, GDK_KEY_a, GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE);
gtk_menu_shell_append (GTK_MENU_SHELL(messages_menu), save_messages);
g_signal_connect(G_OBJECT(save_messages), "activate", G_CALLBACK(ui_callback_on_save_messages), NULL);
g_signal_connect(G_OBJECT(save_messages), "activate", G_CALLBACK(ui_callback_on_save_messages),
(gpointer) FALSE);
save_messages_filtered = gtk_menu_item_new_with_mnemonic ("_Save messages file (filtered)");
gtk_widget_add_accelerator (save_messages_filtered, "activate", accel_group, GDK_KEY_s, GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE);
gtk_menu_shell_append (GTK_MENU_SHELL(messages_menu), save_messages_filtered);
g_signal_connect(G_OBJECT(save_messages_filtered), "activate", G_CALLBACK(ui_callback_on_save_messages),
(gpointer) TRUE);
gtk_menu_shell_append (GTK_MENU_SHELL(messages_menu), gtk_menu_item_new ()); // Separator
......@@ -265,10 +274,19 @@ int ui_toolbar_create(GtkWidget *vbox)
/* Button to save messages file */
{
ui_main_data.save_replay_file = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE);
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.save_replay_file), "Save messages file");
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.save_replay_file), "Save messages file (all)");
g_signal_connect(G_OBJECT(ui_main_data.save_replay_file), "clicked",
G_CALLBACK(ui_callback_on_save_messages), NULL);
G_CALLBACK(ui_callback_on_save_messages), (gpointer) FALSE);
}
/* Button to save messages file */
{
ui_main_data.save_replay_file_filtered = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE_AS);
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.save_replay_file_filtered), "Save messages file (filtered)");
g_signal_connect(G_OBJECT(ui_main_data.save_replay_file_filtered), "clicked",
G_CALLBACK(ui_callback_on_save_messages), (gpointer) TRUE);
}
/* Button to go to first signal in list */
......@@ -352,6 +370,7 @@ int ui_toolbar_create(GtkWidget *vbox)
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ui_main_data.open_replay_file), FALSE, FALSE, BUTTON_SPACE);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ui_main_data.refresh_replay_file), FALSE, FALSE, BUTTON_SPACE);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ui_main_data.save_replay_file), FALSE, FALSE, BUTTON_SPACE);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ui_main_data.save_replay_file_filtered), FALSE, FALSE, BUTTON_SPACE);
gtk_box_pack_start(GTK_BOX(hbox), gtk_separator_new(GTK_ORIENTATION_VERTICAL), FALSE, FALSE, SEPARATOR_SPACE);
......
......@@ -315,7 +315,7 @@ static void ui_message_write_callback(const gpointer buffer, const gchar *signal
fwrite (&itti_dump_message_type_end, sizeof(itti_message_types_t), 1, messages_file);
}
static int ui_messages_file_write(char *file_name)
static int ui_messages_file_write(char *file_name, gboolean filtered)
{
if (file_name == NULL)
{
......@@ -345,7 +345,7 @@ static int ui_messages_file_write(char *file_name)
/* Write messages */
{
message_number = 1;
ui_tree_view_foreach_message (ui_message_write_callback, TRUE);
ui_tree_view_foreach_message (ui_message_write_callback, filtered);
}
fclose (messages_file);
......@@ -395,7 +395,7 @@ int ui_messages_open_file_chooser(void)
return result;
}
int ui_messages_save_file_chooser(void)
int ui_messages_save_file_chooser(gboolean filtered)
{
int result = RC_OK;
GtkWidget *filechooser;
......@@ -403,7 +403,13 @@ int ui_messages_save_file_chooser(void)
/* Check if there is something to save */
if (xml_raw_data_size > 0)
{
filechooser = gtk_file_chooser_dialog_new ("Save file", GTK_WINDOW (ui_main_data.window),
static const char *title[] =
{
"Save file (all messages)",
"Save file (filtered messages)",
};
filechooser = gtk_file_chooser_dialog_new (title[filtered], GTK_WINDOW (ui_main_data.window),
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
gtk_filter_add (filechooser, "Log files", "*.log");
......@@ -426,7 +432,7 @@ int ui_messages_save_file_chooser(void)
char *filename;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
result = ui_messages_file_write (filename);
result = ui_messages_file_write (filename, filtered);
if (result == RC_OK)
{
/* Update filters file name for future use */
......
......@@ -11,7 +11,7 @@ int ui_messages_read(char *filename);
int ui_messages_open_file_chooser(void);
int ui_messages_save_file_chooser(void);
int ui_messages_save_file_chooser(gboolean filtered);
int ui_filters_open_file_chooser(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