Increased delay before autoapply
2000-12-17 Bradford Hovinen <hovinen@helixcode.com> * capplets/new-background-properties/preferences.c (preferences_changed): Increased delay before autoapply * capplets/new-background-properties/prefs-widget.c (auto_apply_toggled_cb): Implement (read_preferences): (prefs_widget_init): Support auto_apply * capplets/new-background-properties/preferences.h (struct _Preferences): Add auto_apply * capplets/new-background-properties/preferences.c (preferences_write_xml): (preferences_read_xml): (preferences_load): (preferences_save): Support auto_apply * capplets/new-background-properties/applier.c (struct _Renderer): Added srcx, srcy to clip wallpaper when it is too big (get_geometry): Set srcx and srcy (renderer_render_to_screen): Tweak rendering geometry to stay within the wallpaper area on the drawable * capplets/new-background-properties/prefs-widget.c (wallpaper_entry_changed_cb): Make sure the file specified is actually a file * capplets/new-background-properties/main.c (do_set_xml): Default NULL for buffer
This commit is contained in:
parent
9d9e373a33
commit
8d8010f252
7 changed files with 155 additions and 20 deletions
26
ChangeLog
26
ChangeLog
|
@ -1,5 +1,31 @@
|
|||
2000-12-17 Bradford Hovinen <hovinen@helixcode.com>
|
||||
|
||||
* capplets/new-background-properties/preferences.c
|
||||
(preferences_changed): Increased delay before autoapply
|
||||
|
||||
* capplets/new-background-properties/prefs-widget.c
|
||||
(auto_apply_toggled_cb): Implement
|
||||
(read_preferences):
|
||||
(prefs_widget_init): Support auto_apply
|
||||
|
||||
* capplets/new-background-properties/preferences.h (struct
|
||||
_Preferences): Add auto_apply
|
||||
* capplets/new-background-properties/preferences.c
|
||||
(preferences_write_xml):
|
||||
(preferences_read_xml):
|
||||
(preferences_load):
|
||||
(preferences_save): Support auto_apply
|
||||
|
||||
* capplets/new-background-properties/applier.c (struct _Renderer):
|
||||
Added srcx, srcy to clip wallpaper when it is too big
|
||||
(get_geometry): Set srcx and srcy
|
||||
(renderer_render_to_screen): Tweak rendering geometry to stay
|
||||
within the wallpaper area on the drawable
|
||||
|
||||
* capplets/new-background-properties/prefs-widget.c
|
||||
(wallpaper_entry_changed_cb): Make sure the file specified is
|
||||
actually a file
|
||||
|
||||
* capplets/new-background-properties/main.c (do_set_xml): Default
|
||||
NULL for buffer
|
||||
|
||||
|
|
|
@ -74,20 +74,23 @@ struct _Renderer
|
|||
|
||||
Preferences *prefs;
|
||||
|
||||
gint x; /* Geometry relative to pixmap */
|
||||
gint x; /* Geometry relative to pixmap */
|
||||
gint y;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
gint wx; /* Geometry of wallpaper as rendered */
|
||||
gint srcx; /* Geometry relative to pixbuf */
|
||||
gint srcy; /* (used when the wallpaper is too big) */
|
||||
|
||||
gint wx; /* Geometry of wallpaper as rendered */
|
||||
gint wy;
|
||||
gint wwidth;
|
||||
gint wheight;
|
||||
|
||||
gint pwidth; /* Geometry of unscaled wallpaper */
|
||||
gint pwidth; /* Geometry of unscaled wallpaper */
|
||||
gint pheight;
|
||||
|
||||
gint gwidth; /* Geometry of gradient-only pixmap */
|
||||
gint gwidth; /* Geometry of gradient-only pixmap */
|
||||
gint gheight;
|
||||
|
||||
guchar *gradient_data;
|
||||
|
@ -135,7 +138,8 @@ static void get_geometry (wallpaper_type_t wallpaper_type,
|
|||
int dwidth, int dheight,
|
||||
int vwidth, int vheight,
|
||||
int *xoffset, int *yoffset,
|
||||
int *rwidth, int *rheight);
|
||||
int *rwidth, int *rheight,
|
||||
int *srcx, int *srcy);
|
||||
static void render_tiled_image (Pixmap pixmap, GC xgc,
|
||||
GdkPixbuf *pixbuf,
|
||||
gint x, gint y,
|
||||
|
@ -715,7 +719,8 @@ renderer_render_wallpaper (Renderer *renderer)
|
|||
renderer->width, renderer->height,
|
||||
root_width, root_height,
|
||||
&renderer->wx, &renderer->wy,
|
||||
&renderer->wwidth, &renderer->wheight);
|
||||
&renderer->wwidth, &renderer->wheight,
|
||||
&renderer->srcx, &renderer->srcy);
|
||||
|
||||
if (renderer->wwidth != renderer->pwidth ||
|
||||
renderer->wheight != renderer->pheight)
|
||||
|
@ -841,10 +846,11 @@ renderer_render_to_screen (Renderer *renderer)
|
|||
gdk_pixbuf_xlib_render_to_drawable
|
||||
(renderer->pixbuf,
|
||||
renderer->pixmap, xgc,
|
||||
0, 0,
|
||||
renderer->x + renderer->wx,
|
||||
renderer->y + renderer->wy,
|
||||
renderer->wwidth, renderer->wheight,
|
||||
renderer->srcx, renderer->srcy,
|
||||
renderer->x + MAX (renderer->wx, 0),
|
||||
renderer->y + MAX (renderer->wy, 0),
|
||||
MIN (renderer->width, renderer->wwidth),
|
||||
MIN (renderer->height, renderer->wheight),
|
||||
GDK_RGB_DITHER_NORMAL, 0, 0);
|
||||
} else {
|
||||
if (renderer->is_root) {
|
||||
|
@ -948,7 +954,8 @@ get_geometry (wallpaper_type_t wallpaper_type, GdkPixbuf *pixbuf,
|
|||
int dwidth, int dheight,
|
||||
int vwidth, int vheight,
|
||||
int *xoffset, int *yoffset,
|
||||
int *rwidth, int *rheight)
|
||||
int *rwidth, int *rheight,
|
||||
int *srcx, int *srcy)
|
||||
{
|
||||
gdouble asp, factor;
|
||||
gint st = 0;
|
||||
|
@ -966,12 +973,35 @@ get_geometry (wallpaper_type_t wallpaper_type, GdkPixbuf *pixbuf,
|
|||
|
||||
*rwidth = gdk_pixbuf_get_width (pixbuf) * factor;
|
||||
|
||||
/* wallpaper_type could be WPTYPE_TILED too */
|
||||
if (vwidth < gdk_pixbuf_get_width (pixbuf) &&
|
||||
wallpaper_type == WPTYPE_CENTERED)
|
||||
*srcx = (gdk_pixbuf_get_width (pixbuf) - vwidth) *
|
||||
factor / 2;
|
||||
else
|
||||
*srcx = 0;
|
||||
|
||||
if (dheight != vheight)
|
||||
factor = (gdouble) dheight / (gdouble) vheight;
|
||||
else
|
||||
factor = 1.0;
|
||||
|
||||
*rheight = gdk_pixbuf_get_height (pixbuf) * factor;
|
||||
|
||||
/* wallpaper_type could be WPTYPE_TILED too */
|
||||
if (vheight < gdk_pixbuf_get_height (pixbuf) &&
|
||||
wallpaper_type == WPTYPE_CENTERED)
|
||||
*srcy = (gdk_pixbuf_get_height (pixbuf) - vheight) *
|
||||
factor / 2;
|
||||
else
|
||||
*srcy = 0;
|
||||
|
||||
/* wallpaper_type could be WPTYPE_TILED too */
|
||||
if (wallpaper_type == WPTYPE_CENTERED) {
|
||||
*xoffset = (dwidth - *rwidth) >> 1;
|
||||
*yoffset = (dheight - *rheight) >> 1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case WPTYPE_SCALED_ASPECT:
|
||||
|
@ -994,23 +1024,22 @@ get_geometry (wallpaper_type_t wallpaper_type, GdkPixbuf *pixbuf,
|
|||
*xoffset = 0;
|
||||
*yoffset = (dheight - *rheight) >> 1;
|
||||
}
|
||||
|
||||
*srcx = *srcy = 0;
|
||||
|
||||
break;
|
||||
|
||||
case WPTYPE_SCALED:
|
||||
*rwidth = dwidth;
|
||||
*rheight = dheight;
|
||||
*xoffset = *yoffset = 0;
|
||||
*srcx = *srcy = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_error ("Bad wallpaper type");
|
||||
break;
|
||||
}
|
||||
|
||||
if (wallpaper_type == WPTYPE_CENTERED) {
|
||||
*xoffset = (dwidth - *rwidth) >> 1;
|
||||
*yoffset = (dheight - *rheight) >> 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<class>GtkTable</class>
|
||||
<name>prefs_widget</name>
|
||||
<border_width>5</border_width>
|
||||
<rows>3</rows>
|
||||
<rows>4</rows>
|
||||
<columns>2</columns>
|
||||
<homogeneous>False</homogeneous>
|
||||
<row_spacing>5</row_spacing>
|
||||
|
@ -521,6 +521,34 @@
|
|||
<class>Placeholder</class>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkCheckButton</class>
|
||||
<name>auto_apply</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>toggled</name>
|
||||
<handler>auto_apply_toggled_cb</handler>
|
||||
<last_modification_time>Sun, 17 Dec 2000 21:35:44 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Apply changes automatically</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<child>
|
||||
<left_attach>0</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>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
|
|
|
@ -20,3 +20,4 @@ gchar *s = N_("Centered");
|
|||
gchar *s = N_("Scaled (keep aspect)");
|
||||
gchar *s = N_("Scaled");
|
||||
gchar *s = N_("Disable background selection");
|
||||
gchar *s = N_("Apply changes automatically");
|
||||
|
|
|
@ -216,6 +216,9 @@ preferences_load (Preferences *prefs)
|
|||
gnome_config_get_string
|
||||
("/Background/Default/wallpapers_dir=./");
|
||||
|
||||
prefs->auto_apply =
|
||||
gnome_config_get_bool ("/Background/Default/autoApply=true");
|
||||
|
||||
if (!g_strcasecmp (prefs->wallpaper_filename, "none")) {
|
||||
g_free(prefs->wallpaper_filename);
|
||||
prefs->wallpaper_filename = NULL;
|
||||
|
@ -260,6 +263,9 @@ preferences_save (Preferences *prefs)
|
|||
gnome_config_set_int ("/Background/Default/wallpaperAlign",
|
||||
prefs->wallpaper_type);
|
||||
|
||||
gnome_config_set_bool ("/Background/Default/autoApply",
|
||||
prefs->auto_apply);
|
||||
|
||||
gnome_config_sync ();
|
||||
}
|
||||
|
||||
|
@ -271,9 +277,10 @@ preferences_changed (Preferences *prefs)
|
|||
if (prefs->timeout_id)
|
||||
gtk_timeout_remove (prefs->timeout_id);
|
||||
|
||||
prefs->timeout_id = gtk_timeout_add (1000,
|
||||
(GtkFunction) apply_timeout_cb,
|
||||
prefs);
|
||||
if (prefs->auto_apply)
|
||||
prefs->timeout_id =
|
||||
gtk_timeout_add (5000, (GtkFunction) apply_timeout_cb,
|
||||
prefs);
|
||||
|
||||
applier_apply_prefs (applier, prefs, FALSE, TRUE);
|
||||
}
|
||||
|
@ -370,6 +377,8 @@ preferences_read_xml (xmlDocPtr xml_doc)
|
|||
else if (!strcmp (node->name, "wallpaper-sel-path"))
|
||||
prefs->wallpaper_sel_path =
|
||||
g_strdup (xmlNodeGetContent (node));
|
||||
else if (!strcmp (node->name, "auto-apply"))
|
||||
prefs->auto_apply = TRUE;
|
||||
}
|
||||
|
||||
return prefs;
|
||||
|
@ -419,6 +428,9 @@ preferences_write_xml (Preferences *prefs)
|
|||
xmlNewChild (node, NULL, "wallpaper-sel-path",
|
||||
prefs->wallpaper_sel_path);
|
||||
|
||||
if (prefs->auto_apply)
|
||||
xmlNewChild (node, NULL, "auto-apply", NULL);
|
||||
|
||||
xmlDocSetRootElement (doc, node);
|
||||
|
||||
return doc;
|
||||
|
|
|
@ -49,6 +49,7 @@ struct _Preferences
|
|||
GtkObject object;
|
||||
|
||||
gboolean frozen;
|
||||
gboolean auto_apply;
|
||||
guint timeout_id;
|
||||
|
||||
gboolean enabled;
|
||||
|
|
|
@ -85,6 +85,8 @@ static void scaled_select_toggled_cb (GtkToggleButton *tb,
|
|||
PrefsWidget *prefs_widget);
|
||||
static void disable_toggled_cb (GtkToggleButton *tb,
|
||||
PrefsWidget *prefs_widget);
|
||||
static void auto_apply_toggled_cb (GtkToggleButton *tb,
|
||||
PrefsWidget *prefs_widget);
|
||||
|
||||
static void set_gradient_controls_sensitive (PrefsWidget *prefs_widget,
|
||||
gboolean s);
|
||||
|
@ -183,6 +185,10 @@ prefs_widget_init (PrefsWidget *prefs_widget)
|
|||
"disable_toggled_cb",
|
||||
disable_toggled_cb,
|
||||
prefs_widget);
|
||||
glade_xml_signal_connect_data (prefs_widget->dialog_data,
|
||||
"auto_apply_toggled_cb",
|
||||
auto_apply_toggled_cb,
|
||||
prefs_widget);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -374,6 +380,15 @@ read_preferences (PrefsWidget *prefs_widget, Preferences *prefs)
|
|||
set_background_controls_sensitive (prefs_widget, FALSE);
|
||||
}
|
||||
|
||||
if (prefs->auto_apply)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
||||
(WID ("auto_apply")),
|
||||
TRUE);
|
||||
else
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
||||
(WID ("auto_apply")),
|
||||
FALSE);
|
||||
|
||||
preferences_apply_preview (prefs);
|
||||
}
|
||||
|
||||
|
@ -502,6 +517,12 @@ wallpaper_entry_changed_cb (GtkEntry *e, PrefsWidget *prefs_widget)
|
|||
gnome_file_entry_get_full_path
|
||||
(GNOME_FILE_ENTRY (WID ("wallpaper_entry")), TRUE);
|
||||
|
||||
if (!g_file_test (prefs_widget->prefs->wallpaper_filename,
|
||||
G_FILE_TEST_ISFILE)) {
|
||||
g_free (prefs_widget->prefs->wallpaper_filename);
|
||||
prefs_widget->prefs->wallpaper_filename = NULL;
|
||||
}
|
||||
|
||||
if (prefs_widget->prefs->wallpaper_filename &&
|
||||
strlen (prefs_widget->prefs->wallpaper_filename) &&
|
||||
g_strcasecmp (prefs_widget->prefs->wallpaper_filename, "none"))
|
||||
|
@ -602,6 +623,23 @@ disable_toggled_cb (GtkToggleButton *tb, PrefsWidget *prefs_widget)
|
|||
capplet_widget_state_changed (CAPPLET_WIDGET (prefs_widget), TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
auto_apply_toggled_cb (GtkToggleButton *tb, PrefsWidget *prefs_widget)
|
||||
{
|
||||
g_return_if_fail (prefs_widget != NULL);
|
||||
g_return_if_fail (IS_PREFS_WIDGET (prefs_widget));
|
||||
g_return_if_fail (prefs_widget->prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs_widget->prefs));
|
||||
|
||||
if (gtk_toggle_button_get_active (tb))
|
||||
prefs_widget->prefs->auto_apply = TRUE;
|
||||
else
|
||||
prefs_widget->prefs->auto_apply = FALSE;
|
||||
|
||||
preferences_changed (prefs_widget->prefs);
|
||||
capplet_widget_state_changed (CAPPLET_WIDGET (prefs_widget), TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
set_gradient_controls_sensitive (PrefsWidget *prefs_widget, gboolean s)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue