Commit d0104e39 authored by winckel's avatar winckel

Applied messages filtering to tree view.

Created a GTK events flush function.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4327 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent f4cfeb08
...@@ -84,7 +84,7 @@ static int socket_read_itti_message(socket_data_t *socket_data, ...@@ -84,7 +84,7 @@ static int socket_read_itti_message(socket_data_t *socket_data,
g_assert(message_header != NULL); 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 */ /* Read the sub-header of signal */
while (data_read != sizeof(itti_signal_header_t)) { while (data_read != sizeof(itti_signal_header_t)) {
...@@ -124,7 +124,7 @@ static int socket_read_itti_message(socket_data_t *socket_data, ...@@ -124,7 +124,7 @@ static int socket_read_itti_message(socket_data_t *socket_data,
socket_notify_gui_update(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); return total_data_read + sizeof(itti_signal_header);
} }
......
...@@ -106,7 +106,7 @@ void ui_signal_add_to_list(gpointer data, gpointer user_data) ...@@ -106,7 +106,7 @@ void ui_signal_add_to_list(gpointer data, gpointer user_data)
ui_main_data.nb_message_received++; ui_main_data.nb_message_received++;
/* Check if no signal was selected in the list or if it was the last signal */ /* 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 */ /* Advance to the new last signal */
ui_callback_signal_go_to_last (NULL, NULL, NULL); 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 ...@@ -132,6 +132,8 @@ static gboolean ui_handle_update_signal_list(gint fd, void *data, size_t data_le
/* Free the message */ /* Free the message */
free (signal_list_message); free (signal_list_message);
ui_gtk_flush_events();
return TRUE; return TRUE;
} }
...@@ -313,7 +315,11 @@ gboolean ui_callback_on_menu_item_selected(GtkWidget *widget, gpointer data) ...@@ -313,7 +315,11 @@ gboolean ui_callback_on_menu_item_selected(GtkWidget *widget, gpointer data)
gboolean enabled; gboolean enabled;
enabled = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM(widget)); enabled = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM(widget));
if (filter_entry->enabled != enabled)
{
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); // g_debug("ui_callback_on_menu_item_selected occurred %x %x %s %d", (int) widget, (int) data, filter_entry->name, enabled);
return TRUE; return TRUE;
......
...@@ -130,19 +130,23 @@ void ui_filters_add(ui_filter_e filter, uint32_t value, char *name) ...@@ -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 (name != NULL)
{
item = ui_search_name (filter, name);
if (item < filter->used) if (item < filter->used)
{ {
return (filter->items[item].enabled ? TRUE : FALSE); return (filter->items[item].enabled ? TRUE : FALSE);
} }
}
return (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; gboolean result;
...@@ -159,7 +163,7 @@ static void write_filter(FILE *filter_file, ui_filter_t *filter) ...@@ -159,7 +163,7 @@ static void write_filter(FILE *filter_file, ui_filter_t *filter)
fprintf (filter_file, " <%s>\n", filter->name); fprintf (filter_file, " <%s>\n", filter->name);
for (item = 0; item < filter->used; item++) 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); fprintf (filter_file, " </%s>\n", filter->name);
} }
......
...@@ -38,7 +38,7 @@ int ui_init_filters(int reset, int clear_ids); ...@@ -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); 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); int ui_write_filters_file(char *file_name);
......
...@@ -22,7 +22,7 @@ gboolean ui_callback_on_pipe_notification( ...@@ -22,7 +22,7 @@ gboolean ui_callback_on_pipe_notification(
/* avoid reentrancy problems and stack overflow */ /* avoid reentrancy problems and stack overflow */
g_source_remove(pipe_input->pipe_input_id); 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)) { if (pipe_input->input_cb(pipe_input->source_fd, pipe_input->user_data)) {
/* restore pipe handler */ /* restore pipe handler */
......
...@@ -134,3 +134,11 @@ int ui_gtk_initialize(int argc, char *argv[]) ...@@ -134,3 +134,11 @@ int ui_gtk_initialize(int argc, char *argv[])
return RC_OK; return RC_OK;
} }
void ui_gtk_flush_events(void)
{
while (gtk_events_pending ())
{
gtk_main_iteration();
}
}
...@@ -49,4 +49,6 @@ extern ui_main_data_t ui_main_data; ...@@ -49,4 +49,6 @@ extern ui_main_data_t ui_main_data;
int ui_gtk_initialize(int argc, char *argv[]); int ui_gtk_initialize(int argc, char *argv[]);
void ui_gtk_flush_events(void);
#endif /* UI_MAIN_SCREEN_H_ */ #endif /* UI_MAIN_SCREEN_H_ */
...@@ -53,12 +53,14 @@ static void ui_change_cursor(gboolean busy) ...@@ -53,12 +53,14 @@ static void ui_change_cursor(gboolean busy)
gdk_window_set_cursor (window, cursor); gdk_window_set_cursor (window, cursor);
gdk_display_sync(display); gdk_display_sync(display);
gdk_cursor_unref (cursor); 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 else
{ {
gdk_window_set_cursor (window, NULL); 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();
} }
} }
......
...@@ -10,15 +10,43 @@ ...@@ -10,15 +10,43 @@
#include "ui_main_screen.h" #include "ui_main_screen.h"
#include "ui_tree_view.h" #include "ui_tree_view.h"
#include "ui_callbacks.h" #include "ui_callbacks.h"
#include "ui_filters.h"
#include "ui_signal_dissect_view.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 static void
ui_tree_view_init_list(GtkWidget *list) ui_tree_view_init_list(GtkWidget *list)
{ {
GtkCellRenderer *renderer; GtkCellRenderer *renderer;
GtkTreeViewColumn *column; GtkTreeViewColumn *column;
GtkListStore *store;
renderer = gtk_cell_renderer_text_new(); renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes( column = gtk_tree_view_column_new_with_attributes(
...@@ -43,7 +71,7 @@ ui_tree_view_init_list(GtkWidget *list) ...@@ -43,7 +71,7 @@ ui_tree_view_init_list(GtkWidget *list)
g_signal_connect(G_OBJECT(column), "clicked", g_signal_connect(G_OBJECT(column), "clicked",
G_CALLBACK(ui_callback_on_tree_column_header_click), (gpointer) COL_TO_TASK); G_CALLBACK(ui_callback_on_tree_column_header_click), (gpointer) COL_TO_TASK);
store = gtk_list_store_new(NUM_COLS, ui_store.store = gtk_list_store_new(NUM_COLS,
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING,
...@@ -54,25 +82,24 @@ ui_tree_view_init_list(GtkWidget *list) ...@@ -54,25 +82,24 @@ ui_tree_view_init_list(GtkWidget *list)
*/ */
G_TYPE_POINTER); 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, static void ui_tree_view_add_to_list(GtkWidget *list, const gchar *message_number,
const gchar *signal_name, const char *origin_task, const gchar *signal_name, const char *origin_task,
const char *to_task, gpointer buffer) const char *to_task, gpointer buffer)
{ {
GtkListStore *store;
GtkTreeIter iter; GtkTreeIter iter;
store = GTK_LIST_STORE(gtk_tree_view_get_model gtk_list_store_append(ui_store.store, &iter);
(GTK_TREE_VIEW(list))); gtk_list_store_set(ui_store.store, &iter,
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
/* Columns */ /* Columns */
COL_MSG_NUM , message_number, COL_MSG_NUM , message_number,
COL_SIGNAL , signal_name, COL_SIGNAL , signal_name,
...@@ -85,13 +112,9 @@ static void ui_tree_view_add_to_list(GtkWidget *list, const gchar *message_numbe ...@@ -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) void ui_tree_view_destroy_list(GtkWidget *list)
{ {
GtkListStore *store;
g_assert(list != NULL); g_assert(list != NULL);
store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list))); gtk_list_store_clear(ui_store.store);
gtk_list_store_clear(store);
/* Reset number of messages */ /* Reset number of messages */
ui_main_data.nb_message_received = 0; ui_main_data.nb_message_received = 0;
...@@ -170,3 +193,8 @@ void ui_tree_view_select_row(gint row, GtkTreePath **path) ...@@ -170,3 +193,8 @@ void ui_tree_view_select_row(gint row, GtkTreePath **path)
*path = path_row; *path = path_row;
} }
} }
void ui_tree_view_refilter(void)
{
gtk_tree_model_filter_refilter (ui_store.filtered);;
}
...@@ -20,4 +20,6 @@ void ui_tree_view_destroy_list(GtkWidget *list); ...@@ -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_select_row(gint row, GtkTreePath **path);
void ui_tree_view_refilter(void);
#endif /* UI_TREE_VIEW_H_ */ #endif /* UI_TREE_VIEW_H_ */
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