[xdg-desktop-portal-gnome/gbsneto/gnome-desktop-4] build: Depend on gnome-desktop-4




commit 1ec6e56de15c0eb664c25f49b7c6802236e037ee
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Dec 15 22:11:45 2021 -0300

    build: Depend on gnome-desktop-4
    
    We don't need to carry our (poorly) ported GnomeBG class
    anymore, since gnome-desktop itself now ships a GTK4 version
    of that.

 .gitlab-ci.yml            |    8 +
 src/gnome-bg-slide-show.c |  838 -----------------
 src/gnome-bg-slide-show.h |   92 --
 src/gnome-bg.c            | 2290 ---------------------------------------------
 src/gnome-bg.h            |  100 --
 src/meson.build           |    4 +-
 src/wallpaperpreview.c    |   22 +-
 7 files changed, 28 insertions(+), 3326 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6173459..961898a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -17,6 +17,10 @@ build-fedora:
   before_script:
     - dnf install -y 'dnf-command(builddep)' meson git gtk4-devel sassc gsettings-desktop-schemas-devel
     - dnf builddep -y xdg-desktop-portal-gtk
+    - git clone https://gitlab.gnome.org/GNOME/gnome-desktop.git && \
+      cd gnome-desktop && \
+      meson . _build --prefix /usr && \
+      ninja -c _build install
 
 build-ubuntu:
   image: ubuntu:rolling
@@ -29,3 +33,7 @@ build-ubuntu:
     - apt-get update
     - apt-get install -y meson git libgtk-4-dev sassc
     - apt-get build-dep -y xdg-desktop-portal-gtk
+    - git clone https://gitlab.gnome.org/GNOME/gnome-desktop.git && \
+      cd gnome-desktop && \
+      meson . _build --prefix /usr && \
+      ninja -c _build install
diff --git a/src/meson.build b/src/meson.build
index e38787f..2492b32 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -76,6 +76,8 @@ deps = [
   dependency('gtk4', version: '>= 4.0'),
   dependency('gtk4-unix-print', version: '>= 4.0'),
   dependency('gsettings-desktop-schemas'),
+  dependency('gnome-desktop-4'),
+  dependency('gnome-bg-4'),
   libadwaita_dep,
   xdg_desktop_portal_dep,
 ]
@@ -92,8 +94,6 @@ sources = built_sources + files(
   'fc-monitor.c',
   'filechooser.c',
   'fdonotification.c',
-  'gnome-bg.c',
-  'gnome-bg-slide-show.c',
   'gnomescreencast.c',
   'lockdown.c',
   'print.c',
diff --git a/src/wallpaperpreview.c b/src/wallpaperpreview.c
index 6f3bcc9..55062f3 100644
--- a/src/wallpaperpreview.c
+++ b/src/wallpaperpreview.c
@@ -28,7 +28,9 @@
 #include <gio/gio.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
-#include "gnome-bg.h"
+
+#define GNOME_DESKTOP_USE_UNSTABLE_API
+#include <gnome-bg/gnome-bg.h>
 
 #include "wallpaperpreview.h"
 
@@ -41,6 +43,7 @@ struct _WallpaperPreview {
   GtkLabel *desktop_clock_label;
   GtkWidget *drawing_area;
 
+  GnomeDesktopThumbnailFactory *thumbnail_factory;
   GnomeBG *bg;
 
   GSettings *desktop_settings;
@@ -63,12 +66,20 @@ draw_preview_func (GtkDrawingArea *drawing_area,
                    gpointer        data)
 {
   WallpaperPreview *self = WALLPAPER_PREVIEW (data);
+  g_autoptr(GdkMonitor) monitor = NULL;
   g_autoptr(GdkPixbuf) pixbuf = NULL;
-  GtkNative *native;
+  GdkRectangle monitor_layout;
+  GdkDisplay *display;
+  GListModel *monitors;
+
+  display = gtk_widget_get_display (GTK_WIDGET (drawing_area));
+  monitors = gdk_display_get_monitors (display);
+  monitor = g_list_model_get_item (monitors, 0);
+  gdk_monitor_get_geometry (monitor, &monitor_layout);
 
-  native = gtk_widget_get_native (GTK_WIDGET (drawing_area));
   pixbuf = gnome_bg_create_thumbnail (self->bg,
-                                      gtk_native_get_surface (native),
+                                      self->thumbnail_factory,
+                                      &monitor_layout,
                                       width,
                                       height);
   gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
@@ -134,6 +145,7 @@ wallpaper_preview_finalize (GObject *object)
   WallpaperPreview *self = WALLPAPER_PREVIEW (object);
 
   g_clear_object (&self->desktop_settings);
+  g_clear_object (&self->thumbnail_factory);
 
   g_clear_pointer (&self->previous_time, g_date_time_unref);
 
@@ -164,6 +176,8 @@ wallpaper_preview_init (WallpaperPreview *self)
 
   self->bg = gnome_bg_new ();
   gnome_bg_set_placement (self->bg, G_DESKTOP_BACKGROUND_STYLE_ZOOM);
+
+  self->thumbnail_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]