- 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

This commit is contained in:
Stefan Gehn 2008-09-29 08:35:02 +00:00
parent 1f28fe7a74
commit 6a6925312a
2 changed files with 27 additions and 7 deletions

View File

@ -1862,13 +1862,21 @@ gboolean
gkrellm_client_mode_connect(void) gkrellm_client_mode_connect(void)
{ {
gchar buf[128]; gchar buf[128];
GtkWidget* dlg;
if (_GK.server_port == 0) if (_GK.server_port == 0)
_GK.server_port = GKRELLMD_SERVER_PORT; _GK.server_port = GKRELLMD_SERVER_PORT;
client_fd = gkrellm_connect_to(_GK.server, _GK.server_port); client_fd = gkrellm_connect_to(_GK.server, _GK.server_port);
if (client_fd < 0) { 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; return FALSE;
} }
@ -1880,7 +1888,15 @@ gkrellm_client_mode_connect(void)
/* Initial setup lines from server are read in blocking mode. /* Initial setup lines from server are read in blocking mode.
*/ */
if(!read_server_setup(client_fd)){ 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; return FALSE;
} }

View File

@ -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? gkrellm_sys_main_init(); //FIXME: call this later or earlier?
_GK.w_display = gdk_screen_get_width(gdk_screen_get_default()); _GK.w_display = gdk_screen_get_width(gdk_screen_get_default());
_GK.h_display = gdk_screen_get_height(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()) if (_GK.server && !gkrellm_client_mode_connect())
exit(0); {
gkrellm_exit(0);
return 0;
}
check_gkrellm_directories(); check_gkrellm_directories();
gkrellm_load_user_config(NULL, FALSE); gkrellm_load_user_config(NULL, FALSE);