X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Fdemo-Gtk.c;h=b2620a4f7ef12d17e8488a2a6b1afae377dea322;hb=96bdd7cf6ea60c418a76921acaf0e34d6f5be930;hp=f0ca8e4aa96a784d6d0dd6bbf49acfffd4b8b9cc;hpb=c28aecf9fc41e3a03494bacf7279745425e2fa18;p=xscreensaver diff --git a/driver/demo-Gtk.c b/driver/demo-Gtk.c index f0ca8e4a..b2620a4f 100644 --- a/driver/demo-Gtk.c +++ b/driver/demo-Gtk.c @@ -1,5 +1,5 @@ /* demo-Gtk.c --- implements the interactive demo-mode and options dialogs. - * xscreensaver, Copyright (c) 1993-2002 Jamie Zawinski + * xscreensaver, Copyright (c) 1993-2003 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -91,6 +91,13 @@ # define DEFAULT_ICONDIR GLADE_DIR #endif +#ifndef HAVE_XML + /* Kludge: this is defined in demo-Gtk-conf.c when HAVE_XML. + It is unused otherwise, so in that case, stub it out. */ + static const char *hack_configuration_path = 0; +#endif + + #include "version.h" #include "prefs.h" @@ -293,12 +300,14 @@ ensure_selected_item_visible (GtkWidget *widget) selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)); if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - return; - - path = gtk_tree_model_get_path (model, &iter); + path = gtk_tree_path_new_first (); + else + path = gtk_tree_model_get_path (model, &iter); - gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (widget), - path, NULL, FALSE, 0.0, 0.0); + gtk_tree_view_set_cursor (GTK_TREE_VIEW (widget), path, NULL, FALSE); + + gtk_tree_path_free (path); + #else /* !HAVE_GTK2 */ GtkScrolledWindow *scroller = 0; @@ -422,7 +431,8 @@ warning_dialog (GtkWidget *parent, const char *message, while (parent && !parent->window) parent = parent->parent; - if (!GTK_WIDGET (parent)->window) /* too early to pop up transient dialogs */ + if (!parent || + !GTK_WIDGET (parent)->window) /* too early to pop up transient dialogs */ { fprintf (stderr, "%s: too early for dialog?\n", progname); return; @@ -631,9 +641,9 @@ about_menu_cb (GtkMenuItem *menuitem, gpointer user_data) look as good in the plain-old default Latin1 "C" locale.) */ #ifdef HAVE_GTK2 - sprintf(copy, ("Copyright \xC2\xA9 1991-2002 %s"), s); + sprintf(copy, ("Copyright \xC2\xA9 1991-2003 %s"), s); #else /* !HAVE_GTK2 */ - sprintf(copy, ("Copyright \251 1991-2002 %s"), s); + sprintf(copy, ("Copyright \251 1991-2003 %s"), s); #endif /* !HAVE_GTK2 */ sprintf (msg, "%s\n\n%s", copy, desc); @@ -760,7 +770,6 @@ doc_menu_cb (GtkMenuItem *menuitem, gpointer user_data) sprintf (help_command + strlen(help_command), p->load_url_command, p->help_url, p->help_url); strcat (help_command, " ) &"); -fprintf(stderr, "## %s\n", help_command); system (help_command); free (help_command); } @@ -2334,6 +2343,15 @@ populate_prefs_page (state *s) { saver_preferences *p = &s->prefs; + Bool can_lock_p = True; + + /* Disable all the "lock" controls if locking support was not provided + at compile-time, or if running on MacOS. */ +# if defined(NO_LOCKING) || defined(__APPLE__) + can_lock_p = False; +# endif + + /* The file supports timeouts of less than a minute, but the GUI does not, so throttle the values to be at least one minute (since "0" is a bad rounding choice...) @@ -2433,8 +2451,9 @@ populate_prefs_page (state *s) /* Blanking and Locking */ - SENSITIZE ("lock_spinbutton", p->lock_p); - SENSITIZE ("lock_mlabel", p->lock_p); + SENSITIZE ("lock_button", can_lock_p); + SENSITIZE ("lock_spinbutton", can_lock_p && p->lock_p); + SENSITIZE ("lock_mlabel", can_lock_p && p->lock_p); /* DPMS */ @@ -2470,14 +2489,7 @@ populate_prefs_page (state *s) static void populate_popup_window (state *s) { - saver_preferences *p = &s->prefs; - GtkWidget *parent = name_to_widget (s, "settings_vbox"); GtkLabel *doc = GTK_LABEL (name_to_widget (s, "doc")); - int list_elt = selected_list_element (s); - int hack_number = (list_elt >= 0 && list_elt < s->list_count - ? s->list_elt_to_hack_number[list_elt] - : -1); - screenhack *hack = (hack_number >= 0 ? p->screenhacks[hack_number] : 0); char *doc_string = 0; /* #### not in Gtk 1.2 @@ -2491,14 +2503,24 @@ populate_popup_window (state *s) s->cdata = 0; } - if (hack) - { - GtkWidget *cmd = GTK_WIDGET (name_to_widget (s, "cmd_text")); - const char *cmd_line = gtk_entry_get_text (GTK_ENTRY (cmd)); - s->cdata = load_configurator (cmd_line, s->debug_p); - if (s->cdata && s->cdata->widget) - gtk_box_pack_start (GTK_BOX (parent), s->cdata->widget, TRUE, TRUE, 0); - } + { + saver_preferences *p = &s->prefs; + int list_elt = selected_list_element (s); + int hack_number = (list_elt >= 0 && list_elt < s->list_count + ? s->list_elt_to_hack_number[list_elt] + : -1); + screenhack *hack = (hack_number >= 0 ? p->screenhacks[hack_number] : 0); + if (hack) + { + GtkWidget *parent = name_to_widget (s, "settings_vbox"); + GtkWidget *cmd = GTK_WIDGET (name_to_widget (s, "cmd_text")); + const char *cmd_line = gtk_entry_get_text (GTK_ENTRY (cmd)); + s->cdata = load_configurator (cmd_line, s->debug_p); + if (s->cdata && s->cdata->widget) + gtk_box_pack_start (GTK_BOX (parent), s->cdata->widget, + TRUE, TRUE, 0); + } + } doc_string = (s->cdata ? s->cdata->description @@ -3238,7 +3260,14 @@ get_best_gl_visual (state *s) sprintf (buf, "%s: running %s", blurb(), av[0]); perror (buf); } - exit (1); /* exits fork */ + + /* Note that one must use _exit() instead of exit() in procs forked + off of Gtk programs -- Gtk installs an atexit handler that has a + copy of the X connection (which we've already closed, for safety.) + If one uses exit() instead of _exit(), then one sometimes gets a + spurious "Gdk-ERROR: Fatal IO error on X server" error message. + */ + _exit (1); /* exits fork */ break; } default: @@ -3404,8 +3433,15 @@ launch_preview_subproc (state *s) exec_command (p->shell, new_cmd, p->nice_inferior); /* Don't bother printing an error message when we are unable to - exec subprocesses; we handle that by polling the pid later. */ - exit (1); /* exits child fork */ + exec subprocesses; we handle that by polling the pid later. + + Note that one must use _exit() instead of exit() in procs forked + off of Gtk programs -- Gtk installs an atexit handler that has a + copy of the X connection (which we've already closed, for safety.) + If one uses exit() instead of _exit(), then one sometimes gets a + spurious "Gdk-ERROR: Fatal IO error on X server" error message. + */ + _exit (1); /* exits child fork */ break; default: