Commit b2eafca9 authored by winckel's avatar winckel
Browse files

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)
{