Commit c90238b7 authored by winckel's avatar winckel

Added a filters enabled toggle button.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4408 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 58471b29
......@@ -29,7 +29,7 @@ gboolean ui_callback_on_open_messages(GtkWidget *widget, gpointer data)
{
gboolean refresh = (data != NULL) ? TRUE : FALSE;
g_debug("Open messages event occurred %d", refresh);
g_message("Open messages event occurred %d", refresh);
if (refresh && (ui_main_data.messages_file_name != NULL))
{
......@@ -45,21 +45,50 @@ gboolean ui_callback_on_open_messages(GtkWidget *widget, gpointer data)
gboolean ui_callback_on_save_messages(GtkWidget *widget, gpointer data)
{
g_debug("Save messages event occurred");
g_message("Save messages event occurred");
// CHECK_FCT(ui_file_chooser());
return TRUE;
}
gboolean ui_callback_on_filters_enabled(GtkWidget *widget, gpointer data)
{
gboolean enabled;
gboolean changed;
enabled = gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON(widget));
g_message("Filters enabled event occurred %d", enabled);
changed = ui_filters_enable(enabled);
if (changed)
{
/* Set the tooltip text */
if (enabled)
{
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM(widget), "Disable messages filtering");
}
else
{
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM(widget), "Enable messages filtering");
}
ui_tree_view_refilter();
}
// CHECK_FCT(ui_filters_open_file_chooser());
return TRUE;
}
gboolean ui_callback_on_open_filters(GtkWidget *widget, gpointer data)
{
g_debug("Open filters event occurred");
g_message("Open filters event occurred");
CHECK_FCT(ui_filters_open_file_chooser());
return TRUE;
}
gboolean ui_callback_on_save_filters(GtkWidget *widget, gpointer data)
{
g_debug("Save filters event occurred");
g_message("Save filters event occurred");
CHECK_FCT(ui_filters_save_file_chooser());
return TRUE;
}
......@@ -271,7 +300,7 @@ gboolean ui_callback_on_connect(GtkWidget *widget, gpointer data)
uint16_t port;
int pipe_fd[2];
g_debug("Connect event occurred");
g_message("Connect event occurred");
port = atoi (gtk_entry_get_text (GTK_ENTRY(ui_main_data.port_entry)));
ip = gtk_entry_get_text (GTK_ENTRY(ui_main_data.ip_entry));
......@@ -306,7 +335,7 @@ gboolean ui_callback_on_disconnect(GtkWidget *widget, gpointer data)
{
/* We have to retrieve the ip address and port of remote host */
g_debug("Disconnect event occurred");
g_message("Disconnect event occurred");
ui_pipe_write_message (ui_main_data.pipe_fd[0], UI_PIPE_DISCONNECT_EVT, NULL, 0);
......@@ -345,12 +374,10 @@ gboolean ui_callback_signal_clear_list(GtkWidget *widget, gpointer data)
/* Clear list of signals */
ui_tree_view_destroy_list (ui_main_data.signalslist);
/*
if (ui_main_data.text_view != NULL)
{
ui_signal_dissect_clear_view(ui_main_data.text_view);
// ui_signal_dissect_clear_view(ui_main_data.text_view);
}
*/
return TRUE;
}
......@@ -369,7 +396,7 @@ gboolean ui_callback_on_menu_none(GtkWidget *widget, gpointer data)
{
GtkWidget *menu = (GtkWidget *) data;
g_debug("ui_callback_on_menu_none occurred %lx %lx)", (long) widget, (long) data);
g_message("ui_callback_on_menu_none occurred %lx %lx)", (long) widget, (long) data);
gtk_container_foreach(GTK_CONTAINER(menu), ui_callback_on_menu_items_selected, (gpointer) FALSE);
......@@ -380,7 +407,7 @@ gboolean ui_callback_on_menu_all(GtkWidget *widget, gpointer data)
{
GtkWidget *menu = (GtkWidget *) data;
g_debug("ui_callback_on_menu_all occurred %lx %lx)", (long) widget, (long) data);
g_message("ui_callback_on_menu_all occurred %lx %lx)", (long) widget, (long) data);
gtk_container_foreach(GTK_CONTAINER(menu), ui_callback_on_menu_items_selected, (gpointer) TRUE);
......@@ -398,7 +425,7 @@ gboolean ui_callback_on_menu_item_selected(GtkWidget *widget, gpointer data)
filter_entry->enabled = enabled;
ui_tree_view_refilter ();
}
g_debug("ui_callback_on_menu_item_selected occurred %lx %lx %s %d (%d messages to display)", (long) widget, (long) data, filter_entry->name, enabled, ui_tree_view_get_filtered_number());
g_message("ui_callback_on_menu_item_selected occurred %p %p %s %d (%d messages to display)", widget, data, filter_entry->name, enabled, ui_tree_view_get_filtered_number());
return TRUE;
}
......@@ -407,7 +434,7 @@ gboolean ui_callback_on_tree_column_header_click(GtkWidget *widget, gpointer dat
{
col_type_e col = (col_type_e) data;
g_debug("ui_callback_on_tree_column_header_click %x", col);
g_message("ui_callback_on_tree_column_header_click %d", col);
switch (col)
{
case COL_MESSAGE:
......
......@@ -9,6 +9,9 @@ gboolean ui_callback_on_open_messages(GtkWidget *widget,
gboolean ui_callback_on_save_messages(GtkWidget *widget,
gpointer data);
gboolean ui_callback_on_filters_enabled(GtkWidget *widget,
gpointer data);
gboolean ui_callback_on_open_filters(GtkWidget *widget,
gpointer data);
......
......@@ -61,6 +61,18 @@ int ui_init_filters(int reset, int clear_ids)
return (RC_OK);
}
gboolean ui_filters_enable(gboolean enabled)
{
gboolean changed = ui_filters.filters_enabled != enabled;
if (changed)
{
ui_filters.filters_enabled = enabled;
}
return changed;
}
static int ui_search_name(ui_filter_t *filter, const char *name)
{
int item;
......@@ -192,8 +204,11 @@ gboolean ui_filters_message_enabled(const uint32_t message, const uint32_t origi
{
gboolean result;
result = ui_item_enabled (&ui_filters.messages, message) && ui_item_enabled (&ui_filters.origin_tasks, origin_task)
&& ui_item_enabled (&ui_filters.destination_tasks, destination_task) && ui_item_enabled (&ui_filters.instances, instance);
result = (!ui_filters.filters_enabled)
|| (ui_item_enabled(&ui_filters.messages, message)
&& ui_item_enabled(&ui_filters.origin_tasks, origin_task)
&& ui_item_enabled(&ui_filters.destination_tasks, destination_task)
&& ui_item_enabled(&ui_filters.instances, instance));
return result;
}
......@@ -285,8 +300,12 @@ static int xml_parse_filters(xmlDocPtr doc)
filter_node = filter_node->next;
}
}
/* Filters have changed destroy filter menus and update tree view */
ui_destroy_filter_menus ();
/* Reactivate filtering */
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON(ui_main_data.filters_enabled), TRUE);
ui_tree_view_refilter ();
}
}
......
......@@ -32,6 +32,7 @@ typedef struct
typedef struct
{
gboolean filters_enabled;
ui_filter_t messages;
ui_filter_t origin_tasks;
ui_filter_t destination_tasks;
......@@ -42,6 +43,8 @@ extern ui_filters_t ui_filters;
int ui_init_filters(int reset, int clear_ids);
gboolean ui_filters_enable(gboolean enabled);
void ui_filters_add(ui_filter_e filter, uint32_t value, const char *name, ui_entry_enabled_e entry_enabled);
gboolean ui_filters_message_enabled(const uint32_t message, const uint32_t origin_task, const uint32_t destination_task, const uint32_t instance);
......
......@@ -16,17 +16,19 @@ typedef struct {
ui_text_view_t *text_view;
/* Buttons */
GtkToolItem *filters_enabled;
GtkToolItem *open_filters_file;
GtkToolItem *save_filters_file;
GtkToolItem *open_replay_file;
GtkToolItem *refresh_replay_file;
GtkToolItem *save_replay_file;
GtkToolItem *open_filters_file;
GtkToolItem *save_filters_file;
GtkToolItem *connect;
GtkToolItem *disconnect;
/* Signal list buttons */
/* Clear signals button */
GtkToolItem *signals_clear_button;
GtkToolItem *signals_go_to_button;
GtkToolItem *signals_go_to_last_button;
GtkToolItem *signals_go_to_first_button;
......
......@@ -98,7 +98,6 @@ int ui_menu_bar_create(GtkWidget *vbox)
int ui_toolbar_create(GtkWidget *vbox)
{
GtkWidget *hbox;
GtkWidget *filters_label;
GtkWidget *messages_label;
GtkWidget *ip_label;
GtkWidget *port_label;
......@@ -108,14 +107,21 @@ int ui_toolbar_create(GtkWidget *vbox)
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
filters_label = gtk_label_new("Filters");
messages_label = gtk_label_new("Messages");
/* Button to deactivate filtering */
{
ui_main_data.filters_enabled = gtk_toggle_tool_button_new();
gtk_tool_button_set_label (GTK_TOOL_BUTTON(ui_main_data.filters_enabled), "Filters");
g_signal_connect(G_OBJECT(ui_main_data.filters_enabled), "clicked",
G_CALLBACK(ui_callback_on_filters_enabled), NULL);
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON(ui_main_data.filters_enabled), TRUE);
}
/* Button to open filters file */
{
ui_main_data.open_filters_file = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.open_filters_file),
"Open filters file");
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.open_filters_file), "Open filters file");
g_signal_connect(G_OBJECT(ui_main_data.open_filters_file), "clicked",
G_CALLBACK(ui_callback_on_open_filters), NULL);
......@@ -124,8 +130,7 @@ int ui_toolbar_create(GtkWidget *vbox)
/* Button to save filters file */
{
ui_main_data.save_filters_file = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE);
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.save_filters_file),
"Save filters file");
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.save_filters_file), "Save filters file");
g_signal_connect(G_OBJECT(ui_main_data.save_filters_file), "clicked",
G_CALLBACK(ui_callback_on_save_filters), NULL);
......@@ -134,8 +139,7 @@ int ui_toolbar_create(GtkWidget *vbox)
/* Button to open replay file */
{
ui_main_data.open_replay_file = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.open_replay_file),
"Open messages file");
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.open_replay_file), "Open messages file");
g_signal_connect(G_OBJECT(ui_main_data.open_replay_file), "clicked",
G_CALLBACK(ui_callback_on_open_messages), (gpointer) FALSE);
......@@ -144,8 +148,7 @@ int ui_toolbar_create(GtkWidget *vbox)
/* Button to refresh replay file */
{
ui_main_data.refresh_replay_file = gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH);
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.refresh_replay_file),
"Reload messages file");
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.refresh_replay_file), "Reload messages file");
g_signal_connect(G_OBJECT(ui_main_data.refresh_replay_file), "clicked",
G_CALLBACK(ui_callback_on_open_messages), (gpointer) TRUE);
......@@ -154,8 +157,7 @@ int ui_toolbar_create(GtkWidget *vbox)
/* Button to save replay 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");
g_signal_connect(G_OBJECT(ui_main_data.save_replay_file), "clicked",
G_CALLBACK(ui_callback_on_save_messages), NULL);
......@@ -166,8 +168,7 @@ int ui_toolbar_create(GtkWidget *vbox)
{
ui_main_data.signals_go_to_button = gtk_tool_button_new_from_stock(GTK_STOCK_INDEX);
/* Set the tooltip text */
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.signals_go_to_button),
"Goto signal");
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.signals_go_to_button), "Goto signal");
gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.signals_go_to_button), FALSE);
......@@ -180,8 +181,7 @@ int ui_toolbar_create(GtkWidget *vbox)
{
ui_main_data.signals_go_to_first_button = gtk_tool_button_new_from_stock(GTK_STOCK_GOTO_FIRST);
/* Set the tooltip text */
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.signals_go_to_first_button),
"Goto first signal");
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.signals_go_to_first_button), "Goto first signal");
gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.signals_go_to_first_button), FALSE);
......@@ -193,8 +193,7 @@ int ui_toolbar_create(GtkWidget *vbox)
{
ui_main_data.signals_go_to_last_button = gtk_tool_button_new_from_stock(GTK_STOCK_GOTO_LAST);
/* Set the tooltip text */
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.signals_go_to_last_button),
"Goto last signal");
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.signals_go_to_last_button), "Goto last signal");
gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.signals_go_to_last_button), FALSE);
......@@ -206,8 +205,7 @@ int ui_toolbar_create(GtkWidget *vbox)
{
ui_main_data.connect = gtk_tool_button_new_from_stock(GTK_STOCK_CONNECT);
/* Set the tooltip text */
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.connect),
"Connect to remote host");
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.connect), "Connect to remote host");
g_signal_connect(G_OBJECT(ui_main_data.connect), "clicked",
G_CALLBACK(ui_callback_on_connect), NULL);
......@@ -217,8 +215,7 @@ int ui_toolbar_create(GtkWidget *vbox)
{
ui_main_data.disconnect = gtk_tool_button_new_from_stock(GTK_STOCK_DISCONNECT);
/* Set the tooltip text */
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.disconnect),
"Disconnect from remote host");
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.disconnect), "Disconnect from remote host");
/* Disabled at startup. Will be activated when a connection is established */
gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.disconnect), FALSE);
......@@ -240,7 +237,7 @@ int ui_toolbar_create(GtkWidget *vbox)
gtk_entry_set_width_chars(GTK_ENTRY(ui_main_data.port_entry), 5);
gtk_entry_set_text(GTK_ENTRY(ui_main_data.port_entry), ui_main_data.port_entry_init);
gtk_box_pack_start(GTK_BOX(hbox), filters_label, FALSE, FALSE, LABEL_SPACE);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ui_main_data.filters_enabled), FALSE, FALSE, LABEL_SPACE);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ui_main_data.open_filters_file), FALSE, FALSE, BUTTON_SPACE);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ui_main_data.save_filters_file), FALSE, FALSE, BUTTON_SPACE);
......
......@@ -49,11 +49,14 @@ int ui_signal_dissect_clear_view(ui_text_view_t *text_view)
g_assert(text_view != NULL);
text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view->text_view));
/* If a text buffer is present for the textview remove it */
if (text_buffer != NULL) {
gtk_text_view_set_buffer(GTK_TEXT_VIEW(text_view->text_view), NULL);
if (text_view->text_view != NULL)
{
text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view->text_view));
/* If a text buffer is present for the textview remove it */
if (text_buffer != NULL) {
gtk_text_view_set_buffer(GTK_TEXT_VIEW(text_view->text_view), NULL);
}
}
return RC_OK;
......
......@@ -269,7 +269,10 @@ void ui_tree_view_refilter(void)
{
ui_store.filtered_last_msg = 0;
ui_store.filtered_msg_number = 0;
gtk_tree_model_filter_refilter (ui_store.filtered);
if (ui_store.filtered != NULL)
{
gtk_tree_model_filter_refilter (ui_store.filtered);
}
}
guint ui_tree_view_get_filtered_number(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