X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Fdemo-Gtk.c;h=0ff66e9382ae0a7bcbb721edff8ad66b1cb439c4;hb=de041722414a2e31c1c04caa10aaec9d6952e9b4;hp=be35a67d15e1055a20cbec529f4c260c4381ef42;hpb=14627f4038ada5d11456f3770090f3c39740d70f;p=xscreensaver diff --git a/driver/demo-Gtk.c b/driver/demo-Gtk.c index be35a67d..0ff66e93 100644 --- a/driver/demo-Gtk.c +++ b/driver/demo-Gtk.c @@ -109,6 +109,7 @@ static void populate_demo_window (GtkWidget *toplevel, static void populate_prefs_page (GtkWidget *top, prefs_pair *pair); static int apply_changes_and_save (GtkWidget *widget); static int maybe_reload_init_file (GtkWidget *widget, prefs_pair *pair); +static void await_xscreensaver (GtkWidget *widget); /* Some random utility functions @@ -501,6 +502,69 @@ restart_menu_cb (GtkWidget *widget, gpointer user_data) sleep (1); system ("xscreensaver -nosplash &"); #endif + + await_xscreensaver (GTK_WIDGET (widget)); +} + +static void +await_xscreensaver (GtkWidget *widget) +{ + int countdown = 5; + + Display *dpy = gdk_display; + /* GtkWidget *dialog = 0;*/ + char *rversion = 0; + + while (!rversion && (--countdown > 0)) + { + /* Check for the version of the running xscreensaver... */ + server_xscreensaver_version (dpy, &rversion, 0, 0); + + /* If it's not there yet, wait a second... */ + sleep (1); + } + +/* if (dialog) gtk_widget_destroy (dialog);*/ + + if (rversion) + { + /* Got it. */ + free (rversion); + } + else + { + /* Timed out, no screensaver running. */ + + char buf [1024]; + Bool root_p = (geteuid () == 0); + + strcpy (buf, + "Error:\n\n" + "The xscreensaver daemon did not start up properly.\n" + "\n"); + + if (root_p) + strcat (buf, + "You are running as root. This usually means that xscreensaver\n" + "was unable to contact your X server because access control is\n" + "turned on. Try running this command:\n" + "\n" + " xhost +localhost\n" + "\n" + "and then selecting `File / Restart Daemon'.\n" + "\n" + "Note that turning off access control will allow anyone logged\n" + "on to this machine to access your screen, which might be\n" + "considered a security problem. Please read the xscreensaver\n" + "manual and FAQ for more information.\n" + "\n" + "You shouldn't run X as root. Instead, you should log in as a\n" + "normal user, and `su' as necessary."); + else + strcat (buf, "Please check your $PATH and permissions."); + + warning_dialog (widget, buf, False, 1); + } }