diff --git a/common/utils/itti_analyzer/libbuffers/socket.c b/common/utils/itti_analyzer/libbuffers/socket.c index ff5e28fd3c0e1cb450c073563817f58c7bf10018..27d9316d6f5ab54c3b9a222d4ff24a5595d64c24 100644 --- a/common/utils/itti_analyzer/libbuffers/socket.c +++ b/common/utils/itti_analyzer/libbuffers/socket.c @@ -84,7 +84,7 @@ static int socket_read_itti_message(socket_data_t *socket_data, g_assert(message_header != NULL); - g_debug("Attempting to read signal header from socket"); + // g_debug("Attempting to read signal header from socket"); /* Read the sub-header of signal */ while (data_read != sizeof(itti_signal_header_t)) { @@ -124,7 +124,7 @@ static int socket_read_itti_message(socket_data_t *socket_data, socket_notify_gui_update(socket_data); } - g_debug("Successfully read new signal %u from socket", itti_signal_header.message_number); + // g_debug("Successfully read new signal %u from socket", itti_signal_header.message_number); return total_data_read + sizeof(itti_signal_header); } diff --git a/common/utils/itti_analyzer/libui/ui_callbacks.c b/common/utils/itti_analyzer/libui/ui_callbacks.c index 27187c373860c0aeec9835ba63ea1d2b44bf8de6..a1b48865ddbfdd490babfbfd34253704d64f76cc 100644 --- a/common/utils/itti_analyzer/libui/ui_callbacks.c +++ b/common/utils/itti_analyzer/libui/ui_callbacks.c @@ -106,7 +106,7 @@ void ui_signal_add_to_list(gpointer data, gpointer user_data) ui_main_data.nb_message_received++; /* Check if no signal was selected in the list or if it was the last signal */ - if ((ui_main_data.path_last == NULL) || (gtk_tree_path_compare(ui_main_data.path_last, path) == 0)) + if ((ui_main_data.path_last == NULL) || (path == NULL) || (gtk_tree_path_compare(ui_main_data.path_last, path) == 0)) { /* Advance to the new last signal */ ui_callback_signal_go_to_last (NULL, NULL, NULL); @@ -132,6 +132,8 @@ static gboolean ui_handle_update_signal_list(gint fd, void *data, size_t data_le /* Free the message */ free (signal_list_message); + ui_gtk_flush_events(); + return TRUE; } @@ -313,7 +315,11 @@ gboolean ui_callback_on_menu_item_selected(GtkWidget *widget, gpointer data) gboolean enabled; enabled = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM(widget)); - filter_entry->enabled = enabled; + if (filter_entry->enabled != enabled) + { + filter_entry->enabled = enabled; + ui_tree_view_refilter(); + } // g_debug("ui_callback_on_menu_item_selected occurred %x %x %s %d", (int) widget, (int) data, filter_entry->name, enabled); return TRUE; diff --git a/common/utils/itti_analyzer/libui/ui_filters.c b/common/utils/itti_analyzer/libui/ui_filters.c index 9899f9f0bc8c2134e61d8fcc23752911ecf27523..0696fbf1dfd6644301f1e5aa2f77edfbe3b54df8 100644 --- a/common/utils/itti_analyzer/libui/ui_filters.c +++ b/common/utils/itti_analyzer/libui/ui_filters.c @@ -130,19 +130,23 @@ void ui_filters_add(ui_filter_e filter, uint32_t value, char *name) } } -static gboolean ui_item_enabled(ui_filter_t *filter, uint32_t value) +static gboolean ui_item_enabled(ui_filter_t *filter, char *name) { - int item = ui_search_id (filter, value); + int item; - if (item < filter->used) + if (name != NULL) { - return (filter->items[item].enabled ? TRUE : FALSE); - } + item = ui_search_name (filter, name); + if (item < filter->used) + { + return (filter->items[item].enabled ? TRUE : FALSE); + } + } return (FALSE); } -gboolean ui_filters_message_enabled(uint32_t message, uint32_t origin_task, uint32_t destination_task) +gboolean ui_filters_message_enabled(char *message, char *origin_task, char *destination_task) { gboolean result; @@ -159,7 +163,7 @@ static void write_filter(FILE *filter_file, ui_filter_t *filter) fprintf (filter_file, " <%s>\n", filter->name); for (item = 0; item < filter->used; item++) { - fprintf (filter_file, " %s=\"%d\"\n", filter->items[item].name, filter->items[item].enabled ? 1 : 0); + fprintf (filter_file, " <%s enabled=\"%d\"/>\n", filter->items[item].name, filter->items[item].enabled ? 1 : 0); } fprintf (filter_file, " </%s>\n", filter->name); } diff --git a/common/utils/itti_analyzer/libui/ui_filters.h b/common/utils/itti_analyzer/libui/ui_filters.h index 94e1a524d045a733179e3b1b8612b4d7f91903d8..74761a58edb9176e2c48a4bc3093492253b968b5 100644 --- a/common/utils/itti_analyzer/libui/ui_filters.h +++ b/common/utils/itti_analyzer/libui/ui_filters.h @@ -38,7 +38,7 @@ int ui_init_filters(int reset, int clear_ids); void ui_filters_add(ui_filter_e filter, uint32_t value, char *name); -gboolean ui_filters_message_enabled(uint32_t message, uint32_t origin_task, uint32_t destination_task); +gboolean ui_filters_message_enabled(char *message, char *origin_task, char *destination_task); int ui_write_filters_file(char *file_name); diff --git a/common/utils/itti_analyzer/libui/ui_interface.c b/common/utils/itti_analyzer/libui/ui_interface.c index 5010a07658e3ab7f60a80a74ab0896a747167cfe..3dd58b275670a87b3a1dbb228b77bb4f3b9c110a 100644 --- a/common/utils/itti_analyzer/libui/ui_interface.c +++ b/common/utils/itti_analyzer/libui/ui_interface.c @@ -22,7 +22,7 @@ gboolean ui_callback_on_pipe_notification( /* avoid reentrancy problems and stack overflow */ g_source_remove(pipe_input->pipe_input_id); - g_debug("Received new data on pipe %d", pipe_input->pipe_input_id); + // g_debug("Received new data on pipe %d", pipe_input->pipe_input_id); if (pipe_input->input_cb(pipe_input->source_fd, pipe_input->user_data)) { /* restore pipe handler */ diff --git a/common/utils/itti_analyzer/libui/ui_main_screen.c b/common/utils/itti_analyzer/libui/ui_main_screen.c index b36c0ce735c8a09c1b9aa1d5a73877052be6e4ed..1b9dbbdacd82484fb5c7f180ac82e95486f78445 100644 --- a/common/utils/itti_analyzer/libui/ui_main_screen.c +++ b/common/utils/itti_analyzer/libui/ui_main_screen.c @@ -134,3 +134,11 @@ int ui_gtk_initialize(int argc, char *argv[]) return RC_OK; } + +void ui_gtk_flush_events(void) +{ + while (gtk_events_pending ()) + { + gtk_main_iteration(); + } +} diff --git a/common/utils/itti_analyzer/libui/ui_main_screen.h b/common/utils/itti_analyzer/libui/ui_main_screen.h index 14012d4a442ebaa78a19799a3c590c1fb8e93c46..749962b29a41b9275b5ca6ca4ebb25fa4ca7861b 100644 --- a/common/utils/itti_analyzer/libui/ui_main_screen.h +++ b/common/utils/itti_analyzer/libui/ui_main_screen.h @@ -49,4 +49,6 @@ extern ui_main_data_t ui_main_data; int ui_gtk_initialize(int argc, char *argv[]); +void ui_gtk_flush_events(void); + #endif /* UI_MAIN_SCREEN_H_ */ diff --git a/common/utils/itti_analyzer/libui/ui_notifications.c b/common/utils/itti_analyzer/libui/ui_notifications.c index 8639d5fdc1fae35a24b06501f6e82b6ac3106e5f..d61bfed7ee6367f3942a86dd08bc940972ddd70c 100644 --- a/common/utils/itti_analyzer/libui/ui_notifications.c +++ b/common/utils/itti_analyzer/libui/ui_notifications.c @@ -53,12 +53,14 @@ static void ui_change_cursor(gboolean busy) gdk_window_set_cursor (window, cursor); gdk_display_sync(display); gdk_cursor_unref (cursor); - gtk_widget_set_sensitive (ui_main_data.window, FALSE); + // gtk_widget_set_sensitive (ui_main_data.window, FALSE); + ui_gtk_flush_events(); } else { gdk_window_set_cursor (window, NULL); - gtk_widget_set_sensitive (ui_main_data.window, TRUE); + // gtk_widget_set_sensitive (ui_main_data.window, TRUE); + ui_gtk_flush_events(); } } diff --git a/common/utils/itti_analyzer/libui/ui_tree_view.c b/common/utils/itti_analyzer/libui/ui_tree_view.c index 8d177bbefe1cb3ff947217bf6a64e8ad96460826..637a48ec28bd33e4efa5497ba2f47b2c9c7e640c 100644 --- a/common/utils/itti_analyzer/libui/ui_tree_view.c +++ b/common/utils/itti_analyzer/libui/ui_tree_view.c @@ -10,15 +10,43 @@ #include "ui_main_screen.h" #include "ui_tree_view.h" #include "ui_callbacks.h" +#include "ui_filters.h" #include "ui_signal_dissect_view.h" +typedef struct +{ + GtkListStore *store; + GtkTreeModelFilter *filtered; +} ui_store_t; + +static ui_store_t ui_store; + +static gboolean ui_tree_filter_messages(GtkTreeModel *model, GtkTreeIter *iter, ui_store_t *store) +{ + char *message; + char *origin_task; + char *destination_task; + gboolean enabled; + + gtk_tree_model_get (model, iter, COL_SIGNAL, &message, COL_FROM_TASK, &origin_task, COL_TO_TASK, &destination_task, + -1); + enabled = ui_filters_message_enabled (message, origin_task, destination_task); + + // g_debug("%x %x %s %s %s %d", model, iter, message, origin_task, destination_task, enabled); + + g_free(message); + g_free(origin_task); + g_free(destination_task); + + return enabled; +} + static void ui_tree_view_init_list(GtkWidget *list) { GtkCellRenderer *renderer; GtkTreeViewColumn *column; - GtkListStore *store; renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes( @@ -43,36 +71,35 @@ ui_tree_view_init_list(GtkWidget *list) g_signal_connect(G_OBJECT(column), "clicked", G_CALLBACK(ui_callback_on_tree_column_header_click), (gpointer) COL_TO_TASK); - store = gtk_list_store_new(NUM_COLS, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - /* HACK: add a reference to the buffer here - * to avoid maintining multiple lists. - * The reference is not displayed - */ - G_TYPE_POINTER); + ui_store.store = gtk_list_store_new(NUM_COLS, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING, + /* HACK: add a reference to the buffer here + * to avoid maintining multiple lists. + * The reference is not displayed + */ + G_TYPE_POINTER); - gtk_tree_view_set_model(GTK_TREE_VIEW(list), GTK_TREE_MODEL(store)); + ui_store.filtered = GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new (GTK_TREE_MODEL (ui_store.store), NULL)); + gtk_tree_model_filter_set_visible_func (ui_store.filtered, + (GtkTreeModelFilterVisibleFunc) ui_tree_filter_messages, + &ui_store, NULL); - gtk_tree_view_columns_autosize(GTK_TREE_VIEW(list)); + gtk_tree_view_set_model(GTK_TREE_VIEW(list), GTK_TREE_MODEL(ui_store.filtered)); - g_object_unref(store); + gtk_tree_view_columns_autosize(GTK_TREE_VIEW(list)); } static void ui_tree_view_add_to_list(GtkWidget *list, const gchar *message_number, const gchar *signal_name, const char *origin_task, const char *to_task, gpointer buffer) { - GtkListStore *store; GtkTreeIter iter; - store = GTK_LIST_STORE(gtk_tree_view_get_model - (GTK_TREE_VIEW(list))); - - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, + gtk_list_store_append(ui_store.store, &iter); + gtk_list_store_set(ui_store.store, &iter, /* Columns */ COL_MSG_NUM , message_number, COL_SIGNAL , signal_name, @@ -85,13 +112,9 @@ static void ui_tree_view_add_to_list(GtkWidget *list, const gchar *message_numbe void ui_tree_view_destroy_list(GtkWidget *list) { - GtkListStore *store; - g_assert(list != NULL); - store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list))); - - gtk_list_store_clear(store); + gtk_list_store_clear(ui_store.store); /* Reset number of messages */ ui_main_data.nb_message_received = 0; @@ -170,3 +193,8 @@ void ui_tree_view_select_row(gint row, GtkTreePath **path) *path = path_row; } } + +void ui_tree_view_refilter(void) +{ + gtk_tree_model_filter_refilter (ui_store.filtered);; +} diff --git a/common/utils/itti_analyzer/libui/ui_tree_view.h b/common/utils/itti_analyzer/libui/ui_tree_view.h index e04224c8578dbb0eac11a955818009d691637e51..b4672ddd77cd403336b87c74f3a577edcb374510 100644 --- a/common/utils/itti_analyzer/libui/ui_tree_view.h +++ b/common/utils/itti_analyzer/libui/ui_tree_view.h @@ -20,4 +20,6 @@ void ui_tree_view_destroy_list(GtkWidget *list); void ui_tree_view_select_row(gint row, GtkTreePath **path); +void ui_tree_view_refilter(void); + #endif /* UI_TREE_VIEW_H_ */