Commit a33913b8 authored by winckel's avatar winckel
Browse files

Added message reload button.

Corrected callback functions parameters list.
Implemented menu-items destruction when filter menus are destroyed.
Added NONE and ALL menu-items in filter pop-up menus.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4363 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent fb843989
...@@ -25,36 +25,46 @@ ...@@ -25,36 +25,46 @@
#include "locate_root.h" #include "locate_root.h"
#include "xml_parse.h" #include "xml_parse.h"
gboolean ui_callback_on_open_messages(GtkWidget *widget, GdkEvent *event, gpointer data) gboolean ui_callback_on_open_messages(GtkWidget *widget, gpointer data)
{ {
g_debug("Open messages event occurred"); gboolean refresh = (data != NULL) ? TRUE : FALSE;
CHECK_FCT(ui_messages_open_file_chooser());
g_debug("Open messages event occurred %d", refresh);
if (refresh && (ui_main_data.messages_file_name != NULL))
{
CHECK_FCT(ui_messages_read (ui_main_data.messages_file_name));
}
else
{
CHECK_FCT(ui_messages_open_file_chooser());
}
return TRUE; return TRUE;
} }
gboolean ui_callback_on_save_messages(GtkWidget *widget, GdkEvent *event, gpointer data) gboolean ui_callback_on_save_messages(GtkWidget *widget, gpointer data)
{ {
g_debug("Save messages event occurred"); g_debug("Save messages event occurred");
// CHECK_FCT(ui_file_chooser()); // CHECK_FCT(ui_file_chooser());
return TRUE; return TRUE;
} }
gboolean ui_callback_on_open_filters(GtkWidget *widget, GdkEvent *event, gpointer data) gboolean ui_callback_on_open_filters(GtkWidget *widget, gpointer data)
{ {
g_debug("Open filters event occurred"); g_debug("Open filters event occurred");
CHECK_FCT(ui_filters_open_file_chooser()); CHECK_FCT(ui_filters_open_file_chooser());
return TRUE; return TRUE;
} }
gboolean ui_callback_on_save_filters(GtkWidget *widget, GdkEvent *event, gpointer data) gboolean ui_callback_on_save_filters(GtkWidget *widget, gpointer data)
{ {
g_debug("Save filters event occurred"); g_debug("Save filters event occurred");
CHECK_FCT(ui_filters_save_file_chooser()); CHECK_FCT(ui_filters_save_file_chooser());
return TRUE; return TRUE;
} }
gboolean ui_callback_on_about(GtkWidget *widget, GdkEvent *event, gpointer data) gboolean ui_callback_on_about(GtkWidget *widget, gpointer data)
{ {
#if defined(PACKAGE_STRING) #if defined(PACKAGE_STRING)
ui_notification_dialog (GTK_MESSAGE_INFO, "about", "%s", PACKAGE_STRING); ui_notification_dialog (GTK_MESSAGE_INFO, "about", "%s", PACKAGE_STRING);
...@@ -118,7 +128,7 @@ void ui_signal_add_to_list(gpointer data, gpointer user_data) ...@@ -118,7 +128,7 @@ void ui_signal_add_to_list(gpointer data, gpointer user_data)
if ((ui_main_data.path_last == NULL) || (path == 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);
} }
} }
...@@ -237,7 +247,7 @@ gboolean ui_pipe_callback(gint source, gpointer user_data) ...@@ -237,7 +247,7 @@ gboolean ui_pipe_callback(gint source, gpointer user_data)
return FALSE; return FALSE;
} }
gboolean ui_callback_on_connect(GtkWidget *widget, GdkEvent *event, gpointer data) gboolean ui_callback_on_connect(GtkWidget *widget, gpointer data)
{ {
/* We have to retrieve the ip address and port of remote host */ /* We have to retrieve the ip address and port of remote host */
const char *ip; const char *ip;
...@@ -263,7 +273,7 @@ gboolean ui_callback_on_connect(GtkWidget *widget, GdkEvent *event, gpointer dat ...@@ -263,7 +273,7 @@ gboolean ui_callback_on_connect(GtkWidget *widget, GdkEvent *event, gpointer dat
/* Disable the connect button */ /* Disable the connect button */
ui_disable_connect_button (); ui_disable_connect_button ();
ui_callback_signal_clear_list (widget, event, data); ui_callback_signal_clear_list (widget, data);
if (socket_connect_to_remote_host (ip, port, pipe_fd[1]) != 0) if (socket_connect_to_remote_host (ip, port, pipe_fd[1]) != 0)
{ {
...@@ -275,7 +285,7 @@ gboolean ui_callback_on_connect(GtkWidget *widget, GdkEvent *event, gpointer dat ...@@ -275,7 +285,7 @@ gboolean ui_callback_on_connect(GtkWidget *widget, GdkEvent *event, gpointer dat
return TRUE; return TRUE;
} }
gboolean ui_callback_on_disconnect(GtkWidget *widget, GdkEvent *event, gpointer data) gboolean ui_callback_on_disconnect(GtkWidget *widget, gpointer data)
{ {
/* We have to retrieve the ip address and port of remote host */ /* We have to retrieve the ip address and port of remote host */
...@@ -287,19 +297,19 @@ gboolean ui_callback_on_disconnect(GtkWidget *widget, GdkEvent *event, gpointer ...@@ -287,19 +297,19 @@ gboolean ui_callback_on_disconnect(GtkWidget *widget, GdkEvent *event, gpointer
return TRUE; return TRUE;
} }
gboolean ui_callback_signal_go_to(GtkWidget *widget, GdkEvent *event, gpointer data) gboolean ui_callback_signal_go_to(GtkWidget *widget, gpointer data)
{ {
ui_tree_view_select_row (ui_main_data.nb_message_received / 2, NULL); ui_tree_view_select_row (ui_main_data.nb_message_received / 2, NULL);
return TRUE; return TRUE;
} }
gboolean ui_callback_signal_go_to_first(GtkWidget *widget, GdkEvent *event, gpointer data) gboolean ui_callback_signal_go_to_first(GtkWidget *widget, gpointer data)
{ {
ui_tree_view_select_row (0, NULL); ui_tree_view_select_row (0, NULL);
return TRUE; return TRUE;
} }
gboolean ui_callback_signal_go_to_last(GtkWidget *widget, GdkEvent *event, gpointer data) gboolean ui_callback_signal_go_to_last(GtkWidget *widget, gpointer data)
{ {
GtkTreePath *path; GtkTreePath *path;
...@@ -309,7 +319,7 @@ gboolean ui_callback_signal_go_to_last(GtkWidget *widget, GdkEvent *event, gpoin ...@@ -309,7 +319,7 @@ gboolean ui_callback_signal_go_to_last(GtkWidget *widget, GdkEvent *event, gpoin
return TRUE; return TRUE;
} }
gboolean ui_callback_signal_clear_list(GtkWidget *widget, GdkEvent *event, gpointer data) gboolean ui_callback_signal_clear_list(GtkWidget *widget, gpointer data)
{ {
/* Disable buttons to move in the list of signals */ /* Disable buttons to move in the list of signals */
ui_set_sensitive_move_buttons (FALSE); ui_set_sensitive_move_buttons (FALSE);
...@@ -317,6 +327,46 @@ gboolean ui_callback_signal_clear_list(GtkWidget *widget, GdkEvent *event, gpoin ...@@ -317,6 +327,46 @@ gboolean ui_callback_signal_clear_list(GtkWidget *widget, GdkEvent *event, gpoin
/* Clear list of signals */ /* Clear list of signals */
ui_tree_view_destroy_list (ui_main_data.signalslist); 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);
}
*/
return TRUE;
}
static void ui_callback_on_menu_items_selected(GtkWidget *widget, gpointer data)
{
gboolean active = data != NULL;
if (GTK_IS_CHECK_MENU_ITEM(widget))
{
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(widget), active);
}
}
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);
gtk_container_foreach(GTK_CONTAINER(menu), ui_callback_on_menu_items_selected, (gpointer) FALSE);
return TRUE;
}
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);
gtk_container_foreach(GTK_CONTAINER(menu), ui_callback_on_menu_items_selected, (gpointer) TRUE);
return TRUE; return TRUE;
} }
...@@ -331,7 +381,7 @@ gboolean ui_callback_on_menu_item_selected(GtkWidget *widget, gpointer data) ...@@ -331,7 +381,7 @@ gboolean ui_callback_on_menu_item_selected(GtkWidget *widget, gpointer data)
filter_entry->enabled = enabled; filter_entry->enabled = enabled;
ui_tree_view_refilter (); ui_tree_view_refilter ();
} }
// g_debug("ui_callback_on_menu_item_selected occurred %x %x %s %d (%d messages to display)", (int) widget, (int) data, filter_entry->name, enabled, ui_tree_view_get_filtered_number()); 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());
return TRUE; return TRUE;
} }
...@@ -340,7 +390,7 @@ gboolean ui_callback_on_tree_column_header_click(GtkWidget *widget, gpointer dat ...@@ -340,7 +390,7 @@ gboolean ui_callback_on_tree_column_header_click(GtkWidget *widget, gpointer dat
{ {
col_type_e col = (col_type_e) data; col_type_e col = (col_type_e) data;
// g_debug("ui_callback_on_tree_column_header_click %x", col); g_debug("ui_callback_on_tree_column_header_click %x", col);
switch (col) switch (col)
{ {
case COL_SIGNAL: case COL_SIGNAL:
......
...@@ -4,34 +4,27 @@ ...@@ -4,34 +4,27 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
gboolean ui_callback_on_open_messages(GtkWidget *widget, gboolean ui_callback_on_open_messages(GtkWidget *widget,
GdkEvent *event,
gpointer data); gpointer data);
gboolean ui_callback_on_save_messages(GtkWidget *widget, gboolean ui_callback_on_save_messages(GtkWidget *widget,
GdkEvent *event,
gpointer data); gpointer data);
gboolean ui_callback_on_open_filters(GtkWidget *widget, gboolean ui_callback_on_open_filters(GtkWidget *widget,
GdkEvent *event,
gpointer data); gpointer data);
gboolean ui_callback_on_save_filters(GtkWidget *widget, gboolean ui_callback_on_save_filters(GtkWidget *widget,
GdkEvent *event,
gpointer data); gpointer data);
gboolean ui_callback_on_about(GtkWidget *widget, gboolean ui_callback_on_about(GtkWidget *widget,
GdkEvent *event,
gpointer data); gpointer data);
void ui_signal_add_to_list(gpointer data, void ui_signal_add_to_list(gpointer data,
gpointer user_data); gpointer user_data);
gboolean ui_callback_on_connect(GtkWidget *widget, gboolean ui_callback_on_connect(GtkWidget *widget,
GdkEvent *event,
gpointer data); gpointer data);
gboolean ui_callback_on_disconnect(GtkWidget *widget, gboolean ui_callback_on_disconnect(GtkWidget *widget,
GdkEvent *event,
gpointer data); gpointer data);
gboolean ui_callback_on_tree_view_select(GtkWidget *widget, gboolean ui_callback_on_tree_view_select(GtkWidget *widget,
...@@ -46,23 +39,25 @@ ui_callback_on_select_signal(GtkTreeSelection *selection, ...@@ -46,23 +39,25 @@ ui_callback_on_select_signal(GtkTreeSelection *selection,
gpointer userdata); gpointer userdata);
gboolean ui_callback_signal_go_to(GtkWidget *widget, gboolean ui_callback_signal_go_to(GtkWidget *widget,
GdkEvent *event,
gpointer data); gpointer data);
gboolean ui_callback_signal_go_to_first(GtkWidget *widget, gboolean ui_callback_signal_go_to_first(GtkWidget *widget,
GdkEvent *event,
gpointer data); gpointer data);
gboolean ui_callback_signal_go_to_last(GtkWidget *widget, gboolean ui_callback_signal_go_to_last(GtkWidget *widget,
GdkEvent *event,
gpointer data); gpointer data);
gboolean ui_callback_signal_clear_list(GtkWidget *widget, gboolean ui_callback_signal_clear_list(GtkWidget *widget,
GdkEvent *event,
gpointer data); gpointer data);
gboolean ui_pipe_callback(gint source, gpointer user_data); gboolean ui_pipe_callback(gint source, gpointer user_data);
gboolean ui_callback_on_menu_none(GtkWidget *widget,
gpointer data);
gboolean ui_callback_on_menu_all(GtkWidget *widget,
gpointer data);
gboolean ui_callback_on_menu_item_selected(GtkWidget *widget, gboolean ui_callback_on_menu_item_selected(GtkWidget *widget,
gpointer data); gpointer data);
......
...@@ -75,6 +75,7 @@ static int ui_search_name(ui_filter_t *filter, const char *name) ...@@ -75,6 +75,7 @@ static int ui_search_name(ui_filter_t *filter, const char *name)
return (item); return (item);
} }
/*
static int ui_search_id(ui_filter_t *filter, uint32_t value) static int ui_search_id(ui_filter_t *filter, uint32_t value)
{ {
int item; int item;
...@@ -89,6 +90,7 @@ static int ui_search_id(ui_filter_t *filter, uint32_t value) ...@@ -89,6 +90,7 @@ static int ui_search_id(ui_filter_t *filter, uint32_t value)
return (item); return (item);
} }
*/
static void ui_filter_set_enabled(uint8_t *enabled, ui_entry_enabled_e entry_enabled, gboolean new) static void ui_filter_set_enabled(uint8_t *enabled, ui_entry_enabled_e entry_enabled, gboolean new)
{ {
...@@ -240,7 +242,7 @@ static int xml_parse_filters(xmlDocPtr doc) ...@@ -240,7 +242,7 @@ static int xml_parse_filters(xmlDocPtr doc)
if (filter_node != NULL) if (filter_node != NULL)
{ {
filter = ui_filter_from_name ((const char*) filter_node->name); filter = ui_filter_from_name ((const char*) filter_node->name);
// g_debug ("Found filter %s %d", filter_node->name, filter); g_debug ("Found filter %s %d", filter_node->name, filter);
if (filter == FILTER_UNKNOWN) if (filter == FILTER_UNKNOWN)
{ {
...@@ -258,7 +260,7 @@ static int xml_parse_filters(xmlDocPtr doc) ...@@ -258,7 +260,7 @@ static int xml_parse_filters(xmlDocPtr doc)
if (cur_node != NULL) if (cur_node != NULL)
{ {
// g_debug(" Found entry %s %s", cur_node->name, cur_node->properties->children->content); g_debug(" Found entry %s %s", cur_node->name, cur_node->properties->children->content);
ui_filters_add ( ui_filters_add (
filter, filter,
FILTER_ID_UNDEFINED, FILTER_ID_UNDEFINED,
...@@ -370,35 +372,90 @@ static void ui_create_filter_menu(GtkWidget **menu, ui_filter_t *filter) ...@@ -370,35 +372,90 @@ static void ui_create_filter_menu(GtkWidget **menu, ui_filter_t *filter)
int item; int item;
gpointer data; gpointer data;
*menu = gtk_menu_new (); *menu = gtk_menu_new();
/* Create the "NONE" menu-item */
{
/* Create a new menu-item with a name */
menu_items = gtk_menu_item_new_with_label("NONE");
/* Add it to the menu. */
gtk_menu_shell_append(GTK_MENU_SHELL(*menu), menu_items);
g_debug("ui_create_filter_menu %lx", (long) menu_items);
g_signal_connect(G_OBJECT(menu_items), "activate",
G_CALLBACK(ui_callback_on_menu_none), *menu);
/* Show the widget */
gtk_widget_show(menu_items);
}
/* Create the "ALL" menu-item */
{
/* Create a new menu-item with a name */
menu_items = gtk_menu_item_new_with_label("ALL");
/* Add it to the menu. */
gtk_menu_shell_append(GTK_MENU_SHELL(*menu), menu_items);
g_debug("ui_create_filter_menu %lx", (long) menu_items);
g_signal_connect(G_OBJECT(menu_items), "activate",
G_CALLBACK(ui_callback_on_menu_all), *menu);
/* Show the widget */
gtk_widget_show(menu_items);
}
/* Create separator */
{
menu_items = gtk_menu_item_new();
/* Add it to the menu. */
gtk_menu_shell_append(GTK_MENU_SHELL(*menu), menu_items);
/* Show the widget */
gtk_widget_show(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 (filter->items[item].name); menu_items = gtk_check_menu_item_new_with_label(
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), filter->items[item].enabled); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_items),
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 %x %x", (int) menu_items, (int) data); g_debug("ui_create_filter_menu %lx %lx", (long) menu_items, (long) data);
g_signal_connect(G_OBJECT (menu_items), "activate", G_CALLBACK(ui_callback_on_menu_item_selected), data); g_signal_connect(G_OBJECT(menu_items), "activate",
G_CALLBACK(ui_callback_on_menu_item_selected), data);
/* Show the widget */ /* Show the widget */
gtk_widget_show (menu_items); gtk_widget_show(menu_items);
} }
} }
static void ui_destroy_filter_menu(GtkWidget **menu, ui_filter_t *filter) static void ui_destroy_filter_menu_item(GtkWidget *widget, gpointer data)
{ {
/* TODO destroy menu items ? */ if (GTK_IS_MENU_ITEM(widget))
{
gtk_widget_destroy(widget);
}
}
static void ui_destroy_filter_menu(GtkWidget **menu, ui_filter_t *filter)
{
if (*menu != NULL) if (*menu != NULL)
{ {
gtk_widget_destroy (*menu); gtk_container_foreach(GTK_CONTAINER(*menu), ui_destroy_filter_menu_item, NULL);
gtk_widget_destroy(*menu);
*menu = NULL; *menu = NULL;
} }
} }
......
...@@ -138,7 +138,17 @@ int ui_toolbar_create(GtkWidget *vbox) ...@@ -138,7 +138,17 @@ int ui_toolbar_create(GtkWidget *vbox)
"Open messages file"); "Open messages file");
g_signal_connect(G_OBJECT(ui_main_data.open_replay_file), "clicked", g_signal_connect(G_OBJECT(ui_main_data.open_replay_file), "clicked",
G_CALLBACK(ui_callback_on_open_messages), NULL); G_CALLBACK(ui_callback_on_open_messages), (gpointer) FALSE);
}
/* 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");
g_signal_connect(G_OBJECT(ui_main_data.refresh_replay_file), "clicked",
G_CALLBACK(ui_callback_on_open_messages), (gpointer) TRUE);
} }
/* Button to save replay file */ /* Button to save replay file */
...@@ -238,6 +248,7 @@ int ui_toolbar_create(GtkWidget *vbox) ...@@ -238,6 +248,7 @@ int ui_toolbar_create(GtkWidget *vbox)
gtk_box_pack_start(GTK_BOX(hbox), messages_label, FALSE, FALSE, LABEL_SPACE); gtk_box_pack_start(GTK_BOX(hbox), messages_label, FALSE, FALSE, LABEL_SPACE);
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.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), FALSE, FALSE, BUTTON_SPACE);
gtk_box_pack_start(GTK_BOX(hbox), gtk_separator_new(GTK_ORIENTATION_VERTICAL), FALSE, FALSE, SEPARATOR_SPACE); gtk_box_pack_start(GTK_BOX(hbox), gtk_separator_new(GTK_ORIENTATION_VERTICAL), FALSE, FALSE, SEPARATOR_SPACE);
......
...@@ -89,7 +89,7 @@ int ui_messages_read(char *filename) ...@@ -89,7 +89,7 @@ int ui_messages_read(char *filename)
{ {
itti_socket_header_t message_header; itti_socket_header_t message_header;
ui_callback_signal_clear_list (NULL, NULL, NULL); ui_callback_signal_clear_list (NULL, NULL);
do do
{ {
...@@ -107,7 +107,7 @@ int ui_messages_read(char *filename) ...@@ -107,7 +107,7 @@ int ui_messages_read(char *filename)
{ {
input_data_length = message_header.message_size - sizeof(itti_socket_header_t); input_data_length = message_header.message_size - sizeof(itti_socket_header_t);
// g_debug ("%x, %x ,%x", message_header.message_type, message_header.message_size, input_data_length); g_debug ("%x, %x ,%x", message_header.message_type, message_header.message_size, input_data_length);
/* Checking for non-header part */ /* Checking for non-header part */
if (input_data_length > 0) if (input_data_length > 0)
......
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