Commit 6e82ddd5 authored by winckel's avatar winckel

Replaced right-click on messageselect handler by a popup menu that control...

Replaced right-click on messageselect  handler by a popup menu that control all filtered items for the row.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4485 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 0d5e035e
...@@ -37,13 +37,16 @@ gboolean ui_callback_on_tree_view_select(GtkWidget *widget, ...@@ -37,13 +37,16 @@ gboolean ui_callback_on_tree_view_select(GtkWidget *widget,
GdkEvent *event, GdkEvent *event,
gpointer data); gpointer data);
gboolean gboolean ui_callback_on_select_signal(GtkTreeSelection *selection,
ui_callback_on_select_signal(GtkTreeSelection *selection,
GtkTreeModel *model, GtkTreeModel *model,
GtkTreePath *path, GtkTreePath *path,
gboolean path_currently_selected, gboolean path_currently_selected,
gpointer userdata); gpointer userdata);
gboolean ui_callback_on_menu_enable (GtkWidget *widget, gpointer data);
gboolean ui_callback_on_menu_color (GtkWidget *widget, gpointer data);
gboolean ui_callback_signal_go_to_first(GtkWidget *widget, gboolean ui_callback_signal_go_to_first(GtkWidget *widget,
gpointer data); gpointer data);
......
...@@ -392,83 +392,89 @@ int ui_filters_file_write(const char *file_name) ...@@ -392,83 +392,89 @@ int ui_filters_file_write(const char *file_name)
return RC_OK; return RC_OK;
} }
void ui_create_filter_menu(GtkWidget **menu, ui_filter_t *filter) static void ui_create_filter_menu(GtkWidget **menu, ui_filter_t *filter)
{ {
if (*menu == NULL)
{
GtkWidget *menu_items; GtkWidget *menu_items;
int item; int item;
gpointer data; gpointer data;
*menu = gtk_menu_new(); *menu = gtk_menu_new ();
/* Create the "NONE" menu-item */ /* Create the "NONE" menu-item */
{ {
/* Create a new menu-item with a name */ /* Create a new menu-item with a name */
menu_items = gtk_menu_item_new_with_label("NONE"); menu_items = gtk_menu_item_new_with_label ("NONE");
/* Add it to the menu. */ /* Add it to the menu. */
gtk_menu_shell_append(GTK_MENU_SHELL(*menu), menu_items); gtk_menu_shell_append (GTK_MENU_SHELL(*menu), menu_items);
g_debug("ui_create_filter_menu %lx", (long) menu_items); g_debug("ui_create_filter_menu %lx", (long) menu_items);
g_signal_connect(G_OBJECT(menu_items), "activate", g_signal_connect(G_OBJECT(menu_items), "activate", G_CALLBACK(ui_callback_on_menu_none), *menu);
G_CALLBACK(ui_callback_on_menu_none), *menu);
/* Show the widget */ /* Show the widget */
gtk_widget_show(menu_items); gtk_widget_show (menu_items);
} }
/* Create the "ALL" menu-item */ /* Create the "ALL" menu-item */
{ {
/* Create a new menu-item with a name */ /* Create a new menu-item with a name */
menu_items = gtk_menu_item_new_with_label("ALL"); menu_items = gtk_menu_item_new_with_label ("ALL");
/* Add it to the menu. */ /* Add it to the menu. */
gtk_menu_shell_append(GTK_MENU_SHELL(*menu), menu_items); gtk_menu_shell_append (GTK_MENU_SHELL(*menu), menu_items);
g_debug("ui_create_filter_menu %lx", (long) menu_items); g_debug("ui_create_filter_menu %lx", (long) menu_items);
g_signal_connect(G_OBJECT(menu_items), "activate", g_signal_connect(G_OBJECT(menu_items), "activate", G_CALLBACK(ui_callback_on_menu_all), *menu);
G_CALLBACK(ui_callback_on_menu_all), *menu);
/* Show the widget */ /* Show the widget */
gtk_widget_show(menu_items); gtk_widget_show (menu_items);
} }
/* Create separator */ /* Create separator */
{ {
menu_items = gtk_menu_item_new(); menu_items = gtk_menu_item_new ();
/* Add it to the menu. */ /* Add it to the menu. */
gtk_menu_shell_append(GTK_MENU_SHELL(*menu), menu_items); gtk_menu_shell_append (GTK_MENU_SHELL(*menu), menu_items);
/* Show the widget */ /* Show the widget */
gtk_widget_show(menu_items); gtk_widget_show (menu_items);
} }
/* Creates menu-items */ /* Creates menu-items */
for (item = 0; item < filter->used; item++) for (item = 0; item < filter->used; item++)
{ {
/* Create a new menu-item with a name */ /* Create a new menu-item with a name */
menu_items = gtk_check_menu_item_new_with_label( menu_items = gtk_check_menu_item_new_with_label (filter->items[item].name);
filter->items[item].name);
/* Add it to the menu. */ /* Add it to the menu. */
gtk_menu_shell_append(GTK_MENU_SHELL(*menu), menu_items); gtk_menu_shell_append (GTK_MENU_SHELL(*menu), menu_items);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_items), gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_items), filter->items[item].enabled);
filter->items[item].enabled);
/* Connect function to be called when the menu item is selected */ /* Connect function to be called when the menu item is selected */
data = &filter->items[item]; data = &filter->items[item];
g_debug("ui_create_filter_menu %lx %lx", (long) menu_items, (long) data); g_debug("ui_create_filter_menu %lx %lx", (long) menu_items, (long) data);
g_signal_connect(G_OBJECT(menu_items), "activate", g_signal_connect(G_OBJECT(menu_items), "activate", G_CALLBACK(ui_callback_on_menu_item_selected), data);
G_CALLBACK(ui_callback_on_menu_item_selected), data);
/* Save the menu_item reference */ /* Save the menu_item reference */
filter->items[item].menu_item = menu_items; filter->items[item].menu_item = menu_items;
/* Show the widget */ /* Show the widget */
gtk_widget_show(menu_items); gtk_widget_show (menu_items);
}
} }
} }
void ui_create_filter_menus(void)
{
ui_create_filter_menu (&ui_main_data.menu_filter_messages, &ui_filters.messages);
ui_create_filter_menu (&ui_main_data.menu_filter_origin_tasks, &ui_filters.origin_tasks);
ui_create_filter_menu (&ui_main_data.menu_filter_destination_tasks, &ui_filters.destination_tasks);
ui_create_filter_menu (&ui_main_data.menu_filter_instances, &ui_filters.instances);
}
static void ui_destroy_filter_menu_item(GtkWidget *widget, gpointer data) static void ui_destroy_filter_menu_item(GtkWidget *widget, gpointer data)
{ {
if (GTK_IS_MENU_ITEM(widget)) if (GTK_IS_MENU_ITEM(widget))
...@@ -524,10 +530,7 @@ void ui_destroy_filter_menu(ui_filter_e filter) ...@@ -524,10 +530,7 @@ void ui_destroy_filter_menu(ui_filter_e filter)
void ui_show_filter_menu(GtkWidget **menu, ui_filter_t *filter) void ui_show_filter_menu(GtkWidget **menu, ui_filter_t *filter)
{ {
if (*menu == NULL)
{
ui_create_filter_menu (menu, filter); ui_create_filter_menu (menu, filter);
}
gtk_menu_popup (GTK_MENU (*menu), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time ()); gtk_menu_popup (GTK_MENU (*menu), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time ());
} }
...@@ -56,7 +56,7 @@ int ui_filters_read(const char *file_name); ...@@ -56,7 +56,7 @@ int ui_filters_read(const char *file_name);
int ui_filters_file_write(const char *file_name); int ui_filters_file_write(const char *file_name);
void ui_create_filter_menu(GtkWidget **menu, ui_filter_t *filter); void ui_create_filter_menus(void);
void ui_destroy_filter_menus(void); void ui_destroy_filter_menus(void);
......
...@@ -28,6 +28,9 @@ static ui_store_t ui_store; ...@@ -28,6 +28,9 @@ static ui_store_t ui_store;
static GValue colors[] = static GValue colors[] =
{ G_VALUE_INIT, G_VALUE_INIT }; { G_VALUE_INIT, G_VALUE_INIT };
GtkWidget *ui_tree_view_menu;
ui_tree_view_menu_enable_t ui_tree_view_menu_enable[NUM_MENU_TYPE];
GdkEventButton *ui_tree_view_last_event; GdkEventButton *ui_tree_view_last_event;
static gboolean ui_tree_filter_messages(GtkTreeModel *model, GtkTreeIter *iter, ui_store_t *store) static gboolean ui_tree_filter_messages(GtkTreeModel *model, GtkTreeIter *iter, ui_store_t *store)
...@@ -38,35 +41,16 @@ static gboolean ui_tree_filter_messages(GtkTreeModel *model, GtkTreeIter *iter, ...@@ -38,35 +41,16 @@ static gboolean ui_tree_filter_messages(GtkTreeModel *model, GtkTreeIter *iter,
uint32_t destination_task_id; uint32_t destination_task_id;
uint32_t instance; uint32_t instance;
gboolean enabled = FALSE; gboolean enabled = TRUE;
if (ui_filters.filters_enabled)
{
gtk_tree_model_get (model, iter, COL_MSG_NUM, &msg_number, COL_MESSAGE_ID, &message_id, COL_FROM_TASK_ID, gtk_tree_model_get (model, iter, COL_MSG_NUM, &msg_number, COL_MESSAGE_ID, &message_id, COL_FROM_TASK_ID,
&origin_task_id, COL_TO_TASK_ID, &destination_task_id, COL_INSTANCE, &instance, -1); &origin_task_id, COL_TO_TASK_ID, &destination_task_id, COL_INSTANCE, &instance, -1);
if (msg_number != 0) if (msg_number != 0)
{ {
enabled = ui_filters_message_enabled(message_id, origin_task_id, destination_task_id, instance); enabled = ui_filters_message_enabled(message_id, origin_task_id, destination_task_id, instance);
#if 0
if (store->filtered_last_msg < msg_number)
{
GtkTreePath *path = gtk_tree_model_get_path (model, iter);
GtkTreePath *true_path = gtk_tree_model_filter_convert_path_to_child_path (GTK_TREE_MODEL_FILTER (store->filtered), path);
g_message ("gtk_tree_model_get: %p %p", path, true_path);
GtkTreeIter iter_;
gtk_tree_model_get_iter (GTK_TREE_MODEL(store->store), &iter_, true_path);
GValue colors = G_VALUE_INIT;
g_value_init (&colors, G_TYPE_STRING);
g_value_set_string (&colors, (enabled ? "Black" : "Grey"));
// gtk_list_store_set_value (ui_store.store, &iter_, COL_FOREGROUND, &gvalue);
// gtk_list_store_set (ui_store.store, &iter_, COL_FOREGROUND, (enabled ? "Black" : "Grey"), -1);
// gtk_list_store_set_value (GTK_LIST_STORE(model), iter, COL_FOREGROUND, &colors);
}
#endif
enabled |= (!ui_filters.filters_enabled);
if ((enabled) && (store->filtered_last_msg < msg_number)) if ((enabled) && (store->filtered_last_msg < msg_number))
{ {
store->filtered_last_msg = msg_number; store->filtered_last_msg = msg_number;
...@@ -74,6 +58,7 @@ static gboolean ui_tree_filter_messages(GtkTreeModel *model, GtkTreeIter *iter, ...@@ -74,6 +58,7 @@ static gboolean ui_tree_filter_messages(GtkTreeModel *model, GtkTreeIter *iter,
} }
g_debug("ui_tree_filter_messages: %p %p %d m:%d o:%d d:%d i:%d %d %d", model, iter, msg_number, message_id, origin_task_id, destination_task_id, instance, enabled, store->filtered_msg_number); g_debug("ui_tree_filter_messages: %p %p %d m:%d o:%d d:%d i:%d %d %d", model, iter, msg_number, message_id, origin_task_id, destination_task_id, instance, enabled, store->filtered_msg_number);
} }
}
return enabled; return enabled;
} }
...@@ -119,7 +104,7 @@ static void ui_tree_view_init_list(GtkWidget *list) ...@@ -119,7 +104,7 @@ static void ui_tree_view_init_list(GtkWidget *list)
gtk_tree_view_column_set_alignment (column, 0.5); gtk_tree_view_column_set_alignment (column, 0.5);
gtk_tree_view_append_column (GTK_TREE_VIEW(list), column); gtk_tree_view_append_column (GTK_TREE_VIEW(list), column);
column = gtk_tree_view_column_new_with_attributes ("Signal", renderer_left, "text", COL_MESSAGE, "foreground", COL_FOREGROUND, NULL); column = gtk_tree_view_column_new_with_attributes ("Message", renderer_left, "text", COL_MESSAGE, "foreground", COL_FOREGROUND, NULL);
gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_column_set_alignment (column, 0.5); gtk_tree_view_column_set_alignment (column, 0.5);
gtk_tree_view_append_column (GTK_TREE_VIEW(list), column); gtk_tree_view_append_column (GTK_TREE_VIEW(list), column);
...@@ -257,6 +242,88 @@ static gboolean ui_tree_view_search(GtkTreeModel *model, gint column, const gcha ...@@ -257,6 +242,88 @@ static gboolean ui_tree_view_search(GtkTreeModel *model, gint column, const gcha
return 1; return 1;
} }
static void ui_tree_view_create_menu(GtkWidget **menu)
{
GtkWidget *menu_items;
*menu = gtk_menu_new();
/* Create the "Message enable" menu-item */
{
/* Create a new menu-item */
menu_items = gtk_check_menu_item_new();
ui_tree_view_menu_enable[MENU_MESSAGE].menu_enable = menu_items;
/* Add it to the menu. */
gtk_menu_shell_append(GTK_MENU_SHELL(*menu), menu_items);
g_signal_connect(G_OBJECT(menu_items), "activate",
G_CALLBACK(ui_callback_on_menu_enable), &ui_tree_view_menu_enable[MENU_MESSAGE]);
/* Show the widget */
gtk_widget_show(menu_items);
}
/* Create the "Destination task enable" menu-item */
{
/* Create a new menu-item */
menu_items = gtk_check_menu_item_new();
ui_tree_view_menu_enable[MENU_FROM_TASK].menu_enable = menu_items;
/* Add it to the menu. */
gtk_menu_shell_append(GTK_MENU_SHELL(*menu), menu_items);
g_signal_connect(G_OBJECT(menu_items), "activate",
G_CALLBACK(ui_callback_on_menu_enable), &ui_tree_view_menu_enable[MENU_FROM_TASK]);
/* Show the widget */
gtk_widget_show(menu_items);
}
/* Create the "Origin task enable" menu-item */
{
/* Create a new menu-item */
menu_items = gtk_check_menu_item_new();
ui_tree_view_menu_enable[MENU_TO_TASK].menu_enable = menu_items;
/* Add it to the menu. */
gtk_menu_shell_append(GTK_MENU_SHELL(*menu), menu_items);
g_signal_connect(G_OBJECT(menu_items), "activate",
G_CALLBACK(ui_callback_on_menu_enable), &ui_tree_view_menu_enable[MENU_TO_TASK]);
/* Show the widget */
gtk_widget_show(menu_items);
}
/* Create the "Instance enable" menu-item */
{
/* Create a new menu-item */
menu_items = gtk_check_menu_item_new();
ui_tree_view_menu_enable[MENU_INSTANCE].menu_enable = menu_items;
/* Add it to the menu. */
gtk_menu_shell_append(GTK_MENU_SHELL(*menu), menu_items);
g_signal_connect(G_OBJECT(menu_items), "activate",
G_CALLBACK(ui_callback_on_menu_enable), &ui_tree_view_menu_enable[MENU_INSTANCE]);
/* Show the widget */
gtk_widget_show(menu_items);
}
/* Create the "Color" menu-item */
if (0)
{
/* Create a new menu-item with a name */
menu_items = gtk_menu_item_new_with_label("Select color");
/* Add it to the menu. */
gtk_menu_shell_append(GTK_MENU_SHELL(*menu), menu_items);
g_signal_connect(G_OBJECT(menu_items), "activate",
G_CALLBACK(ui_callback_on_menu_color), *menu);
/* Show the widget */
gtk_widget_show(menu_items);
}
}
int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox) int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox)
{ {
GtkWidget *hbox; GtkWidget *hbox;
...@@ -266,7 +333,7 @@ int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox) ...@@ -266,7 +333,7 @@ int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox)
g_value_init (&colors[0], G_TYPE_STRING); g_value_init (&colors[0], G_TYPE_STRING);
g_value_init (&colors[1], G_TYPE_STRING); g_value_init (&colors[1], G_TYPE_STRING);
g_value_set_string (&colors[0], "Grey"); g_value_set_string (&colors[0], "Grey");
g_value_set_string (&colors[1], "Black"); g_value_set_string (&colors[1], "#585858");
scrolled_window = gtk_scrolled_window_new (NULL, NULL); scrolled_window = gtk_scrolled_window_new (NULL, NULL);
...@@ -289,7 +356,7 @@ int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox) ...@@ -289,7 +356,7 @@ int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox)
ui_tree_view_init_list (ui_main_data.messages_list); ui_tree_view_init_list (ui_main_data.messages_list);
gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW(ui_main_data.messages_list), TRUE); gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW(ui_main_data.messages_list), TRUE);
gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW(scrolled_window), 620); gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW(scrolled_window), 670);
gtk_paned_pack1 (GTK_PANED (hbox), scrolled_window, FALSE, TRUE); gtk_paned_pack1 (GTK_PANED (hbox), scrolled_window, FALSE, TRUE);
ui_main_data.text_view = ui_signal_dissect_new (hbox); ui_main_data.text_view = ui_signal_dissect_new (hbox);
...@@ -307,6 +374,8 @@ int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox) ...@@ -307,6 +374,8 @@ int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox)
ui_main_data.selection = selection; ui_main_data.selection = selection;
ui_tree_view_create_menu (&ui_tree_view_menu);
return 0; return 0;
} }
...@@ -374,7 +443,7 @@ static gboolean updateForegroundColor (GtkTreeModel *model, GtkTreePath *path, G ...@@ -374,7 +443,7 @@ static gboolean updateForegroundColor (GtkTreeModel *model, GtkTreePath *path, G
return FALSE; return FALSE;
} }
void ui_tree_view_refilter(void) void ui_tree_view_refilter()
{ {
ui_store.filtered_last_msg = 0; ui_store.filtered_last_msg = 0;
ui_store.filtered_msg_number = 0; ui_store.filtered_msg_number = 0;
...@@ -382,7 +451,7 @@ void ui_tree_view_refilter(void) ...@@ -382,7 +451,7 @@ void ui_tree_view_refilter(void)
/* Update foreground color of messages, this will also update filtered model */ /* Update foreground color of messages, this will also update filtered model */
if (ui_store.store != NULL) if (ui_store.store != NULL)
{ {
gtk_tree_model_foreach(GTK_TREE_MODEL(ui_store.store), updateForegroundColor, NULL); gtk_tree_model_foreach (GTK_TREE_MODEL(ui_store.store), updateForegroundColor, NULL);
} }
g_debug("ui_tree_view_refilter: last message %d, %d messages displayed", ui_store.filtered_last_msg, ui_store.filtered_msg_number); g_debug("ui_tree_view_refilter: last message %d, %d messages displayed", ui_store.filtered_last_msg, ui_store.filtered_msg_number);
......
#ifndef UI_TREE_VIEW_H_ #ifndef UI_TREE_VIEW_H_
#define UI_TREE_VIEW_H_ #define UI_TREE_VIEW_H_
typedef enum typedef enum col_type_e
{ {
COL_MSG_NUM = 0, COL_MSG_NUM = 0,
COL_LTE_TIME, COL_LTE_TIME,
...@@ -17,7 +17,25 @@ typedef enum ...@@ -17,7 +17,25 @@ typedef enum
COL_BUFFER, COL_BUFFER,
NUM_COLS NUM_COLS
} col_type_e; } col_type_t;
typedef enum ui_tree_view_menu_type_e
{
MENU_MESSAGE = 0,
MENU_FROM_TASK,
MENU_TO_TASK,
MENU_INSTANCE,
NUM_MENU_TYPE,
} ui_tree_view_menu_type_t;
typedef struct ui_tree_view_menu_enable_s
{
GtkWidget *menu_enable;
GtkWidget *menu_item;
} ui_tree_view_menu_enable_t;
extern GtkWidget *ui_tree_view_menu;
extern ui_tree_view_menu_enable_t ui_tree_view_menu_enable[NUM_MENU_TYPE];
extern GdkEventButton *ui_tree_view_last_event; extern GdkEventButton *ui_tree_view_last_event;
......
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