[gnome-control-center/wip/jsparber/background: 5/28] 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: 5/28] background: add slide icon to time changing wallpapers
- Date: Sat, 17 Feb 2018 19:41:56 +0000 (UTC)
commit d321074dcb1d733b10f36cc3beca02672bae9feb
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 | 63 +++++++++++++++++++++++++++++++--
1 file changed, 61 insertions(+), 2 deletions(-)
---
diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c
index 995389e65..fc25f4b7a 100644
--- a/panels/background/cc-background-panel.c
+++ b/panels/background/cc-background-panel.c
@@ -177,8 +177,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,
@@ -576,6 +578,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 - 5;
+ y = h - eh - 5;
+
+ 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)
@@ -598,6 +653,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]