[gnome-control-center/wip/jsparber/background: 9/28] background: add icon for with time changing wallpapers
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/jsparber/background: 9/28] background: add icon for with time changing wallpapers
- Date: Sat, 17 Feb 2018 19:42:16 +0000 (UTC)
commit 4471b20a4d19dfa257aba44b3f026c6e15328117
Author: Julian Sparber <julian sparber net>
Date: Sat Nov 11 23:57:35 2017 +0100
background: add icon for with time changing wallpapers
https://bugzilla.gnome.org/show_bug.cgi?id=788515
panels/background/cc-background-panel.c | 153 ++++++++++++++++++--------------
1 file changed, 87 insertions(+), 66 deletions(-)
---
diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c
index 8d4a09d29..8872f3706 100644
--- a/panels/background/cc-background-panel.c
+++ b/panels/background/cc-background-panel.c
@@ -57,7 +57,6 @@ struct _CcBackgroundPanel
CcBackgroundItem *current_background;
CcBackgroundStore *store;
- gint gallery_size;
GCancellable *copy_cancellable;
@@ -163,15 +162,93 @@ get_save_path (const char *filename)
NULL);
}
+static void
+add_slideshow_emblem (GdkPixbuf *pixbuf,
+ gint w,
+ gint h,
+ 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 GdkPixbuf*
+get_or_create_cached_pixbuf_with_size (CcBackgroundPanel *panel,
+ const gint width,
+ const gint height,
+ CcBackgroundItem *item)
+{
+ gint scale_factor;
+ GdkPixbuf *pixbuf;
+
+ pixbuf = g_object_get_data (G_OBJECT (item), "pixbuf");
+ if (pixbuf == NULL ||
+ gdk_pixbuf_get_width (pixbuf) != width ||
+ gdk_pixbuf_get_height (pixbuf) != height) {
+ scale_factor = gtk_widget_get_scale_factor (panel);
+ pixbuf = cc_background_item_get_frame_thumbnail (item,
+ panel->thumb_factory,
+ width,
+ height,
+ scale_factor,
+ -2, TRUE);
+ g_object_set_data_full (G_OBJECT (item), "pixbuf", pixbuf, g_object_unref);
+ }
+
+ return pixbuf;
+}
+
static GdkPixbuf*
get_or_create_cached_pixbuf (CcBackgroundPanel *panel,
GtkWidget *widget,
CcBackgroundItem *background)
{
- GtkAllocation allocation;
-
- //const gint preview_width = 310; //309
- //const gint preview_height = 174; //168
gint scale_factor;
GdkPixbuf *pixbuf;
const gint preview_width = gtk_widget_get_allocated_width (widget);
@@ -181,8 +258,6 @@ get_or_create_cached_pixbuf (CcBackgroundPanel *panel,
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,
panel->thumb_factory,
@@ -595,58 +670,6 @@ 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,
@@ -655,12 +678,11 @@ create_gallery_item (gpointer item,
CcBackgroundPanel *panel = user_data;
GtkWidget *flow;
GtkWidget *widget;
- GtkWidget *frame;
GdkPixbuf *pixbuf;
CcBackgroundItem *self = item;
gint scale_factor;
- const gint preview_width = 800;//panel->gallery_size;//309;
- const gint preview_height = 800 * 9 / 16; //panel->gallery_size * 9/16;//168;
+ const gint preview_width = 400;
+ const gint preview_height = 400 * 9 / 16;
scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (panel));
@@ -671,11 +693,11 @@ create_gallery_item (gpointer item,
scale_factor,
-2, TRUE);
- if (cc_background_item_changes_with_time (self)) {
+ /*if (cc_background_item_changes_with_time (self)) {
add_slideshow_emblem (pixbuf, scale_factor);
- }
+ }
+ */
widget = gtk_drawing_area_new ();
- gtk_widget_set_size_request (widget, 250, 250 * 9/16);
gtk_widget_set_hexpand(widget, TRUE);
gtk_widget_set_vexpand(widget, TRUE);
g_signal_connect (G_OBJECT (widget), "draw",
@@ -702,7 +724,6 @@ cc_background_panel_init (CcBackgroundPanel *panel)
/* Create wallpapers store */
panel->store = cc_background_store_new ();
- panel->gallery_size = 300;
panel->connection = g_application_get_dbus_connection (g_application_get_default ());
g_resources_register (cc_background_get_resource ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]