Commit 57dea23f authored by winckel's avatar winckel

Added messages background color selector.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4486 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 6e82ddd5
......@@ -187,7 +187,7 @@ gboolean ui_callback_on_select_signal(GtkTreeSelection *selection, GtkTreeModel
/* Message Id menu */
{
/* Invalidate associated menu item to avoid issue with call back when updating the menu item check state */
ui_tree_view_menu_enable[MENU_MESSAGE].menu_item = NULL;
ui_tree_view_menu_enable[MENU_MESSAGE].filter_item = NULL;
item = ui_filters_search_id (&ui_filters.messages, message_id);
/* Update the menu item check state based on message ID state */
gtk_check_menu_item_set_active (
......@@ -198,14 +198,13 @@ gboolean ui_callback_on_select_signal(GtkTreeSelection *selection, GtkTreeModel
gtk_menu_item_set_label (GTK_MENU_ITEM(ui_tree_view_menu_enable[MENU_MESSAGE].menu_enable),
label);
/* Save menu item associated to this row */
ui_tree_view_menu_enable[MENU_MESSAGE].menu_item =
ui_filters.messages.items[item].menu_item;
ui_tree_view_menu_enable[MENU_MESSAGE].filter_item = &ui_filters.messages.items[item];
}
/* Origin task id */
{
/* Invalidate associated menu item to avoid issue with call back when updating the menu item check state */
ui_tree_view_menu_enable[MENU_FROM_TASK].menu_item = NULL;
ui_tree_view_menu_enable[MENU_FROM_TASK].filter_item = NULL;
item = ui_filters_search_id (&ui_filters.origin_tasks, origin_task_id);
/* Update the menu item check state based on message ID state */
gtk_check_menu_item_set_active (
......@@ -216,14 +215,13 @@ gboolean ui_callback_on_select_signal(GtkTreeSelection *selection, GtkTreeModel
gtk_menu_item_set_label (
GTK_MENU_ITEM(ui_tree_view_menu_enable[MENU_FROM_TASK].menu_enable), label);
/* Save menu item associated to this row */
ui_tree_view_menu_enable[MENU_FROM_TASK].menu_item =
ui_filters.origin_tasks.items[item].menu_item;
ui_tree_view_menu_enable[MENU_FROM_TASK].filter_item = &ui_filters.origin_tasks.items[item];
}
/* Destination task id */
{
/* Invalidate associated menu item to avoid issue with call back when updating the menu item check state */
ui_tree_view_menu_enable[MENU_TO_TASK].menu_item = NULL;
ui_tree_view_menu_enable[MENU_TO_TASK].filter_item = NULL;
item = ui_filters_search_id (&ui_filters.destination_tasks, destination_task_id);
/* Update the menu item check state based on message ID state */
gtk_check_menu_item_set_active (
......@@ -235,14 +233,14 @@ gboolean ui_callback_on_select_signal(GtkTreeSelection *selection, GtkTreeModel
gtk_menu_item_set_label (GTK_MENU_ITEM(ui_tree_view_menu_enable[MENU_TO_TASK].menu_enable),
label);
/* Save menu item associated to this row */
ui_tree_view_menu_enable[MENU_TO_TASK].menu_item =
ui_filters.destination_tasks.items[item].menu_item;
ui_tree_view_menu_enable[MENU_TO_TASK].filter_item =
&ui_filters.destination_tasks.items[item];
}
/* Instance */
{
/* Invalidate associated menu item to avoid issue with call back when updating the menu item check state */
ui_tree_view_menu_enable[MENU_INSTANCE].menu_item = NULL;
ui_tree_view_menu_enable[MENU_INSTANCE].filter_item = NULL;
item = ui_filters_search_id (&ui_filters.instances, instance);
/* Update the menu item check state based on message ID state */
gtk_check_menu_item_set_active (
......@@ -253,8 +251,7 @@ gboolean ui_callback_on_select_signal(GtkTreeSelection *selection, GtkTreeModel
gtk_menu_item_set_label (GTK_MENU_ITEM(ui_tree_view_menu_enable[MENU_INSTANCE].menu_enable),
label);
/* Save menu item associated to this row */
ui_tree_view_menu_enable[MENU_INSTANCE].menu_item =
ui_filters.instances.items[item].menu_item;
ui_tree_view_menu_enable[MENU_INSTANCE].filter_item = &ui_filters.instances.items[item];
}
gtk_menu_popup (GTK_MENU (ui_tree_view_menu), NULL, NULL, NULL, NULL, 0,
......@@ -319,11 +316,11 @@ gboolean ui_callback_on_menu_enable(GtkWidget *widget, gpointer data)
{
ui_tree_view_menu_enable_t *menu_enable = data;
if (menu_enable->menu_item != NULL)
if (menu_enable->filter_item != NULL)
{
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_enable->menu_item),
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_enable->filter_item->menu_item),
gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM(menu_enable->menu_enable)));
menu_enable->menu_item = NULL;
menu_enable->filter_item = NULL;
}
return TRUE;
......@@ -331,19 +328,29 @@ gboolean ui_callback_on_menu_enable(GtkWidget *widget, gpointer data)
gboolean ui_callback_on_menu_color(GtkWidget *widget, gpointer data)
{
ui_tree_view_menu_enable_t *menu_enable = data;
GdkRGBA color;
GtkWidget *color_chooser;
gint response;
color_chooser = gtk_color_chooser_dialog_new ("Select color", GTK_WINDOW(ui_main_data.window));
color_chooser = gtk_color_chooser_dialog_new ("Select message background color", GTK_WINDOW(ui_main_data.window));
gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER(color_chooser), FALSE);
response = gtk_dialog_run (GTK_DIALOG (color_chooser));
if (response == GTK_RESPONSE_OK)
{
int red, green, blue;
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER(color_chooser), &color);
g_message("Selected color %f %f %f", color.red, color.green, color.blue);
red = (int) (color.red * 255);
green = (int) (color.green * 255);
blue = (int) (color.blue * 255);
g_debug("Selected color for %s %f->%02x %f->%02x %f->%02x", menu_enable->filter_item->name, color.red, red, color.green, green, color.blue, blue);
snprintf (menu_enable->filter_item->background, BACKGROUND_SIZE, "#%02x%02x%02x", red, green, blue);
ui_tree_view_refilter ();
}
gtk_widget_destroy (color_chooser);
......
......@@ -14,6 +14,7 @@
const uint32_t FILTER_ALLOC_NUMBER = 100;
const uint32_t FILTER_ID_UNDEFINED = ~0;
const char * const COLOR_WHITE = "#ffffff";
ui_filters_t ui_filters;
......@@ -125,7 +126,8 @@ static void ui_filter_set_enabled(uint8_t *enabled, ui_entry_enabled_e entry_ena
}
}
static int ui_filter_add(ui_filter_t *filter, uint32_t value, const char *name, ui_entry_enabled_e entry_enabled)
static int ui_filter_add(ui_filter_t *filter, uint32_t value, const char *name, ui_entry_enabled_e entry_enabled,
const char *background)
{
int item = ui_filters_search_name (filter, name);
......@@ -145,12 +147,17 @@ static int ui_filter_add(ui_filter_t *filter, uint32_t value, const char *name,
/* New entry */
strncpy (filter->items[item].name, name, SIGNAL_NAME_LENGTH);
ui_filter_set_enabled (&filter->items[item].enabled, entry_enabled, TRUE);
strncpy (filter->items[item].background, background != NULL ? background : COLOR_WHITE, BACKGROUND_SIZE);
filter->used++;
}
else
{
ui_filter_set_enabled (&filter->items[item].enabled, entry_enabled, FALSE);
if (background != NULL)
{
strncpy (filter->items[item].background, background, BACKGROUND_SIZE);
}
}
g_debug("filter \"%s\" add %d \"%s\" %d", filter->name, value, name, entry_enabled);
......@@ -158,24 +165,25 @@ static int ui_filter_add(ui_filter_t *filter, uint32_t value, const char *name,
return (item);
}
void ui_filters_add(ui_filter_e filter, uint32_t value, const char *name, ui_entry_enabled_e entry_enabled)
void ui_filters_add(ui_filter_e filter, uint32_t value, const char *name, ui_entry_enabled_e entry_enabled,
const char *background)
{
switch (filter)
{
case FILTER_MESSAGES:
ui_filter_add (&ui_filters.messages, value, name, entry_enabled);
ui_filter_add (&ui_filters.messages, value, name, entry_enabled, background);
break;
case FILTER_ORIGIN_TASKS:
ui_filter_add (&ui_filters.origin_tasks, value, name, entry_enabled);
ui_filter_add (&ui_filters.origin_tasks, value, name, entry_enabled, background);
break;
case FILTER_DESTINATION_TASKS:
ui_filter_add (&ui_filters.destination_tasks, value, name, entry_enabled);
ui_filter_add (&ui_filters.destination_tasks, value, name, entry_enabled, background);
break;
case FILTER_INSTANCES:
ui_filter_add (&ui_filters.instances, value, name, entry_enabled);
ui_filter_add (&ui_filters.instances, value, name, entry_enabled, background);
break;
default:
......@@ -200,13 +208,14 @@ static gboolean ui_item_enabled(ui_filter_t *filter, const uint32_t value)
return (FALSE);
}
gboolean ui_filters_message_enabled(const uint32_t message, const uint32_t origin_task, const uint32_t destination_task, const uint32_t instance)
gboolean ui_filters_message_enabled(const uint32_t message, const uint32_t origin_task, const uint32_t destination_task,
const uint32_t instance)
{
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_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;
}
......@@ -264,7 +273,7 @@ static int xml_parse_filters(xmlDocPtr doc)
if (filter_node != NULL)
{
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)
{
......@@ -282,13 +291,21 @@ static int xml_parse_filters(xmlDocPtr doc)
if (cur_node != NULL)
{
char *background = NULL;
if (cur_node->properties->next != NULL)
{
background = (char *) cur_node->properties->next->children->content;
}
g_debug(" Found entry %s %s", cur_node->name, cur_node->properties->children->content);
ui_filters_add (
filter,
FILTER_ID_UNDEFINED,
(const char*) cur_node->name,
cur_node->properties->children->content[0] == '0' ?
ENTRY_ENABLED_FALSE : ENTRY_ENABLED_TRUE);
ENTRY_ENABLED_FALSE : ENTRY_ENABLED_TRUE,
background);
filters_entries++;
cur_node = cur_node->next;
......@@ -315,7 +332,8 @@ static int xml_parse_filters(xmlDocPtr doc)
ret = RC_OK;
}
g_message("Parsed XML filters definition found %d entries (%d messages to display)", filters_entries, ui_tree_view_get_filtered_number());
g_message(
"Parsed XML filters definition found %d entries (%d messages to display)", filters_entries, ui_tree_view_get_filtered_number());
return ret;
}
......@@ -356,8 +374,8 @@ static void write_filter(FILE *filter_file, ui_filter_t *filter)
fprintf (filter_file, " <%s>\n", filter->name);
for (item = 0; item < filter->used; item++)
{
fprintf (filter_file, " <%s enabled=\"%d\"/>\n", filter->items[item].name,
filter->items[item].enabled ? 1 : 0);
fprintf (filter_file, " <%s enabled=\"%d\" background_color=\"%s\"/>\n", filter->items[item].name,
filter->items[item].enabled ? 1 : 0, filter->items[item].background);
}
fprintf (filter_file, " </%s>\n", filter->name);
}
......@@ -479,7 +497,7 @@ static void ui_destroy_filter_menu_item(GtkWidget *widget, gpointer data)
{
if (GTK_IS_MENU_ITEM(widget))
{
gtk_widget_destroy(widget);
gtk_widget_destroy (widget);
}
}
......@@ -487,9 +505,9 @@ static void ui_destroy_filter_menu_widget(GtkWidget **menu)
{
if (*menu != NULL)
{
gtk_container_foreach(GTK_CONTAINER(*menu), ui_destroy_filter_menu_item, NULL);
gtk_container_foreach (GTK_CONTAINER(*menu), ui_destroy_filter_menu_item, NULL);
gtk_widget_destroy(*menu);
gtk_widget_destroy (*menu);
*menu = NULL;
}
}
......
......@@ -5,6 +5,8 @@
#include "itti_types.h"
#define BACKGROUND_SIZE 10
typedef enum
{
FILTER_UNKNOWN, FILTER_MESSAGES, FILTER_ORIGIN_TASKS, FILTER_DESTINATION_TASKS, FILTER_INSTANCES,
......@@ -20,6 +22,7 @@ typedef struct
uint32_t id;
char name[SIGNAL_NAME_LENGTH];
uint8_t enabled;
char background[BACKGROUND_SIZE];
GtkWidget *menu_item;
} ui_filter_item_t;
......@@ -48,9 +51,11 @@ gboolean ui_filters_enable(gboolean enabled);
int ui_filters_search_id(ui_filter_t *filter, uint32_t value);
void ui_filters_add(ui_filter_e filter, uint32_t value, const char *name, ui_entry_enabled_e entry_enabled);
void ui_filters_add(ui_filter_e filter, uint32_t value, const char *name, ui_entry_enabled_e entry_enabled,
const char *background);
gboolean ui_filters_message_enabled(const uint32_t message, const uint32_t origin_task, const uint32_t destination_task, const uint32_t instance);
gboolean ui_filters_message_enabled(const uint32_t message, const uint32_t origin_task, const uint32_t destination_task,
const uint32_t instance);
int ui_filters_read(const char *file_name);
......
#ifndef UI_TREE_VIEW_H_
#define UI_TREE_VIEW_H_
#include "ui_filters.h"
typedef enum col_type_e
{
COL_MSG_NUM = 0,
......@@ -14,6 +16,7 @@ typedef enum col_type_e
COL_FROM_TASK_ID,
COL_TO_TASK_ID,
COL_FOREGROUND,
COL_BACKGROUND,
COL_BUFFER,
NUM_COLS
......@@ -31,7 +34,7 @@ typedef enum ui_tree_view_menu_type_e
typedef struct ui_tree_view_menu_enable_s
{
GtkWidget *menu_enable;
GtkWidget *menu_item;
ui_filter_item_t *filter_item;
} ui_tree_view_menu_enable_t;
extern GtkWidget *ui_tree_view_menu;
......
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