X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=driver%2Fdemo-Gtk.c;h=298860a7e130a07dfb0cd4f4c0a9cd5435e8b27c;hp=3a3f2d6f1c2a0aec019ca8276744511d46a8b4d7;hb=ffd8c0873576a9e3065696a624dce6b766b77062;hpb=723c9eeee862766a1534b2ce17b78adbfac1c3be diff --git a/driver/demo-Gtk.c b/driver/demo-Gtk.c index 3a3f2d6f..298860a7 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-2004 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 @@ -24,6 +24,13 @@ # include #endif +# ifdef __GNUC__ +# define STFU __extension__ /* ignore gcc -pendantic warnings in next sexp */ +# else +# define STFU /* */ +# endif + + #ifdef ENABLE_NLS # include #endif /* ENABLE_NLS */ @@ -91,6 +98,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" @@ -102,6 +116,9 @@ #include "logo-50.xpm" #include "logo-180.xpm" +#undef dgettext /* else these are defined twice... */ +#undef dcgettext + #include "demo-Gtk-widgets.h" #include "demo-Gtk-support.h" #include "demo-Gtk-conf.h" @@ -121,6 +138,8 @@ enum { /* from exec.c */ extern void exec_command (const char *shell, const char *command, int nice); +static void hack_subproc_environment (Window preview_window_id, Bool debug_p); + #undef countof #define countof(x) (sizeof((x))/sizeof((*x))) @@ -163,6 +182,10 @@ typedef struct { int *list_elt_to_hack_number; /* table for sorting the hack list */ int *hack_number_to_list_elt; /* the inverse table */ + Bool *hacks_available_p; /* whether hacks are on $PATH */ + int list_count; /* how many items are in the list: this may be + less than p->screenhacks_count, if some are + suppressed. */ int _selected_list_element; /* don't use this: call selected_list_element() instead */ @@ -193,7 +216,7 @@ static int maybe_reload_init_file (state *); static void await_xscreensaver (state *); static void schedule_preview (state *, const char *cmd); -static void kill_preview_subproc (state *); +static void kill_preview_subproc (state *, Bool reset_p); static void schedule_preview_check (state *); @@ -229,16 +252,32 @@ name_to_widget (state *s, const char *name) #ifdef HAVE_GTK2 if (!s->glade_ui) { - s->glade_ui = glade_xml_new (GLADE_DIR "/xscreensaver-demo.glade2", - NULL, NULL); + /* First try to load the Glade file from the current directory; + if there isn't one there, check the installed directory. + */ +# define GLADE_FILE_NAME "xscreensaver-demo.glade2" + const char * const files[] = { GLADE_FILE_NAME, + GLADE_DIR "/" GLADE_FILE_NAME }; + int i; + for (i = 0; i < countof (files); i++) + { + struct stat st; + if (!stat (files[i], &st)) + { + s->glade_ui = glade_xml_new (files[i], NULL, NULL); + break; + } + } if (!s->glade_ui) { fprintf (stderr, - "%s: could not load glade file" - " \"%s/xscreensaver-demo.glade2\"\n", - blurb(), GLADE_DIR); + "%s: could not load \"" GLADE_FILE_NAME "\"\n" + "\tfrom " GLADE_DIR "/ or current directory.\n", + blurb()); exit (-1); } +# undef GLADE_FILE_NAME + glade_xml_signal_autoconnect (s->glade_ui); } @@ -273,12 +312,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; @@ -402,7 +443,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; @@ -485,13 +527,13 @@ warning_dialog (GtkWidget *parent, const char *message, gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); gtk_container_set_border_width (GTK_CONTAINER (dialog), 10); gtk_window_set_title (GTK_WINDOW (dialog), progclass); - GTK_WIDGET_SET_FLAGS (ok, GTK_CAN_DEFAULT); + STFU GTK_WIDGET_SET_FLAGS (ok, GTK_CAN_DEFAULT); gtk_widget_show (ok); gtk_widget_grab_focus (ok); if (cancel) { - GTK_WIDGET_SET_FLAGS (cancel, GTK_CAN_DEFAULT); + STFU GTK_WIDGET_SET_FLAGS (cancel, GTK_CAN_DEFAULT); gtk_widget_show (cancel); } gtk_widget_show (label); @@ -535,6 +577,11 @@ run_cmd (state *s, Atom command, int arg) flush_dialog_changes_and_save (s); status = xscreensaver_command (GDK_DISPLAY(), command, arg, False, &err); + + /* Kludge: ignore the spurious "window unexpectedly deleted" errors... */ + if (status < 0 && err && strstr (err, "unexpectedly deleted")) + status = 0; + if (status < 0) { char buf [255]; @@ -578,16 +625,17 @@ exit_menu_cb (GtkMenuItem *menuitem, gpointer user_data) { state *s = global_state_kludge; /* I hate C so much... */ flush_dialog_changes_and_save (s); - kill_preview_subproc (s); + kill_preview_subproc (s, False); gtk_main_quit (); } -static void +static gboolean wm_toplevel_close_cb (GtkWidget *widget, GdkEvent *event, gpointer data) { state *s = (state *) data; flush_dialog_changes_and_save (s); gtk_main_quit (); + return TRUE; } @@ -604,10 +652,15 @@ about_menu_cb (GtkMenuItem *menuitem, gpointer user_data) *s = 0; s += 2; + /* Ole Laursen says "don't use _() here because + non-ASCII characters aren't allowed in localizable string keys." + (I don't want to just use (c) instead of © because that doesn't + 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-2004 %s"), s); #else /* !HAVE_GTK2 */ - sprintf(copy, _("Copyright \251 1991-2002 %s"), s); + sprintf(copy, ("Copyright \251 1991-2004 %s"), s); #endif /* !HAVE_GTK2 */ sprintf (msg, "%s\n\n%s", copy, desc); @@ -814,6 +867,12 @@ await_xscreensaver (state *s) "\n")); if (root_p) + +# ifdef __GNUC__ + __extension__ /* don't warn about "string length is greater than + the length ISO C89 compilers are required to + support" in the following expression... */ +# endif 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" @@ -896,7 +955,7 @@ manual_cb (GtkButton *button, gpointer user_data) { state *s = global_state_kludge; /* I hate C so much... */ saver_preferences *p = &s->prefs; - GtkList *list_widget = GTK_LIST (name_to_widget (s, "list")); + GtkWidget *list_widget = name_to_widget (s, "list"); int list_elt = selected_list_element (s); int hack_number; char *name, *name2, *cmd, *str; @@ -904,7 +963,7 @@ manual_cb (GtkButton *button, gpointer user_data) hack_number = s->list_elt_to_hack_number[list_elt]; flush_dialog_changes_and_save (s); - ensure_selected_item_visible (GTK_WIDGET (list_widget)); + ensure_selected_item_visible (list_widget); name = strdup (p->screenhacks[hack_number]->command); name2 = name; @@ -952,7 +1011,7 @@ force_list_select_item (state *s, GtkWidget *list, int list_elt, Bool scroll_p) if (!was) gtk_widget_set_sensitive (parent, True); #ifdef HAVE_GTK2 model = gtk_tree_view_get_model (GTK_TREE_VIEW (list)); - g_assert (model); + STFU g_assert (model); gtk_tree_model_iter_nth_child (model, &iter, NULL, list_elt); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list)); gtk_tree_selection_select_iter (selection, &iter); @@ -968,7 +1027,7 @@ void run_next_cb (GtkButton *button, gpointer user_data) { state *s = global_state_kludge; /* I hate C so much... */ - saver_preferences *p = &s->prefs; + /* saver_preferences *p = &s->prefs; */ Bool ops = s->preview_suppressed_p; GtkWidget *list_widget = name_to_widget (s, "list"); @@ -979,7 +1038,7 @@ run_next_cb (GtkButton *button, gpointer user_data) else list_elt++; - if (list_elt >= p->screenhacks_count) + if (list_elt >= s->list_count) list_elt = 0; s->preview_suppressed_p = True; @@ -997,19 +1056,19 @@ void run_prev_cb (GtkButton *button, gpointer user_data) { state *s = global_state_kludge; /* I hate C so much... */ - saver_preferences *p = &s->prefs; + /* saver_preferences *p = &s->prefs; */ Bool ops = s->preview_suppressed_p; GtkWidget *list_widget = name_to_widget (s, "list"); int list_elt = selected_list_element (s); if (list_elt < 0) - list_elt = p->screenhacks_count - 1; + list_elt = s->list_count - 1; else list_elt--; if (list_elt < 0) - list_elt = p->screenhacks_count - 1; + list_elt = s->list_count - 1; s->preview_suppressed_p = True; @@ -1037,7 +1096,7 @@ flush_changes (state *s, Bool changed = False; screenhack *hack; int hack_number; - if (list_elt < 0 || list_elt >= p->screenhacks_count) + if (list_elt < 0 || list_elt >= s->list_count) abort(); hack_number = s->list_elt_to_hack_number[list_elt]; @@ -1100,7 +1159,7 @@ hack_time_text (state *s, const char *line, Time *store, Bool sec_p) else { char c; - if (sscanf (line, "%u%c", &value, &c) != 1) + if (sscanf (line, "%d%c", &value, &c) != 1) value = -1; if (!sec_p) value *= 60; @@ -1141,8 +1200,8 @@ normalize_directory (const char *path) { int L; char *p2, *s; - if (!path) return 0; - L = strlen (path);; + if (!path || !*path) return 0; + L = strlen (path); p2 = (char *) malloc (L + 2); strcpy (p2, path); if (p2[L-1] == '/') /* remove trailing slash */ @@ -1352,7 +1411,7 @@ flush_dialog_changes_and_save (state *s) if (p->field != p2->field) { \ changed = True; \ if (s->debug_p) \ - fprintf (stderr, "%s: %s => %d\n", blurb(), name, p2->field); \ + fprintf (stderr, "%s: %s => %d\n", blurb(), name, (int) p2->field); \ } \ p->field = p2->field @@ -1470,7 +1529,7 @@ flush_popup_changes_and_save (state *s) else if (!strcasecmp (visual, "greyscale")) visual = "GrayScale"; else if (!strcasecmp (visual, "pseudocolor")) visual = "PseudoColor"; else if (!strcasecmp (visual, "directcolor")) visual = "DirectColor"; - else if (1 == sscanf (visual, " %ld %c", &id, &c)) ; + else if (1 == sscanf (visual, " %lu %c", &id, &c)) ; else if (1 == sscanf (visual, " 0x%lx %c", &id, &c)) ; else { @@ -1527,7 +1586,6 @@ mode_menu_item_cb (GtkWidget *widget, gpointer user_data) GList *menu_items = gtk_container_children (GTK_CONTAINER (widget->parent)); int menu_index = 0; saver_mode new_mode; - int old_selected = p->selected_hack; while (menu_items) { @@ -1541,17 +1599,12 @@ mode_menu_item_cb (GtkWidget *widget, gpointer user_data) new_mode = mode_menu_order[menu_index]; /* Keep the same list element displayed as before; except if we're - switching *to* "one screensaver" mode from any other mode, scroll - to and select "the one". + switching *to* "one screensaver" mode from any other mode, set + "the one" to be that which is currently selected. */ - list_elt = -1; + list_elt = selected_list_element (s); if (new_mode == ONE_HACK) - list_elt = (p->selected_hack >= 0 - ? s->hack_number_to_list_elt[p->selected_hack] - : -1); - - if (list_elt < 0) - list_elt = selected_list_element (s); + p->selected_hack = s->list_elt_to_hack_number[list_elt]; { saver_mode old_mode = p->mode; @@ -1562,9 +1615,6 @@ mode_menu_item_cb (GtkWidget *widget, gpointer user_data) } pref_changed_cb (widget, user_data); - - if (old_selected != p->selected_hack) - abort(); /* dammit, not again... */ } @@ -1594,7 +1644,7 @@ list_activated_cb (GtkTreeView *list, char *str; int list_elt; - g_return_if_fail (!gdk_pointer_is_grabbed ()); + STFU g_return_if_fail (!gdk_pointer_is_grabbed ()); str = gtk_tree_path_to_string (path); list_elt = strtol (str, NULL, 10); @@ -1942,11 +1992,12 @@ settings_ok_cb (GtkButton *button, gpointer user_data) gtk_widget_hide (s->popup_widget); } -static void +static gboolean wm_popup_close_cb (GtkWidget *widget, GdkEvent *event, gpointer data) { state *s = (state *) data; settings_cancel_cb (0, (gpointer) s); + return TRUE; } @@ -1963,7 +2014,7 @@ server_current_hack (void) Atom type; int format; unsigned long nitems, bytesafter; - CARD32 *data = 0; + unsigned char *dataP = 0; Display *dpy = GDK_DISPLAY(); int hack_number = -1; @@ -1971,14 +2022,17 @@ server_current_hack (void) XA_SCREENSAVER_STATUS, 0, 3, False, XA_INTEGER, &type, &format, &nitems, &bytesafter, - (unsigned char **) &data) + &dataP) == Success && type == XA_INTEGER && nitems >= 3 - && data) - hack_number = (int) data[2] - 1; + && dataP) + { + CARD32 *data = (CARD32 *) dataP; + hack_number = (int) data[2] - 1; + } - if (data) free (data); + if (dataP) XFree (dataP); return hack_number; } @@ -2008,6 +2062,52 @@ scroll_to_current_hack (state *s) } +static Bool +on_path_p (const char *program) +{ + int result = False; + struct stat st; + char *cmd = strdup (program); + char *token = strchr (cmd, ' '); + char *path = 0; + int L; + + if (token) *token = 0; + token = 0; + + if (strchr (cmd, '/')) + { + result = (0 == stat (cmd, &st)); + goto DONE; + } + + path = getenv("PATH"); + if (!path || !*path) + goto DONE; + + L = strlen (cmd); + path = strdup (path); + token = strtok (path, ":"); + + while (token) + { + char *p2 = (char *) malloc (strlen (token) + L + 3); + strcpy (p2, token); + strcat (p2, "/"); + strcat (p2, cmd); + result = (0 == stat (p2, &st)); + if (result) + goto DONE; + token = strtok (0, ":"); + } + + DONE: + free (cmd); + if (path) free (path); + return result; +} + + static void populate_hack_list (state *s) { @@ -2042,7 +2142,7 @@ populate_hack_list (state *s) ren = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (list, COL_NAME, _("Screen Saver"), ren, - "text", COL_NAME, + "markup", COL_NAME, NULL); g_signal_connect_after (list, "row_activated", @@ -2056,20 +2156,49 @@ populate_hack_list (state *s) } - for (i = 0; i < p->screenhacks_count; i++) + for (i = 0; i < s->list_count; i++) { - screenhack *hack = p->screenhacks[s->list_elt_to_hack_number[i]]; + int hack_number = s->list_elt_to_hack_number[i]; + screenhack *hack = (hack_number < 0 ? 0 : p->screenhacks[hack_number]); + char *pretty_name; + Bool available_p = (hack && s->hacks_available_p [hack_number]); + + if (!hack) continue; + + /* If we're to suppress uninstalled hacks, check $PATH now. */ + if (p->ignore_uninstalled_p && !available_p) + continue; - char *pretty_name = (hack->name - ? strdup (hack->name) - : make_hack_name (hack->command)); + pretty_name = (hack->name + ? strdup (hack->name) + : make_hack_name (hack->command)); + + if (!available_p) + { + /* Make the text foreground be the color of insensitive widgets + (but don't actually make it be insensitive, since we still + want to be able to click on it.) + */ + GtkStyle *style = GTK_WIDGET (list)->style; + GdkColor *fg = &style->fg[GTK_STATE_INSENSITIVE]; + /* GdkColor *bg = &style->bg[GTK_STATE_INSENSITIVE]; */ + char *buf = (char *) malloc (strlen (pretty_name) + 100); + + sprintf (buf, "%s", + fg->red >> 8, fg->green >> 8, fg->blue >> 8, + /* bg->red >> 8, bg->green >> 8, bg->blue >> 8, */ + pretty_name); + free (pretty_name); + pretty_name = buf; + } gtk_list_store_append (model, &iter); gtk_list_store_set (model, &iter, COL_ENABLED, hack->enabled_p, COL_NAME, pretty_name, -1); - free (pretty_name); } @@ -2078,9 +2207,10 @@ populate_hack_list (state *s) saver_preferences *p = &s->prefs; GtkList *list = GTK_LIST (name_to_widget (s, "list")); int i; - for (i = 0; i < p->screenhacks_count; i++) + for (i = 0; i < s->list_count; i++) { - screenhack *hack = p->screenhacks[s->list_elt_to_hack_number[i]]; + int hack_number = s->list_elt_to_hack_number[i]; + screenhack *hack = (hack_number < 0 ? 0 : p->screenhacks[hack_number]); /* A GtkList must contain only GtkListItems, but those can contain an arbitrary widget. We add an Hbox, and inside that, a Checkbox @@ -2092,10 +2222,18 @@ populate_hack_list (state *s) GtkWidget *line_hbox; GtkWidget *line_check; GtkWidget *line_label; + char *pretty_name; + Bool available_p = (hack && s->hacks_available_p [hack_number]); + + if (!hack) continue; + + /* If we're to suppress uninstalled hacks, check $PATH now. */ + if (p->ignore_uninstalled_p && !available_p) + continue; - char *pretty_name = (hack->name - ? strdup (hack->name) - : make_hack_name (hack->command)); + pretty_name = (hack->name + ? strdup (hack->name) + : make_hack_name (hack->command)); line = gtk_list_item_new (); line_hbox = gtk_hbox_new (FALSE, 0); @@ -2126,11 +2264,30 @@ populate_hack_list (state *s) GTK_SIGNAL_FUNC (list_checkbox_cb), (gpointer) s); -#if 0 /* #### */ - GTK_WIDGET (GTK_BIN(line)->child)->style = - gtk_style_copy (GTK_WIDGET (text_line)->style); -#endif gtk_widget_show (line); + + if (!available_p) + { + /* Make the widget be colored like insensitive widgets + (but don't actually make it be insensitive, since we + still want to be able to click on it.) + */ + GtkRcStyle *rc_style; + GdkColor fg, bg; + + gtk_widget_realize (GTK_WIDGET (line_label)); + + fg = GTK_WIDGET (line_label)->style->fg[GTK_STATE_INSENSITIVE]; + bg = GTK_WIDGET (line_label)->style->bg[GTK_STATE_INSENSITIVE]; + + rc_style = gtk_rc_style_new (); + rc_style->fg[GTK_STATE_NORMAL] = fg; + rc_style->bg[GTK_STATE_NORMAL] = bg; + rc_style->color_flags[GTK_STATE_NORMAL] |= GTK_RC_FG|GTK_RC_BG; + + gtk_widget_modify_style (GTK_WIDGET (line_label), rc_style); + gtk_rc_style_unref (rc_style); + } } gtk_signal_connect (GTK_OBJECT (list), "select_child", @@ -2203,6 +2360,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...) @@ -2210,7 +2376,7 @@ populate_prefs_page (state *s) # define THROTTLE(NAME) if (p->NAME != 0 && p->NAME < 60000) p->NAME = 60000 THROTTLE (timeout); THROTTLE (cycle); - THROTTLE (passwd_timeout); + /* THROTTLE (passwd_timeout); */ /* GUI doesn't set this; leave it alone */ # undef THROTTLE # define FMT_MINUTES(NAME,N) \ @@ -2302,8 +2468,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 */ @@ -2339,14 +2506,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 < p->screenhacks_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 @@ -2360,14 +2520,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 @@ -2409,7 +2579,9 @@ sensitize_demo_widgets (state *s, Bool sensitive_p) static void fix_text_entry_sizes (state *s) { -#ifdef FIXME + GtkWidget *w; + +# if 0 /* appears no longer necessary with Gtk 1.2.10 */ const char * const spinbuttons[] = { "timeout_spinbutton", "cycle_spinbutton", "lock_spinbutton", "dpms_standby_spinbutton", "dpms_suspend_spinbutton", @@ -2417,7 +2589,6 @@ fix_text_entry_sizes (state *s) "-fade_spinbutton" }; int i; int width = 0; - GtkWidget *w; for (i = 0; i < countof(spinbuttons); i++) { @@ -2448,22 +2619,35 @@ fix_text_entry_sizes (state *s) width = gdk_string_width (w->style->font, "mmmmmmmmmmmmmmmmmmmm"); gtk_widget_set_usize (w, width, -2); - /* Now fix the height of the list. +# endif /* 0 */ + + /* Now fix the height of the list widget: + make it default to being around 10 text-lines high instead of 4. */ + w = GTK_WIDGET (name_to_widget (s, "list")); { int lines = 10; int height; int leading = 3; /* approximate is ok... */ int border = 2; - w = GTK_WIDGET (name_to_widget (s, "list")); + +#ifdef HAVE_GTK2 + PangoFontMetrics *pain = + pango_context_get_metrics (gtk_widget_get_pango_context (w), + w->style->font_desc, + gtk_get_default_language ()); + height = PANGO_PIXELS (pango_font_metrics_get_ascent (pain) + + pango_font_metrics_get_descent (pain)); +#else /* !HAVE_GTK2 */ height = w->style->font->ascent + w->style->font->descent; +#endif /* !HAVE_GTK2 */ + height += leading; height *= lines; height += border * 2; w = GTK_WIDGET (name_to_widget (s, "scroller")); gtk_widget_set_usize (w, -2, height); } -#endif } @@ -2640,7 +2824,7 @@ populate_demo_window (state *s, int list_elt) } else { - int hack_number = (list_elt >= 0 && list_elt < p->screenhacks_count + int hack_number = (list_elt >= 0 && list_elt < s->list_count ? s->list_elt_to_hack_number[list_elt] : -1); hack = (hack_number >= 0 ? p->screenhacks[hack_number] : 0); @@ -2660,15 +2844,15 @@ populate_demo_window (state *s, int list_elt) if (!pretty_name) pretty_name = strdup (_("Preview")); - gtk_frame_set_label (frame1, pretty_name); - gtk_frame_set_label (frame2, pretty_name); + gtk_frame_set_label (frame1, _(pretty_name)); + gtk_frame_set_label (frame2, _(pretty_name)); gtk_entry_set_text (cmd, (hack ? hack->command : "")); gtk_entry_set_position (cmd, 0); { char title[255]; - sprintf (title, "%s: %.100s Settings", + sprintf (title, _("%s: %.100s Settings"), progclass, (pretty_name ? pretty_name : "???")); gtk_window_set_title (GTK_WINDOW (s->popup_widget), title); } @@ -2716,8 +2900,13 @@ sort_hack_cmp (const void *a, const void *b) if (a == b) return 0; else - return strcmp (sort_hack_cmp_names_kludge[*(int *) a], - sort_hack_cmp_names_kludge[*(int *) b]); + { + int aa = *(int *) a; + int bb = *(int *) b; + const char last[] = "\377\377\377\377\377\377\377\377\377\377\377"; + return strcmp ((aa < 0 ? last : sort_hack_cmp_names_kludge[aa]), + (bb < 0 ? last : sort_hack_cmp_names_kludge[bb])); + } } @@ -2725,21 +2914,44 @@ static void initialize_sort_map (state *s) { saver_preferences *p = &s->prefs; - int i; + int i, j; if (s->list_elt_to_hack_number) free (s->list_elt_to_hack_number); if (s->hack_number_to_list_elt) free (s->hack_number_to_list_elt); + if (s->hacks_available_p) free (s->hacks_available_p); s->list_elt_to_hack_number = (int *) calloc (sizeof(int), p->screenhacks_count + 1); s->hack_number_to_list_elt = (int *) calloc (sizeof(int), p->screenhacks_count + 1); + s->hacks_available_p = (Bool *) + calloc (sizeof(Bool), p->screenhacks_count + 1); - /* Initialize table to 1:1 mapping */ + /* Check which hacks actually exist on $PATH + */ for (i = 0; i < p->screenhacks_count; i++) - s->list_elt_to_hack_number[i] = i; + { + screenhack *hack = p->screenhacks[i]; + s->hacks_available_p[i] = on_path_p (hack->command); + } + + /* Initialize list->hack table to unsorted mapping, omitting nonexistent + hacks, if desired. + */ + j = 0; + for (i = 0; i < p->screenhacks_count; i++) + { + if (!p->ignore_uninstalled_p || + s->hacks_available_p[i]) + s->list_elt_to_hack_number[j++] = i; + } + s->list_count = j; + + for (; j < p->screenhacks_count; j++) + s->list_elt_to_hack_number[j] = -1; + - /* Generate list of names (once) + /* Generate list of sortable names (once) */ sort_hack_cmp_names_kludge = (char **) calloc (sizeof(char *), p->screenhacks_count); @@ -2755,7 +2967,7 @@ initialize_sort_map (state *s) sort_hack_cmp_names_kludge[i] = name; } - /* Sort alphabetically + /* Sort list->hack map alphabetically */ qsort (s->list_elt_to_hack_number, p->screenhacks_count, @@ -2860,41 +3072,78 @@ clear_preview_window (state *s) gdk_window_set_background (window, &p->style->bg[GTK_STATE_NORMAL]); gdk_window_clear (window); -#ifdef HAVE_GTK2 { - GtkWidget *notebook; - - notebook = name_to_widget (s, "preview_notebook"); + int list_elt = selected_list_element (s); + int hack_number = (list_elt >= 0 + ? s->list_elt_to_hack_number[list_elt] + : -1); + Bool available_p = (hack_number >= 0 + ? s->hacks_available_p [hack_number] + : True); +#ifdef HAVE_GTK2 + GtkWidget *notebook = name_to_widget (s, "preview_notebook"); gtk_notebook_set_page (GTK_NOTEBOOK (notebook), - s->running_preview_error_p - ? 1 : 0); - } + (s->running_preview_error_p + ? (available_p ? 1 : 2) + : 0)); #else /* !HAVE_GTK2 */ - if (s->running_preview_error_p) - { - const char * const lines[] = { N_("No Preview"), N_("Available") }; - int lh = p->style->font->ascent + p->style->font->descent; - int y, i; - gint w, h; - gdk_window_get_size (window, &w, &h); - y = (h - (lh * countof(lines))) / 2; - y += p->style->font->ascent; - for (i = 0; i < countof(lines); i++) - { - int sw = gdk_string_width (p->style->font, _(lines[i])); - int x = (w - sw) / 2; - gdk_draw_string (window, p->style->font, - p->style->fg_gc[GTK_STATE_NORMAL], - x, y, _(lines[i])); - y += lh; - } - } + if (s->running_preview_error_p) + { + const char * const lines1[] = { N_("No Preview"), N_("Available") }; + const char * const lines2[] = { N_("Not"), N_("Installed") }; + int nlines = countof(lines1); + int lh = p->style->font->ascent + p->style->font->descent; + int y, i; + gint w, h; + + const char * const *lines = (available_p ? lines1 : lines2); + + gdk_window_get_size (window, &w, &h); + y = (h - (lh * nlines)) / 2; + y += p->style->font->ascent; + for (i = 0; i < nlines; i++) + { + int sw = gdk_string_width (p->style->font, _(lines[i])); + int x = (w - sw) / 2; + gdk_draw_string (window, p->style->font, + p->style->fg_gc[GTK_STATE_NORMAL], + x, y, _(lines[i])); + y += lh; + } + } #endif /* !HAVE_GTK2 */ + } gdk_flush (); } +static void +reset_preview_window (state *s) +{ + /* On some systems (most recently, MacOS X) OpenGL programs get confused + when you kill one and re-start another on the same window. So maybe + it's best to just always destroy and recreate the preview window + when changing hacks, instead of always trying to reuse the same one? + */ + GtkWidget *pr = name_to_widget (s, "preview"); + if (GTK_WIDGET_REALIZED (pr)) + { + Window oid = (pr->window ? GDK_WINDOW_XWINDOW (pr->window) : 0); + Window id; + gtk_widget_hide (pr); + gtk_widget_unrealize (pr); + gtk_widget_realize (pr); + gtk_widget_show (pr); + id = (pr->window ? GDK_WINDOW_XWINDOW (pr->window) : 0); + if (s->debug_p) + fprintf (stderr, "%s: window id 0x%X -> 0x%X\n", blurb(), + (unsigned int) oid, + (unsigned int) id); + } +} + + static void fix_preview_visual (state *s) { @@ -2938,6 +3187,11 @@ fix_preview_visual (state *s) style->fg_gc[GTK_STATE_NORMAL] = fgc; style->bg_gc[GTK_STATE_NORMAL] = fgc; gtk_widget_set_style (widget, style); + + /* For debugging purposes, put a title on the window (so that + it can be easily found in the output of "xwininfo -tree".) + */ + gdk_window_set_title (window, "Preview"); } gtk_widget_show (widget); @@ -2956,8 +3210,13 @@ subproc_pretty_name (state *s) char *ss = strchr (ps, ' '); if (ss) *ss = 0; ss = strrchr (ps, '/'); - if (ss) *ss = 0; - else ss = ps; + if (!ss) + ss = ps; + else + { + ss = strdup (ss+1); + free (ps); + } return ss; } else @@ -2977,11 +3236,13 @@ reap_zombies (state *s) if (pid == s->running_preview_pid) { char *ss = subproc_pretty_name (s); - fprintf (stderr, "%s: pid %lu (%s) died\n", blurb(), pid, ss); + fprintf (stderr, "%s: pid %lu (%s) died\n", blurb(), + (unsigned long) pid, ss); free (ss); } else - fprintf (stderr, "%s: pid %lu died\n", blurb(), pid); + fprintf (stderr, "%s: pid %lu died\n", blurb(), + (unsigned long) pid); } } } @@ -3042,7 +3303,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: @@ -3051,7 +3319,7 @@ get_best_gl_visual (state *s) int wait_status = 0; FILE *f = fdopen (in, "r"); - unsigned long v = 0; + unsigned int v = 0; char c; close (out); /* don't need this one */ @@ -3090,7 +3358,7 @@ get_best_gl_visual (state *s) static void -kill_preview_subproc (state *s) +kill_preview_subproc (state *s, Bool reset_p) { s->running_preview_error_p = False; @@ -3115,19 +3383,19 @@ kill_preview_subproc (state *s) { if (s->debug_p) fprintf (stderr, "%s: pid %lu (%s) was already dead.\n", - blurb(), s->running_preview_pid, ss); + blurb(), (unsigned long) s->running_preview_pid, ss); } else { char buf [1024]; sprintf (buf, "%s: couldn't kill pid %lu (%s)", - blurb(), s->running_preview_pid, ss); + blurb(), (unsigned long) s->running_preview_pid, ss); perror (buf); } } else if (s->debug_p) fprintf (stderr, "%s: killed pid %lu (%s)\n", blurb(), - s->running_preview_pid, ss); + (unsigned long) s->running_preview_pid, ss); free (ss); s->running_preview_pid = 0; @@ -3136,6 +3404,12 @@ kill_preview_subproc (state *s) } reap_zombies (s); + + if (reset_p) + { + reset_preview_window (s); + clear_preview_window (s); + } } @@ -3152,13 +3426,17 @@ launch_preview_subproc (state *s) const char *cmd = s->desired_preview_cmd; GtkWidget *pr = name_to_widget (s, "preview"); - GdkWindow *window = pr->window; + GdkWindow *window; + + reset_preview_window (s); + + window = pr->window; s->running_preview_error_p = False; if (s->preview_suppressed_p) { - kill_preview_subproc (s); + kill_preview_subproc (s, False); goto DONE; } @@ -3174,10 +3452,11 @@ launch_preview_subproc (state *s) else { strcpy (new_cmd, cmd); - sprintf (new_cmd + strlen (new_cmd), " -window-id 0x%X", id); + sprintf (new_cmd + strlen (new_cmd), " -window-id 0x%X", + (unsigned int) id); } - kill_preview_subproc (s); + kill_preview_subproc (s, False); if (! new_cmd) { s->running_preview_error_p = True; @@ -3200,6 +3479,8 @@ launch_preview_subproc (state *s) { close (ConnectionNumber (GDK_DISPLAY())); + hack_subproc_environment (id, s->debug_p); + usleep (250000); /* pause for 1/4th second before launching, to give the previous program time to die and flush its X buffer, so we don't get leftover turds on the @@ -3207,8 +3488,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: @@ -3220,7 +3508,8 @@ launch_preview_subproc (state *s) if (s->debug_p) { char *ss = subproc_pretty_name (s); - fprintf (stderr, "%s: forked %lu (%s)\n", blurb(), forked, ss); + fprintf (stderr, "%s: forked %lu (%s)\n", blurb(), + (unsigned long) forked, ss); free (ss); } break; @@ -3282,6 +3571,29 @@ hack_environment (state *s) } +static void +hack_subproc_environment (Window preview_window_id, Bool debug_p) +{ + /* Store a window ID in $XSCREENSAVER_WINDOW -- this isn't strictly + necessary yet, but it will make programs work if we had invoked + them with "-root" and not with "-window-id" -- which, of course, + doesn't happen. + */ + char *nssw = (char *) malloc (40); + sprintf (nssw, "XSCREENSAVER_WINDOW=0x%X", (unsigned int) preview_window_id); + + /* Allegedly, BSD 4.3 didn't have putenv(), but nobody runs such systems + any more, right? It's not Posix, but everyone seems to have it. */ + if (putenv (nssw)) + abort (); + + if (debug_p) + fprintf (stderr, "%s: %s\n", blurb(), nssw); + + /* do not free(nssw) -- see above */ +} + + /* Called from a timer: Launches the currently-chosen subprocess, if it's not already running. If there's a different process running, kills it. @@ -3291,7 +3603,7 @@ update_subproc_timer (gpointer data) { state *s = (state *) data; if (! s->desired_preview_cmd) - kill_preview_subproc (s); + kill_preview_subproc (s, True); else if (!s->running_preview_cmd || !!strcmp (s->desired_preview_cmd, s->running_preview_cmd)) launch_preview_subproc (s); @@ -3354,7 +3666,7 @@ check_subproc_timer (gpointer data) { char *ss = subproc_pretty_name (s); fprintf (stderr, "%s: timer: pid %lu (%s) is %s\n", blurb(), - s->running_preview_pid, ss, + (unsigned long) s->running_preview_pid, ss, (s->running_preview_error_p ? "dead" : "alive")); free (ss); } @@ -3414,7 +3726,7 @@ screen_blanked_p (void) Atom type; int format; unsigned long nitems, bytesafter; - CARD32 *data = 0; + unsigned char *dataP = 0; Display *dpy = GDK_DISPLAY(); Bool blanked_p = False; @@ -3422,14 +3734,17 @@ screen_blanked_p (void) XA_SCREENSAVER_STATUS, 0, 3, False, XA_INTEGER, &type, &format, &nitems, &bytesafter, - (unsigned char **) &data) + &dataP) == Success && type == XA_INTEGER && nitems >= 3 - && data) - blanked_p = (data[0] == XA_BLANK || data[0] == XA_LOCK); + && dataP) + { + Atom *data = (Atom *) dataP; + blanked_p = (data[0] == XA_BLANK || data[0] == XA_LOCK); + } - if (data) free (data); + if (dataP) XFree (dataP); return blanked_p; } @@ -3447,7 +3762,7 @@ check_blanked_timer (gpointer data) { if (s->debug_p) fprintf (stderr, "%s: screen is blanked: killing preview\n", blurb()); - kill_preview_subproc (s); + kill_preview_subproc (s, True); } return True; /* re-execute timer */ @@ -3563,11 +3878,11 @@ the_network_is_not_the_computer (state *s) "xscreensaver as \"%s\".\n" "\n" "Restart the xscreensaver daemon now?\n"), - blurb(), luser, lhost, + progname, luser, lhost, d, (ruser ? ruser : "???"), (rhost ? rhost : "???"), - blurb(), - blurb(), (ruser ? ruser : "???"), + progname, + progname, (ruser ? ruser : "???"), luser); } else if (rhost && *rhost && !!strcmp (rhost, lhost)) @@ -3585,11 +3900,11 @@ the_network_is_not_the_computer (state *s) "%s won't work right.\n" "\n" "Restart the daemon on \"%s\" as \"%s\" now?\n"), - blurb(), luser, lhost, + progname, luser, lhost, d, (ruser ? ruser : "???"), (rhost ? rhost : "???"), luser, - blurb(), + progname, lhost, luser); } else if (!!strcmp (rversion, s->short_version)) @@ -3628,7 +3943,7 @@ demo_ehandler (Display *dpy, XErrorEvent *error) state *s = global_state_kludge; /* I hate C so much... */ fprintf (stderr, "\nX error in %s:\n", blurb()); XmuPrintDefaultErrorMessage (dpy, error, stderr); - kill_preview_subproc (s); + kill_preview_subproc (s, False); exit (-1); return 0; } @@ -3665,6 +3980,12 @@ g_log_handler (const gchar *log_domain, GLogLevelFlags log_level, } +#ifdef __GNUC__ + __extension__ /* shut up about "string length is greater than the length + ISO C89 compilers are required to support" when including + the .ad file... */ +#endif + static char *defaults[] = { #include "XScreenSaver_ad.h" 0 @@ -3682,7 +4003,7 @@ const char *usage = "[--display dpy] [--prefs]" # ifdef HAVE_CRAPPLET " [--crapplet]" # endif - "\n\t\t [--debug] [--sync] [--no-xshm]"; + "\n\t\t [--debug] [--sync] [--no-xshm] [--configdir dir]"; static void map_popup_window_cb (GtkWidget *w, gpointer user_data) @@ -3780,7 +4101,8 @@ main (int argc, char **argv) Display *dpy; Widget toplevel_shell; char *real_progname = argv[0]; - char window_title[255]; + char *window_title; + char *geom = 0; Bool crapplet_p = False; char *str; @@ -3845,35 +4167,86 @@ main (int argc, char **argv) /* We need to parse this arg really early... Sigh. */ for (i = 1; i < argc; i++) - if (argv[i] && - (!strcmp(argv[i], "--crapplet") || - !strcmp(argv[i], "--capplet"))) - { + { + if (argv[i] && + (!strcmp(argv[i], "--crapplet") || + !strcmp(argv[i], "--capplet"))) + { # if defined(HAVE_CRAPPLET) || defined(HAVE_GTK2) - int j; - crapplet_p = True; - for (j = i; j < argc; j++) /* remove it from the list */ - argv[j] = argv[j+1]; - argc--; + int j; + crapplet_p = True; + for (j = i; j < argc; j++) /* remove it from the list */ + argv[j] = argv[j+1]; + argc--; # else /* !HAVE_CRAPPLET && !HAVE_GTK2 */ - fprintf (stderr, "%s: not compiled with --crapplet support\n", - real_progname); - fprintf (stderr, "%s: %s\n", real_progname, usage); - exit (1); + fprintf (stderr, "%s: not compiled with --crapplet support\n", + real_progname); + fprintf (stderr, "%s: %s\n", real_progname, usage); + exit (1); # endif /* !HAVE_CRAPPLET && !HAVE_GTK2 */ - } - else if (argv[i] && - (!strcmp(argv[i], "--debug") || - !strcmp(argv[i], "-debug") || - !strcmp(argv[i], "-d"))) - { - int j; - s->debug_p = True; - for (j = i; j < argc; j++) /* remove it from the list */ - argv[j] = argv[j+1]; - argc--; + } + else if (argv[i] && + (!strcmp(argv[i], "--debug") || + !strcmp(argv[i], "-debug") || + !strcmp(argv[i], "-d"))) + { + int j; + s->debug_p = True; + for (j = i; j < argc; j++) /* remove it from the list */ + argv[j] = argv[j+1]; + argc--; + i--; + } + else if (argv[i] && + argc > i+1 && + *argv[i+1] && + (!strcmp(argv[i], "-geometry") || + !strcmp(argv[i], "-geom") || + !strcmp(argv[i], "-geo") || + !strcmp(argv[i], "-g"))) + { + int j; + geom = argv[i+1]; + for (j = i; j < argc; j++) /* remove them from the list */ + argv[j] = argv[j+2]; + argc -= 2; + i -= 2; + } + else if (argv[i] && + argc > i+1 && + *argv[i+1] && + (!strcmp(argv[i], "--configdir"))) + { + int j; + struct stat st; + hack_configuration_path = argv[i+1]; + for (j = i; j < argc; j++) /* remove them from the list */ + argv[j] = argv[j+2]; + argc -= 2; + i -= 2; + + if (0 != stat (hack_configuration_path, &st)) + { + char buf[255]; + sprintf (buf, "%s: %.200s", blurb(), hack_configuration_path); + perror (buf); + exit (1); + } + else if (!S_ISDIR (st.st_mode)) + { + fprintf (stderr, "%s: not a directory: %s\n", + blurb(), hack_configuration_path); + exit (1); + } + } } + + if (s->debug_p) + fprintf (stderr, "%s: using config directory \"%s\"\n", + progname, hack_configuration_path); + + /* Let Gtk open the X connection, then initialize Xt to use that same connection. Doctor Frankenstein would be proud. */ @@ -3996,7 +4369,8 @@ main (int argc, char **argv) ; else { - fprintf (stderr, _("%s: unknown option: %s\n"), real_progname, argv[i]); + fprintf (stderr, _("%s: unknown option: %s\n"), real_progname, + argv[i]); fprintf (stderr, "%s: %s\n", real_progname, usage); exit (1); } @@ -4008,6 +4382,9 @@ main (int argc, char **argv) was in argv[0]. */ p->db = db; + + hack_environment (s); /* must be before initialize_sort_map() */ + load_init_file (p); initialize_sort_map (s); @@ -4056,6 +4433,7 @@ main (int argc, char **argv) /* Set the main window's title. */ { + char *base_title = _("Screensaver Preferences"); char *v = (char *) strdup(strchr(screensaver_id, ' ')); char *s1, *s2, *s3, *s4; s1 = (char *) strchr(v, ' '); s1++; @@ -4064,7 +4442,12 @@ main (int argc, char **argv) s4 = (char *) strchr(s3, ')'); *s2 = 0; *s4 = 0; - sprintf (window_title, "%.50s %.50s, %.50s", progclass, s1, s3); + + window_title = (char *) malloc (strlen (base_title) + + strlen (progclass) + + strlen (s1) + strlen (s3) + + 100); + sprintf (window_title, "%s (%s %s, %s)", base_title, progclass, s1, s3); gtk_window_set_title (GTK_WINDOW (s->toplevel_widget), window_title); gtk_window_set_title (GTK_WINDOW (s->popup_widget), window_title); free (v); @@ -4153,7 +4536,6 @@ main (int argc, char **argv) # ifdef HAVE_CRAPPLET_IMMEDIATE capplet_widget_changes_are_immediate (CAPPLET_WIDGET (capplet)); # endif /* HAVE_CRAPPLET_IMMEDIATE */ - /* In crapplet-mode, take off the menubar. */ gtk_widget_hide (name_to_widget (s, "menubar")); @@ -4164,7 +4546,7 @@ main (int argc, char **argv) gtk_widget_ref (outer_vbox); gtk_container_remove (GTK_CONTAINER (s->toplevel_widget), outer_vbox); - GTK_OBJECT_SET_FLAGS (outer_vbox, GTK_FLOATING); + STFU GTK_OBJECT_SET_FLAGS (outer_vbox, GTK_FLOATING); gtk_container_add (GTK_CONTAINER (capplet), outer_vbox); /* Find the window above us, and set the title and close handler. */ @@ -4186,9 +4568,27 @@ main (int argc, char **argv) # endif /* HAVE_CRAPPLET */ + /* The Gnome folks hate the menubar. I think it's important to have access + to the commands on the File menu (Restart Daemon, etc.) and to the + About and Documentation commands on the Help menu. + */ +#if 0 +#ifdef HAVE_GTK2 + gtk_widget_hide (name_to_widget (s, "menubar")); +#endif +#endif + + free (window_title); + window_title = 0; + +#ifdef HAVE_GTK2 + /* After picking the default size, allow -geometry to override it. */ + if (geom) + gtk_window_parse_geometry (GTK_WINDOW (s->toplevel_widget), geom); +#endif + gtk_widget_show (s->toplevel_widget); init_icon (GTK_WIDGET (s->toplevel_widget)->window); /* after `show' */ - hack_environment (s); fix_preview_visual (s); /* Realize page zero, so that we can diddle the scrollbar when the @@ -4230,7 +4630,7 @@ main (int argc, char **argv) int i; for (i = 0; i < p->screenhacks_count; i++) { - screenhack *hack = p->screenhacks[s->hack_number_to_list_elt[i]]; + screenhack *hack = p->screenhacks[i]; conf_data *d = load_configurator (hack->command, False); if (d) free_conf_data (d); } @@ -4245,7 +4645,7 @@ main (int argc, char **argv) # endif /* HAVE_CRAPPLET */ gtk_main (); - kill_preview_subproc (s); + kill_preview_subproc (s, False); exit (0); }