Commit b2eafca9 authored by winckel's avatar winckel

Added foreground messages color selector.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4494 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 91e7fb1c
...@@ -707,7 +707,7 @@ static int update_filters() { ...@@ -707,7 +707,7 @@ static int update_filters() {
{ {
if (strcmp (types->name, "MESSAGES_ID_MAX") != 0) if (strcmp (types->name, "MESSAGES_ID_MAX") != 0)
{ {
ui_filters_add (FILTER_MESSAGES, types->init_value, types->name, ENTRY_ENABLED_UNDEFINED, NULL); ui_filters_add (FILTER_MESSAGES, types->init_value, types->name, ENTRY_ENABLED_UNDEFINED, NULL, NULL);
} }
types = types->next; types = types->next;
} }
...@@ -721,7 +721,7 @@ static int update_filters() { ...@@ -721,7 +721,7 @@ static int update_filters() {
while (types != NULL) { while (types != NULL) {
if ((strcmp (types->name, "TASK_FIRST") != 0) && (strcmp (types->name, "TASK_MAX") != 0)) if ((strcmp (types->name, "TASK_FIRST") != 0) && (strcmp (types->name, "TASK_MAX") != 0))
{ {
ui_filters_add(FILTER_ORIGIN_TASKS, types->init_value, types->name, ENTRY_ENABLED_UNDEFINED, NULL); ui_filters_add(FILTER_ORIGIN_TASKS, types->init_value, types->name, ENTRY_ENABLED_UNDEFINED, NULL, NULL);
} }
types = types->next; types = types->next;
} }
...@@ -735,7 +735,7 @@ static int update_filters() { ...@@ -735,7 +735,7 @@ static int update_filters() {
while (types != NULL) { while (types != NULL) {
if ((strcmp (types->name, "TASK_FIRST") != 0) && (strcmp (types->name, "TASK_MAX") != 0)) if ((strcmp (types->name, "TASK_FIRST") != 0) && (strcmp (types->name, "TASK_MAX") != 0))
{ {
ui_filters_add(FILTER_DESTINATION_TASKS, types->init_value, types->name, ENTRY_ENABLED_UNDEFINED, NULL); ui_filters_add(FILTER_DESTINATION_TASKS, types->init_value, types->name, ENTRY_ENABLED_UNDEFINED, NULL, NULL);
} }
types = types->next; types = types->next;
} }
......
...@@ -14,7 +14,13 @@ ...@@ -14,7 +14,13 @@
const uint32_t FILTER_ALLOC_NUMBER = 100; const uint32_t FILTER_ALLOC_NUMBER = 100;
const uint32_t FILTER_ID_UNDEFINED = ~0; const uint32_t FILTER_ID_UNDEFINED = ~0;
const char * const COLOR_WHITE = "#ffffff"; const char * const COLOR_WHITE = "#ffffff";
const char * const COLOR_DARK_GREY = "#585858";
#define ENABLED_NAME "enabled"
#define FOREGROUND_NAME "foreground_color"
#define BACKGROUND_NAME "background_color"
ui_filters_t ui_filters; ui_filters_t ui_filters;
...@@ -127,7 +133,7 @@ static void ui_filter_set_enabled(uint8_t *enabled, ui_entry_enabled_e entry_ena ...@@ -127,7 +133,7 @@ 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) const char *foreground, const char *background)
{ {
int item = ui_filters_search_name (filter, name); int item = ui_filters_search_name (filter, name);
...@@ -147,16 +153,21 @@ static int ui_filter_add(ui_filter_t *filter, uint32_t value, const char *name, ...@@ -147,16 +153,21 @@ static int ui_filter_add(ui_filter_t *filter, uint32_t value, const char *name,
/* New entry */ /* New entry */
strncpy (filter->items[item].name, name, SIGNAL_NAME_LENGTH); strncpy (filter->items[item].name, name, SIGNAL_NAME_LENGTH);
ui_filter_set_enabled (&filter->items[item].enabled, entry_enabled, TRUE); ui_filter_set_enabled (&filter->items[item].enabled, entry_enabled, TRUE);
strncpy (filter->items[item].background, background != NULL ? background : COLOR_WHITE, BACKGROUND_SIZE); strncpy (filter->items[item].foreground, foreground != NULL ? foreground : COLOR_DARK_GREY, COLOR_SIZE);
strncpy (filter->items[item].background, background != NULL ? background : COLOR_WHITE, COLOR_SIZE);
filter->used++; filter->used++;
} }
else else
{ {
ui_filter_set_enabled (&filter->items[item].enabled, entry_enabled, FALSE); ui_filter_set_enabled (&filter->items[item].enabled, entry_enabled, FALSE);
if (foreground != NULL)
{
strncpy (filter->items[item].foreground, foreground, COLOR_SIZE);
}
if (background != NULL) if (background != NULL)
{ {
strncpy (filter->items[item].background, background, BACKGROUND_SIZE); strncpy (filter->items[item].background, background, COLOR_SIZE);
} }
} }
...@@ -166,24 +177,24 @@ static int ui_filter_add(ui_filter_t *filter, uint32_t value, const char *name, ...@@ -166,24 +177,24 @@ static int ui_filter_add(ui_filter_t *filter, uint32_t value, const char *name,
} }
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) const char *foreground, const char *background)
{ {
switch (filter) switch (filter)
{ {
case FILTER_MESSAGES: case FILTER_MESSAGES:
ui_filter_add (&ui_filters.messages, value, name, entry_enabled, background); ui_filter_add (&ui_filters.messages, value, name, entry_enabled, foreground, background);
break; break;
case FILTER_ORIGIN_TASKS: case FILTER_ORIGIN_TASKS:
ui_filter_add (&ui_filters.origin_tasks, value, name, entry_enabled, background); ui_filter_add (&ui_filters.origin_tasks, value, name, entry_enabled, foreground, background);
break; break;
case FILTER_DESTINATION_TASKS: case FILTER_DESTINATION_TASKS:
ui_filter_add (&ui_filters.destination_tasks, value, name, entry_enabled, background); ui_filter_add (&ui_filters.destination_tasks, value, name, entry_enabled, foreground, background);
break; break;
case FILTER_INSTANCES: case FILTER_INSTANCES:
ui_filter_add (&ui_filters.instances, value, name, entry_enabled, background); ui_filter_add (&ui_filters.instances, value, name, entry_enabled, foreground, background);
break; break;
default: default:
...@@ -291,21 +302,32 @@ static int xml_parse_filters(xmlDocPtr doc) ...@@ -291,21 +302,32 @@ static int xml_parse_filters(xmlDocPtr doc)
if (cur_node != NULL) if (cur_node != NULL)
{ {
xmlAttr *prop_node;
ui_entry_enabled_e enabled = ENTRY_ENABLED_UNDEFINED;
char *foreground = NULL;
char *background = NULL; char *background = NULL;
if (cur_node->properties->next != NULL) for (prop_node = cur_node->properties; prop_node != NULL; prop_node = prop_node->next)
{ {
background = (char *) cur_node->properties->next->children->content; if (strcmp ((char *) prop_node->name, ENABLED_NAME) == 0)
{
enabled =
prop_node->children->content[0] == '0' ?
ENTRY_ENABLED_FALSE : ENTRY_ENABLED_TRUE;
}
if (strcmp ((char *) prop_node->name, FOREGROUND_NAME) == 0)
{
foreground = (char *) prop_node->children->content;
}
if (strcmp ((char *) prop_node->name, BACKGROUND_NAME) == 0)
{
background = (char *) prop_node->children->content;
}
} }
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_ID_UNDEFINED, (const char*) cur_node->name, enabled,
filter, foreground, background);
FILTER_ID_UNDEFINED,
(const char*) cur_node->name,
cur_node->properties->children->content[0] == '0' ?
ENTRY_ENABLED_FALSE : ENTRY_ENABLED_TRUE,
background);
filters_entries++; filters_entries++;
cur_node = cur_node->next; cur_node = cur_node->next;
...@@ -367,15 +389,25 @@ int ui_filters_read(const char *file_name) ...@@ -367,15 +389,25 @@ int ui_filters_read(const char *file_name)
return ret; return ret;
} }
static void write_filter(FILE *filter_file, ui_filter_t *filter) static void write_filter(FILE *filter_file, ui_filter_t *filter, gboolean save_colors)
{ {
int item; int item;
fprintf (filter_file, " <%s>\n", filter->name); fprintf (filter_file, " <%s>\n", filter->name);
for (item = 0; item < filter->used; item++) for (item = 0; item < filter->used; item++)
{ {
fprintf (filter_file, " <%s enabled=\"%d\" background_color=\"%s\"/>\n", filter->items[item].name, if (save_colors)
filter->items[item].enabled ? 1 : 0, filter->items[item].background); {
fprintf (filter_file,
" <%s " ENABLED_NAME "=\"%d\" " FOREGROUND_NAME "=\"%s\" " BACKGROUND_NAME "=\"%s\"/>\n",
filter->items[item].name, filter->items[item].enabled ? 1 : 0, filter->items[item].foreground,
filter->items[item].background);
}
else
{
fprintf (filter_file, " <%s " ENABLED_NAME "=\"%d\"/>\n", filter->items[item].name,
filter->items[item].enabled ? 1 : 0);
}
} }
fprintf (filter_file, " </%s>\n", filter->name); fprintf (filter_file, " </%s>\n", filter->name);
} }
...@@ -400,9 +432,9 @@ int ui_filters_file_write(const char *file_name) ...@@ -400,9 +432,9 @@ int ui_filters_file_write(const char *file_name)
fprintf (filter_file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" fprintf (filter_file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<filters>\n"); "<filters>\n");
write_filter (filter_file, &ui_filters.messages); write_filter (filter_file, &ui_filters.messages, TRUE);
write_filter (filter_file, &ui_filters.origin_tasks); write_filter (filter_file, &ui_filters.origin_tasks, FALSE);
write_filter (filter_file, &ui_filters.destination_tasks); write_filter (filter_file, &ui_filters.destination_tasks, FALSE);
fprintf (filter_file, "</filters>\n"); fprintf (filter_file, "</filters>\n");
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "itti_types.h" #include "itti_types.h"
#define BACKGROUND_SIZE 10 #define COLOR_SIZE 10
typedef enum typedef enum
{ {
...@@ -22,7 +22,8 @@ typedef struct ...@@ -22,7 +22,8 @@ typedef struct
uint32_t id; uint32_t id;
char name[SIGNAL_NAME_LENGTH]; char name[SIGNAL_NAME_LENGTH];
uint8_t enabled; uint8_t enabled;
char background[BACKGROUND_SIZE]; char foreground[COLOR_SIZE];
char background[COLOR_SIZE];
GtkWidget *menu_item; GtkWidget *menu_item;
} ui_filter_item_t; } ui_filter_item_t;
...@@ -52,7 +53,7 @@ gboolean ui_filters_enable(gboolean enabled); ...@@ -52,7 +53,7 @@ gboolean ui_filters_enable(gboolean enabled);
int ui_filters_search_id(ui_filter_t *filter, uint32_t value); 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); const char *foreground, const char *background);
gboolean ui_filters_message_enabled(const uint32_t message, const uint32_t origin_task, const uint32_t destination_task, gboolean ui_filters_message_enabled(const uint32_t message, const uint32_t origin_task, const uint32_t destination_task,
const uint32_t instance); const uint32_t instance);
......
...@@ -25,9 +25,6 @@ typedef struct ...@@ -25,9 +25,6 @@ typedef struct
static ui_store_t ui_store; static ui_store_t ui_store;
static GValue colors[] =
{G_VALUE_INIT, G_VALUE_INIT};
GtkWidget *ui_tree_view_menu; GtkWidget *ui_tree_view_menu;
ui_tree_view_menu_enable_t ui_tree_view_menu_enable[NUM_MENU_TYPE]; ui_tree_view_menu_enable_t ui_tree_view_menu_enable[NUM_MENU_TYPE];
...@@ -106,7 +103,8 @@ static void ui_tree_view_init_list(GtkWidget *list) ...@@ -106,7 +103,8 @@ static void ui_tree_view_init_list(GtkWidget *list)
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 ("Message", renderer_left, "text", COL_MESSAGE, "foreground", column = gtk_tree_view_column_new_with_attributes ("Message", renderer_left, "text", COL_MESSAGE, "foreground",
COL_FOREGROUND, "background", COL_BACKGROUND, NULL); COL_FOREGROUND, "background", COL_BACKGROUND, "strikethrough",
COL_STRIKETHROUGH, 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);
...@@ -148,6 +146,7 @@ static void ui_tree_view_init_list(GtkWidget *list) ...@@ -148,6 +146,7 @@ static void ui_tree_view_init_list(GtkWidget *list)
G_TYPE_UINT, // COL_TO_TASK_ID G_TYPE_UINT, // COL_TO_TASK_ID
G_TYPE_STRING, // COL_FOREGROUND G_TYPE_STRING, // COL_FOREGROUND
G_TYPE_STRING, // COL_BACKGROUND G_TYPE_STRING, // COL_BACKGROUND
G_TYPE_BOOLEAN, // COL_STRIKETHROUGH
// Reference to the buffer here to avoid maintaining multiple lists. // Reference to the buffer here to avoid maintaining multiple lists.
G_TYPE_POINTER); G_TYPE_POINTER);
...@@ -174,6 +173,7 @@ static void ui_tree_view_add_to_list(GtkWidget *list, const gchar *lte_time, con ...@@ -174,6 +173,7 @@ static void ui_tree_view_add_to_list(GtkWidget *list, const gchar *lte_time, con
gboolean enabled; gboolean enabled;
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);
int message_index = ui_filters_search_id (&ui_filters.messages, message_id);
gtk_list_store_append (ui_store.store, &iter); gtk_list_store_append (ui_store.store, &iter);
gtk_list_store_set (ui_store.store, &iter, gtk_list_store_set (ui_store.store, &iter,
...@@ -182,11 +182,10 @@ static void ui_tree_view_add_to_list(GtkWidget *list, const gchar *lte_time, con ...@@ -182,11 +182,10 @@ static void ui_tree_view_add_to_list(GtkWidget *list, const gchar *lte_time, con
message_number, COL_LTE_TIME, lte_time, COL_MESSAGE, signal_name, COL_FROM_TASK, origin_task, message_number, COL_LTE_TIME, lte_time, COL_MESSAGE, signal_name, COL_FROM_TASK, origin_task,
COL_TO_TASK, destination_task, COL_INSTANCE, instance, COL_MESSAGE_ID, message_id, COL_TO_TASK, destination_task, COL_INSTANCE, instance, COL_MESSAGE_ID, message_id,
COL_FROM_TASK_ID, origin_task_id, COL_TO_TASK_ID, destination_task_id, COL_BUFFER, buffer, COL_FROM_TASK_ID, origin_task_id, COL_TO_TASK_ID, destination_task_id, COL_BUFFER, buffer,
COL_BACKGROUND, COL_FOREGROUND, ui_filters.messages.items[message_index].foreground, COL_BACKGROUND,
ui_filters.messages.items[ui_filters_search_id (&ui_filters.messages, message_id)].background, ui_filters.messages.items[message_index].background, COL_STRIKETHROUGH, !enabled,
/* End of columns */ /* End of columns */
-1); -1);
gtk_list_store_set_value (ui_store.store, &iter, COL_FOREGROUND, &colors[enabled ? 1 : 0]);
} }
void ui_tree_view_destroy_list(GtkWidget *list) void ui_tree_view_destroy_list(GtkWidget *list)
...@@ -307,15 +306,35 @@ static void ui_tree_view_create_menu(GtkWidget **menu) ...@@ -307,15 +306,35 @@ static void ui_tree_view_create_menu(GtkWidget **menu)
gtk_widget_show (menu_items); gtk_widget_show (menu_items);
} }
/* Create the "Color" menu-item */ /* Create the "Foreground color" menu-item */
{
static ui_tree_view_menu_color_t menu_color_foreground =
{TRUE, &ui_tree_view_menu_enable[MENU_MESSAGE]};
/* Create a new menu-item with a name */
menu_items = gtk_menu_item_new_with_label ("Select message foreground 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_color_foreground);
/* Show the widget */
gtk_widget_show (menu_items);
}
/* Create the "Background color" menu-item */
{ {
static ui_tree_view_menu_color_t menu_color_background =
{FALSE, &ui_tree_view_menu_enable[MENU_MESSAGE]};
/* Create a new menu-item with a name */ /* Create a new menu-item with a name */
menu_items = gtk_menu_item_new_with_label ("Select message background color"); menu_items = gtk_menu_item_new_with_label ("Select message background color");
/* 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_signal_connect(G_OBJECT(menu_items), "activate", G_CALLBACK(ui_callback_on_menu_color), g_signal_connect(G_OBJECT(menu_items), "activate", G_CALLBACK(ui_callback_on_menu_color),
&ui_tree_view_menu_enable[MENU_MESSAGE]); &menu_color_background);
/* Show the widget */ /* Show the widget */
gtk_widget_show (menu_items); gtk_widget_show (menu_items);
...@@ -328,11 +347,6 @@ int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox) ...@@ -328,11 +347,6 @@ int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox)
GtkTreeSelection *selection; GtkTreeSelection *selection;
GtkWidget *scrolled_window; GtkWidget *scrolled_window;
g_value_init (&colors[0], G_TYPE_STRING);
g_value_init (&colors[1], G_TYPE_STRING);
g_value_set_string (&colors[0], "Grey");
g_value_set_string (&colors[1], "#585858");
scrolled_window = gtk_scrolled_window_new (NULL, NULL); scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
...@@ -390,7 +404,7 @@ int ui_tree_view_new_signal_ind(const uint32_t message_number, const gchar *lte_ ...@@ -390,7 +404,7 @@ int ui_tree_view_new_signal_ind(const uint32_t message_number, const gchar *lte_
for (i = ui_store.instance_number; i <= instance; i++) for (i = ui_store.instance_number; i <= instance; i++)
{ {
sprintf (name, "%d", i); sprintf (name, "%d", i);
ui_filters_add (FILTER_INSTANCES, i, name, ENTRY_ENABLED_TRUE, NULL); ui_filters_add (FILTER_INSTANCES, i, name, ENTRY_ENABLED_TRUE, NULL, NULL);
} }
ui_store.instance_number = (instance + 1); ui_store.instance_number = (instance + 1);
ui_destroy_filter_menu (FILTER_INSTANCES); ui_destroy_filter_menu (FILTER_INSTANCES);
...@@ -431,15 +445,16 @@ static gboolean updateColors(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter ...@@ -431,15 +445,16 @@ static gboolean updateColors(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter
uint32_t instance; uint32_t instance;
gboolean enabled = FALSE; gboolean enabled = FALSE;
int message_index;
gtk_tree_model_get (model, iter, COL_MESSAGE_ID, &message_id, COL_FROM_TASK_ID, &origin_task_id, COL_TO_TASK_ID, gtk_tree_model_get (model, iter, COL_MESSAGE_ID, &message_id, COL_FROM_TASK_ID, &origin_task_id, COL_TO_TASK_ID,
&destination_task_id, COL_INSTANCE, &instance, -1); &destination_task_id, COL_INSTANCE, &instance, -1);
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);
message_index = ui_filters_search_id (&ui_filters.messages, message_id);
gtk_list_store_set (GTK_LIST_STORE(model), iter, COL_FOREGROUND, g_value_get_string (&colors[enabled ? 1 : 0]), gtk_list_store_set (GTK_LIST_STORE(model), iter, COL_FOREGROUND,
COL_BACKGROUND, ui_filters.messages.items[message_index].foreground, COL_BACKGROUND,
ui_filters.messages.items[ui_filters_search_id (&ui_filters.messages, message_id)].background, ui_filters.messages.items[message_index].background, COL_STRIKETHROUGH, !enabled, -1);
-1);
return FALSE; return FALSE;
} }
......
...@@ -17,6 +17,7 @@ typedef enum col_type_e ...@@ -17,6 +17,7 @@ typedef enum col_type_e
COL_TO_TASK_ID, COL_TO_TASK_ID,
COL_FOREGROUND, COL_FOREGROUND,
COL_BACKGROUND, COL_BACKGROUND,
COL_STRIKETHROUGH,
COL_BUFFER, COL_BUFFER,
NUM_COLS NUM_COLS
...@@ -37,6 +38,12 @@ typedef struct ui_tree_view_menu_enable_s ...@@ -37,6 +38,12 @@ typedef struct ui_tree_view_menu_enable_s
ui_filter_item_t *filter_item; ui_filter_item_t *filter_item;
} ui_tree_view_menu_enable_t; } ui_tree_view_menu_enable_t;
typedef struct ui_tree_view_menu_color_s
{
gboolean foreground;
ui_tree_view_menu_enable_t *menu_enable;
} ui_tree_view_menu_color_t;
extern GtkWidget *ui_tree_view_menu; extern GtkWidget *ui_tree_view_menu;
extern ui_tree_view_menu_enable_t ui_tree_view_menu_enable[NUM_MENU_TYPE]; extern ui_tree_view_menu_enable_t ui_tree_view_menu_enable[NUM_MENU_TYPE];
......
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