[gnome-control-center/wip/jsparber/background: 10/40] background: add slide icon to time changing wallpapers
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/jsparber/background: 10/40] background: add slide icon to time changing wallpapers
- Date: Tue, 6 Feb 2018 19:18:46 +0000 (UTC)
commit dbddcdcf5d4242b3c165187d1c9d5a262d2bc909
Author: Julian Sparber <julian sparber net>
Date: Wed Nov 8 19:23:01 2017 +0100
background: add slide icon to time changing wallpapers
https://bugzilla.gnome.org/show_bug.cgi?id=788515
panels/background/cc-background-panel.c | 64 ++++++++++++++++++++++++++++++-
1 files changed, 62 insertions(+), 2 deletions(-)
---
diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c
index 2e19006..7c547fd 100644
--- a/panels/background/cc-background-panel.c
+++ b/panels/background/cc-background-panel.c
@@ -198,8 +198,10 @@ get_or_create_cached_pixbuf (CcBackgroundPanel *panel,
const gint preview_height = gtk_widget_get_allocated_height (widget);
pixbuf = g_object_get_data (G_OBJECT (background), "pixbuf");
- if (pixbuf == NULL)
- {
+ if (pixbuf == NULL ||
+ gdk_pixbuf_get_width (pixbuf) != preview_width ||
+ gdk_pixbuf_get_height (pixbuf) != preview_height) {
+
gtk_widget_get_allocation (widget, &allocation);
scale_factor = gtk_widget_get_scale_factor (widget);
pixbuf = cc_background_item_get_frame_thumbnail (background,
@@ -208,6 +210,7 @@ get_or_create_cached_pixbuf (CcBackgroundPanel *panel,
preview_height,
scale_factor,
-2, TRUE);
+ g_object_set_data_full (G_OBJECT (background), "pixbuf", pixbuf, g_object_unref);
}
return pixbuf;
@@ -771,6 +774,59 @@ is_gnome_photos_installed ()
return TRUE;
}
+static void
+add_slideshow_emblem (GdkPixbuf *pixbuf,
+ gint scale_factor)
+{
+ GdkPixbuf *slideshow_emblem;
+ GIcon *icon = NULL;
+ GtkIconInfo *icon_info = NULL;
+ GError *error = NULL;
+ GtkIconTheme *theme;
+
+ int eh;
+ int ew;
+ int h;
+ int w;
+ int x;
+ int y;
+
+ icon = g_themed_icon_new ("slideshow-emblem");
+ theme = gtk_icon_theme_get_default ();
+ icon_info = gtk_icon_theme_lookup_by_gicon_for_scale (theme,
+ icon,
+ 16,
+ scale_factor,
+ GTK_ICON_LOOKUP_FORCE_SIZE |
+ GTK_ICON_LOOKUP_USE_BUILTIN);
+ if (icon_info == NULL) {
+ g_warning ("Your icon theme is missing the slideshow-emblem icon, "
+ "please file a bug against it");
+ }
+ else {
+
+ slideshow_emblem = gtk_icon_info_load_icon (icon_info, &error);
+ if (slideshow_emblem == NULL) {
+ g_warning ("Failed to load slideshow emblem: %s", error->message);
+ g_error_free (error);
+ }
+ else {
+ eh = gdk_pixbuf_get_height (slideshow_emblem);
+ ew = gdk_pixbuf_get_width (slideshow_emblem);
+ h = gdk_pixbuf_get_height (pixbuf);
+ w = gdk_pixbuf_get_width (pixbuf);
+ x = w - ew;
+ y = h - eh;
+
+ gdk_pixbuf_composite (slideshow_emblem, pixbuf, x, y, ew, eh, x, y, 1.0, 1.0, GDK_INTERP_BILINEAR,
255);
+ }
+ }
+
+ g_clear_object (&icon_info);
+ g_clear_object (&icon);
+}
+
+
static GtkWidget *
create_gallery_item (gpointer item,
gpointer user_data)
@@ -793,6 +849,10 @@ create_gallery_item (gpointer item,
scale_factor,
-2, TRUE);
+
+ if (cc_background_item_changes_with_time (self)) {
+ add_slideshow_emblem (pixbuf, scale_factor);
+ }
widget = gtk_image_new_from_pixbuf (pixbuf);
flow = cc_background_grid_item_new(self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]