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;
}
......
......@@ -28,7 +28,7 @@
static gboolean refresh_message_list = TRUE;
static gboolean filters_changed = FALSE;
gboolean ui_callback_on_open_messages (GtkWidget *widget, gpointer data)
gboolean ui_callback_on_open_messages(GtkWidget *widget, gpointer data)
{
gboolean refresh = (data != NULL) ? TRUE : FALSE;
......@@ -46,47 +46,48 @@ gboolean ui_callback_on_open_messages (GtkWidget *widget, gpointer data)
return TRUE;
}
gboolean ui_callback_on_save_messages (GtkWidget *widget, gpointer data)
gboolean ui_callback_on_save_messages(GtkWidget *widget, gpointer data)
{
g_message("Save messages event occurred");
// CHECK_FCT(ui_file_chooser());
return TRUE;
}
gboolean ui_callback_on_filters_enabled (GtkToolButton *button, gpointer data)
gboolean ui_callback_on_filters_enabled(GtkToolButton *button, gpointer data)
{
gboolean enabled;
gboolean changed;
enabled = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(button));
enabled = gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON(button));
g_debug("Filters enabled event occurred %d", enabled);
changed = ui_filters_enable(enabled);
changed = ui_filters_enable (enabled);
if (changed)
{
/* Set the tool tip text */
if (enabled)
{
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(button), "Disable messages filtering");
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM(button), "Disable messages filtering");
}
else
{
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(button), "Enable messages filtering");
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM(button), "Enable messages filtering");
}
ui_tree_view_refilter();
ui_tree_view_refilter ();
if (ui_main_data.messages_list != NULL)
{
GtkTreePath *path_row;
/* Get the currently selected message */
gtk_tree_view_get_cursor(GTK_TREE_VIEW(ui_main_data.messages_list), &path_row, NULL);
gtk_tree_view_get_cursor (GTK_TREE_VIEW(ui_main_data.messages_list), &path_row, NULL);
if (path_row != NULL)
{
/* Center the message in the middle of the list if possible */
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(ui_main_data.messages_list), path_row, NULL, TRUE, 0.5, 0.0);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(ui_main_data.messages_list), path_row, NULL, TRUE, 0.5,
0.0);
}
}
}
......@@ -94,7 +95,7 @@ gboolean ui_callback_on_filters_enabled (GtkToolButton *button, gpointer data)
return TRUE;
}
gboolean ui_callback_on_open_filters (GtkWidget *widget, gpointer data)
gboolean ui_callback_on_open_filters(GtkWidget *widget, gpointer data)
{
gboolean refresh = (data != NULL) ? TRUE : FALSE;
......@@ -112,43 +113,42 @@ gboolean ui_callback_on_open_filters (GtkWidget *widget, gpointer data)
return TRUE;
}
gboolean ui_callback_on_save_filters (GtkWidget *widget, gpointer data)
gboolean ui_callback_on_save_filters(GtkWidget *widget, gpointer data)
{
g_message("Save filters event occurred");
CHECK_FCT(ui_filters_save_file_chooser());
return TRUE;
}
gboolean ui_callback_on_enable_filters (GtkWidget *widget, gpointer data)
gboolean ui_callback_on_enable_filters(GtkWidget *widget, gpointer data)
{
gboolean enabled;
enabled = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(ui_main_data.filters_enabled));
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(ui_main_data.filters_enabled), !enabled);
enabled = gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON(ui_main_data.filters_enabled));
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON(ui_main_data.filters_enabled), !enabled);
return TRUE;
}
gboolean ui_callback_on_about (GtkWidget *widget, gpointer data)
gboolean ui_callback_on_about(GtkWidget *widget, gpointer data)
{
#if defined(PACKAGE_STRING)
ui_notification_dialog (GTK_MESSAGE_INFO, "about", "Eurecom %s", PACKAGE_STRING);
#else
ui_notification_dialog(GTK_MESSAGE_INFO, "about", "Eurecom itti_analyzer");
ui_notification_dialog (GTK_MESSAGE_INFO, "about", "Eurecom itti_analyzer");
#endif
return TRUE;
}
gboolean ui_callback_on_select_signal (GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path,
gboolean path_currently_selected, gpointer user_data)
gboolean ui_callback_on_select_signal(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path,
gboolean path_currently_selected, gpointer user_data)
{
static gpointer buffer_current;
ui_text_view_t *text_view;
GtkTreeIter iter;
g_debug("Message selected %d %p %p %s", path_currently_selected, buffer_current, path,
gtk_tree_path_to_string(path));
g_debug("Message selected %d %p %p %s", path_currently_selected, buffer_current, path, gtk_tree_path_to_string(path));
if (!path_currently_selected)
{
......@@ -156,7 +156,7 @@ gboolean ui_callback_on_select_signal (GtkTreeSelection *selection, GtkTreeModel
g_assert(text_view != NULL);
if (gtk_tree_model_get_iter(model, &iter, path))
if (gtk_tree_model_get_iter (model, &iter, path))
{
gpointer buffer;
......@@ -166,15 +166,14 @@ gboolean ui_callback_on_select_signal (GtkTreeSelection *selection, GtkTreeModel
uint32_t instance;
char label[100];
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, COL_BUFFER, &buffer, -1);
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, COL_BUFFER, &buffer, -1);
g_debug(" Get iter %p %p", buffer_current, buffer);
if (ui_tree_view_last_event)
{
g_debug("last_event %p %d %d", ui_tree_view_last_event, ui_tree_view_last_event->type,
ui_tree_view_last_event->button);
g_debug("last_event %p %d %d", ui_tree_view_last_event, ui_tree_view_last_event->type, ui_tree_view_last_event->button);
if (ui_tree_view_last_event->type == GDK_BUTTON_PRESS)
{
......@@ -191,25 +190,24 @@ gboolean ui_callback_on_select_signal (GtkTreeSelection *selection, GtkTreeModel
if (ui_main_data.menu_filter_messages == NULL)
{
ui_create_filter_menus();
ui_create_filter_menus ();
}
g_debug("Message selected right click %d %d %d %d", message_id, origin_task_id,
destination_task_id, instance);
g_debug("Message selected right click %d %d %d %d", message_id, origin_task_id, destination_task_id, instance);
/* 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].filter_item = NULL;
item = ui_filters_search_id(&ui_filters.messages, message_id);
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(
gtk_check_menu_item_set_active (
GTK_CHECK_MENU_ITEM(ui_tree_view_menu_enable[MENU_MESSAGE].menu_enable),
ui_filters.messages.items[item].enabled);
/* Set menu item label */
sprintf(label, "Message: %s", message_id_to_string(message_id));
gtk_menu_item_set_label(GTK_MENU_ITEM(ui_tree_view_menu_enable[MENU_MESSAGE].menu_enable),
label);
sprintf (label, "Message: %s", message_id_to_string (message_id));
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].filter_item = &ui_filters.messages.items[item];
}
......@@ -218,15 +216,15 @@ gboolean ui_callback_on_select_signal (GtkTreeSelection *selection, GtkTreeModel
{
/* 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].filter_item = NULL;
item = ui_filters_search_id(&ui_filters.origin_tasks, origin_task_id);
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(
gtk_check_menu_item_set_active (
GTK_CHECK_MENU_ITEM(ui_tree_view_menu_enable[MENU_FROM_TASK].menu_enable),
ui_filters.origin_tasks.items[item].enabled);
/* Set menu item label */
sprintf(label, "From: %s", task_id_to_string(origin_task_id, origin_task_id_type));
gtk_menu_item_set_label(GTK_MENU_ITEM(ui_tree_view_menu_enable[MENU_FROM_TASK].menu_enable),
label);
sprintf (label, "From: %s", task_id_to_string (origin_task_id, origin_task_id_type));
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].filter_item = &ui_filters.origin_tasks.items[item];
}
......@@ -235,15 +233,16 @@ gboolean ui_callback_on_select_signal (GtkTreeSelection *selection, GtkTreeModel
{
/* 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].filter_item = NULL;
item = ui_filters_search_id(&ui_filters.destination_tasks, destination_task_id);
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(
gtk_check_menu_item_set_active (
GTK_CHECK_MENU_ITEM(ui_tree_view_menu_enable[MENU_TO_TASK].menu_enable),
ui_filters.destination_tasks.items[item].enabled);
/* Set menu item label */
sprintf(label, "To: %s", task_id_to_string(destination_task_id, destination_task_id_type));
gtk_menu_item_set_label(GTK_MENU_ITEM(ui_tree_view_menu_enable[MENU_TO_TASK].menu_enable),
label);
sprintf (label, "To: %s",
task_id_to_string (destination_task_id, destination_task_id_type));
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].filter_item =
&ui_filters.destination_tasks.items[item];
......@@ -253,21 +252,21 @@ gboolean ui_callback_on_select_signal (GtkTreeSelection *selection, GtkTreeModel
{
/* Invalidate associated menu item to avoid issue with call back when updating the menu item check state */
ui_tree_view_menu_enable[MENU_INSTANCE].filter_item = NULL;
item = ui_filters_search_id(&ui_filters.instances, instance);
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(
gtk_check_menu_item_set_active (
GTK_CHECK_MENU_ITEM(ui_tree_view_menu_enable[MENU_INSTANCE].menu_enable),
ui_filters.instances.items[item].enabled);
/* Set menu item label */
sprintf(label, "Instance: %d", instance);
gtk_menu_item_set_label(GTK_MENU_ITEM(ui_tree_view_menu_enable[MENU_INSTANCE].menu_enable),
label);
sprintf (label, "Instance: %d", instance);
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].filter_item = &ui_filters.instances.items[item];
}
gtk_menu_popup(GTK_MENU (ui_tree_view_menu), NULL, NULL, NULL, NULL, 0,
gtk_get_current_event_time());
gtk_menu_popup (GTK_MENU (ui_tree_view_menu), NULL, NULL, NULL, NULL, 0,
gtk_get_current_event_time ());
}
}
......@@ -287,12 +286,12 @@ gboolean ui_callback_on_select_signal (GtkTreeSelection *selection, GtkTreeModel
CHECK_FCT_DO(dissect_signal_header((buffer_t*)buffer, ui_signal_set_text, text_view), return FALSE);
}
if ((strcmp(message_id_to_string(message_id), "ERROR_LOG") == 0)
|| (strcmp(message_id_to_string(message_id), "WARNING_LOG") == 0)
|| (strcmp(message_id_to_string(message_id), "NOTICE_LOG") == 0)
|| (strcmp(message_id_to_string(message_id), "INFO_LOG") == 0)
|| (strcmp(message_id_to_string(message_id), "DEBUG_LOG") == 0)
|| (strcmp(message_id_to_string(message_id), "GENERIC_LOG") == 0))
if ((strcmp (message_id_to_string (message_id), "ERROR_LOG") == 0)
|| (strcmp (message_id_to_string (message_id), "WARNING_LOG") == 0)
|| (strcmp (message_id_to_string (message_id), "NOTICE_LOG") == 0)
|| (strcmp (message_id_to_string (message_id), "INFO_LOG") == 0)
|| (strcmp (message_id_to_string (message_id), "DEBUG_LOG") == 0)
|| (strcmp (message_id_to_string (message_id), "GENERIC_LOG") == 0))
{
gchar *data;
gint data_size;
......@@ -300,17 +299,16 @@ gboolean ui_callback_on_select_signal (GtkTreeSelection *selection, GtkTreeModel
if (ui_main_data.display_message_header)
{
ui_signal_set_text(text_view, "\n", 1);
ui_signal_set_text (text_view, "\n", 1);
}
message_header_type_size = get_message_header_type_size();
data = (gchar *) buffer_at_offset((buffer_t*) buffer, message_header_type_size);
data_size = get_message_size((buffer_t*) buffer);
message_header_type_size = get_message_header_type_size ();
data = (gchar *) buffer_at_offset ((buffer_t*) buffer, message_header_type_size);
data_size = get_message_size ((buffer_t*) buffer);
g_debug(" message header type size: %u, data size: %u %p %d", message_header_type_size,
data_size, buffer, ui_main_data.follow_last);
g_debug(" message header type size: %u, data size: %u %p %d", message_header_type_size, data_size, buffer, ui_main_data.follow_last);
ui_signal_set_text(text_view, data, data_size);
ui_signal_set_text (text_view, data, data_size);
}
else
{
......@@ -325,53 +323,60 @@ gboolean ui_callback_on_select_signal (GtkTreeSelection *selection, GtkTreeModel
return TRUE;
}
gboolean ui_callback_on_menu_enable (GtkWidget *widget, gpointer data)
gboolean ui_callback_on_menu_enable(GtkWidget *widget, gpointer data)
{
ui_tree_view_menu_enable_t *menu_enable = data;
if (menu_enable->filter_item != NULL)
{
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)));
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->filter_item = NULL;
}
return TRUE;
}
gboolean ui_callback_on_menu_color (GtkWidget *widget, gpointer data)
gboolean ui_callback_on_menu_color(GtkWidget *widget, gpointer data)
{
ui_tree_view_menu_enable_t *menu_enable = data;
ui_tree_view_menu_color_t *menu_color = data;
GdkRGBA color;
GtkWidget *color_chooser;
gint response;
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));
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;
char *color_string;
color_string =
menu_color->foreground ?
menu_color->menu_enable->filter_item->foreground :
menu_color->menu_enable->filter_item->background;
gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(color_chooser), &color);
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER(color_chooser), &color);
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();
snprintf (color_string, COLOR_SIZE, "#%02x%02x%02x", red, green, blue);
ui_tree_view_refilter ();
g_message("Selected color for %s %f->%02x %f->%02x %f->%02x %s",
menu_color->menu_enable->filter_item->name, color.red, red, color.green, green, color.blue, blue, color_string);
}
gtk_widget_destroy(color_chooser);
gtk_widget_destroy (color_chooser);
return TRUE;
}
void ui_signal_add_to_list (gpointer data, gpointer user_data)
void ui_signal_add_to_list(gpointer data, gpointer user_data)
{
gboolean goto_last = user_data ? TRUE : FALSE;
buffer_t *signal_buffer;
......@@ -385,23 +390,23 @@ void ui_signal_add_to_list (gpointer data, gpointer user_data)
char lte_time[15];
gtk_tree_view_get_cursor(GTK_TREE_VIEW(ui_main_data.messages_list), &path, &focus_column);
gtk_tree_view_get_cursor (GTK_TREE_VIEW(ui_main_data.messages_list), &path, &focus_column);
signal_buffer = (buffer_t *) data;
lte_frame = get_lte_frame(signal_buffer);
lte_slot = get_lte_slot(signal_buffer);
sprintf(lte_time, "%d.%02d", lte_frame, lte_slot);
lte_frame = get_lte_frame (signal_buffer);
lte_slot = get_lte_slot (signal_buffer);
sprintf (lte_time, "%d.%02d", lte_frame, lte_slot);
get_message_id(root, signal_buffer, &signal_buffer->message_id);
origin_task_id = get_task_id(signal_buffer, origin_task_id_type);
destination_task_id = get_task_id(signal_buffer, destination_task_id_type);
instance = get_instance(signal_buffer);
get_message_id (root, signal_buffer, &signal_buffer->message_id);
origin_task_id = get_task_id (signal_buffer, origin_task_id_type);
destination_task_id = get_task_id (signal_buffer, destination_task_id_type);
instance = get_instance (signal_buffer);
ui_tree_view_new_signal_ind(signal_buffer->message_number, lte_time, signal_buffer->message_id,
message_id_to_string(signal_buffer->message_id), origin_task_id,
task_id_to_string(origin_task_id, origin_task_id_type), destination_task_id,
task_id_to_string(destination_task_id, destination_task_id_type), instance, data);
ui_tree_view_new_signal_ind (signal_buffer->message_number, lte_time, signal_buffer->message_id,
message_id_to_string (signal_buffer->message_id), origin_task_id,
task_id_to_string (origin_task_id, origin_task_id_type), destination_task_id,
task_id_to_string (destination_task_id, destination_task_id_type), instance, data);
/* Increment number of messages */
ui_main_data.nb_message_received++;
......@@ -409,65 +414,67 @@ void ui_signal_add_to_list (gpointer data, gpointer user_data)
if ((ui_main_data.follow_last) && (goto_last))
{
/* Advance to the new last signal */
ui_tree_view_select_row(ui_tree_view_get_filtered_number() - 1);
ui_tree_view_select_row (ui_tree_view_get_filtered_number () - 1);
}
}
static gboolean ui_handle_update_signal_list (gint fd, void *data, size_t data_length)
static gboolean ui_handle_update_signal_list(gint fd, void *data, size_t data_length)
{
pipe_new_signals_list_message_t *signal_list_message;
/* Enable buttons to move in the list of signals */
ui_set_sensitive_move_buttons(TRUE);
ui_set_sensitive_move_buttons (TRUE);
signal_list_message = (pipe_new_signals_list_message_t *) data;
g_assert(signal_list_message != NULL);
g_assert(signal_list_message->signal_list != NULL);
g_list_foreach(signal_list_message->signal_list, ui_signal_add_to_list, (gpointer) TRUE);
g_list_foreach (signal_list_message->signal_list, ui_signal_add_to_list, (gpointer) TRUE);
/* Free the list but not user data associated with each element */
g_list_free(signal_list_message->signal_list);
g_list_free (signal_list_message->signal_list);
/* Free the message */
free(signal_list_message);
free (signal_list_message);
ui_gtk_flush_events();
ui_gtk_flush_events ();
return TRUE;
}
static gboolean ui_handle_socket_connection_failed (gint fd)
static gboolean ui_handle_socket_connection_failed(gint fd)
{
GtkWidget *dialogbox;
dialogbox = gtk_message_dialog_new(GTK_WINDOW(ui_main_data.window), GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Failed to connect to provided host/ip address");
dialogbox = gtk_message_dialog_new (GTK_WINDOW(ui_main_data.window), GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
"Failed to connect to provided host/ip address");
gtk_dialog_run(GTK_DIALOG(dialogbox));
gtk_widget_destroy(dialogbox);
gtk_dialog_run (GTK_DIALOG(dialogbox));
gtk_widget_destroy (dialogbox);
/* Re-enable connect button */
ui_enable_connect_button();
ui_enable_connect_button ();
return TRUE;
}
static gboolean ui_handle_socket_connection_lost (gint fd)
static gboolean ui_handle_socket_connection_lost(gint fd)
{
GtkWidget *dialogbox;
dialogbox = gtk_message_dialog_new(GTK_WINDOW(ui_main_data.window), GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Connection with remote host has been lost");
dialogbox = gtk_message_dialog_new (GTK_WINDOW(ui_main_data.window), GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
"Connection with remote host has been lost");
gtk_dialog_run(GTK_DIALOG(dialogbox));
gtk_widget_destroy(dialogbox);
gtk_dialog_run (GTK_DIALOG(dialogbox));
gtk_widget_destroy (dialogbox);
/* Re-enable connect button */
ui_enable_connect_button();
ui_enable_connect_button ();
return TRUE;
}
static gboolean ui_handle_socket_xml_definition (gint fd, void *data, size_t data_length)
static gboolean ui_handle_socket_xml_definition(gint fd, void *data, size_t data_length)
{
pipe_xml_definition_message_t *xml_definition_message;
......@@ -475,21 +482,21 @@ static gboolean ui_handle_socket_xml_definition (gint fd, void *data, size_t dat
g_assert(xml_definition_message != NULL);
g_assert(data_length == sizeof(pipe_xml_definition_message_t));
xml_parse_buffer(xml_definition_message->xml_definition, xml_definition_message->xml_definition_length);
xml_parse_buffer (xml_definition_message->xml_definition, xml_definition_message->xml_definition_length);
free(data);
free (data);
return TRUE;
}
gboolean ui_pipe_callback (gint source, gpointer user_data)
gboolean ui_pipe_callback(gint source, gpointer user_data)
{
void *input_data = NULL;
size_t input_data_length = 0;
pipe_input_header_t input_header;
/* Read the header */
if (read(source, &input_header, sizeof(input_header)) < 0)
if (read (source, &input_header, sizeof(input_header)) < 0)
{
g_warning("Failed to read from pipe %d: %s", source, g_strerror(errno));
return FALSE;
......@@ -500,9 +507,9 @@ gboolean ui_pipe_callback (gint source, gpointer user_data)
/* Checking for non-header part */
if (input_data_length > 0)
{
input_data = malloc(input_data_length);
input_data = malloc (input_data_length);
if (read(source, input_data, input_data_length) < 0)
if (read (source, input_data, input_data_length) < 0)
{
g_warning("Failed to read from pipe %d: %s", source, g_strerror(errno));
return FALSE;
......@@ -511,234 +518,233 @@ gboolean ui_pipe_callback (gint source, gpointer user_data)
switch (input_header.message_type)
{
case UI_PIPE_CONNECTION_FAILED:
return ui_handle_socket_connection_failed(source);
case UI_PIPE_XML_DEFINITION:
return ui_handle_socket_xml_definition(source, input_data, input_data_length);
case UI_PIPE_CONNECTION_LOST:
return ui_handle_socket_connection_lost(source);
case UI_PIPE_UPDATE_SIGNAL_LIST:
return ui_handle_update_signal_list(source, input_data, input_data_length);
default:
g_warning("[gui] Unhandled message type %u", input_header.message_type);
g_assert_not_reached();
case UI_PIPE_CONNECTION_FAILED:
return ui_handle_socket_connection_failed (source);
case UI_PIPE_XML_DEFINITION:
return ui_handle_socket_xml_definition (source, input_data, input_data_length);
case UI_PIPE_CONNECTION_LOST:
return ui_handle_socket_connection_lost (source);
case UI_PIPE_UPDATE_SIGNAL_LIST:
return ui_handle_update_signal_list (source, input_data, input_data_length);
default:
g_warning("[gui] Unhandled message type %u", input_header.message_type);
g_assert_not_reached();
}
return FALSE;
}
gboolean ui_callback_on_connect (GtkWidget *widget, gpointer data)
gboolean ui_callback_on_connect(GtkWidget *widget, gpointer data)
{
/* We have to retrieve the ip address and port of remote host */
const char *ip;
uint16_t port;
int pipe_fd[2];
port = atoi(gtk_entry_get_text(GTK_ENTRY(ui_main_data.port_entry)));
ip = gtk_entry_get_text(GTK_ENTRY(ui_main_data.ip_entry));
port = atoi (gtk_entry_get_text (GTK_ENTRY(ui_main_data.port_entry)));
ip = gtk_entry_get_text (GTK_ENTRY(ui_main_data.ip_entry));
g_message("Connect event occurred to %s:%d", ip, port);
if (strlen(ip) == 0)
if (strlen (ip) == 0)
{
ui_notification_dialog(GTK_MESSAGE_WARNING, "Connect", "Empty host ip address");
ui_notification_dialog (GTK_MESSAGE_WARNING, "Connect", "Empty host ip address");
return FALSE;
}
if (port == 0)
{
ui_notification_dialog(GTK_MESSAGE_WARNING, "Connect", "Invalid host port value");
ui_notification_dialog (GTK_MESSAGE_WARNING, "Connect", "Invalid host port value");
return FALSE;
}
ui_pipe_new(pipe_fd, ui_pipe_callback, NULL);
ui_pipe_new (pipe_fd, ui_pipe_callback, NULL);
memcpy(ui_main_data.pipe_fd, pipe_fd, sizeof(int) * 2);
memcpy (ui_main_data.pipe_fd, pipe_fd, sizeof(int) * 2);
/* Disable the connect button */
ui_disable_connect_button();
ui_disable_connect_button ();
ui_callback_signal_clear_list(widget, 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)
{
ui_enable_connect_button();
ui_enable_connect_button ();
return FALSE;
}
ui_set_title("%s:%d", ip, port);
ui_set_title ("%s:%d", ip, port);
return TRUE;
}
gboolean ui_callback_on_disconnect (GtkWidget *widget, gpointer data)
gboolean ui_callback_on_disconnect(GtkWidget *widget, gpointer data)
{
/* We have to retrieve the ip address and port of remote host */
g_message("Disconnect event occurred");
ui_pipe_write_message(ui_main_data.pipe_fd[0], UI_PIPE_DISCONNECT_EVT, NULL, 0);
ui_pipe_write_message (ui_main_data.pipe_fd[0], UI_PIPE_DISCONNECT_EVT, NULL, 0);
ui_enable_connect_button();
ui_enable_connect_button ();
return TRUE;
}
gboolean ui_callback_signal_go_to_first (GtkWidget *widget, gpointer data)
gboolean ui_callback_signal_go_to_first(GtkWidget *widget, gpointer data)
{
ui_tree_view_select_row(0);
ui_tree_view_select_row (0);
ui_main_data.follow_last = FALSE;
return TRUE;
}
gboolean ui_callback_signal_go_to (GtkWidget *widget, gpointer data)
gboolean ui_callback_signal_go_to(GtkWidget *widget, gpointer data)
{
gtk_window_set_focus(GTK_WINDOW(ui_main_data.window), ui_main_data.signals_go_to_entry);
gtk_window_set_focus (GTK_WINDOW(ui_main_data.window), ui_main_data.signals_go_to_entry);
return TRUE;
}
gboolean ui_callback_signal_go_to_entry (GtkWidget *widget, gpointer data)
gboolean ui_callback_signal_go_to_entry(GtkWidget *widget, gpointer data)
{
// gtk_entry_buffer_set_text(GTK_ENTRY(ui_main_data.signals_go_to_entry), "");
gtk_window_set_focus(GTK_WINDOW(ui_main_data.window), ui_main_data.messages_list);
gtk_window_set_focus (GTK_WINDOW(ui_main_data.window), ui_main_data.messages_list);
return TRUE;
}
gboolean ui_callback_signal_go_to_last (GtkWidget *widget, gpointer data)
gboolean ui_callback_signal_go_to_last(GtkWidget *widget, gpointer data)
{
ui_tree_view_select_row(ui_tree_view_get_filtered_number() - 1);
ui_tree_view_select_row (ui_tree_view_get_filtered_number () - 1);
ui_main_data.follow_last = TRUE;
return TRUE;
}
gboolean ui_callback_display_message_header (GtkWidget *widget, gpointer data)
gboolean ui_callback_display_message_header(GtkWidget *widget, gpointer data)
{
ui_main_data.display_message_header = !ui_main_data.display_message_header;
// TODO refresh textview.
return TRUE;
}
gboolean ui_callback_display_brace (GtkWidget *widget, gpointer data)
gboolean ui_callback_display_brace(GtkWidget *widget, gpointer data)
{
ui_main_data.display_brace = !ui_main_data.display_brace;
// TODO refresh textview.
return TRUE;
}
gboolean ui_callback_signal_clear_list (GtkWidget *widget, gpointer data)
gboolean ui_callback_signal_clear_list(GtkWidget *widget, gpointer data)
{
/* Disable buttons to move in the list of signals */
ui_set_sensitive_move_buttons(FALSE);
ui_set_title("");
ui_set_sensitive_move_buttons (FALSE);
ui_set_title ("");
/* Clear list of signals */
ui_tree_view_destroy_list(ui_main_data.messages_list);
ui_tree_view_destroy_list (ui_main_data.messages_list);
if (ui_main_data.text_view != NULL)
{
ui_signal_dissect_clear_view(ui_main_data.text_view);
ui_signal_dissect_clear_view (ui_main_data.text_view);
}
return TRUE;
}
static void ui_callback_on_menu_items_selected (GtkWidget *widget, gpointer data)
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);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(widget), active);
}
}
gboolean ui_callback_on_menu_none (GtkWidget *widget, gpointer data)
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);
refresh_message_list = FALSE;
gtk_container_foreach(GTK_CONTAINER(menu), ui_callback_on_menu_items_selected, (gpointer) FALSE);
gtk_container_foreach (GTK_CONTAINER(menu), ui_callback_on_menu_items_selected, (gpointer) FALSE);
refresh_message_list = TRUE;
if (filters_changed)
{
ui_tree_view_refilter();
ui_tree_view_refilter ();
filters_changed = FALSE;
}
return TRUE;
}
gboolean ui_callback_on_menu_all (GtkWidget *widget, gpointer data)
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);
refresh_message_list = FALSE;
gtk_container_foreach(GTK_CONTAINER(menu), ui_callback_on_menu_items_selected, (gpointer) TRUE);
gtk_container_foreach (GTK_CONTAINER(menu), ui_callback_on_menu_items_selected, (gpointer) TRUE);
refresh_message_list = TRUE;
if (filters_changed)
{
ui_tree_view_refilter();
ui_tree_view_refilter ();
filters_changed = FALSE;
}
return TRUE;
}
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;
enabled = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
enabled = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM(widget));
if (filter_entry->enabled != enabled)
{
filter_entry->enabled = enabled;
if (refresh_message_list)
{
ui_tree_view_refilter();
ui_tree_view_refilter ();
}
else
{
filters_changed = TRUE;
}
}
g_debug("ui_callback_on_menu_item_selected occurred %p %p %s %d (%d messages to display)", widget, data,
filter_entry->name, enabled, ui_tree_view_get_filtered_number());
g_debug("ui_callback_on_menu_item_selected occurred %p %p %s %d (%d messages to display)", widget, data, filter_entry->name, enabled, ui_tree_view_get_filtered_number());
return TRUE;
}
gboolean ui_callback_on_tree_column_header_click (GtkWidget *widget, gpointer data)
gboolean ui_callback_on_tree_column_header_click(GtkWidget *widget, gpointer data)
{
col_type_t col = (col_type_t) data;
g_debug("ui_callback_on_tree_column_header_click %d", col);
switch (col)
{
case COL_MESSAGE:
ui_show_filter_menu(&ui_main_data.menu_filter_messages, &ui_filters.messages);
break;
case COL_MESSAGE:
ui_show_filter_menu (&ui_main_data.menu_filter_messages, &ui_filters.messages);
break;
case COL_FROM_TASK:
ui_show_filter_menu(&ui_main_data.menu_filter_origin_tasks, &ui_filters.origin_tasks);
break;
case COL_FROM_TASK:
ui_show_filter_menu (&ui_main_data.menu_filter_origin_tasks, &ui_filters.origin_tasks);
break;
case COL_TO_TASK:
ui_show_filter_menu(&ui_main_data.menu_filter_destination_tasks, &ui_filters.destination_tasks);
break;
case COL_TO_TASK:
ui_show_filter_menu (&ui_main_data.menu_filter_destination_tasks, &ui_filters.destination_tasks);
break;
case COL_INSTANCE:
ui_show_filter_menu(&ui_main_data.menu_filter_instances, &ui_filters.instances);
break;
case COL_INSTANCE:
ui_show_filter_menu (&ui_main_data.menu_filter_instances, &ui_filters.instances);
break;
default:
g_warning("Unknown column filter %d in call to ui_callback_on_tree_column_header_click", col);
return FALSE;
default:
g_warning("Unknown column filter %d in call to ui_callback_on_tree_column_header_click", col);
return FALSE;
}
return TRUE;
......
......@@ -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