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() {
{
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;
}
......@@ -721,7 +721,7 @@ static int update_filters() {
while (types != NULL) {
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;
}
......@@ -735,7 +735,7 @@ static int update_filters() {
while (types != NULL) {
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;
}
......
......@@ -14,7 +14,13 @@
const uint32_t FILTER_ALLOC_NUMBER = 100;
const uint32_t FILTER_ID_UNDEFINED = ~0;
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;
......@@ -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,
const char *background)
const char *foreground, const char *background)
{
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,
/* 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);
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++;
}
else
{
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)
{
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,
}
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)
{
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;
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;
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;
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;
default:
......@@ -291,21 +302,32 @@ static int xml_parse_filters(xmlDocPtr doc)
if (cur_node != NULL)
{
xmlAttr *prop_node;
ui_entry_enabled_e enabled = ENTRY_ENABLED_UNDEFINED;
char *foreground = 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);
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,
background);
ui_filters_add (filter, FILTER_ID_UNDEFINED, (const char*) cur_node->name, enabled,
foreground, background);
filters_entries++;
cur_node = cur_node->next;
......@@ -367,15 +389,25 @@ int ui_filters_read(const char *file_name)
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;
fprintf (filter_file, " <%s>\n", filter->name);
for (item = 0; item < filter->used; item++)
{
fprintf (filter_file, " <%s enabled=\"%d\" background_color=\"%s\"/>\n", filter->items[item].name,
filter->items[item].enabled ? 1 : 0, filter->items[item].background);
if (save_colors)
{
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);
}
......@@ -400,9 +432,9 @@ int ui_filters_file_write(const char *file_name)
fprintf (filter_file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<filters>\n");
write_filter (filter_file, &ui_filters.messages);
write_filter (filter_file, &ui_filters.origin_tasks);
write_filter (filter_file, &ui_filters.destination_tasks);
write_filter (filter_file, &ui_filters.messages, TRUE);
write_filter (filter_file, &ui_filters.origin_tasks, FALSE);
write_filter (filter_file, &ui_filters.destination_tasks, FALSE);
fprintf (filter_file, "</filters>\n");
......
......@@ -5,7 +5,7 @@
#include "itti_types.h"
#define BACKGROUND_SIZE 10
#define COLOR_SIZE 10
typedef enum
{
......@@ -22,7 +22,8 @@ typedef struct
uint32_t id;
char name[SIGNAL_NAME_LENGTH];
uint8_t enabled;
char background[BACKGROUND_SIZE];
char foreground[COLOR_SIZE];
char background[COLOR_SIZE];
GtkWidget *menu_item;
} ui_filter_item_t;
......@@ -52,7 +53,7 @@ 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,
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,
const uint32_t instance);
......
......@@ -25,9 +25,6 @@ typedef struct
static ui_store_t ui_store;
static GValue colors[] =
{G_VALUE_INIT, G_VALUE_INIT};
GtkWidget *ui_tree_view_menu;
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)
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",
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_alignment (column, 0.5);
gtk_tree_view_append_column (GTK_TREE_VIEW(list), column);
......@@ -148,6 +146,7 @@ static void ui_tree_view_init_list(GtkWidget *list)
G_TYPE_UINT, // COL_TO_TASK_ID
G_TYPE_STRING, // COL_FOREGROUND
G_TYPE_STRING, // COL_BACKGROUND
G_TYPE_BOOLEAN, // COL_STRIKETHROUGH
// Reference to the buffer here to avoid maintaining multiple lists.
G_TYPE_POINTER);
......@@ -174,6 +173,7 @@ static void ui_tree_view_add_to_list(GtkWidget *list, const gchar *lte_time, con
gboolean enabled;
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_set (ui_store.store, &iter,
......@@ -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,
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_BACKGROUND,
ui_filters.messages.items[ui_filters_search_id (&ui_filters.messages, message_id)].background,
COL_FOREGROUND, ui_filters.messages.items[message_index].foreground, COL_BACKGROUND,
ui_filters.messages.items[message_index].background, COL_STRIKETHROUGH, !enabled,
/* End of columns */
-1);
gtk_list_store_set_value (ui_store.store, &iter, COL_FOREGROUND, &colors[enabled ? 1 : 0]);
}
void ui_tree_view_destroy_list(GtkWidget *list)
......@@ -307,15 +306,35 @@ static void ui_tree_view_create_menu(GtkWidget **menu)
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 */
menu_items = gtk_menu_item_new_with_label ("Select message background 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),
&ui_tree_view_menu_enable[MENU_MESSAGE]);
&menu_color_background);
/* Show the widget */
gtk_widget_show (menu_items);
......@@ -328,11 +347,6 @@ int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox)
GtkTreeSelection *selection;
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);
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_
for (i = ui_store.instance_number; i <= instance; 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_destroy_filter_menu (FILTER_INSTANCES);
......@@ -431,15 +445,16 @@ static gboolean updateColors(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter
uint32_t instance;
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,
&destination_task_id, COL_INSTANCE, &instance, -1);
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]),
COL_BACKGROUND,
ui_filters.messages.items[ui_filters_search_id (&ui_filters.messages, message_id)].background,
-1);
gtk_list_store_set (GTK_LIST_STORE(model), iter, COL_FOREGROUND,
ui_filters.messages.items[message_index].foreground, COL_BACKGROUND,
ui_filters.messages.items[message_index].background, COL_STRIKETHROUGH, !enabled, -1);
return FALSE;
}
......
......@@ -17,6 +17,7 @@ typedef enum col_type_e
COL_TO_TASK_ID,
COL_FOREGROUND,
COL_BACKGROUND,
COL_STRIKETHROUGH,
COL_BUFFER,
NUM_COLS
......@@ -37,6 +38,12 @@ typedef struct ui_tree_view_menu_enable_s
ui_filter_item_t *filter_item;
} 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 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