diff --git a/common/utils/itti_analyzer/libui/ui_callbacks.c b/common/utils/itti_analyzer/libui/ui_callbacks.c index c2f8a399aa130fb5f9d15ba9777ac436478ab22c..d06070cd5802f4a2584c1d2025319fb6e1e24706 100644 --- a/common/utils/itti_analyzer/libui/ui_callbacks.c +++ b/common/utils/itti_analyzer/libui/ui_callbacks.c @@ -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; } diff --git a/common/utils/itti_analyzer/libui/ui_main_screen.h b/common/utils/itti_analyzer/libui/ui_main_screen.h index 7419e7100f606d35e1e893a9fccb706af08170d7..c21c6e66f032d36c6a41f36ddbd891c31e660d9b 100644 --- a/common/utils/itti_analyzer/libui/ui_main_screen.h +++ b/common/utils/itti_analyzer/libui/ui_main_screen.h @@ -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; diff --git a/common/utils/itti_analyzer/libui/ui_menu_bar.c b/common/utils/itti_analyzer/libui/ui_menu_bar.c index 40d3712cb67751a55044a970906784d8479708a9..c6647730c7bc8f5f5da33227da53cfe7eb2607f4 100644 --- a/common/utils/itti_analyzer/libui/ui_menu_bar.c +++ b/common/utils/itti_analyzer/libui/ui_menu_bar.c @@ -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); diff --git a/common/utils/itti_analyzer/libui/ui_notifications.c b/common/utils/itti_analyzer/libui/ui_notifications.c index 496545d910a37cd2fd6d4d627bd06e45ae7f923d..89e106eb0c9d9e445c5bbe047426416234f93262 100644 --- a/common/utils/itti_analyzer/libui/ui_notifications.c +++ b/common/utils/itti_analyzer/libui/ui_notifications.c @@ -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 */ diff --git a/common/utils/itti_analyzer/libui/ui_notifications.h b/common/utils/itti_analyzer/libui/ui_notifications.h index a56c5a68f645385ec82a44a412fca7fb6003cacd..c941b2af2411a48640b59d718fd88d02e37e45c0 100644 --- a/common/utils/itti_analyzer/libui/ui_notifications.h +++ b/common/utils/itti_analyzer/libui/ui_notifications.h @@ -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);