Commit e8aaa119 authored by winckel's avatar winckel
Browse files

Moved some filters functions back to ui_filters files.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4324 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 560b7c7d
......@@ -21,8 +21,6 @@
#include "locate_root.h"
#include "xml_parse.h"
static gboolean ui_handle_socket_connection_failed(gint fd);
gboolean ui_callback_on_open_messages(GtkWidget *widget, GdkEvent *event, gpointer data)
{
g_debug("Open messages event occurred");
......@@ -309,7 +307,7 @@ gboolean ui_callback_signal_clear_list(GtkWidget *widget, GdkEvent *event, gpoin
return TRUE;
}
static gboolean ui_callback_on_menu_item_selected(GtkWidget *widget, gpointer data)
gboolean ui_callback_on_menu_item_selected(GtkWidget *widget, gpointer data)
{
ui_filter_item_t *filter_entry = data;
gboolean enabled;
......@@ -321,67 +319,11 @@ static gboolean ui_callback_on_menu_item_selected(GtkWidget *widget, gpointer da
return TRUE;
}
static void ui_create_filter_menu(GtkWidget **menu, ui_filter_t *filter)
{
GtkWidget *menu_items;
int item;
gpointer data;
*menu = gtk_menu_new ();
for (item = 0; item < filter->used; item++)
{
/* Create a new menu-item with a name */
menu_items = gtk_check_menu_item_new_with_label (filter->items[item].name);
/* Add it to the menu. */
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);
/* Connect function to be called when the menu item is selected */
data = &filter->items[item];
// g_debug("ui_create_filter_menu %x %x", (int) menu_items, (int) data);
g_signal_connect(G_OBJECT (menu_items), "activate", G_CALLBACK(ui_callback_on_menu_item_selected), data);
/* Show the widget */
gtk_widget_show (menu_items);
}
}
static void ui_destroy_filter_menu(GtkWidget **menu, ui_filter_t *filter)
{
/* TODO destroy menu items ? */
if (*menu != NULL)
{
gtk_widget_destroy (*menu);
*menu = NULL;
}
}
void ui_destroy_filter_menus(void)
{
ui_destroy_filter_menu (&ui_main_data.menu_filter_messages, &ui_filters.messages);
ui_destroy_filter_menu (&ui_main_data.menu_filter_origin_tasks, &ui_filters.origin_tasks);
ui_destroy_filter_menu (&ui_main_data.menu_filter_destination_tasks, &ui_filters.destination_tasks);
}
static void ui_show_filter_menu(GtkWidget **menu, ui_filter_t *filter)
{
if (*menu == NULL)
{
ui_create_filter_menu (menu, filter);
}
gtk_menu_popup (GTK_MENU (*menu), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time ());
}
gboolean ui_callback_on_tree_column_header_click(GtkWidget *widget, gpointer 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)
{
case COL_SIGNAL:
......
......@@ -63,7 +63,8 @@ gboolean ui_callback_signal_clear_list(GtkWidget *widget,
gboolean ui_pipe_callback(gint source, gpointer user_data);
void ui_destroy_filter_menus(void);
gboolean ui_callback_on_menu_item_selected(GtkWidget *widget,
gpointer data);
gboolean ui_callback_on_tree_column_header_click(GtkWidget *widget,
gpointer data);
......
......@@ -3,6 +3,7 @@
#include <glib.h>
#include "ui_callbacks.h"
#include "ui_main_screen.h"
#include "ui_filters.h"
#include "rc.h"
......@@ -150,3 +151,59 @@ int ui_write_filters_file(char *file_name)
fclose (filter_file);
return RC_OK;
}
static void ui_create_filter_menu(GtkWidget **menu, ui_filter_t *filter)
{
GtkWidget *menu_items;
int item;
gpointer data;
*menu = gtk_menu_new ();
for (item = 0; item < filter->used; item++)
{
/* Create a new menu-item with a name */
menu_items = gtk_check_menu_item_new_with_label (filter->items[item].name);
/* Add it to the menu. */
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);
/* Connect function to be called when the menu item is selected */
data = &filter->items[item];
// g_debug("ui_create_filter_menu %x %x", (int) menu_items, (int) data);
g_signal_connect(G_OBJECT (menu_items), "activate", G_CALLBACK(ui_callback_on_menu_item_selected), data);
/* Show the widget */
gtk_widget_show (menu_items);
}
}
static void ui_destroy_filter_menu(GtkWidget **menu, ui_filter_t *filter)
{
/* TODO destroy menu items ? */
if (*menu != NULL)
{
gtk_widget_destroy (*menu);
*menu = NULL;
}
}
void ui_destroy_filter_menus(void)
{
ui_destroy_filter_menu (&ui_main_data.menu_filter_messages, &ui_filters.messages);
ui_destroy_filter_menu (&ui_main_data.menu_filter_origin_tasks, &ui_filters.origin_tasks);
ui_destroy_filter_menu (&ui_main_data.menu_filter_destination_tasks, &ui_filters.destination_tasks);
}
void ui_show_filter_menu(GtkWidget **menu, ui_filter_t *filter)
{
if (*menu == NULL)
{
ui_create_filter_menu (menu, filter);
}
gtk_menu_popup (GTK_MENU (*menu), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time ());
}
......@@ -40,4 +40,8 @@ void ui_filters_add(ui_filter_e filter, uint32_t value, char *name);
int ui_write_filters_file(char *file_name);
void ui_destroy_filter_menus(void);
void ui_show_filter_menu(GtkWidget **menu, ui_filter_t *filter);
#endif /* UI_FILTERS_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