#include <Xm/RowColumn.h>
#include <Xm/MessageB.h>
+#ifdef HAVE_XMCOMBOBOX /* a Motif 2.0 widget */
+# include <Xm/ComboBox.h>
+# ifndef XmNtextField /* Lesstif 0.89.4 bug */
+# undef HAVE_XMCOMBOBOX
+# endif
+#endif /* HAVE_XMCOMBOBOX */
+
#include "version.h"
#include "prefs.h"
#include "resources.h" /* for parse_time() */
static void populate_prefs_page (Widget top, prefs_pair *pair);
static int apply_changes_and_save (Widget widget);
static int maybe_reload_init_file (Widget widget, prefs_pair *pair);
+static void await_xscreensaver (Widget widget);
\f
/* Some random utility functions
sleep (1);
system ("xscreensaver -nosplash &");
#endif
+
+ await_xscreensaver (button);
+}
+
+static void
+await_xscreensaver (Widget widget)
+{
+ int countdown = 5;
+
+ Display *dpy = XtDisplay (widget);
+ 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 (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 (XtParent (widget), buf, 1);
+ }
}
Widget vis = name_to_widget (widget, "combo");
# ifdef HAVE_XMCOMBOBOX
- Widget text;
+ Widget text = 0;
# else /* !HAVE_XMCOMBOBOX */
Widget menu = 0, *kids = 0, selected_item = 0;
- Cardinal nkids;
+ Cardinal nkids = 0;
int i = 0;
# endif /* !HAVE_XMCOMBOBOX */
# ifdef HAVE_XMCOMBOBOX
XtVaGetValues (vis, XmNtextField, &text, 0);
+ if (!text)
+ /* If we can't get at the text field of this combo box, we're screwed. */
+ abort();
XtVaGetValues (text, XmNvalue, &visual, 0);
# else /* !HAVE_XMCOMBOBOX */
this parses the text, and does error checking.
*/
static void
-hack_time_text (const char *line, Time *store, Bool sec_p)
+hack_time_text (Widget button, const char *line, Time *store, Bool sec_p)
{
if (*line)
{
value = parse_time ((char *) line, sec_p, True);
value *= 1000; /* Time measures in microseconds */
if (value < 0)
- /* gdk_beep () */;
+ {
+ char b[255];
+ sprintf (b,
+ "Error:\n\n"
+ "Unparsable time format: \"%s\"\n",
+ line);
+ warning_dialog (XtParent (button), b, 100);
+ }
else
*store = value;
}
# define SECONDS(field, name) \
v = 0; \
XtVaGetValues (name_to_widget (button, (name)), XtNvalue, &v, 0); \
- hack_time_text (v, (field), True)
+ hack_time_text (button, v, (field), True)
# define MINUTES(field, name) \
v = 0; \
XtVaGetValues (name_to_widget (button, (name)), XtNvalue, &v, 0); \
- hack_time_text (v, (field), False)
+ hack_time_text (button, v, (field), False)
# define INTEGER(field, name) do { \
unsigned int value; \
if (! *v) \
; \
else if (sscanf (v, "%u%c", &value, &c) != 1) \
- XBell(XtDisplay(button), 0); \
+ { \
+ char b[255]; \
+ sprintf (b, "Error:\n\n" "Not an integer: \"%s\"\n", v); \
+ warning_dialog (XtParent (button), b, 100); \
+ } \
else \
*(field) = value; \
} while(0)