X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Fdemo-Gtk.c;h=6564748fce36886fc8ec7e800b2a4f9ace85d6c1;hb=a445bdd3e3ba4abbee441844b6665b4c3c13d48c;hp=11c64d8985de896a76f8c47856559f4da3c80aae;hpb=0316d74da7982288abddd34e7a62698eb7f79965;p=xscreensaver diff --git a/driver/demo-Gtk.c b/driver/demo-Gtk.c index 11c64d89..6564748f 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-1999 Jamie Zawinski + * xscreensaver, Copyright (c) 1993-2001 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 @@ -70,6 +70,9 @@ extern Display *gdk_display; #include "remote.h" /* for xscreensaver_command() */ #include "usleep.h" +#include "logo-50.xpm" +#include "logo-180.xpm" + #include "demo-Gtk-widgets.h" #include @@ -109,6 +112,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 @@ -171,7 +175,7 @@ ensure_selected_item_visible (GtkWidget *widget) kids; kids = kids->next) nkids++; - adj = gtk_scrolled_window_get_vadjustment (scroller); + adj = gtk_scrolled_window_get_vadjustment (scroller); gdk_window_get_geometry (GTK_WIDGET(vp)->window, &ignore, &ignore, &ignore, &parent_h, &ignore); @@ -257,12 +261,19 @@ warning_dialog (GtkWidget *parent, const char *message, sprintf (name, "label%d", i++); { - char buf[255]; label = gtk_label_new (head); - sprintf (buf, "warning_dialog.%s.font", name); - GTK_WIDGET (label)->style = gtk_style_copy (GTK_WIDGET (label)->style); - GTK_WIDGET (label)->style->font = - gdk_font_load (get_string_resource (buf, "Dialog.Label.Font")); + + if (i == 1) + { + GTK_WIDGET (label)->style = + gtk_style_copy (GTK_WIDGET (label)->style); + GTK_WIDGET (label)->style->font = + gdk_font_load (get_string_resource("warning_dialog.headingFont", + "Dialog.Font")); + gtk_widget_set_style (GTK_WIDGET (label), + GTK_WIDGET (label)->style); + } + if (center <= 0) gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), @@ -420,20 +431,110 @@ paste_menu_cb (GtkMenuItem *menuitem, gpointer user_data) void about_menu_cb (GtkMenuItem *menuitem, gpointer user_data) { - char buf [2048]; - char *s = strdup (screensaver_id + 4); - char *s2; + char msg [2048]; + char *vers = strdup (screensaver_id + 4); + char *s; + char copy[1024]; + char *desc = "For updates, check http://www.jwz.org/xscreensaver/"; - s2 = strchr (s, ','); - *s2 = 0; - s2 += 2; + s = strchr (vers, ','); + *s = 0; + s += 2; + + sprintf(copy, "Copyright \251 1991-2001 %s", s); + + sprintf (msg, "%s\n\n%s", copy, desc); - sprintf (buf, "%s\n%s\n\n" - "For updates, check http://www.jwz.org/xscreensaver/", - s, s2); - free (s); + /* I can't make gnome_about_new() work here -- it starts dying in + gdk_imlib_get_visual() under gnome_about_new(). If this worked, + then this might be the thing to do: - warning_dialog (GTK_WIDGET (menuitem), buf, False, 100); + #ifdef HAVE_CRAPPLET + { + const gchar *auth[] = { 0 }; + GtkWidget *about = gnome_about_new (progclass, vers, "", auth, desc, + "xscreensaver.xpm"); + gtk_widget_show (about); + } + #else / * GTK but not GNOME * / + ... + */ + { + GdkColormap *colormap; + GdkPixmap *gdkpixmap; + GdkBitmap *mask; + + GtkWidget *dialog = gtk_dialog_new (); + GtkWidget *hbox, *icon, *vbox, *label1, *label2, *hb, *ok; + GtkWidget *parent = GTK_WIDGET (menuitem); + while (parent->parent) + parent = parent->parent; + + hbox = gtk_hbox_new (FALSE, 20); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), + hbox, TRUE, TRUE, 0); + + colormap = gtk_widget_get_colormap (parent); + gdkpixmap = + gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask, NULL, + (gchar **) logo_180_xpm); + icon = gtk_pixmap_new (gdkpixmap, mask); + gtk_misc_set_padding (GTK_MISC (icon), 10, 10); + + gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0); + + vbox = gtk_vbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); + + label1 = gtk_label_new (vers); + gtk_box_pack_start (GTK_BOX (vbox), label1, TRUE, TRUE, 0); + gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_LEFT); + gtk_misc_set_alignment (GTK_MISC (label1), 0.0, 0.75); + + GTK_WIDGET (label1)->style = gtk_style_copy (GTK_WIDGET (label1)->style); + GTK_WIDGET (label1)->style->font = + gdk_font_load (get_string_resource ("about.headingFont","Dialog.Font")); + gtk_widget_set_style (GTK_WIDGET (label1), GTK_WIDGET (label1)->style); + + label2 = gtk_label_new (msg); + gtk_box_pack_start (GTK_BOX (vbox), label2, TRUE, TRUE, 0); + gtk_label_set_justify (GTK_LABEL (label2), GTK_JUSTIFY_LEFT); + gtk_misc_set_alignment (GTK_MISC (label2), 0.0, 0.25); + + GTK_WIDGET (label2)->style = gtk_style_copy (GTK_WIDGET (label2)->style); + GTK_WIDGET (label2)->style->font = + gdk_font_load (get_string_resource ("about.bodyFont","Dialog.Font")); + gtk_widget_set_style (GTK_WIDGET (label2), GTK_WIDGET (label2)->style); + + hb = gtk_hbutton_box_new (); + + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), + hb, TRUE, TRUE, 0); + + ok = gtk_button_new_with_label ("OK"); + gtk_container_add (GTK_CONTAINER (hb), ok); + + 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_show (hbox); + gtk_widget_show (icon); + gtk_widget_show (vbox); + gtk_widget_show (label1); + gtk_widget_show (label2); + gtk_widget_show (hb); + gtk_widget_show (ok); + gtk_widget_show (dialog); + + gtk_signal_connect_object (GTK_OBJECT (ok), "clicked", + GTK_SIGNAL_FUNC (warning_dialog_dismiss_cb), + (gpointer) dialog); + gdk_window_set_transient_for (GTK_WIDGET (dialog)->window, + GTK_WIDGET (parent)->window); + gdk_window_show (GTK_WIDGET (dialog)->window); + gdk_window_raise (GTK_WIDGET (dialog)->window); + } } @@ -497,6 +598,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); + } } @@ -817,17 +981,24 @@ prefs_ok_cb (GtkButton *button, gpointer user_data) field = gtk_toggle_button_get_active (\ GTK_TOGGLE_BUTTON (name_to_widget (GTK_WIDGET(button), (name)))) - MINUTES (&p2->timeout, "timeout_text"); - MINUTES (&p2->cycle, "cycle_text"); - SECONDS (&p2->fade_seconds, "fade_text"); - INTEGER (&p2->fade_ticks, "ticks_text"); - MINUTES (&p2->lock_timeout, "lock_text"); - SECONDS (&p2->passwd_timeout, "pass_text"); - CHECKBOX (p2->verbose_p, "verbose_button"); - CHECKBOX (p2->install_cmap_p, "install_button"); - CHECKBOX (p2->fade_p, "fade_button"); - CHECKBOX (p2->unfade_p, "unfade_button"); - CHECKBOX (p2->lock_p, "lock_button"); + MINUTES (&p2->timeout, "timeout_text"); + MINUTES (&p2->cycle, "cycle_text"); + CHECKBOX (p2->lock_p, "lock_button"); + MINUTES (&p2->lock_timeout, "lock_text"); + + CHECKBOX (p2->dpms_enabled_p, "dpms_button"); + MINUTES (&p2->dpms_standby, "dpms_standby_text"); + MINUTES (&p2->dpms_suspend, "dpms_suspend_text"); + MINUTES (&p2->dpms_off, "dpms_off_text"); + + CHECKBOX (p2->verbose_p, "verbose_button"); + CHECKBOX (p2->capture_stderr_p, "capture_button"); + CHECKBOX (p2->splash_p, "splash_button"); + + CHECKBOX (p2->install_cmap_p, "install_button"); + CHECKBOX (p2->fade_p, "fade_button"); + CHECKBOX (p2->unfade_p, "unfade_button"); + SECONDS (&p2->fade_seconds, "fade_text"); # undef SECONDS # undef MINUTES @@ -840,21 +1011,37 @@ prefs_ok_cb (GtkButton *button, gpointer user_data) COPY(timeout); COPY(cycle); + COPY(lock_p); COPY(lock_timeout); - COPY(passwd_timeout); - COPY(fade_seconds); - COPY(fade_ticks); + + COPY(dpms_enabled_p); + COPY(dpms_standby); + COPY(dpms_suspend); + COPY(dpms_off); + COPY(verbose_p); + COPY(capture_stderr_p); + COPY(splash_p); + COPY(install_cmap_p); COPY(fade_p); COPY(unfade_p); - COPY(lock_p); + COPY(fade_seconds); # undef COPY populate_prefs_page (GTK_WIDGET (button), pair); if (changed) - demo_write_init_file (GTK_WIDGET (button), p); + { + Display *dpy = gdk_display; + sync_server_dpms_settings (dpy, p->dpms_enabled_p, + p->dpms_standby / 1000, + p->dpms_suspend / 1000, + p->dpms_off / 1000, + False); + + demo_write_init_file (GTK_WIDGET (button), p); + } } @@ -915,6 +1102,80 @@ list_unselect_cb (GtkList *list, GtkWidget *child) populate_demo_window (GTK_WIDGET (list), -1, pair); } + +static int updating_enabled_cb = 0; /* kludge to make sure that enabled_cb + is only run by user action, not by + program action. */ + +/* Called when the checkboxes that are in the left column of the + scrolling list are clicked. This both populates the right pane + (just as clicking on the label (really, listitem) does) and + also syncs this checkbox with the right pane Enabled checkbox. + */ +static void +list_checkbox_cb (GtkWidget *cb, gpointer client_data) +{ + prefs_pair *pair = (prefs_pair *) client_data; + + GtkWidget *line_hbox = GTK_WIDGET (cb)->parent; + GtkWidget *line = GTK_WIDGET (line_hbox)->parent; + + GtkList *list = GTK_LIST (GTK_WIDGET (line)->parent); + GtkViewport *vp = GTK_VIEWPORT (GTK_WIDGET (list)->parent); + GtkScrolledWindow *scroller = GTK_SCROLLED_WINDOW (GTK_WIDGET (vp)->parent); + GtkAdjustment *adj; + double scroll_top; + + GtkToggleButton *enabled = + GTK_TOGGLE_BUTTON (name_to_widget (cb, "enabled")); + + int which = gtk_list_child_position (list, line); + + /* remember previous scroll position of the top of the list */ + adj = gtk_scrolled_window_get_vadjustment (scroller); + scroll_top = adj->value; + + apply_changes_and_save (GTK_WIDGET (list)); + gtk_list_select_item (list, which); + /* ensure_selected_item_visible (GTK_WIDGET (list)); */ + populate_demo_window (GTK_WIDGET (list), which, pair); + + updating_enabled_cb++; + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enabled), + GTK_TOGGLE_BUTTON (cb)->active); + updating_enabled_cb--; + + /* restore the previous scroll position of the top of the list. + this is weak, but I don't really know why it's moving... */ + gtk_adjustment_set_value (adj, scroll_top); +} + + +/* Called when the right pane Enabled checkbox is clicked. This syncs + the corresponding checkbox inside the scrolling list to the state + of this checkbox. + */ +void +enabled_cb (GtkWidget *cb, gpointer client_data) +{ + int which = selected_hack_number (cb); + + if (updating_enabled_cb) return; + + if (which != -1) + { + GtkList *list = GTK_LIST (name_to_widget (cb, "list")); + GList *kids = GTK_LIST (list)->children; + GtkWidget *line = GTK_WIDGET (g_list_nth_data (kids, which)); + GtkWidget *line_hbox = GTK_WIDGET (GTK_BIN (line)->child); + GtkWidget *line_check = + GTK_WIDGET (gtk_container_children (GTK_CONTAINER (line_hbox))->data); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (line_check), + GTK_TOGGLE_BUTTON (cb)->active); + } +} + /* Populating the various widgets */ @@ -941,48 +1202,6 @@ format_time (char *buf, Time time) } -static char * -make_pretty_name (const char *shell_command) -{ - char *s = strdup (shell_command); - char *s2; - char res_name[255]; - - for (s2 = s; *s2; s2++) /* truncate at first whitespace */ - if (isspace (*s2)) - { - *s2 = 0; - break; - } - - s2 = strrchr (s, '/'); /* if pathname, take last component */ - if (s2) - { - s2 = strdup (s2+1); - free (s); - s = s2; - } - - if (strlen (s) > 50) /* 51 is hereby defined as "unreasonable" */ - s[50] = 0; - - sprintf (res_name, "hacks.%s.name", s); /* resource? */ - s2 = get_string_resource (res_name, res_name); - if (s2) - return s2; - - for (s2 = s; *s2; s2++) /* if it has any capitals, return it */ - if (*s2 >= 'A' && *s2 <= 'Z') - return s; - - if (s[0] >= 'a' && s[0] <= 'z') /* else cap it */ - s[0] -= 'a'-'A'; - if (s[0] == 'X' && s[1] >= 'a' && s[1] <= 'z') /* (magic leading X) */ - s[1] -= 'a'-'A'; - return s; -} - - /* Finds the number of the last hack to run, and makes that item be selected by default. */ @@ -1036,18 +1255,50 @@ populate_hack_list (GtkWidget *toplevel, prefs_pair *pair) for (h = hacks; h && *h; h++) { + /* A GtkList must contain only GtkListItems, but those can contain + an arbitrary widget. We add an Hbox, and inside that, a Checkbox + and a Label. We handle single and double click events on the + line itself, for clicking on the text, but the interior checkbox + also handles its own events. + */ GtkWidget *line; + GtkWidget *line_hbox; + GtkWidget *line_check; + GtkWidget *line_label; + char *pretty_name = (h[0]->name ? strdup (h[0]->name) - : make_pretty_name (h[0]->command)); + : make_hack_name (h[0]->command)); + + line = gtk_list_item_new (); + line_hbox = gtk_hbox_new (FALSE, 0); + line_check = gtk_check_button_new (); + line_label = gtk_label_new (pretty_name); + + gtk_container_add (GTK_CONTAINER (line), line_hbox); + gtk_box_pack_start (GTK_BOX (line_hbox), line_check, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (line_hbox), line_label, FALSE, FALSE, 0); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (line_check), + h[0]->enabled_p); + gtk_label_set_justify (GTK_LABEL (line_label), GTK_JUSTIFY_LEFT); + + gtk_widget_show (line_check); + gtk_widget_show (line_label); + gtk_widget_show (line_hbox); + gtk_widget_show (line); - line = gtk_list_item_new_with_label (pretty_name); free (pretty_name); gtk_container_add (GTK_CONTAINER (list), line); gtk_signal_connect (GTK_OBJECT (line), "button_press_event", GTK_SIGNAL_FUNC (list_doubleclick_cb), (gpointer) pair); + + gtk_signal_connect (GTK_OBJECT (line_check), "toggled", + GTK_SIGNAL_FUNC (list_checkbox_cb), + (gpointer) pair); + #if 0 /* #### */ GTK_WIDGET (GTK_BIN(line)->child)->style = gtk_style_copy (GTK_WIDGET (text_line)->style); @@ -1076,16 +1327,34 @@ populate_prefs_page (GtkWidget *top, prefs_pair *pair) gtk_entry_set_text (GTK_ENTRY (name_to_widget (top, "cycle_text")), s); format_time (s, p->lock_timeout); gtk_entry_set_text (GTK_ENTRY (name_to_widget (top, "lock_text")), s); - format_time (s, p->passwd_timeout); - gtk_entry_set_text (GTK_ENTRY (name_to_widget (top, "pass_text")), s); + + format_time (s, p->dpms_standby); + gtk_entry_set_text (GTK_ENTRY (name_to_widget (top, "dpms_standby_text")),s); + format_time (s, p->dpms_suspend); + gtk_entry_set_text (GTK_ENTRY (name_to_widget (top, "dpms_suspend_text")),s); + format_time (s, p->dpms_off); + gtk_entry_set_text (GTK_ENTRY (name_to_widget (top, "dpms_off_text")), s); + format_time (s, p->fade_seconds); gtk_entry_set_text (GTK_ENTRY (name_to_widget (top, "fade_text")), s); - sprintf (s, "%u", p->fade_ticks); - gtk_entry_set_text (GTK_ENTRY (name_to_widget (top, "ticks_text")), s); + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON (name_to_widget (top, "lock_button")), + p->lock_p); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (name_to_widget (top, "verbose_button")), p->verbose_p); + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON (name_to_widget (top, "capture_button")), + p->capture_stderr_p); + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON (name_to_widget (top, "splash_button")), + p->splash_p); + + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON (name_to_widget (top, "dpms_button")), + p->dpms_enabled_p); + gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (name_to_widget (top, "install_button")), p->install_cmap_p); @@ -1095,13 +1364,12 @@ populate_prefs_page (GtkWidget *top, prefs_pair *pair) gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (name_to_widget (top, "unfade_button")), p->unfade_p); - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (name_to_widget (top, "lock_button")), - p->lock_p); { Bool found_any_writable_cells = False; + Bool dpms_supported = False; + Display *dpy = gdk_display; int nscreens = ScreenCount(dpy); int i; @@ -1115,17 +1383,55 @@ populate_prefs_page (GtkWidget *top, prefs_pair *pair) } } +#ifdef HAVE_DPMS_EXTENSION + { + int op = 0, event = 0, error = 0; + if (XQueryExtension (dpy, "DPMS", &op, &event, &error)) + dpms_supported = True; + } +#endif /* HAVE_DPMS_EXTENSION */ + + + /* Blanking and Locking + */ gtk_widget_set_sensitive ( - GTK_WIDGET (name_to_widget (top, "fade_label")), - found_any_writable_cells); + GTK_WIDGET (name_to_widget (top, "lock_label")), + p->lock_p); gtk_widget_set_sensitive ( - GTK_WIDGET (name_to_widget (top, "ticks_label")), - found_any_writable_cells); + GTK_WIDGET (name_to_widget (top, "lock_text")), + p->lock_p); + + /* DPMS + */ gtk_widget_set_sensitive ( - GTK_WIDGET (name_to_widget (top, "fade_text")), - found_any_writable_cells); + GTK_WIDGET (name_to_widget (top, "dpms_frame")), + dpms_supported); + gtk_widget_set_sensitive ( + GTK_WIDGET (name_to_widget (top, "dpms_button")), + dpms_supported); + gtk_widget_set_sensitive ( + GTK_WIDGET (name_to_widget (top, "dpms_standby_label")), + dpms_supported && p->dpms_enabled_p); + gtk_widget_set_sensitive ( + GTK_WIDGET (name_to_widget (top, "dpms_standby_text")), + dpms_supported && p->dpms_enabled_p); + gtk_widget_set_sensitive ( + GTK_WIDGET (name_to_widget (top, "dpms_suspend_label")), + dpms_supported && p->dpms_enabled_p); + gtk_widget_set_sensitive ( + GTK_WIDGET (name_to_widget (top, "dpms_suspend_text")), + dpms_supported && p->dpms_enabled_p); gtk_widget_set_sensitive ( - GTK_WIDGET (name_to_widget (top, "ticks_text")), + GTK_WIDGET (name_to_widget (top, "dpms_off_label")), + dpms_supported && p->dpms_enabled_p); + gtk_widget_set_sensitive ( + GTK_WIDGET (name_to_widget (top, "dpms_off_text")), + dpms_supported && p->dpms_enabled_p); + + /* Colormaps + */ + gtk_widget_set_sensitive ( + GTK_WIDGET (name_to_widget (top, "cmap_frame")), found_any_writable_cells); gtk_widget_set_sensitive ( GTK_WIDGET (name_to_widget (top, "install_button")), @@ -1136,6 +1442,15 @@ populate_prefs_page (GtkWidget *top, prefs_pair *pair) gtk_widget_set_sensitive ( GTK_WIDGET (name_to_widget (top, "unfade_button")), found_any_writable_cells); + + gtk_widget_set_sensitive ( + GTK_WIDGET (name_to_widget (top, "fade_label")), + (found_any_writable_cells && + (p->fade_p || p->unfade_p))); + gtk_widget_set_sensitive ( + GTK_WIDGET (name_to_widget (top, "fade_text")), + (found_any_writable_cells && + (p->fade_p || p->unfade_p))); } } @@ -1173,8 +1488,9 @@ sensitize_demo_widgets (GtkWidget *toplevel, Bool sensitive_p) static void fix_text_entry_sizes (GtkWidget *toplevel) { - const char *names[] = { "timeout_text", "cycle_text", "fade_text", - "ticks_text", "lock_text", "pass_text" }; + const char *names[] = { "timeout_text", "cycle_text", "lock_text", + "dpms_standby_text", "dpms_suspend_text", + "dpms_off_text", "fade_text" }; int i; int width = 0; GtkWidget *w; @@ -1268,7 +1584,7 @@ static char *down_arrow_xpm[] = { }; static void -pixmapify_buttons (GtkWidget *toplevel) +pixmapify_button (GtkWidget *toplevel, int down_p) { GdkPixmap *pixmap; GdkBitmap *mask; @@ -1276,27 +1592,31 @@ pixmapify_buttons (GtkWidget *toplevel) GtkStyle *style; GtkWidget *w; - w = GTK_WIDGET (name_to_widget (GTK_WIDGET (toplevel), "next")); + w = GTK_WIDGET (name_to_widget (GTK_WIDGET (toplevel), + (down_p ? "next" : "prev"))); style = gtk_widget_get_style (w); mask = 0; pixmap = gdk_pixmap_create_from_xpm_d (w->window, &mask, &style->bg[GTK_STATE_NORMAL], - (gchar **) down_arrow_xpm); + (down_p + ? (gchar **) down_arrow_xpm + : (gchar **) up_arrow_xpm)); pixmapwid = gtk_pixmap_new (pixmap, mask); gtk_widget_show (pixmapwid); gtk_container_remove (GTK_CONTAINER (w), GTK_BIN (w)->child); gtk_container_add (GTK_CONTAINER (w), pixmapwid); +} - w = GTK_WIDGET (name_to_widget (GTK_WIDGET (toplevel), "prev")); - style = gtk_widget_get_style (w); - mask = 0; - pixmap = gdk_pixmap_create_from_xpm_d (w->window, &mask, - &style->bg[GTK_STATE_NORMAL], - (gchar **) up_arrow_xpm); - pixmapwid = gtk_pixmap_new (pixmap, mask); - gtk_widget_show (pixmapwid); - gtk_container_remove (GTK_CONTAINER (w), GTK_BIN (w)->child); - gtk_container_add (GTK_CONTAINER (w), pixmapwid); +static void +map_next_button_cb (GtkWidget *w, gpointer user_data) +{ + pixmapify_button (w, 1); +} + +static void +map_prev_button_cb (GtkWidget *w, gpointer user_data) +{ + pixmapify_button (w, 0); } @@ -1353,7 +1673,7 @@ get_hack_blurb (screenhack *hack) char *prog_name = strdup (hack->command); char *pretty_name = (hack->name ? strdup (hack->name) - : make_pretty_name (hack->command)); + : make_hack_name (hack->command)); char doc_name[255], doc_class[255]; char *s, *s2; @@ -1458,7 +1778,7 @@ populate_demo_window (GtkWidget *toplevel, int which, prefs_pair *pair) char *pretty_name = (hack ? (hack->name ? strdup (hack->name) - : make_pretty_name (hack->command)) + : make_hack_name (hack->command)) : 0); char *doc_string = hack ? get_hack_blurb (hack) : 0; @@ -1466,7 +1786,11 @@ populate_demo_window (GtkWidget *toplevel, int which, prefs_pair *pair) gtk_label_set_text (doc, (doc_string ? doc_string : "")); gtk_entry_set_text (cmd, (hack ? hack->command : "")); gtk_entry_set_position (cmd, 0); + + updating_enabled_cb++; gtk_toggle_button_set_active (enabled, (hack ? hack->enabled_p : False)); + updating_enabled_cb--; + gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (vis)->entry), (hack ? (hack->visual && *hack->visual @@ -1549,6 +1873,22 @@ maybe_reload_init_file (GtkWidget *widget, prefs_pair *pair) } + +/* Setting window manager icon + */ + +static void +init_icon (GdkWindow *window) +{ + GdkBitmap *mask = 0; + GdkColor transp; + GdkPixmap *pixmap = + gdk_pixmap_create_from_xpm_d (window, &mask, &transp, + (gchar **) logo_50_xpm); + if (pixmap) + gdk_window_set_icon (window, 0, pixmap, mask); +} + /* The main demo-mode command loop. */ @@ -1764,7 +2104,6 @@ map_window_cb (GtkWidget *w, gpointer user_data) { Boolean oi = initializing_p; initializing_p = True; - pixmapify_buttons (w); eschew_gtk_lossage (w); ensure_selected_item_visible (GTK_WIDGET(name_to_widget(w, "list"))); initializing_p = oi; @@ -1775,11 +2114,6 @@ int main (int argc, char **argv) { XtAppContext app; -# ifdef HAVE_CRAPPLET - GnomeClient *client; - GnomeClientFlags flags; - int init_results; -# endif /* HAVE_CRAPPLET */ prefs_pair Pair, *pair; saver_preferences P, P2, *p, *p2; Bool prefs = False; @@ -1858,9 +2192,21 @@ main (int argc, char **argv) # ifdef HAVE_CRAPPLET if (crapplet_p) { - init_results = gnome_capplet_init ("screensaver-properties", - short_version, - argc, argv, NULL, 0, NULL); + GnomeClient *client; + GnomeClientFlags flags = 0; + + int init_results = gnome_capplet_init ("screensaver-properties", + short_version, + argc, argv, NULL, 0, NULL); + /* init_results is: + 0 upon successful initialization; + 1 if --init-session-settings was passed on the cmdline; + 2 if --ignore was passed on the cmdline; + -1 on error. + + So the 1 signifies just to init the settings, and quit, basically. + (Meaning launch the xscreensaver daemon.) + */ if (init_results < 0) { @@ -1878,14 +2224,38 @@ main (int argc, char **argv) if (client) flags = gnome_client_get_flags (client); - else - flags = 0; if (flags & GNOME_CLIENT_IS_CONNECTED) { - gnome_client_set_restart_style (client, GNOME_RESTART_NEVER); + int token = + gnome_startup_acquire_token ("GNOME_SCREENSAVER_PROPERTIES", + gnome_client_get_id (client)); + if (token) + { + char *session_args[20]; + int i = 0; + session_args[i++] = real_progname; + session_args[i++] = "--capplet"; + session_args[i++] = "--init-session-settings"; + session_args[i] = 0; + gnome_client_set_priority (client, 20); + gnome_client_set_restart_style (client, GNOME_RESTART_ANYWAY); + gnome_client_set_restart_command (client, i, session_args); + } + else + { + gnome_client_set_restart_style (client, GNOME_RESTART_NEVER); + } + gnome_client_flush (client); } + + if (init_results == 1) + { + system ("xscreensaver -nosplash &"); + return 0; + } + } else # endif /* HAVE_CRAPPLET */ @@ -2022,6 +2392,12 @@ main (int argc, char **argv) gtk_signal_connect ( GTK_OBJECT (name_to_widget (GTK_WIDGET (gtk_window), "list")), "map", GTK_SIGNAL_FUNC(map_window_cb), 0); + gtk_signal_connect ( + GTK_OBJECT (name_to_widget (GTK_WIDGET (gtk_window), "prev")), + "map", GTK_SIGNAL_FUNC(map_prev_button_cb), 0); + gtk_signal_connect ( + GTK_OBJECT (name_to_widget (GTK_WIDGET (gtk_window), "next")), + "map", GTK_SIGNAL_FUNC(map_next_button_cb), 0); /* Handle the -prefs command-line argument. */ @@ -2046,10 +2422,6 @@ main (int argc, char **argv) gtk_container_remove (GTK_CONTAINER (gtk_window), top_vbox); GTK_OBJECT_SET_FLAGS (top_vbox, GTK_FLOATING); - /* This is a crock, but otherwise, the Control Center expands to - be as tall as the screen. */ - gtk_window_set_default_size (GTK_WINDOW (top_vbox), 600, 400); - /* In crapplet-mode, take off the menubar. */ gtk_widget_hide (name_to_widget (gtk_window, "menubar")); @@ -2068,6 +2440,7 @@ main (int argc, char **argv) # endif /* HAVE_CRAPPLET */ { gtk_widget_show (gtk_window); + init_icon (GTK_WIDGET(gtk_window)->window); /* Issue any warnings about the running xscreensaver daemon. */ the_network_is_not_the_computer (gtk_window);