From f48054ccf1f5cbfa4700f5b369ce302d4e575153 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Tue, 14 Dec 2010 19:24:19 +0000 Subject: background: Show wallpaper size on startup When available. Remove the "px" from the size label. --- panels/background/bg-wallpapers-source.c | 2 +- panels/background/cc-background-panel.c | 4 ++-- panels/background/gnome-wp-item.c | 27 +++++++++++++++++---------- panels/background/gnome-wp-item.h | 2 +- panels/background/gnome-wp-xml.c | 2 +- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/panels/background/bg-wallpapers-source.c b/panels/background/bg-wallpapers-source.c index 035bf1c32..38f4f2156 100644 --- a/panels/background/bg-wallpapers-source.c +++ b/panels/background/bg-wallpapers-source.c @@ -179,7 +179,7 @@ load_wallpapers (gchar *key, pixbuf = gnome_wp_item_get_thumbnail (item, priv->thumb_factory, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT); - gnome_wp_item_update_size (item); + gnome_wp_item_update_size (item, NULL); gtk_list_store_set (store, &iter, 0, pixbuf, diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c index 195a40ef1..7e92cb937 100644 --- a/panels/background/cc-background-panel.c +++ b/panels/background/cc-background-panel.c @@ -337,7 +337,7 @@ update_preview (CcBackgroundPanelPrivate *priv, priv->current_background->shade_type = item->shade_type; gnome_wp_item_ensure_gnome_bg (priv->current_background); - gnome_wp_item_update_size (priv->current_background); + gnome_wp_item_update_size (priv->current_background, priv->thumb_factory); } @@ -750,7 +750,7 @@ cc_background_panel_init (CcBackgroundPanel *self) gnome_wp_item_update (priv->current_background); gnome_wp_item_ensure_gnome_bg (priv->current_background); - gnome_wp_item_update_size (priv->current_background); + gnome_wp_item_update_size (priv->current_background, priv->thumb_factory); update_preview (priv, NULL, TRUE); } diff --git a/panels/background/gnome-wp-item.c b/panels/background/gnome-wp-item.c index 07e3bb5f2..67c4d4374 100644 --- a/panels/background/gnome-wp-item.c +++ b/panels/background/gnome-wp-item.c @@ -173,7 +173,7 @@ GnomeWPItem * gnome_wp_item_new (const gchar * filename, gnome_wp_item_update (item); gnome_wp_item_ensure_gnome_bg (item); - gnome_wp_item_update_size (item); + gnome_wp_item_update_size (item, NULL); if (wallpapers) g_hash_table_insert (wallpapers, item->filename, item); @@ -275,22 +275,29 @@ GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item, return gnome_wp_item_get_frame_thumbnail (item, thumbs, width, height, -1); } -void gnome_wp_item_update_size (GnomeWPItem * item) { +void gnome_wp_item_update_size (GnomeWPItem * item, + GnomeDesktopThumbnailFactory * thumbs) { g_free (item->size); + item->size = NULL; if (!strcmp (item->filename, "(none)")) { item->size = g_strdup (item->name); } else { if (gnome_bg_has_multiple_sizes (item->bg)) item->size = g_strdup (_("multiple sizes")); - else if (item->width > 0 && item->height > 0) { - /* translators: 100 × 100px - * Note that this is not an "x", but U+00D7 MULTIPLICATION SIGN */ - item->size = g_strdup_printf (_("%d \303\227 %dpx"), - item->width, - item->height); - } else { - item->size = g_strdup (""); + else { + if (thumbs != NULL && (item->width <= 0 || item->height <= 0)) { + gnome_bg_get_image_size (item->bg, thumbs, 1, 1, &item->width, &item->height); + } + if (item->width > 0 && item->height > 0) { + /* translators: 100 × 100px + * Note that this is not an "x", but U+00D7 MULTIPLICATION SIGN */ + item->size = g_strdup_printf (_("%d \303\227 %d"), + item->width, + item->height); + } else { + item->size = g_strdup (""); + } } } } diff --git a/panels/background/gnome-wp-item.h b/panels/background/gnome-wp-item.h index 94820f465..33a148922 100644 --- a/panels/background/gnome-wp-item.h +++ b/panels/background/gnome-wp-item.h @@ -83,7 +83,7 @@ GdkPixbuf * gnome_wp_item_get_frame_thumbnail (GnomeWPItem *item, gint height, gint frame); void gnome_wp_item_update (GnomeWPItem *item); -void gnome_wp_item_update_size (GnomeWPItem *item); +void gnome_wp_item_update_size (GnomeWPItem *item, GnomeDesktopThumbnailFactory *thumbs); void gnome_wp_item_ensure_gnome_bg (GnomeWPItem *item); const gchar *wp_item_option_to_string (GDesktopBackgroundStyle type); diff --git a/panels/background/gnome-wp-xml.c b/panels/background/gnome-wp-xml.c index fef729a9b..f40770c19 100644 --- a/panels/background/gnome-wp-xml.c +++ b/panels/background/gnome-wp-xml.c @@ -231,7 +231,7 @@ static void gnome_wp_xml_load_xml (GnomeWpXml *data, } gnome_wp_item_ensure_gnome_bg (wp); - gnome_wp_item_update_size (wp); + gnome_wp_item_update_size (wp, NULL); g_hash_table_insert (data->wp_hash, wp->filename, wp); } else { gnome_wp_item_free (wp); -- cgit v1.2.1