Free structures only if they were ever allocated

2000-08-07  Bradford Hovinen  <hovinen@helixcode.com>

	* screensaver-prefs-dialog.c (screensaver_prefs_dialog_destroy):
	Free structures only if they were ever allocated

	* selection-dialog.c (get_known_savers): Implement. Read the
	screensaver directory for a list of valid screensavers
	(place_screensaver_list): Use known_savers rather than XML data

	* preferences.c (screensaver_get_label): Implement. Copy from
	get_label in resources.c

	* prefs-widget.c (deselect_saver_cb): Toggle only if event was a
	mouse button press, not a keyboard press
	(prefs_widget_init): Change vertical size of preview window to 200
	(prefs_widget_init): Use a table for the buttons below the
	screensaver list
	(prefs_widget_init): Change label of edit button to Settings...
	(prefs_widget_init): Don't have description and preview frames
	expand, have selection frame expand

	* Makefile.am (screensaver_properties_capplet_LDADD): Don't link
	against glade
	(INCLUDES): Don't set glade compilation flags

	* screensaver-prefs-dialog.c (get_select_widget): Show menu item
	(populate_table): Don't skip hgroups that lack ids
	(place_number):
	(place_boolean): Attach items with GTK_FILL
	(get_check_button):
	(get_select_widget): Set object data to point back to dialog
	(populate_table): Pass dialog, remove extraneous arguments
	(get_check_button): Connect toggled signal from here
	(get_select_widget): Set data and connect activate signals from
	here
	(place_number): Set default from default attribute
	(get_spinbutton): Set step_increment, page_increment, and
	page_size on adjustment
	(get_spinbutton):
	(place_number): Set default to average of high and low if not
	supplied
	(get_argument_data): Add i18n support
	(read_boolean):
	(read_number):
	(read_select):
	(write_boolean):
	(write_number):
	(write_select): Check if id is NULL before trying to look up a node
	(screensaver_prefs_dialog_new): Make sure CLI arguments and XML
	data were read successfully before trying to build the widget
	(get_argument_data): Return pointer to document rather than root node
	(screensaver_prefs_dialog_new): Set argument_data from argument_doc
	(screensaver_prefs_dialog_class_init): Set parent_class
	(screensaver_prefs_dialog_destroy): Implement; free all structures
	(free_set_cb): Implement
	(write_number): Don't assume correct format on the output string;
	just replace the '%' with the appropriate argument
	(write_command_line): Free arg iff generated from number

2000-08-06  Bradford Hovinen  <hovinen@helixcode.com>

	* screensaver-prefs-dialog.c (get_screensaver_widget): Accept
	ScreensaverPrefsDialog as option
	(get_argument_data): Assume one file per screensaver
	(get_spinbutton):
	(get_check_button):
	(get_select_widget):
	(place_number):
	(place_boolean):
	(place_hgroup):
	(place_select):
	(populate_table): Implement
	(get_screensaver_widget): Rewrite to build screensaver config
	dialogs manually from the XML data
	(activate_option_cb):
	(toggle_check_cb): Pass dialog to set_widgets_sensitive
	(set_widgets_sensitive): Rewrite to use dialog->widget_db
	(write_boolean):
	(write_number):
	(write_select): Use widget_db
	(write_select):
	(write_command_line): Don't check no-output
	(write_command_line): Pass widget_db
	(read_boolean):
	(read_number):
	(read_select): Use widget_db
	(place_screensaver_properties): Pass dialog->widget_db to above
	functions
	(arg_mapping_exists): Use XML file rather than Glade definition
	(screensaver_prefs_dialog_new): Initialize settings_widget with
	the widget to be placed in the settings frame
	(place_screensaver_properties): Take xml node; process hgroups
	recursively
	(write_command_line): Process hgroups recursively
	(read_boolean):
	(read_number):
	(read_select): Check if set and set->value_widget are set before
	proceeding

	* screensaver-prefs-dialog.h (struct _PrefsDialogConfigOption):
	New structure
	(struct _ScreensaverPrefsDialog ): New member widget_db --
	key-value database of PrefsDialogConfigOptions indexed by id
	attribute from XML
This commit is contained in:
Bradford Hovinen 2000-08-07 16:04:33 +00:00 committed by Bradford Hovinen (Gdict maintainer)
parent 8c5ee35a90
commit 148d8186a5
14 changed files with 1178 additions and 1323 deletions

View file

@ -1,3 +1,108 @@
2000-08-07 Bradford Hovinen <hovinen@helixcode.com>
* screensaver-prefs-dialog.c (screensaver_prefs_dialog_destroy):
Free structures only if they were ever allocated
* selection-dialog.c (get_known_savers): Implement. Read the
screensaver directory for a list of valid screensavers
(place_screensaver_list): Use known_savers rather than XML data
* preferences.c (screensaver_get_label): Implement. Copy from
get_label in resources.c
* prefs-widget.c (deselect_saver_cb): Toggle only if event was a
mouse button press, not a keyboard press
(prefs_widget_init): Change vertical size of preview window to 200
(prefs_widget_init): Use a table for the buttons below the
screensaver list
(prefs_widget_init): Change label of edit button to Settings...
(prefs_widget_init): Don't have description and preview frames
expand, have selection frame expand
* Makefile.am (screensaver_properties_capplet_LDADD): Don't link
against glade
(INCLUDES): Don't set glade compilation flags
* screensaver-prefs-dialog.c (get_select_widget): Show menu item
(populate_table): Don't skip hgroups that lack ids
(place_number):
(place_boolean): Attach items with GTK_FILL
(get_check_button):
(get_select_widget): Set object data to point back to dialog
(populate_table): Pass dialog, remove extraneous arguments
(get_check_button): Connect toggled signal from here
(get_select_widget): Set data and connect activate signals from
here
(place_number): Set default from default attribute
(get_spinbutton): Set step_increment, page_increment, and
page_size on adjustment
(get_spinbutton):
(place_number): Set default to average of high and low if not
supplied
(get_argument_data): Add i18n support
(read_boolean):
(read_number):
(read_select):
(write_boolean):
(write_number):
(write_select): Check if id is NULL before trying to look up a node
(screensaver_prefs_dialog_new): Make sure CLI arguments and XML
data were read successfully before trying to build the widget
(get_argument_data): Return pointer to document rather than root node
(screensaver_prefs_dialog_new): Set argument_data from argument_doc
(screensaver_prefs_dialog_class_init): Set parent_class
(screensaver_prefs_dialog_destroy): Implement; free all structures
(free_set_cb): Implement
(write_number): Don't assume correct format on the output string;
just replace the '%' with the appropriate argument
(write_command_line): Free arg iff generated from number
2000-08-06 Bradford Hovinen <hovinen@helixcode.com>
* screensaver-prefs-dialog.c (get_screensaver_widget): Accept
ScreensaverPrefsDialog as option
(get_argument_data): Assume one file per screensaver
(get_spinbutton):
(get_check_button):
(get_select_widget):
(place_number):
(place_boolean):
(place_hgroup):
(place_select):
(populate_table): Implement
(get_screensaver_widget): Rewrite to build screensaver config
dialogs manually from the XML data
(activate_option_cb):
(toggle_check_cb): Pass dialog to set_widgets_sensitive
(set_widgets_sensitive): Rewrite to use dialog->widget_db
(write_boolean):
(write_number):
(write_select): Use widget_db
(write_select):
(write_command_line): Don't check no-output
(write_command_line): Pass widget_db
(read_boolean):
(read_number):
(read_select): Use widget_db
(place_screensaver_properties): Pass dialog->widget_db to above
functions
(arg_mapping_exists): Use XML file rather than Glade definition
(screensaver_prefs_dialog_new): Initialize settings_widget with
the widget to be placed in the settings frame
(place_screensaver_properties): Take xml node; process hgroups
recursively
(write_command_line): Process hgroups recursively
(read_boolean):
(read_number):
(read_select): Check if set and set->value_widget are set before
proceeding
* screensaver-prefs-dialog.h (struct _PrefsDialogConfigOption):
New structure
(struct _ScreensaverPrefsDialog ): New member widget_db --
key-value database of PrefsDialogConfigOptions indexed by id
attribute from XML
2000-07-31 Bradford Hovinen <hovinen@helixcode.com>
* all: Removed ENABLE_{LIBGLADE|CAPPLET|PREVIEW} ifdefs

View file

@ -8,15 +8,15 @@ Applications_DATA = \
SUBDIRS = screensavers
EXTRA_DIST = ChangeLog TODO $(Applications_DATA) $(pixmap_DATA) \
EXTRA_DIST = ChangeLog $(Applications_DATA) $(pixmap_DATA) \
checked.xpm unchecked.xpm checked-disabled.xpm unchecked-disabled.xpm
INCLUDES = \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DSSPROP_DATADIR=\""${prefix}/share/screensaver-properties"\" \
-DGNOME_ICONDIR=\""${prefix}/share/pixmaps"\" \
-DSSPROP_DATADIR=\""${prefix}/share"\" \
-DG_LOG_DOMAIN=\"screensaver-properties\" \
$(GNOME_INCLUDEDIR) \
$(LIBGLADE_CFLAGS) \
$(XML_CFLAGS) \
-I$(top_srcdir)/
-I../intl
@ -43,8 +43,7 @@ screensaver_properties_capplet_LDADD = \
$(GNOME_LIBDIR) \
$(GNOMEUI_LIBS) \
$(ORBIT_LIBS) \
$(LIBGLADE_LIBS) \
$(GNOME_XML_LIB) \
-lXt \
-lgdk_pixbuf \
../../control-center/libcapplet.la
../../libcapplet/libcapplet.la

View file

@ -4,6 +4,7 @@
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen <hovinen@helixcode.com>
* Parts written by Jamie Zawinski <jwz@jwz.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -286,3 +287,27 @@ screensaver_get_desc (Screensaver *saver)
return saver->description;
}
/* Adapted from xscreensaver 3.24 driver/demo-Gtk.c line 944 ... */
char *
screensaver_get_label (gchar *name)
{
char *s, *label;
label = screensaver_get_label_from_xrdb (name);
if (label) return label;
label = g_strdup (name);
for (s = label; *s; s++) /* if it has any capitals, return it */
if (*s >= 'A' && *s <= 'Z')
return s;
if (label[0] >= 'a' && label[0] <= 'z') /* else cap it */
label[0] -= 'a'-'A';
if (label[0] == 'X' && label[1] >= 'a' && label[1] <= 'z')
label[1] -= 'a'-'A';
return label;
}

View file

@ -107,4 +107,6 @@ GList *screensaver_remove (Screensaver *saver, GList *screensavers);
char *screensaver_get_desc (Screensaver *saver);
char *screensaver_get_label (gchar *name);
#endif /* __PREFERENCES_H */

View file

@ -171,7 +171,7 @@ static void
prefs_widget_init (PrefsWidget *prefs)
{
GtkWidget *table, *frame, *vbox, *vbox1, *hbox, *label;
GtkWidget *hbuttonbox, *scrolled_window, *button;
GtkWidget *hbuttonbox, *scrolled_window, *button, *table1;
GtkObject *adjustment;
GSList *no_screensavers_group = NULL;
GtkWidget *viewport;
@ -184,8 +184,8 @@ prefs_widget_init (PrefsWidget *prefs)
frame = gtk_frame_new (_("Selection"));
gtk_table_attach (GTK_TABLE (table), frame, 0, 1, 0, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
GTK_EXPAND | GTK_FILL,
GTK_EXPAND | GTK_FILL, 0, 0);
vbox = gtk_vbox_new (FALSE, 5);
gtk_container_add (GTK_CONTAINER (frame), vbox);
@ -258,45 +258,49 @@ prefs_widget_init (PrefsWidget *prefs)
gtk_container_add (GTK_CONTAINER (scrolled_window),
prefs->screensaver_list);
hbuttonbox = gtk_hbutton_box_new ();
gtk_box_pack_start (GTK_BOX (vbox), hbuttonbox, FALSE, FALSE, 0);
table1 = gtk_table_new (2, 3, TRUE);
gtk_table_set_row_spacings (GTK_TABLE (table1), GNOME_PAD_SMALL);
gtk_table_set_col_spacings (GTK_TABLE (table1), GNOME_PAD_SMALL);
gtk_box_pack_start (GTK_BOX (vbox), table1, FALSE, FALSE, 0);
button = gtk_button_new_with_label (_("Add..."));
gtk_container_add (GTK_CONTAINER (hbuttonbox), button);
gtk_table_attach (GTK_TABLE (table1), button, 0, 1, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
screensaver_add_cb, prefs);
prefs->remove_button = gtk_button_new_with_label (_("Remove"));
gtk_container_add (GTK_CONTAINER (hbuttonbox), prefs->remove_button);
gtk_table_attach (GTK_TABLE (table1), prefs->remove_button, 1, 2, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_signal_connect (GTK_OBJECT (prefs->remove_button), "clicked",
screensaver_remove_cb, prefs);
gtk_widget_set_sensitive (prefs->remove_button, FALSE);
prefs->settings_button = gtk_button_new_with_label (_("Edit..."));
gtk_container_add (GTK_CONTAINER (hbuttonbox), prefs->settings_button);
prefs->settings_button = gtk_button_new_with_label (_("Settings..."));
gtk_table_attach (GTK_TABLE (table1), prefs->settings_button,
2, 3, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_set_sensitive (prefs->settings_button, FALSE);
hbuttonbox = gtk_hbutton_box_new ();
gtk_box_pack_start (GTK_BOX (vbox), hbuttonbox, FALSE, FALSE, 0);
prefs->demo_button = gtk_button_new_with_label (_("Demo"));
gtk_container_add (GTK_CONTAINER (hbuttonbox), prefs->demo_button);
gtk_table_attach (GTK_TABLE (table1), prefs->demo_button, 0, 1, 1, 2,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_set_sensitive (prefs->demo_button, FALSE);
button = gtk_button_new_with_label (_("Demo Next"));
gtk_container_add (GTK_CONTAINER (hbuttonbox), button);
gtk_table_attach (GTK_TABLE (table1), button, 1, 2, 1, 2,
GTK_FILL, GTK_FILL, 0, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
demo_next_cb, prefs);
button = gtk_button_new_with_label (_("Demo Previous"));
gtk_container_add (GTK_CONTAINER (hbuttonbox), button);
gtk_table_attach (GTK_TABLE (table1), button, 2, 3, 1, 2,
GTK_FILL, GTK_FILL, 0, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
demo_prev_cb, prefs);
frame = gtk_frame_new (_("Preview"));
gtk_table_attach (GTK_TABLE (table), frame, 1, 2, 0, 1,
(GtkAttachOptions) (GTK_EXPAND),
(GtkAttachOptions) (GTK_FILL), 0, 0);
GTK_FILL, GTK_FILL, 0, 0);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (frame), scrolled_window);
@ -309,13 +313,12 @@ prefs_widget_init (PrefsWidget *prefs)
prefs->preview_window = gtk_drawing_area_new ();
gtk_container_add (GTK_CONTAINER (viewport), prefs->preview_window);
gtk_widget_set_usize (prefs->preview_window, 300, 250);
gtk_widget_set_usize (prefs->preview_window, 300, 200);
frame = gtk_frame_new (_("Description"));
gtk_table_attach (GTK_TABLE (table), frame, 1, 2, 1, 2,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
@ -1340,9 +1343,12 @@ deselect_saver_cb (GtkCList *list, gint row, gint column,
Screensaver *saver;
int r, c;
if (column == 0 && widget->selection_mode == SM_CHOOSE_FROM_LIST) {
if (event && column == 0 &&
widget->selection_mode == SM_CHOOSE_FROM_LIST)
{
gtk_clist_get_selection_info (list, event->x, event->y,
&r, &c);
if (r == row) {
saver = gtk_clist_get_row_data (list, row);
toggle_saver (widget, row, saver);

View file

@ -179,28 +179,6 @@ get_settings_name (const char *command_line)
return s2;
}
static char *
get_label (char *name)
{
char *s, *label;
label = screensaver_get_label_from_xrdb (name);
if (label) return label;
label = g_strdup (name);
for (s = label; *s; s++) /* if it has any capitals, return it */
if (*s >= 'A' && *s <= 'Z')
return s;
if (label[0] >= 'a' && label[0] <= 'z') /* else cap it */
label[0] -= 'a'-'A';
if (label[0] == 'X' && label[1] >= 'a' && label[1] <= 'z')
label[1] -= 'a'-'A';
return label;
}
/* WARNING: Looking at the following code is likely to cause seizures ... */
static gchar *
@ -321,7 +299,7 @@ parse_screensaver (const char *line)
}
h->name = get_settings_name (h->command_line);
if (!h->label) h->label = get_label (h->name);
if (!h->label) h->label = screensaver_get_label (h->name);
return h;
}

File diff suppressed because it is too large Load diff

View file

@ -35,17 +35,26 @@
#define SCREENSAVER_PREFS_DIALOG_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, screensaver_prefs_dialog_get_type (), ScreensaverPrefsDialogClass)
#define IS_SCREENSAVER_PREFS_DIALOG(obj) GTK_CHECK_TYPE (obj, screensaver_prefs_dialog_get_type ())
typedef struct _PrefsDialogWidgetSet PrefsDialogWidgetSet;
typedef struct _ScreensaverPrefsDialog ScreensaverPrefsDialog;
typedef struct _ScreensaverPrefsDialogClass ScreensaverPrefsDialogClass;
struct _PrefsDialogWidgetSet
{
GList *widgets;
GtkWidget *value_widget;
};
struct _ScreensaverPrefsDialog
{
GnomeDialog gnome_dialog;
Screensaver *saver;
PrefsWidget *global_prefs_widget;
GladeXML *prefs_widget_data;
xmlDocPtr argument_doc;
xmlNodePtr argument_data;
GTree *widget_db;
GScanner *cli_args_db;
GtkWidget *settings_dialog_frame;
@ -68,5 +77,6 @@ struct _ScreensaverPrefsDialogClass
guint screensaver_prefs_dialog_get_type (void);
GtkWidget *screensaver_prefs_dialog_new (Screensaver *saver);
void screensaver_prefs_dialog_destroy (ScreensaverPrefsDialog *dialog);
#endif /* __SCREENSAVER_PREFS_DIALOG_H */

View file

@ -1,4 +1,8 @@
SUBDIRS = fr
Screensaversdir = $(datadir)/screensavers
Screensavers_DATA = \
hacks.xml \
qix-settings.glade
qix.xml \
attraction.xml
EXTRA_DIST = $(Screensavers_DATA)

View file

@ -1,51 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<screensaver-descriptions>
<hack name="attraction">
<command arg="-root"/>
<select id="mode">
<option id="balls" arg-set="-mode balls"/>
<option id="lines" arg-set="-mode lines" test="mode = lines"/>
<option id="tails" arg-set="-mode tails" test="mode = tails"/>
<option id="polygons" arg-set="-mode polygons" test="mode = polygons"/>
<option id="splines" arg-set="-mode splines" test="mode = splines"/>
</select>
<number id="threshold" arg="-threshold %d"/>
<number id="segments" arg="-segments %d"/>
<number id="speed" arg="-delay %d" from-cli-conv="20000 - var" to-cli-conv="20000 - var"/>
<select id="use_color">
<option id="color" enable="number_colors_label,number_colors_widget,color_contrast_label,color_contrast_low_label,color_contrast_high_label,color_contrast_widget"/>
<option id="mono" arg-set="-mono" test="mono"/>
</select>
<number id="number_colors" arg="-colors %d"/>
<number id="color_contrast" arg="-color-shift %d"/>
</hack>
<hack name="qix">
<command arg="-root"/>
<select id="shape">
<option id="lines" enable="trail_type_widget,width_widget,width_label,width_high_label,width_low_label" arg-set="-poly 2"/>
<option id="poly" enable="no_pts_widget,no_pts_label" test="poly > 2"/>
</select>
<number id="no_pts" arg="-poly %d"/>
<select id="trail_type">
<option id="discrete" enable="spread_widget,spread_label,spread_low_label,spread_high_label"/>
<option id="solid" arg-set="-solid" test="solid and not (transparent or xor)"/>
<option id="transparent" arg-set="-solid -transparent" test="solid and transparent"/>
<option id="xor" arg-set="-solid -xor" test="solid and xor"/>
</select>
<boolean id="gravity" arg-set="-gravity" test="gravity"/>
<number id="speed" arg="-delay %d" from-cli-conv="20000 - var" to-cli-conv="20000 - var"/>
<number id="length" arg="-segments %d"/>
<number id="width" arg="-size %d"/>
<number id="count" arg="-count %d"/>
<number id="spread" arg="-spread %d"/>
<select id="use_color">
<option id="color" enable="shift_widget,shift_label,shift_low_label,shift_high_label"/>
<option id="mono" arg-set="-mono" test="mono"/>
</select>
<number id="shift" arg="-color-shift %d"/>
</hack>
</screensaver-descriptions>

View file

@ -1,839 +0,0 @@
<?xml version="1.0"?>
<GTK-Interface>
<project>
<name>Screensaver-properties-capplet</name>
<program_name>screensaver-properties-capplet</program_name>
<directory></directory>
<source_directory>src</source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
</project>
<widget>
<class>GtkWindow</class>
<name>window</name>
<title>window1</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>True</allow_grow>
<auto_shrink>False</auto_shrink>
<widget>
<class>GtkTable</class>
<name>widget</name>
<border_width>10</border_width>
<rows>7</rows>
<columns>3</columns>
<homogeneous>False</homogeneous>
<row_spacing>5</row_spacing>
<column_spacing>5</column_spacing>
<widget>
<class>GtkOptionMenu</class>
<name>shape_widget</name>
<can_focus>True</can_focus>
<items>Lines
Polygons
</items>
<initial_choice>0</initial_choice>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkTable</class>
<name>table2</name>
<rows>8</rows>
<columns>3</columns>
<homogeneous>False</homogeneous>
<row_spacing>5</row_spacing>
<column_spacing>5</column_spacing>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
<widget>
<class>GtkHScale</class>
<name>speed_widget</name>
<can_focus>True</can_focus>
<draw_value>False</draw_value>
<value_pos>GTK_POS_TOP</value_pos>
<digits>1</digits>
<policy>GTK_UPDATE_CONTINUOUS</policy>
<value>10000</value>
<lower>0</lower>
<upper>20000</upper>
<step>0</step>
<page>0</page>
<page_size>0</page_size>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
</widget>
<widget>
<class>GtkHScale</class>
<name>length_widget</name>
<can_focus>True</can_focus>
<draw_value>False</draw_value>
<value_pos>GTK_POS_TOP</value_pos>
<digits>1</digits>
<policy>GTK_UPDATE_CONTINUOUS</policy>
<value>50</value>
<lower>0</lower>
<upper>1000</upper>
<step>0</step>
<page>0</page>
<page_size>0</page_size>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
</widget>
<widget>
<class>GtkHScale</class>
<name>width_widget</name>
<can_focus>True</can_focus>
<draw_value>False</draw_value>
<value_pos>GTK_POS_TOP</value_pos>
<digits>1</digits>
<policy>GTK_UPDATE_CONTINUOUS</policy>
<value>100</value>
<lower>0</lower>
<upper>1000</upper>
<step>0</step>
<page>0</page>
<page_size>0</page_size>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>5</top_attach>
<bottom_attach>6</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label21</name>
<label>Speed</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>width_label</name>
<label>Width</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>4</top_attach>
<bottom_attach>5</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label22</name>
<label>Length</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>width_low_label</name>
<label>Narrow</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>5</top_attach>
<bottom_attach>6</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>width_high_label</name>
<label>Wide</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>5</top_attach>
<bottom_attach>6</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label18</name>
<label>Long</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label16</name>
<label>Fast</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label15</name>
<label>Slow</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label17</name>
<label>Short</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkHScale</class>
<name>spread_widget</name>
<can_focus>True</can_focus>
<draw_value>False</draw_value>
<value_pos>GTK_POS_TOP</value_pos>
<digits>1</digits>
<policy>GTK_UPDATE_CONTINUOUS</policy>
<value>8</value>
<lower>0</lower>
<upper>30</upper>
<step>0</step>
<page>0</page>
<page_size>0</page_size>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>7</top_attach>
<bottom_attach>8</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>spread_label</name>
<label>Spread between lines</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>6</top_attach>
<bottom_attach>7</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>spread_low_label</name>
<label>Short</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>7</top_attach>
<bottom_attach>8</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>spread_high_label</name>
<label>Long</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>7</top_attach>
<bottom_attach>8</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<name>no_pts_label</name>
<label>Number of points:</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label5</name>
<label>Number of trails:</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>2</right_attach>
<top_attach>4</top_attach>
<bottom_attach>5</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>gravity_widget</name>
<can_focus>True</can_focus>
<label>Trails attract each other</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkTable</class>
<name>table3</name>
<rows>2</rows>
<columns>3</columns>
<homogeneous>False</homogeneous>
<row_spacing>5</row_spacing>
<column_spacing>5</column_spacing>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>6</top_attach>
<bottom_attach>7</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
<widget>
<class>GtkLabel</class>
<name>shift_low_label</name>
<label>Low</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>False</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>shift_high_label</name>
<label>High</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>False</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>shift_label</name>
<label>Color contrast</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkHScale</class>
<name>shift_widget</name>
<can_focus>True</can_focus>
<draw_value>False</draw_value>
<value_pos>GTK_POS_TOP</value_pos>
<digits>1</digits>
<policy>GTK_UPDATE_CONTINUOUS</policy>
<value>8.4</value>
<lower>0</lower>
<upper>25</upper>
<step>0</step>
<page>0</page>
<page_size>0</page_size>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
</widget>
</widget>
<widget>
<class>GtkOptionMenu</class>
<name>use_color_widget</name>
<can_focus>True</can_focus>
<items>Full Color
Monochrome
</items>
<initial_choice>0</initial_choice>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>5</top_attach>
<bottom_attach>6</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkOptionMenu</class>
<name>trail_type_widget</name>
<can_focus>True</can_focus>
<items>Discrete Lines
Solid Trails
Transparent Trails
XOR Trails
</items>
<initial_choice>0</initial_choice>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkSpinButton</class>
<name>count_widget</name>
<can_focus>True</can_focus>
<climb_rate>1</climb_rate>
<digits>0</digits>
<numeric>False</numeric>
<update_policy>GTK_UPDATE_ALWAYS</update_policy>
<snap>False</snap>
<wrap>False</wrap>
<value>1</value>
<lower>0</lower>
<upper>100</upper>
<step>1</step>
<page>10</page>
<page_size>10</page_size>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>4</top_attach>
<bottom_attach>5</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkSpinButton</class>
<name>no_pts_widget</name>
<can_focus>True</can_focus>
<climb_rate>1</climb_rate>
<digits>0</digits>
<numeric>False</numeric>
<update_policy>GTK_UPDATE_ALWAYS</update_policy>
<snap>False</snap>
<wrap>False</wrap>
<value>3</value>
<lower>3</lower>
<upper>100</upper>
<step>1</step>
<page>10</page>
<page_size>10</page_size>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
</widget>
</widget>
</GTK-Interface>

View file

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<screensaver name="qix">
<command arg="-root"/>
<hgroup>
<select id="shape">
<option id="lines" label="Lines"
enable="trail_type,width" arg-set="-poly 2"/>
<option id="poly" label="Polygons"
enable="no_pts" test="poly > 2"/>
</select>
<number id="no_pts" label="Number of points:"
type="spinbutton" low="3" high="16" default="3"
arg="-poly %"/>
</hgroup>
<select id="trail_type">
<option id="discrete" label="Discrete Lines" enable="spread"/>
<option id="solid" label="Solid Trails"
arg-set="-solid" test="solid and not (transparent or xor)"/>
<option id="transparent" label="Transparent Trails"
arg-set="-solid -transparent" test="solid and transparent"/>
<option id="xor" label="XOR Trails"
arg-set="-solid -xor" test="solid and xor"/>
</select>
<boolean id="gravity" label="Trails attract each other"
arg-set="-gravity" test="gravity"/>
<number id="speed" label="Speed" low-label="Slow" high-label="Fast"
type="slider" low="0" high="20000" default="10000" arg="-delay %"
from-cli-conv="20000 - var" to-cli-conv="20000 - var"/>
<number id="length" label="Length" low-label="Short" high-label="Long"
type="slider" low="0" high="1000" default="50" arg="-segments %"/>
<number id="width" label="Width" low-label="Narrow" high-label="Wide"
type="slider" low="0" high="1000" default="100" arg="-size %"/>
<number id="spread" label="Spread between lines"
low-label="Short" high-label="Long"
type="slider" low="0" high="30" default="8" arg="-spread %"/>
<number id="count" label="Number of trails:"
type="spinbutton" low="1" high="100" default="1" arg="-count %"/>
<select id="use_color">
<option id="color" label="Full Color" enable="shift"/>
<option id="mono" label="Monochrome" arg-set="-mono" test="mono"/>
</select>
<number id="shift" label="Color contrast"
low-label="Low" high-label="High"
type="slider" low="0" high="25" default="3" arg="-color-shift %"/>
</screensaver>

View file

@ -26,6 +26,9 @@
# include "config.h"
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <ctype.h>
#include <gnome.h>
@ -39,10 +42,16 @@ enum {
LAST_SIGNAL
};
static xmlDocPtr screensaver_doc;
static gint selection_dialog_signals[LAST_SIGNAL] = { 0 };
typedef struct _saver_entry_t
{
gchar *name;
gchar *label;
} saver_entry_t;
GList *known_savers;
static void selection_dialog_init (SelectionDialog *dialog);
static void selection_dialog_class_init (SelectionDialogClass *dialog);
@ -55,6 +64,8 @@ static void selection_dialog_ok_cb (GtkWidget *widget,
static void selection_dialog_cancel_cb (GtkWidget *widget,
SelectionDialog *dialog);
static GList *get_known_savers (void);
guint
selection_dialog_get_type (void)
{
@ -94,7 +105,8 @@ selection_dialog_init (SelectionDialog *dialog)
vbox = GTK_BOX (GNOME_DIALOG (dialog)->vbox);
label = gtk_label_new (_("Select the screensaver to run from the list below:"));
label = gtk_label_new (_("Select the screensaver to run from " \
"the list below:"));
gtk_box_pack_start (vbox, label, FALSE, TRUE, 0);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
@ -141,6 +153,8 @@ selection_dialog_class_init (SelectionDialogClass *class)
selection_dialog_signals,
LAST_SIGNAL);
known_savers = get_known_savers ();
class->ok_clicked = NULL;
}
@ -150,12 +164,7 @@ selection_dialog_new (PrefsWidget *prefs_widget)
GtkWidget *widget;
widget = gtk_type_new (selection_dialog_get_type ());
if (!screensaver_doc)
screensaver_doc = xmlParseFile (SSPROP_DATADIR "/hacks.xml");
place_screensaver_list (SELECTION_DIALOG (widget));
gtk_widget_show (widget);
return widget;
@ -165,34 +174,25 @@ static void
place_screensaver_list (SelectionDialog *dialog)
{
GtkWidget *item;
GList *item_list_head = NULL, *item_list_tail = NULL;
xmlNodePtr node;
GList *item_list_head = NULL, *item_list_tail = NULL, *node;
gchar *label;
saver_entry_t *entry;
node = xmlDocGetRootElement (screensaver_doc);
if (node) {
node = node->childs;
while (node) {
label = xmlGetProp (node, "name");
label[0] = toupper (label[0]);
item = gtk_list_item_new_with_label (label);
for (node = known_savers; node; node = node->next) {
entry = (saver_entry_t *) node->data;
item = gtk_list_item_new_with_label (entry->label);
gtk_widget_show (item);
gtk_object_set_data (GTK_OBJECT (item), "node", node);
gtk_object_set_data (GTK_OBJECT (item), "name", entry->name);
gtk_signal_connect (GTK_OBJECT (item), "select",
GTK_SIGNAL_FUNC
(select_program_cb),
GTK_SIGNAL_FUNC (select_program_cb),
dialog);
item_list_tail = g_list_append (item_list_tail, item);
if (!item_list_head) item_list_head = item_list_tail;
item_list_tail = g_list_last (item_list_tail);
node = node->next;
}
}
item = gtk_list_item_new_with_label ("Custom");
item = gtk_list_item_new_with_label (_("Custom"));
gtk_widget_show (item);
gtk_signal_connect (GTK_OBJECT (item), "select",
GTK_SIGNAL_FUNC (select_program_cb), dialog);
@ -208,8 +208,8 @@ static void
select_program_cb (GtkListItem *item, SelectionDialog *dialog)
{
dialog->selected_program_item = item;
dialog->selected_program_node =
gtk_object_get_data (GTK_OBJECT (item), "node");
dialog->selected_name =
gtk_object_get_data (GTK_OBJECT (item), "name");
}
static void
@ -220,11 +220,11 @@ selection_dialog_ok_cb (GtkWidget *widget, SelectionDialog *dialog)
saver = screensaver_new ();
saver->label = g_strdup (_("New screensaver"));
if (dialog->selected_program_node) {
if (dialog->selected_name) {
saver->name =
g_strdup (xmlGetProp (dialog->selected_program_node,
"name"));
saver->command_line = g_strconcat (saver->name, " -root", NULL);
g_strdup (dialog->selected_name);
saver->command_line =
g_strconcat (saver->name, " -root", NULL);
}
gtk_signal_emit (GTK_OBJECT (dialog),
@ -237,3 +237,74 @@ selection_dialog_cancel_cb (GtkWidget *widget, SelectionDialog *dialog)
{
gnome_dialog_close (GNOME_DIALOG (dialog));
}
static gint
node_compare (gconstpointer a, gconstpointer b)
{
return strcmp (((saver_entry_t *) a)->label,
((saver_entry_t *) b)->label);
}
static GList *
get_known_savers (void)
{
GList *list_head, *list_tail;
DIR *parent_dir;
struct dirent *child_dir;
struct stat filedata;
gchar *fullpath;
saver_entry_t *entry;
char *tmp, *name;
if (known_savers) return known_savers;
parent_dir = opendir (SSPROP_DATADIR "/screensavers");
if (parent_dir == NULL)
return NULL;
list_head = list_tail = NULL;
while ((child_dir = readdir (parent_dir)) != NULL) {
if (child_dir->d_name[0] != '.') {
fullpath = g_concat_dir_and_file
(SSPROP_DATADIR "/screensavers",
child_dir->d_name);
if (stat (fullpath, &filedata) != -1) {
if (!S_ISDIR (filedata.st_mode)) {
name = g_strdup (child_dir->d_name);
tmp = strstr (name, ".xml");
if (tmp) {
*tmp = '\0';
entry = g_new0
(saver_entry_t, 1);
entry->name = name;
entry->label =
screensaver_get_label
(name);
} else {
g_free (name);
}
} else {
entry = NULL;
}
if (entry) {
list_tail = g_list_append
(list_tail, entry);
if (!list_head)
list_head = list_tail;
else
list_tail = list_tail->next;
}
}
g_free (fullpath);
}
}
closedir (parent_dir);
list_head = g_list_sort (list_head, node_compare);
}

View file

@ -44,7 +44,7 @@ struct _SelectionDialog
GtkList *program_list;
GtkListItem *selected_program_item;
xmlNodePtr selected_program_node;
char *selected_name;
};
struct _SelectionDialogClass