always apply the current GConf settings to the initially selected

2008-02-16  Jens Granseuer  <jensgr@gmx.net>

	* appearance-desktop.c: (wp_option_menu_set), (wp_load_stuffs):
	* gnome-wp-item.c: (gnome_wp_item_update), (gnome_wp_item_new):
	* gnome-wp-item.h: always apply the current GConf settings to the
	initially selected wallpaper so that we don't modify the settings if
	GConf state and the definition in backgrounds.xml are not identical
	(bug #516746)

	* gnome-wp-xml.c: (gnome_wp_xml_load_xml): get rid of redundant if

svn path=/trunk/; revision=8489
This commit is contained in:
Jens Granseuer 2008-02-16 00:03:24 +00:00 committed by Jens Granseuer
parent b695ca96d1
commit 254b98c405
5 changed files with 84 additions and 80 deletions

View file

@ -1,3 +1,14 @@
2008-02-16 Jens Granseuer <jensgr@gmx.net>
* appearance-desktop.c: (wp_option_menu_set), (wp_load_stuffs):
* gnome-wp-item.c: (gnome_wp_item_update), (gnome_wp_item_new):
* gnome-wp-item.h: always apply the current GConf settings to the
initially selected wallpaper so that we don't modify the settings if
GConf state and the definition in backgrounds.xml are not identical
(bug #516746)
* gnome-wp-xml.c: (gnome_wp_xml_load_xml): get rid of redundant if
2008-02-15 Kjartan Maraas <kmaraas@gnome.org>
* appearance-desktop.c: (wp_scale_type_changed),

View file

@ -274,31 +274,21 @@ wp_option_menu_set (AppearanceData *data,
}
else
{
gint style;
if (!strcmp (value, "centered"))
{
gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_style_menu),
GNOME_WP_SCALE_TYPE_CENTERED);
}
style = GNOME_WP_SCALE_TYPE_CENTERED;
else if (!strcmp (value, "stretched"))
{
gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_style_menu),
GNOME_WP_SCALE_TYPE_STRETCHED);
}
style = GNOME_WP_SCALE_TYPE_STRETCHED;
else if (!strcmp (value, "scaled"))
{
gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_style_menu),
GNOME_WP_SCALE_TYPE_SCALED);
}
style = GNOME_WP_SCALE_TYPE_SCALED;
else if (!strcmp (value, "zoom"))
{
style = GNOME_WP_SCALE_TYPE_ZOOM;
else
style = GNOME_WP_SCALE_TYPE_TILED;
gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_style_menu),
GNOME_WP_SCALE_TYPE_ZOOM);
}
else if (!strcmp (value, "none"))
{
gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_style_menu),
GNOME_WP_SCALE_TYPE_TILED);
}
style);
}
}
@ -878,8 +868,8 @@ static gboolean
wp_load_stuffs (void *user_data)
{
AppearanceData *data;
gchar * imagepath, * style, * uri;
GnomeWPItem * item;
gchar *imagepath, *style, *uri;
GnomeWPItem *item;
data = (AppearanceData *) user_data;
@ -887,8 +877,6 @@ wp_load_stuffs (void *user_data)
g_hash_table_foreach (data->wp_hash, (GHFunc) wp_props_load_wallpaper,
data);
/*gdk_window_set_cursor (data->window->window, NULL);*/
style = gconf_client_get_string (data->client,
WP_OPTIONS_KEY,
NULL);
@ -910,7 +898,12 @@ wp_load_stuffs (void *user_data)
item = g_hash_table_lookup (data->wp_hash, imagepath);
if (item != NULL && strcmp (style, "none") != 0)
if (item != NULL)
{
/* update with the current gconf settings */
gnome_wp_item_update (item);
if (strcmp (style, "none") != 0)
{
if (item->deleted == TRUE)
{
@ -919,13 +912,7 @@ wp_load_stuffs (void *user_data)
}
select_item (data, item, FALSE);
wp_option_menu_set (data, item->options, FALSE);
wp_option_menu_set (data, item->shade_type, TRUE);
gtk_color_button_set_color (GTK_COLOR_BUTTON (data->wp_pcpicker), item->pcolor);
gtk_color_button_set_color (GTK_COLOR_BUTTON (data->wp_scpicker), item->scolor);
}
}
else if (strcmp (style, "none") != 0)
{

View file

@ -74,39 +74,21 @@ void gnome_wp_item_ensure_gnome_bg (GnomeWPItem *item)
}
}
GnomeWPItem * gnome_wp_item_new (const gchar * filename,
GHashTable * wallpapers,
GnomeThumbnailFactory * thumbnails) {
GnomeWPItem * item = NULL;
void gnome_wp_item_update (GnomeWPItem *item) {
GConfClient *client;
GdkColor color1 = { 0, 0, 0, 0 }, color2 = { 0, 0, 0, 0 };
gchar * col_str;
GConfClient * client;
gchar *col_str;
client = gconf_client_get_default ();
item = g_new0 (GnomeWPItem, 1);
item->filename = gnome_vfs_unescape_string_for_display (filename);
item->fileinfo = gnome_wp_info_new (item->filename, thumbnails);
if (item->fileinfo != NULL &&
(g_str_has_prefix (item->fileinfo->mime_type, "image/") ||
strcmp (item->fileinfo->mime_type, "application/xml") == 0)) {
if (item->name == NULL) {
if (g_utf8_validate (item->fileinfo->name, -1, NULL))
item->name = g_strdup (item->fileinfo->name);
else
item->name = g_filename_to_utf8 (item->fileinfo->name, -1, NULL,
NULL, NULL);
}
g_free (item->options);
item->options = gconf_client_get_string (client, WP_OPTIONS_KEY, NULL);
if (item->options == NULL || !strcmp (item->options, "none")) {
g_free (item->options);
item->options = g_strdup ("scaled");
}
g_free (item->shade_type);
item->shade_type = gconf_client_get_string (client, WP_SHADING_KEY, NULL);
if (item->shade_type == NULL)
item->shade_type = g_strdup ("solid");
@ -123,10 +105,41 @@ GnomeWPItem * gnome_wp_item_new (const gchar * filename,
g_free (col_str);
}
g_object_unref (client);
if (item->pcolor != NULL)
gdk_color_free (item->pcolor);
if (item->scolor != NULL)
gdk_color_free (item->scolor);
item->pcolor = gdk_color_copy (&color1);
item->scolor = gdk_color_copy (&color2);
}
GnomeWPItem * gnome_wp_item_new (const gchar * filename,
GHashTable * wallpapers,
GnomeThumbnailFactory * thumbnails) {
GnomeWPItem *item = g_new0 (GnomeWPItem, 1);
item->filename = gnome_vfs_unescape_string_for_display (filename);
item->fileinfo = gnome_wp_info_new (item->filename, thumbnails);
if (item->fileinfo != NULL &&
(g_str_has_prefix (item->fileinfo->mime_type, "image/") ||
strcmp (item->fileinfo->mime_type, "application/xml") == 0)) {
if (item->name == NULL) {
if (g_utf8_validate (item->fileinfo->name, -1, NULL))
item->name = g_strdup (item->fileinfo->name);
else
item->name = g_filename_to_utf8 (item->fileinfo->name, -1, NULL,
NULL, NULL);
}
gnome_wp_item_update (item);
gnome_wp_item_update_description (item);
gnome_wp_item_ensure_gnome_bg (item);
g_hash_table_insert (wallpapers, item->filename, item);
} else {
@ -134,12 +147,6 @@ GnomeWPItem * gnome_wp_item_new (const gchar * filename,
item = NULL;
}
if (item) {
gnome_wp_item_ensure_gnome_bg (item);
}
g_object_unref (client);
return item;
}

View file

@ -73,6 +73,7 @@ GnomeWPItem * gnome_wp_item_new (const gchar * filename,
void gnome_wp_item_free (GnomeWPItem * item);
GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item,
GnomeThumbnailFactory * thumbs);
void gnome_wp_item_update (GnomeWPItem * item);
void gnome_wp_item_update_description (GnomeWPItem * item);
void gnome_wp_item_ensure_gnome_bg (GnomeWPItem *item);

View file

@ -227,13 +227,11 @@ static void gnome_wp_xml_load_xml (AppearanceData *data,
gnome_wp_item_update_description (wp);
g_hash_table_insert (data->wp_hash, wp->filename, wp);
gnome_wp_item_ensure_gnome_bg (wp);
} else {
gnome_wp_item_free (wp);
wp = NULL;
}
if (wp)
gnome_wp_item_ensure_gnome_bg (wp);
}
}
xmlFreeDoc (wplist);