From 6a6925312a7d8d8c8b8732c020909d3e7f0414a2 Mon Sep 17 00:00:00 2001 From: Stefan Gehn Date: Mon, 29 Sep 2008 08:35:02 +0000 Subject: [PATCH] - Show message dialog when initial connect to server fails in client-mode, instead of only printing a line on stdout which is invisible on most windowing-systems anyway --- src/client.c | 22 +++++++++++++++++++--- src/main.c | 12 ++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/client.c b/src/client.c index af262ac..2a588f5 100644 --- a/src/client.c +++ b/src/client.c @@ -1699,7 +1699,7 @@ read_server_setup(gint fd) gkrellm_free_glist_and_data(&client_plugin_setup_line_list); gint rs; - + while (1) { rs=getline(fd, buf, sizeof(buf)); @@ -1862,13 +1862,21 @@ gboolean gkrellm_client_mode_connect(void) { gchar buf[128]; + GtkWidget* dlg; if (_GK.server_port == 0) _GK.server_port = GKRELLMD_SERVER_PORT; client_fd = gkrellm_connect_to(_GK.server, _GK.server_port); if (client_fd < 0) { - printf("%s\n", _("Unable to connect.")); + g_warning("%s\n", _("Unable to connect.")); + + dlg = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, + "Unable to connect to server '%s:%d'", + _GK.server, _GK.server_port); + gtk_dialog_run(GTK_DIALOG(dlg)); + gtk_widget_destroy(dlg); return FALSE; } @@ -1880,7 +1888,15 @@ gkrellm_client_mode_connect(void) /* Initial setup lines from server are read in blocking mode. */ if(!read_server_setup(client_fd)){ - close(client_fd); + + close(client_fd); + + dlg = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, + "Initial setup with server '%s:%d' failed.", + _GK.server, _GK.server_port); + gtk_dialog_run(GTK_DIALOG(dlg)); + gtk_widget_destroy(dlg); return FALSE; } diff --git a/src/main.c b/src/main.c index d0a9b73..9095008 100644 --- a/src/main.c +++ b/src/main.c @@ -2169,16 +2169,20 @@ main(gint argc, gchar **argv) } } + if (_GK.debug_level > 0) + g_debug("--- GKrellM %d.%d.%d ---\n", GKRELLM_VERSION_MAJOR, + GKRELLM_VERSION_MINOR, GKRELLM_VERSION_REV); + gkrellm_sys_main_init(); //FIXME: call this later or earlier? _GK.w_display = gdk_screen_get_width(gdk_screen_get_default()); _GK.h_display = gdk_screen_get_height(gdk_screen_get_default()); - if (_GK.debug_level > 0) - g_debug("--- GKrellM %d.%d.%d ---\n", GKRELLM_VERSION_MAJOR, - GKRELLM_VERSION_MINOR, GKRELLM_VERSION_REV); if (_GK.server && !gkrellm_client_mode_connect()) - exit(0); + { + gkrellm_exit(0); + return 0; + } check_gkrellm_directories(); gkrellm_load_user_config(NULL, FALSE);