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 @@
#include "xml_parse.h"
#define SOCKET_NB_CONNECT_RETRY (5 * 60 * 10) /* About 5 minutes time-out for connecting to peer */
#define SOCKET_US_BEFORE_CONNECT_RETRY (100 * 1000) /* Retry connection after 100 ms */
/* 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_MS_BEFORE_SIGNALLING 100
......@@ -330,6 +332,7 @@ void *socket_thread_fct(void *arg)
}
free(socket_data->ip_address);
free(socket_data);
socket_abort_connection = FALSE;
/* Quit the thread */
pthread_exit(NULL);
}
......
......@@ -33,8 +33,10 @@ static gboolean refresh_message_list = TRUE;
static gboolean filters_changed = FALSE;
static gboolean operation_running = FALSE;
static const char *ui_ip;
static uint16_t ui_port;
static const char *ui_ip;
static uint16_t ui_port;
static GtkWidget *dialogbox_connect;
static gboolean ui_auto_reconnect;
gboolean ui_callback_on_open_messages(GtkWidget *widget, gpointer data)
{
......@@ -223,7 +225,11 @@ gboolean ui_callback_on_select_signal(GtkTreeSelection *selection, GtkTreeModel
if (ui_tree_view_last_event->type == GDK_BUTTON_PRESS)
{
/* 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)
{
......@@ -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)
{
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;
}
static gboolean ui_handle_socket_connection_lost(gint fd)
{
ui_notification_dialog (GTK_MESSAGE_WARNING, FALSE, "Connect", "Connection with remote host has been lost");
/* Re-enable connect button */
ui_enable_connect_button ();
operation_running = FALSE;
if (operation_running)
{
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;
}
......@@ -578,7 +589,7 @@ gboolean ui_pipe_callback(gint source, gpointer user_data)
return ui_handle_socket_connection_lost (source);
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);
case UI_PIPE_UPDATE_SIGNAL_LIST:
......@@ -591,26 +602,68 @@ gboolean ui_pipe_callback(gint source, gpointer user_data)
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)
{
/* We have to retrieve the ip address and ui_port of remote host */
gboolean start = (data != NULL) ? TRUE : FALSE;
int pipe_fd[2];
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));
g_message("Connect event occurred to %s:%d", ui_ip, ui_port);
if (strlen (ui_ip) == 0)
if (start)
{
ui_notification_dialog (GTK_MESSAGE_ERROR, FALSE, "Connect", "Empty host ip address");
return FALSE;
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));
}
if (ui_port == 0)
g_message("Connect event occurred to %s:%d %s", ui_ip, ui_port, start ? "START" : "RETRY");
if (start)
{
ui_notification_dialog (GTK_MESSAGE_ERROR, FALSE, "Connect", "Invalid host ui_port value");
return FALSE;
if (strlen (ui_ip) == 0)
{
ui_notification_dialog (GTK_MESSAGE_ERROR, FALSE, "Connect", "Empty host ip address");
return FALSE;
}
if (ui_port == 0)
{
ui_notification_dialog (GTK_MESSAGE_ERROR, FALSE, "Connect", "Invalid host ui_port value");
return FALSE;
}
}
if (operation_running == FALSE)
......@@ -623,17 +676,51 @@ gboolean ui_callback_on_connect(GtkWidget *widget, gpointer data)
/* Disable the 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);
if (socket_connect_to_remote_host (ui_ip, ui_port, pipe_fd[1]) != 0)
{
ui_enable_connect_button ();
operation_running = FALSE;
return FALSE;
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)
{
ui_enable_connect_button ();
operation_running = 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);
}
}
......@@ -654,8 +741,8 @@ gboolean ui_callback_on_disconnect(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_main_data.follow_last = FALSE;
return TRUE;
}
......@@ -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)
{
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_window_set_focus (GTK_WINDOW(ui_main_data.window), ui_main_data.messages_list);
return TRUE;
......@@ -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)
{
ui_tree_view_select_row (ui_tree_view_get_filtered_number () - 1);
ui_main_data.follow_last = TRUE;
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_tree_view_select_row (ui_tree_view_get_filtered_number () - 1);
}
else
{
ui_main_data.follow_last = FALSE;
}
return TRUE;
}
......
......@@ -28,6 +28,11 @@ gint ui_callback_check_string (const char *string,
const gint lenght,
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,
gpointer data);
......@@ -72,8 +77,6 @@ gboolean ui_callback_display_brace(GtkWidget *widget,
gboolean ui_callback_signal_clear_list(GtkWidget *widget,
gpointer data);
gboolean ui_pipe_callback(gint source, gpointer user_data);
gboolean ui_callback_on_menu_none(GtkWidget *widget,
gpointer data);
......
......@@ -25,10 +25,11 @@ typedef struct {
GtkToolItem *open_replay_file;
GtkToolItem *refresh_replay_file;
GtkToolItem *stop;
GtkToolItem *stop_loading;
GtkToolItem *save_replay_file;
GtkToolItem *save_replay_file_filtered;
GtkToolItem *auto_reconnect;
GtkToolItem *connect;
GtkToolItem *disconnect;
......
......@@ -34,6 +34,10 @@ int ui_menu_bar_create(GtkWidget *vbox)
GtkAccelGroup *accel_group;
GtkWidget *menu_bar;
GtkWidget *system_menu;
GtkWidget *system;
GtkWidget *quit;
GtkWidget *filters_menu;
GtkWidget *filters;
GtkWidget *open_filters;
......@@ -45,6 +49,7 @@ int ui_menu_bar_create(GtkWidget *vbox)
GtkWidget *messages;
GtkWidget *open_messages;
GtkWidget *reload_messages;
GtkWidget *stop_loading;
GtkWidget *save_messages;
GtkWidget *save_messages_filtered;
GtkWidget *goto_first_messages;
......@@ -53,9 +58,14 @@ int ui_menu_bar_create(GtkWidget *vbox)
GtkWidget *display_message_header;
GtkWidget *display_brace;
GtkWidget *connect_menu;
GtkWidget *connect;
GtkWidget *auto_reconnect;
GtkWidget *connect_to;
GtkWidget *disconnect;
GtkWidget *help_menu;
GtkWidget *help;
GtkWidget *quit;
GtkWidget *about;
if (!vbox)
......@@ -66,6 +76,23 @@ int ui_menu_bar_create(GtkWidget *vbox)
menu_bar = gtk_menu_bar_new();
/* Create the System sub-menu */
{
system = gtk_menu_item_new_with_mnemonic ("_System");
gtk_menu_shell_append (GTK_MENU_SHELL(menu_bar), system);
system_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM(system), system_menu);
/* Create the Filters menu items */
{
quit = gtk_menu_item_new_with_mnemonic ("_Quit");
gtk_widget_add_accelerator (quit, "activate", accel_group, GDK_KEY_q, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
gtk_menu_shell_append (GTK_MENU_SHELL(system_menu), quit);
g_signal_connect(G_OBJECT(quit), "activate", ui_main_window_destroy, NULL);
}
}
/* Create the Filters sub-menu */
{
filters = gtk_menu_item_new_with_mnemonic ("_Filters");
......@@ -103,13 +130,6 @@ int ui_menu_bar_create(GtkWidget *vbox)
GTK_ACCEL_VISIBLE);
gtk_menu_shell_append (GTK_MENU_SHELL(filters_menu), enable_filters);
g_signal_connect(G_OBJECT(enable_filters), "activate", G_CALLBACK(ui_callback_on_enable_filters), NULL);
gtk_menu_shell_append (GTK_MENU_SHELL(filters_menu), gtk_menu_item_new ()); // Separator
quit = gtk_menu_item_new_with_mnemonic ("_Quit");
gtk_widget_add_accelerator (quit, "activate", accel_group, GDK_KEY_q, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
gtk_menu_shell_append (GTK_MENU_SHELL(filters_menu), quit);
g_signal_connect(G_OBJECT(quit), "activate", ui_main_window_destroy, NULL);
}
}
......@@ -138,7 +158,14 @@ int ui_menu_bar_create(GtkWidget *vbox)
g_signal_connect(G_OBJECT(reload_messages), "activate", G_CALLBACK(ui_callback_on_open_messages),
(gpointer) TRUE);
save_messages = gtk_menu_item_new_with_mnemonic ("_Save messages file (all)");
stop_loading = gtk_menu_item_new_with_mnemonic ("S_top loading messages file");
gtk_widget_add_accelerator (stop_loading, "activate", accel_group, GDK_KEY_x, GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE);
gtk_menu_shell_append (GTK_MENU_SHELL(messages_menu), stop_loading);
g_signal_connect(G_OBJECT(stop_loading), "activate", G_CALLBACK(ui_progressbar_window_destroy),
NULL);
save_messages = gtk_menu_item_new_with_mnemonic ("S_ave messages file (all)");
gtk_widget_add_accelerator (save_messages, "activate", accel_group, GDK_KEY_a, GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE);
gtk_menu_shell_append (GTK_MENU_SHELL(messages_menu), save_messages);
......@@ -171,7 +198,7 @@ int ui_menu_bar_create(GtkWidget *vbox)
gtk_widget_add_accelerator (goto_last_messages, "activate", accel_group, GDK_KEY_l, GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE);
gtk_menu_shell_append (GTK_MENU_SHELL(messages_menu), goto_last_messages);
g_signal_connect(G_OBJECT(goto_last_messages), "activate", G_CALLBACK(ui_callback_signal_go_to_last), NULL);
g_signal_connect(G_OBJECT(goto_last_messages), "activate", G_CALLBACK(ui_callback_signal_go_to_last), (gpointer) TRUE);
gtk_menu_shell_append (GTK_MENU_SHELL(messages_menu), gtk_menu_item_new ()); // Separator
......@@ -190,6 +217,36 @@ int ui_menu_bar_create(GtkWidget *vbox)
}
}
/* Create the Connect sub-menu */
{
connect = gtk_menu_item_new_with_mnemonic ("_Connect");
gtk_menu_shell_append (GTK_MENU_SHELL(menu_bar), connect);
connect_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM(connect), connect_menu);
/* Create the Help menu item */
{
auto_reconnect = gtk_menu_item_new_with_mnemonic ("_Automatic reconnection");
gtk_widget_add_accelerator (auto_reconnect, "activate", accel_group, GDK_KEY_t, GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE);
gtk_menu_shell_append (GTK_MENU_SHELL(connect_menu), auto_reconnect);
g_signal_connect(G_OBJECT(auto_reconnect), "activate", G_CALLBACK(ui_callback_on_auto_reconnect), (gpointer) TRUE);
connect_to = gtk_menu_item_new_with_mnemonic ("_Connect");
gtk_widget_add_accelerator (connect_to, "activate", accel_group, GDK_KEY_c, GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE);
gtk_menu_shell_append (GTK_MENU_SHELL(connect_menu), connect_to);
g_signal_connect(G_OBJECT(connect_to), "activate", G_CALLBACK(ui_callback_on_connect), (gpointer) TRUE);
disconnect = gtk_menu_item_new_with_mnemonic ("_Disconnect");
gtk_widget_add_accelerator (disconnect, "activate", accel_group, GDK_KEY_u, GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE);
gtk_menu_shell_append (GTK_MENU_SHELL(connect_menu), disconnect);
g_signal_connect(G_OBJECT(disconnect), "activate", G_CALLBACK(ui_callback_on_disconnect), NULL);
}
}
/* Create the Help sub-menu */
{
help = gtk_menu_item_new_with_mnemonic ("_Help");
......@@ -282,10 +339,10 @@ int ui_toolbar_create(GtkWidget *vbox)
/* Stop reading messages file */
{
ui_main_data.stop = gtk_tool_button_new_from_stock(GTK_STOCK_STOP);
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.stop), "Stop loading messages file");
ui_main_data.stop_loading = gtk_tool_button_new_from_stock(GTK_STOCK_STOP);
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.stop_loading), "Stop loading messages file");
g_signal_connect(G_OBJECT(ui_main_data.stop), "clicked",
g_signal_connect(G_OBJECT(ui_main_data.stop_loading), "clicked",
ui_progressbar_window_destroy, NULL);
}
......@@ -331,14 +388,24 @@ int ui_toolbar_create(GtkWidget *vbox)
/* Button to go to last signal in list */
{
ui_main_data.signals_go_to_last_button = gtk_tool_button_new_from_stock(GTK_STOCK_GOTO_LAST);
ui_main_data.signals_go_to_last_button = gtk_toggle_tool_button_new_from_stock(GTK_STOCK_GOTO_LAST);
/* Set the tooltip text */
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.signals_go_to_last_button), "Goto last signal");
gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.signals_go_to_last_button), FALSE);
g_signal_connect(G_OBJECT(ui_main_data.signals_go_to_last_button), "clicked",
G_CALLBACK(ui_callback_signal_go_to_last), NULL);
G_CALLBACK(ui_callback_signal_go_to_last), (gpointer) FALSE);
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON(ui_main_data.signals_go_to_last_button), TRUE);
}
/* Button to automatically try to reconnect */
{
ui_main_data.auto_reconnect = gtk_toggle_tool_button_new();
gtk_tool_button_set_label (GTK_TOOL_BUTTON(ui_main_data.auto_reconnect), "Auto");
g_signal_connect(G_OBJECT(ui_main_data.auto_reconnect), "clicked",
G_CALLBACK(ui_callback_on_auto_reconnect), (gpointer) FALSE);
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON(ui_main_data.auto_reconnect), FALSE);
}
/* Button to connect to remote */
......@@ -348,7 +415,7 @@ int ui_toolbar_create(GtkWidget *vbox)
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(ui_main_data.connect), "Connect to remote host");
g_signal_connect(G_OBJECT(ui_main_data.connect), "clicked",
G_CALLBACK(ui_callback_on_connect), NULL);
G_CALLBACK(ui_callback_on_connect), (gpointer) TRUE);
}
/* Button to disconnect from remote */
......@@ -387,8 +454,8 @@ int ui_toolbar_create(GtkWidget *vbox)
gtk_box_pack_start(GTK_BOX(hbox), messages_label, FALSE, FALSE, LABEL_SPACE);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ui_main_data.open_replay_file), FALSE, FALSE, BUTTON_SPACE);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ui_main_data.refresh_replay_file), FALSE, FALSE, BUTTON_SPACE);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ui_main_data.stop), FALSE, FALSE, BUTTON_SPACE);
gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.stop), FALSE);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ui_main_data.stop_loading), FALSE, FALSE, BUTTON_SPACE);
gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.stop_loading), FALSE);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ui_main_data.save_replay_file), FALSE, FALSE, BUTTON_SPACE);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ui_main_data.save_replay_file_filtered), FALSE, FALSE, BUTTON_SPACE);
ui_set_sensitive_save_message_buttons(FALSE);
......@@ -401,6 +468,7 @@ int ui_toolbar_create(GtkWidget *vbox)
gtk_box_pack_start(GTK_BOX(hbox), gtk_separator_new(GTK_ORIENTATION_VERTICAL), FALSE, FALSE, SEPARATOR_SPACE);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ui_main_data.auto_reconnect), FALSE, FALSE, LABEL_SPACE);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ui_main_data.connect), FALSE, FALSE, BUTTON_SPACE);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ui_main_data.disconnect), FALSE, FALSE, BUTTON_SPACE);
gtk_box_pack_start(GTK_BOX(hbox), ip_label, FALSE, FALSE, LABEL_SPACE);
......
......@@ -5,9 +5,26 @@
#include "ui_notif_dlg.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"};
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, ...)
{
va_list args;
......@@ -26,7 +43,7 @@ int ui_notification_dialog(GtkMessageType type, gboolean cancel, const char *tit
buffer);
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);
if (gtk_dialog_run (GTK_DIALOG (dialogbox)) == GTK_RESPONSE_CANCEL)
......
......@@ -3,6 +3,8 @@
#ifndef 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, ...);
#endif /* UI_NOTIF_DLG_H_ */
......@@ -127,7 +127,6 @@ int ui_messages_read(char *file_name)
size = st.st_size;
ui_callback_signal_clear_list (NULL, NULL);
ui_main_data.follow_last = TRUE;
/* Initialize the progress bar */
ui_abort = FALSE;
......@@ -585,7 +584,7 @@ int ui_progress_bar_set_fraction(double fraction)
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);
......@@ -608,7 +607,7 @@ int ui_progress_bar_terminate(void)
gtk_widget_destroy (ui_main_data.progressbar_window);
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;
}
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