Commit 3736324a authored by winckel's avatar winckel

Modified UI.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4947 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 099bc6b6
...@@ -24,8 +24,10 @@ ...@@ -24,8 +24,10 @@
#include "xml_parse.h" #include "xml_parse.h"
#define SOCKET_NB_CONNECT_RETRY (5 * 60 * 10) /* About 5 minutes time-out for connecting to peer */ /* Retry connection after 100 ms */
#define SOCKET_US_BEFORE_CONNECT_RETRY (100 * 1000) /* Retry connection after 100 ms */ #define SOCKET_US_BEFORE_CONNECT_RETRY (100 * 1000)
/* About 10 minutes time-out for connecting to peer */
#define SOCKET_NB_CONNECT_RETRY ((10 * 60 * 1000 * 1000) / SOCKET_US_BEFORE_CONNECT_RETRY)
#define SOCKET_NB_SIGNALS_BEFORE_SIGNALLING 10 #define SOCKET_NB_SIGNALS_BEFORE_SIGNALLING 10
#define SOCKET_MS_BEFORE_SIGNALLING 100 #define SOCKET_MS_BEFORE_SIGNALLING 100
...@@ -330,6 +332,7 @@ void *socket_thread_fct(void *arg) ...@@ -330,6 +332,7 @@ void *socket_thread_fct(void *arg)
} }
free(socket_data->ip_address); free(socket_data->ip_address);
free(socket_data); free(socket_data);
socket_abort_connection = FALSE;
/* Quit the thread */ /* Quit the thread */
pthread_exit(NULL); pthread_exit(NULL);
} }
......
...@@ -35,6 +35,8 @@ static gboolean operation_running = FALSE; ...@@ -35,6 +35,8 @@ static gboolean operation_running = FALSE;
static const char *ui_ip; static const char *ui_ip;
static uint16_t ui_port; static uint16_t ui_port;
static GtkWidget *dialogbox_connect;
static gboolean ui_auto_reconnect;
gboolean ui_callback_on_open_messages(GtkWidget *widget, gpointer data) gboolean ui_callback_on_open_messages(GtkWidget *widget, gpointer data)
{ {
...@@ -223,7 +225,11 @@ gboolean ui_callback_on_select_signal(GtkTreeSelection *selection, GtkTreeModel ...@@ -223,7 +225,11 @@ gboolean ui_callback_on_select_signal(GtkTreeSelection *selection, GtkTreeModel
if (ui_tree_view_last_event->type == GDK_BUTTON_PRESS) if (ui_tree_view_last_event->type == GDK_BUTTON_PRESS)
{ {
/* Callback is due to a button click */ /* Callback is due to a button click */
ui_main_data.follow_last = FALSE; if (ui_tree_view_last_event->button == 1)
{
/* It was a left mouse click */
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON(ui_main_data.signals_go_to_last_button), FALSE);
}
if (ui_tree_view_last_event->button == 3) if (ui_tree_view_last_event->button == 3)
{ {
...@@ -510,21 +516,26 @@ static gboolean ui_handle_update_signal_list(gint fd, void *data, size_t data_le ...@@ -510,21 +516,26 @@ static gboolean ui_handle_update_signal_list(gint fd, void *data, size_t data_le
static gboolean ui_handle_socket_connection_failed(gint fd) static gboolean ui_handle_socket_connection_failed(gint fd)
{ {
ui_notification_dialog (GTK_MESSAGE_WARNING, FALSE, "connect", "Failed to connect to provided host/ip address"); gtk_dialog_response(GTK_DIALOG (dialogbox_connect), GTK_RESPONSE_REJECT);
/* Re-enable connect button */
ui_enable_connect_button ();
operation_running = FALSE;
return TRUE; return TRUE;
} }
static gboolean ui_handle_socket_connection_lost(gint fd) static gboolean ui_handle_socket_connection_lost(gint fd)
{ {
ui_notification_dialog (GTK_MESSAGE_WARNING, FALSE, "Connect", "Connection with remote host has been lost"); if (operation_running)
{
/* Re-enable connect button */
ui_enable_connect_button ();
operation_running = FALSE; operation_running = FALSE;
if (ui_auto_reconnect)
{
ui_callback_on_connect (NULL, (gpointer) FALSE);
}
else
{
ui_enable_connect_button();
ui_set_sensitive_save_message_buttons (TRUE);
}
}
return TRUE; return TRUE;
} }
...@@ -578,7 +589,7 @@ gboolean ui_pipe_callback(gint source, gpointer user_data) ...@@ -578,7 +589,7 @@ gboolean ui_pipe_callback(gint source, gpointer user_data)
return ui_handle_socket_connection_lost (source); return ui_handle_socket_connection_lost (source);
case UI_PIPE_XML_DEFINITION: case UI_PIPE_XML_DEFINITION:
ui_set_title ("%s:%d", ui_ip, ui_port); gtk_dialog_response(GTK_DIALOG (dialogbox_connect), GTK_RESPONSE_OK);
return ui_handle_socket_xml_definition (source, input_data, input_data_length); return ui_handle_socket_xml_definition (source, input_data, input_data_length);
case UI_PIPE_UPDATE_SIGNAL_LIST: case UI_PIPE_UPDATE_SIGNAL_LIST:
...@@ -591,16 +602,57 @@ gboolean ui_pipe_callback(gint source, gpointer user_data) ...@@ -591,16 +602,57 @@ gboolean ui_pipe_callback(gint source, gpointer user_data)
return FALSE; return FALSE;
} }
gboolean ui_callback_on_auto_reconnect(GtkWidget *widget, gpointer data)
{
gboolean enabled;
gboolean changed = TRUE;
gboolean toggle = (data != NULL) ? TRUE : FALSE;
enabled = gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON(ui_main_data.auto_reconnect));
if (toggle)
{
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON(ui_main_data.auto_reconnect), !enabled);
return TRUE;
}
g_info("Auto reconnect event occurred %d %d ", toggle, enabled);
ui_auto_reconnect = enabled;
if (changed)
{
/* Set the tool tip text */
if (enabled)
{
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM(ui_main_data.auto_reconnect), "Disable automatic reconnection");
}
else
{
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM(ui_main_data.auto_reconnect), "Enable automatic reconnection");
}
}
return TRUE;
}
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 ui_port of remote host */ /* We have to retrieve the ip address and ui_port of remote host */
gboolean start = (data != NULL) ? TRUE : FALSE;
int pipe_fd[2]; int pipe_fd[2];
if (start)
{
ui_port = atoi (gtk_entry_get_text (GTK_ENTRY(ui_main_data.port_entry))); ui_port = atoi (gtk_entry_get_text (GTK_ENTRY(ui_main_data.port_entry)));
ui_ip = gtk_entry_get_text (GTK_ENTRY(ui_main_data.ip_entry)); ui_ip = gtk_entry_get_text (GTK_ENTRY(ui_main_data.ip_entry));
}
g_message("Connect event occurred to %s:%d", ui_ip, ui_port); g_message("Connect event occurred to %s:%d %s", ui_ip, ui_port, start ? "START" : "RETRY");
if (start)
{
if (strlen (ui_ip) == 0) if (strlen (ui_ip) == 0)
{ {
ui_notification_dialog (GTK_MESSAGE_ERROR, FALSE, "Connect", "Empty host ip address"); ui_notification_dialog (GTK_MESSAGE_ERROR, FALSE, "Connect", "Empty host ip address");
...@@ -612,6 +664,7 @@ gboolean ui_callback_on_connect(GtkWidget *widget, gpointer data) ...@@ -612,6 +664,7 @@ gboolean ui_callback_on_connect(GtkWidget *widget, gpointer data)
ui_notification_dialog (GTK_MESSAGE_ERROR, FALSE, "Connect", "Invalid host ui_port value"); ui_notification_dialog (GTK_MESSAGE_ERROR, FALSE, "Connect", "Invalid host ui_port value");
return FALSE; return FALSE;
} }
}
if (operation_running == FALSE) if (operation_running == FALSE)
{ {
...@@ -623,11 +676,15 @@ gboolean ui_callback_on_connect(GtkWidget *widget, gpointer data) ...@@ -623,11 +676,15 @@ gboolean ui_callback_on_connect(GtkWidget *widget, gpointer data)
/* Disable the connect button */ /* Disable the connect button */
ui_disable_connect_button (); ui_disable_connect_button ();
ui_set_sensitive_save_message_buttons (FALSE);
ui_callback_signal_clear_list (widget, data);
ui_set_title ("connecting to %s:%d ...", ui_ip, ui_port); ui_set_title ("connecting to %s:%d ...", ui_ip, ui_port);
{
const static char *message_formats[] =
{
"Connecting to %s:%d ...",
"Connection lost!\n\n" "Trying to reconnect to %s:%d ..."
};
gint response;
if (socket_connect_to_remote_host (ui_ip, ui_port, pipe_fd[1]) != 0) if (socket_connect_to_remote_host (ui_ip, ui_port, pipe_fd[1]) != 0)
{ {
...@@ -635,6 +692,36 @@ gboolean ui_callback_on_connect(GtkWidget *widget, gpointer data) ...@@ -635,6 +692,36 @@ gboolean ui_callback_on_connect(GtkWidget *widget, gpointer data)
operation_running = FALSE; operation_running = FALSE;
return FALSE; return FALSE;
} }
dialogbox_connect = gtk_message_dialog_new (GTK_WINDOW(ui_main_data.window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_OTHER,
GTK_BUTTONS_CANCEL, message_formats[start ? 0 : 1], ui_ip, ui_port);
gtk_window_set_title (GTK_WINDOW(dialogbox_connect), "Connect");
response = gtk_dialog_run (GTK_DIALOG (dialogbox_connect));
g_message("Connect dialog response %s (%d)", gtk_get_respose_string(response), response);
if (response == GTK_RESPONSE_OK)
{
/* Connection is established */
ui_set_sensitive_save_message_buttons (FALSE);
ui_callback_signal_clear_list (NULL, NULL);
ui_set_title ("%s:%d", ui_ip, ui_port);
}
else
{
/* Connection can not be established */
if (response == GTK_RESPONSE_REJECT)
{
/* Connection retry time-out */
ui_notification_dialog (GTK_MESSAGE_WARNING, FALSE, "Connect", "Failed to connect to provided host/ip address");
}
/* Re-enable connect button */
ui_enable_connect_button();
operation_running = FALSE;
}
gtk_widget_destroy (dialogbox_connect);
}
} }
return TRUE; return TRUE;
...@@ -654,8 +741,8 @@ gboolean ui_callback_on_disconnect(GtkWidget *widget, gpointer data) ...@@ -654,8 +741,8 @@ gboolean ui_callback_on_disconnect(GtkWidget *widget, gpointer data)
gboolean ui_callback_signal_go_to_first(GtkWidget *widget, gpointer data) gboolean ui_callback_signal_go_to_first(GtkWidget *widget, gpointer data)
{ {
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON(ui_main_data.signals_go_to_last_button), FALSE);
ui_tree_view_select_row (0); ui_tree_view_select_row (0);
ui_main_data.follow_last = FALSE;
return TRUE; return TRUE;
} }
...@@ -668,6 +755,7 @@ gboolean ui_callback_signal_go_to(GtkWidget *widget, gpointer data) ...@@ -668,6 +755,7 @@ gboolean ui_callback_signal_go_to(GtkWidget *widget, gpointer data)
gboolean ui_callback_signal_go_to_entry(GtkWidget *widget, gpointer data) gboolean ui_callback_signal_go_to_entry(GtkWidget *widget, gpointer data)
{ {
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON(ui_main_data.signals_go_to_last_button), FALSE);
// gtk_entry_buffer_set_text(GTK_ENTRY(ui_main_data.signals_go_to_entry), ""); // 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; return TRUE;
...@@ -675,8 +763,28 @@ gboolean ui_callback_signal_go_to_entry(GtkWidget *widget, gpointer data) ...@@ -675,8 +763,28 @@ gboolean ui_callback_signal_go_to_entry(GtkWidget *widget, gpointer data)
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); gboolean enable = (data != NULL) ? TRUE : FALSE;
gboolean enabled;
if (enable)
{
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON(ui_main_data.signals_go_to_last_button), TRUE);
return TRUE;
}
enabled = gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON(ui_main_data.signals_go_to_last_button));
g_info("Button signal go to last event occurred %d %d", enable, enabled);
if (enabled)
{
ui_main_data.follow_last = TRUE; ui_main_data.follow_last = TRUE;
ui_tree_view_select_row (ui_tree_view_get_filtered_number () - 1);
}
else
{
ui_main_data.follow_last = FALSE;
}
return TRUE; return TRUE;
} }
......
...@@ -28,6 +28,11 @@ gint ui_callback_check_string (const char *string, ...@@ -28,6 +28,11 @@ gint ui_callback_check_string (const char *string,
const gint lenght, const gint lenght,
const guint message_number); const guint message_number);
gboolean ui_pipe_callback(gint source, gpointer user_data);
gboolean ui_callback_on_auto_reconnect(GtkWidget *widget,
gpointer data);
gboolean ui_callback_on_connect(GtkWidget *widget, gboolean ui_callback_on_connect(GtkWidget *widget,
gpointer data); gpointer data);
...@@ -72,8 +77,6 @@ gboolean ui_callback_display_brace(GtkWidget *widget, ...@@ -72,8 +77,6 @@ gboolean ui_callback_display_brace(GtkWidget *widget,
gboolean ui_callback_signal_clear_list(GtkWidget *widget, gboolean ui_callback_signal_clear_list(GtkWidget *widget,
gpointer data); gpointer data);
gboolean ui_pipe_callback(gint source, gpointer user_data);
gboolean ui_callback_on_menu_none(GtkWidget *widget, gboolean ui_callback_on_menu_none(GtkWidget *widget,
gpointer data); gpointer data);
......
...@@ -25,10 +25,11 @@ typedef struct { ...@@ -25,10 +25,11 @@ typedef struct {
GtkToolItem *open_replay_file; GtkToolItem *open_replay_file;
GtkToolItem *refresh_replay_file; GtkToolItem *refresh_replay_file;
GtkToolItem *stop; GtkToolItem *stop_loading;
GtkToolItem *save_replay_file; GtkToolItem *save_replay_file;
GtkToolItem *save_replay_file_filtered; GtkToolItem *save_replay_file_filtered;
GtkToolItem *auto_reconnect;
GtkToolItem *connect; GtkToolItem *connect;
GtkToolItem *disconnect; GtkToolItem *disconnect;
......
...@@ -5,9 +5,26 @@ ...@@ -5,9 +5,26 @@
#include "ui_notif_dlg.h" #include "ui_notif_dlg.h"
#include "ui_main_screen.h" #include "ui_main_screen.h"
static const char * const title_type[] = static const char * const gtk_response_strings[] =
{"GTK_RESPONSE_NONE", "GTK_RESPONSE_REJECT", "GTK_RESPONSE_ACCEPT", "GTK_RESPONSE_DELETE_EVENT", "GTK_RESPONSE_OK",
"GTK_RESPONSE_CANCEL", "GTK_RESPONSE_CLOSE", "GTK_RESPONSE_YES", "GTK_RESPONSE_NO", "GTK_RESPONSE_APPLY", "GTK_RESPONSE_HELP"};
static const char * const title_type_strings[] =
{"Info", "Warning", "Question", "Error", "Other"}; {"Info", "Warning", "Question", "Error", "Other"};
const char * gtk_get_respose_string (gint response)
{
gint response_index = - response - 1;
if ((0 <= response_index) && (response_index < (sizeof (gtk_response_strings) / sizeof (gtk_response_strings[0]))))
{
return (gtk_response_strings[response_index]);
}
else
{
return ("Invalid response value!");
}
}
int ui_notification_dialog(GtkMessageType type, gboolean cancel, const char *title, const char *fmt, ...) int ui_notification_dialog(GtkMessageType type, gboolean cancel, const char *title, const char *fmt, ...)
{ {
va_list args; va_list args;
...@@ -26,7 +43,7 @@ int ui_notification_dialog(GtkMessageType type, gboolean cancel, const char *tit ...@@ -26,7 +43,7 @@ int ui_notification_dialog(GtkMessageType type, gboolean cancel, const char *tit
buffer); buffer);
gtk_dialog_set_default_response (GTK_DIALOG(dialogbox), GTK_RESPONSE_OK); gtk_dialog_set_default_response (GTK_DIALOG(dialogbox), GTK_RESPONSE_OK);
snprintf (buffer, sizeof(buffer), "%s: %s", title_type[type], title); snprintf (buffer, sizeof(buffer), "%s: %s", title_type_strings[type], title);
gtk_window_set_title (GTK_WINDOW(dialogbox), buffer); gtk_window_set_title (GTK_WINDOW(dialogbox), buffer);
if (gtk_dialog_run (GTK_DIALOG (dialogbox)) == GTK_RESPONSE_CANCEL) if (gtk_dialog_run (GTK_DIALOG (dialogbox)) == GTK_RESPONSE_CANCEL)
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
#ifndef UI_NOTIF_DLG_H_ #ifndef UI_NOTIF_DLG_H_
#define UI_NOTIF_DLG_H_ #define UI_NOTIF_DLG_H_
const char *gtk_get_respose_string (gint response);
extern int ui_notification_dialog(GtkMessageType type, gboolean cancel, const char *title, const char *fmt, ...); extern int ui_notification_dialog(GtkMessageType type, gboolean cancel, const char *title, const char *fmt, ...);
#endif /* UI_NOTIF_DLG_H_ */ #endif /* UI_NOTIF_DLG_H_ */
...@@ -127,7 +127,6 @@ int ui_messages_read(char *file_name) ...@@ -127,7 +127,6 @@ int ui_messages_read(char *file_name)
size = st.st_size; size = st.st_size;
ui_callback_signal_clear_list (NULL, NULL); ui_callback_signal_clear_list (NULL, NULL);
ui_main_data.follow_last = TRUE;
/* Initialize the progress bar */ /* Initialize the progress bar */
ui_abort = FALSE; ui_abort = FALSE;
...@@ -585,7 +584,7 @@ int ui_progress_bar_set_fraction(double fraction) ...@@ -585,7 +584,7 @@ int ui_progress_bar_set_fraction(double fraction)
gtk_widget_show_all (ui_main_data.progressbar_window); gtk_widget_show_all (ui_main_data.progressbar_window);
gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.stop), TRUE); gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.stop_loading), TRUE);
} }
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(ui_main_data.progressbar), fraction); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(ui_main_data.progressbar), fraction);
...@@ -608,7 +607,7 @@ int ui_progress_bar_terminate(void) ...@@ -608,7 +607,7 @@ int ui_progress_bar_terminate(void)
gtk_widget_destroy (ui_main_data.progressbar_window); gtk_widget_destroy (ui_main_data.progressbar_window);
ui_main_data.progressbar_window = NULL; ui_main_data.progressbar_window = NULL;
} }
gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.stop), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.stop_loading), FALSE);
return RC_OK; return RC_OK;
} }
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