[gnome-flashback] desktop-background: rename DesktopBackground to GfDesktopBackground



commit 0c203abb9a29b14de4b9d4e5d120bd31db054e02
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sun Sep 13 20:56:58 2015 +0300

    desktop-background: rename DesktopBackground to GfDesktopBackground

 gnome-flashback/flashback-application.c            |    6 +-
 .../libdesktop-background/gf-desktop-background.c  |  649 +++++++++++---------
 .../libdesktop-background/gf-desktop-background.h  |   28 +-
 3 files changed, 361 insertions(+), 322 deletions(-)
---
diff --git a/gnome-flashback/flashback-application.c b/gnome-flashback/flashback-application.c
index 3bde524..9babb72 100644
--- a/gnome-flashback/flashback-application.c
+++ b/gnome-flashback/flashback-application.c
@@ -46,7 +46,6 @@ struct _FlashbackApplication
   GtkCssProvider            *provider;
 
   GsdAutomountManager       *automount;
-  DesktopBackground         *background;
   FlashbackDisplayConfig    *config;
   FlashbackEndSessionDialog *dialog;
   FlashbackIdleMonitor      *idle_monitor;
@@ -54,6 +53,7 @@ struct _FlashbackApplication
   FlashbackScreencast       *screencast;
   FlashbackShell            *shell;
   GfBluetoothApplet         *bluetooth;
+  GfDesktopBackground       *background;
   GfPowerApplet             *power;
   GfScreenshot              *screenshot;
   GfSoundApplet             *sound;
@@ -137,7 +137,6 @@ settings_changed (GSettings   *settings,
     }
 
   SETTING_CHANGED (automount, "automount-manager", gsd_automount_manager_new)
-  SETTING_CHANGED (background, "desktop-background", desktop_background_new)
   SETTING_CHANGED (config, "display-config", flashback_display_config_new)
   SETTING_CHANGED (idle_monitor, "idle-monitor", flashback_idle_monitor_new)
   SETTING_CHANGED (dialog, "end-session-dialog", flashback_end_session_dialog_new)
@@ -145,6 +144,7 @@ settings_changed (GSettings   *settings,
   SETTING_CHANGED (screencast, "screencast", flashback_screencast_new)
   SETTING_CHANGED (shell, "shell", flashback_shell_new)
   SETTING_CHANGED (bluetooth, "bluetooth-applet", gf_bluetooth_applet_new)
+  SETTING_CHANGED (background, "desktop-background", gf_desktop_background_new)
   SETTING_CHANGED (power, "power-applet", gf_power_applet_new)
   SETTING_CHANGED (screenshot, "screenshot", gf_screenshot_new)
   SETTING_CHANGED (sound, "sound-applet", gf_sound_applet_new)
@@ -174,7 +174,6 @@ flashback_application_finalize (GObject *object)
   remove_style_provider (application, gdk_screen_get_default ());
 
   g_clear_object (&application->automount);
-  g_clear_object (&application->background);
   g_clear_object (&application->config);
   g_clear_object (&application->dialog);
   g_clear_object (&application->idle_monitor);
@@ -182,6 +181,7 @@ flashback_application_finalize (GObject *object)
   g_clear_object (&application->screencast);
   g_clear_object (&application->shell);
   g_clear_object (&application->bluetooth);
+  g_clear_object (&application->background);
   g_clear_object (&application->power);
   g_clear_object (&application->screenshot);
   g_clear_object (&application->sound);
diff --git a/gnome-flashback/libdesktop-background/gf-desktop-background.c 
b/gnome-flashback/libdesktop-background/gf-desktop-background.c
index 8f6adca..f29064a 100644
--- a/gnome-flashback/libdesktop-background/gf-desktop-background.c
+++ b/gnome-flashback/libdesktop-background/gf-desktop-background.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Alberts Muktupāvels
+ * Copyright (C) 2014 - 2015 Alberts Muktupāvels
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -15,138 +15,164 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <gtk/gtk.h>
+#include "config.h"
+
 #include <gdk/gdkx.h>
-#include <X11/Xatom.h>
+#include <gtk/gtk.h>
 #include <libgnome-desktop/gnome-bg.h>
+#include <X11/Xatom.h>
 
-#include "gf-desktop-window.h"
 #include "gf-desktop-background.h"
+#include "gf-desktop-window.h"
 
-struct _DesktopBackgroundPrivate {
-       GnomeBG          *bg;
-       GnomeBGCrossfade *fade;
+#define DESKTOP_BG "org.gnome.desktop.background"
+#define GNOME_FLASHBACK_BG "org.gnome.gnome-flashback.desktop-background"
 
-       GSettings        *gnome_settings;
-       GSettings        *background_settings;
+struct _GfDesktopBackground
+{
+  GObject           parent;
+
+  GnomeBG          *bg;
+  GnomeBGCrossfade *fade;
 
-       GtkWidget        *background;
+  GSettings        *gnome_settings;
+  GSettings        *background_settings;
 
-       cairo_surface_t  *surface;
-       int               width;
-       int               height;
+  GtkWidget        *background;
 
-       guint             change_idle_id;
+  cairo_surface_t  *surface;
+  gint              width;
+  gint              height;
+
+  guint             change_idle_id;
 };
 
-G_DEFINE_TYPE_WITH_PRIVATE (DesktopBackground, desktop_background, G_TYPE_OBJECT);
+G_DEFINE_TYPE (GfDesktopBackground, gf_desktop_background, G_TYPE_OBJECT)
 
 static gboolean
 is_nautilus_desktop_manager (void)
 {
-       GdkDisplay *display;
-       GdkScreen  *screen;
-       gchar      *name;
-       Atom        atom;
-       Window      window;
+  GdkDisplay *display;
+  Display *xdisplay;
+  GdkScreen *screen;
+  gint screen_number;
+  gchar *name;
+  Atom atom;
+  Window window;
 
-       display = gdk_display_get_default ();
-       screen = gdk_display_get_default_screen (display);
+  display = gdk_display_get_default ();
+  xdisplay = GDK_DISPLAY_XDISPLAY (display);
+  screen = gdk_display_get_default_screen (display);
+  screen_number = gdk_screen_get_number (screen);
 
-       name = g_strdup_printf ("_NET_DESKTOP_MANAGER_S%d", gdk_screen_get_number (screen));
-       atom = XInternAtom (GDK_DISPLAY_XDISPLAY (display), name, FALSE);
-       g_free (name);
+  name = g_strdup_printf ("_NET_DESKTOP_MANAGER_S%d", screen_number);
+  atom = XInternAtom (xdisplay, name, False);
+  g_free (name);
 
-       window = XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display), atom);
+  window = XGetSelectionOwner (xdisplay, atom);
 
-       if (window != None)
-               return TRUE;
+  if (window != None)
+    return TRUE;
 
-       return FALSE;
+  return FALSE;
 }
 
 static gboolean
 is_desktop_window (Display *display,
                    Window   window)
 {
-       Atom           type;
-       Atom          *atoms;
-       int            result;
-       int            format;
-       unsigned long  items;
-       unsigned long  left;
-       unsigned char *data;
-
-       result = XGetWindowProperty (display, window,
-                                    XInternAtom (display, "_NET_WM_WINDOW_TYPE", False),
-                                    0L, 1L, False, XA_ATOM, &type, &format,
-                                    &items, &left, &data);
-
-       if (result != Success)
-               return FALSE;
-
-       atoms = (Atom *) data;
-
-       if (items && atoms[0] == XInternAtom (display, "_NET_WM_WINDOW_TYPE_DESKTOP", False)) {
-               XFree (data);
-               return TRUE;
-       }
-
-       XFree (data);
-       return FALSE;
+  Atom window_type;
+  Atom desktop;
+  Atom type;
+  Atom *atoms;
+  int result;
+  int format;
+  unsigned long items;
+  unsigned long left;
+  unsigned char *data;
+
+  window_type = XInternAtom (display, "_NET_WM_WINDOW_TYPE", False);
+  desktop = XInternAtom (display, "_NET_WM_WINDOW_TYPE_DESKTOP", False);
+
+  result = XGetWindowProperty (display, window, window_type,
+                               0L, 1L, False, XA_ATOM, &type, &format,
+                               &items, &left, &data);
+
+  if (result != Success)
+    return FALSE;
+
+  atoms = (Atom *) data;
+
+  if (items && atoms[0] == desktop)
+    {
+      XFree (data);
+      return TRUE;
+    }
+
+  XFree (data);
+  return FALSE;
 }
 
 static GdkWindow *
-get_nautilus_window (DesktopBackground *background)
+get_nautilus_window (GfDesktopBackground *background)
 {
-       GdkDisplay    *display;
-       GdkWindow     *window;
-       Display       *xdisplay;
-       Atom           type;
-       int            result;
-       int            format;
-       unsigned long  items;
-       unsigned long  left;
-       unsigned char *list;
-       unsigned long  i;
-       Window        *windows;
-       Window         nautilus;
-       Window         desktop;
-
-       gdk_error_trap_push ();
-
-       display = gdk_display_get_default ();
-       xdisplay = GDK_DISPLAY_XDISPLAY (display);
-       result = XGetWindowProperty (xdisplay, XDefaultRootWindow (xdisplay),
-                                    XInternAtom (xdisplay, "_NET_CLIENT_LIST", False),
-                                    0L, 1024L, False, XA_WINDOW, &type, &format,
-                                    &items, &left, &list);
-
-       if (result != Success) {
-               gdk_error_trap_pop_ignored ();
-               return NULL;
-       }
-
-       nautilus = None;
-       desktop = GDK_WINDOW_XID (gtk_widget_get_window (background->priv->background));
-       windows = (Window *) list;
-       for     (i = 0; i < items; i++) {
-               if (is_desktop_window (xdisplay, windows[i]) && windows[i] != desktop) {
-                       nautilus = windows[i];
-                       break;
-               }
-       }
-
-       XFree (list);
-
-       window = NULL;
-       if (nautilus != None) {
-               window = gdk_x11_window_foreign_new_for_display (display, nautilus);
-       }
-
-       gdk_error_trap_pop_ignored ();
-
-       return window;
+  GdkDisplay *display;
+  GdkWindow *window;
+  Display *xdisplay;
+  Atom client_list;
+  Window root;
+  Atom type;
+  int result;
+  int format;
+  unsigned long items;
+  unsigned long left;
+  unsigned char *list;
+  unsigned long i;
+  Window *windows;
+  Window nautilus;
+  GdkWindow *background_window;
+  Window desktop;
+
+  gdk_error_trap_push ();
+
+  display = gdk_display_get_default ();
+  xdisplay = GDK_DISPLAY_XDISPLAY (display);
+  client_list = XInternAtom (xdisplay, "_NET_CLIENT_LIST", False);
+  root = XDefaultRootWindow (xdisplay);
+
+  result = XGetWindowProperty (xdisplay, root, client_list,
+                               0L, 1024L, False, XA_WINDOW, &type, &format,
+                               &items, &left, &list);
+
+  if (result != Success)
+    {
+      gdk_error_trap_pop_ignored ();
+      return NULL;
+    }
+
+  nautilus = None;
+  background_window = gtk_widget_get_window (background->background);
+  desktop = GDK_WINDOW_XID (background_window);
+  windows = (Window *) list;
+
+  for (i = 0; i < items; i++)
+    {
+      if (is_desktop_window (xdisplay, windows[i]) && windows[i] != desktop)
+        {
+          nautilus = windows[i];
+          break;
+        }
+    }
+
+  XFree (list);
+
+  window = NULL;
+  if (nautilus != None)
+    window = gdk_x11_window_foreign_new_for_display (display, nautilus);
+
+  gdk_error_trap_pop_ignored ();
+
+  return window;
 }
 
 static GdkFilterReturn
@@ -154,112 +180,135 @@ event_filter_func (GdkXEvent *xevent,
                    GdkEvent  *event,
                    gpointer   data)
 {
-       DesktopBackground *background = DESKTOP_BACKGROUND (data);
-       static gboolean nautilus_raised = FALSE;
-
-       if (is_nautilus_desktop_manager ()) {
-               if (nautilus_raised == FALSE) {
-                       GdkWindow *nautilus = get_nautilus_window (background);
-
-                       if (GDK_IS_WINDOW (nautilus)) {
-                               gdk_window_hide (nautilus);
-                               gdk_window_show (nautilus);
-
-                               nautilus_raised = TRUE;
-                       }
-               }
-       } else {
-               nautilus_raised = FALSE;
-       }
-
-       return GDK_FILTER_CONTINUE;
+  static gboolean nautilus_raised = FALSE;
+  GfDesktopBackground *background;
+
+  background = GF_DESKTOP_BACKGROUND (data);
+
+  if (is_nautilus_desktop_manager ())
+    {
+      if (nautilus_raised == FALSE)
+        {
+          GdkWindow *nautilus;
+
+          nautilus = get_nautilus_window (background);
+
+          if (GDK_IS_WINDOW (nautilus))
+            {
+              gdk_window_hide (nautilus);
+              gdk_window_show (nautilus);
+
+              nautilus_raised = TRUE;
+            }
+        }
+    }
+  else
+    {
+      nautilus_raised = FALSE;
+    }
+
+  return GDK_FILTER_CONTINUE;
 }
 
 static void
-free_fade (DesktopBackground *background)
+free_fade (GfDesktopBackground *background)
 {
-       g_clear_object (&background->priv->fade);
+  g_clear_object (&background->fade);
 }
 
 static void
-free_surface (DesktopBackground *background)
+free_surface (GfDesktopBackground *background)
 {
-       if (background->priv->surface != NULL) {
-               cairo_surface_destroy (background->priv->surface);
-               background->priv->surface = NULL;
-       }
+  if (background->surface == NULL)
+    return;
+
+  cairo_surface_destroy (background->surface);
+  background->surface = NULL;
 }
 
 static void
-background_unrealize (DesktopBackground *background)
+background_unrealize (GfDesktopBackground *background)
 {
-       free_surface (background);
+  free_surface (background);
 
-       background->priv->width = 0;
-       background->priv->height = 0;
+  background->width = 0;
+  background->height = 0;
 }
 
 static void
-init_fade (DesktopBackground *background)
+init_fade (GfDesktopBackground *background)
 {
-       DesktopBackgroundPrivate *priv;
-       gboolean                  fade;
-       GdkScreen                *screen;
-
-       priv = background->priv;
-       fade = g_settings_get_boolean (priv->background_settings, "fade");
-       screen = gdk_screen_get_default ();
-
-       if (!fade)
-               return;
-
-       if (priv->fade == NULL) {
-               GdkWindow *window = gtk_widget_get_window (priv->background);
-               int width = gdk_screen_get_width (screen);
-               int height = gdk_screen_get_height (screen);
-
-               if (width == gdk_window_get_width (window) && height == gdk_window_get_height (window)) {
-                       priv->fade = gnome_bg_crossfade_new (width, height);
-                       g_signal_connect_swapped (priv->fade, "finished", G_CALLBACK (free_fade), background);
-               }
-       }
-
-       if (priv->fade != NULL && !gnome_bg_crossfade_is_started (priv->fade)) {
-               cairo_surface_t *surface;
-
-               if (priv->surface == NULL) {
-                       surface = gnome_bg_get_surface_from_root (screen);
-               } else {
-                       surface = cairo_surface_reference (priv->surface);
-               }
-
-               gnome_bg_crossfade_set_start_surface (priv->fade, surface);
-               cairo_surface_destroy (surface);
-       }
+  GdkScreen *screen;
+  gboolean fade;
+
+  screen = gdk_screen_get_default ();
+  fade = g_settings_get_boolean (background->background_settings, "fade");
+
+  if (!fade)
+    return;
+
+  if (background->fade == NULL)
+    {
+      GdkWindow *window;
+      gint window_width;
+      gint window_height;
+      gint screen_width;
+      gint screen_height;
+
+      window = gtk_widget_get_window (background->background);
+      window_width = gdk_window_get_width (window);
+      window_height = gdk_window_get_height (window);
+      screen_width = gdk_screen_get_width (screen);
+      screen_height = gdk_screen_get_height (screen);
+
+      if (window_width == screen_width && window_height == screen_height)
+        {
+          background->fade = gnome_bg_crossfade_new (window_width,
+                                                     window_height);
+
+          g_signal_connect_swapped (background->fade, "finished",
+                                    G_CALLBACK (free_fade), background);
+        }
+    }
+
+  if (background->fade != NULL &&
+      !gnome_bg_crossfade_is_started (background->fade))
+    {
+      cairo_surface_t *surface;
+
+      if (background->surface == NULL)
+        surface = gnome_bg_get_surface_from_root (screen);
+      else
+        surface = cairo_surface_reference (background->surface);
+
+      gnome_bg_crossfade_set_start_surface (background->fade, surface);
+      cairo_surface_destroy (surface);
+    }
 }
 
 static void
-background_ensure_realized (DesktopBackground *bg)
+background_ensure_realized (GfDesktopBackground *background)
 {
-       int        width;
-       int        height;
-       GdkScreen *screen;
-       GdkWindow *window;
+  GdkScreen *screen;
+  gint width;
+  gint height;
+  GdkWindow *window;
 
-       screen = gdk_screen_get_default ();
-       height = gdk_screen_get_height (screen);
-       width = gdk_screen_get_width (screen);
+  screen = gdk_screen_get_default ();
+  width = gdk_screen_get_width (screen);
+  height = gdk_screen_get_height (screen);
+  window = gtk_widget_get_window (background->background);
 
-       if (width == bg->priv->width && height == bg->priv->height)
-               return;
+  if (width == background->width && height == background->height)
+    return;
 
-       free_surface (bg);
+  free_surface (background);
 
-       window = gtk_widget_get_window (bg->priv->background);
-       bg->priv->surface = gnome_bg_create_surface (bg->priv->bg, window, width, height, TRUE);
+  background->surface = gnome_bg_create_surface (background->bg, window,
+                                                 width, height, TRUE);
 
-       bg->priv->width = width;
-       bg->priv->height = height;
+  background->width = width;
+  background->height = height;
 }
 
 static void
@@ -267,112 +316,115 @@ on_fade_finished (GnomeBGCrossfade *fade,
                   GdkWindow        *window,
                   gpointer          user_data)
 {
-    DesktopBackground        *background;
-    DesktopBackgroundPrivate *priv;
+  GfDesktopBackground *background;
+  GdkScreen *screen;
 
-       background = DESKTOP_BACKGROUND (user_data);
-       priv = background->priv;
+  background = GF_DESKTOP_BACKGROUND (user_data);
+  screen = gdk_window_get_screen (window);
 
-       background_ensure_realized (background);
+  background_ensure_realized (background);
 
-       if (priv->surface != NULL)
-               gnome_bg_set_surface_as_root (gdk_window_get_screen (window), priv->surface);
+  if (background->surface != NULL)
+    gnome_bg_set_surface_as_root (screen, background->surface);
 }
 
 static gboolean
-fade_to_surface (DesktopBackground *background,
-                 GdkWindow         *window,
-                 cairo_surface_t   *surface)
+fade_to_surface (GfDesktopBackground *background,
+                 GdkWindow           *window,
+                 cairo_surface_t     *surface)
 {
-       DesktopBackgroundPrivate *priv;
+  if (background->fade == NULL)
+    return FALSE;
 
-       priv = background->priv;
+  if (!gnome_bg_crossfade_set_end_surface (background->fade, surface))
+    return FALSE;
 
-       if (priv->fade == NULL || !gnome_bg_crossfade_set_end_surface (priv->fade, surface))
-               return FALSE;
+  if (!gnome_bg_crossfade_is_started (background->fade))
+    {
+      gnome_bg_crossfade_start (background->fade, window);
 
-       if (!gnome_bg_crossfade_is_started (priv->fade)) {
-               gnome_bg_crossfade_start (priv->fade, window);
-               g_signal_connect (priv->fade, "finished", G_CALLBACK (on_fade_finished), background);
-       }
+      g_signal_connect (background->fade, "finished",
+                        G_CALLBACK (on_fade_finished), background);
+    }
 
-       return gnome_bg_crossfade_is_started (priv->fade);
+       return gnome_bg_crossfade_is_started (background->fade);
 }
 
 static void
-background_set_up (DesktopBackground *background)
+background_set_up (GfDesktopBackground *background)
 {
-       DesktopBackgroundPrivate *priv;
-       GdkWindow                *window;
+  GdkWindow *window;
 
-       priv = background->priv;
+  background_ensure_realized (background);
 
-       background_ensure_realized (background);
+  if (background->surface == NULL)
+    return;
 
-       if (priv->surface == NULL)
-               return;
+  window = gtk_widget_get_window (background->background);
 
-       window = gtk_widget_get_window (priv->background);
+  if (!fade_to_surface (background, window, background->surface))
+    {
+      GdkScreen *screen;
+      cairo_pattern_t *pattern;
 
-       if (!fade_to_surface (background, window, priv->surface)) {
-               cairo_pattern_t *pattern;
+      screen = gdk_screen_get_default ();
+      pattern = cairo_pattern_create_for_surface (background->surface);
 
-               pattern = cairo_pattern_create_for_surface (priv->surface);
-               gdk_window_set_background_pattern (window, pattern);
-               cairo_pattern_destroy (pattern);
+      gdk_window_set_background_pattern (window, pattern);
+      cairo_pattern_destroy (pattern);
 
-               gnome_bg_set_surface_as_root (gdk_screen_get_default (), priv->surface);
-       }
+      gnome_bg_set_surface_as_root (screen, background->surface);
+    }
 }
 
 static gboolean
 background_changed_cb (gpointer user_data)
 {
-       DesktopBackground *background = DESKTOP_BACKGROUND (user_data);
+  GfDesktopBackground *background;
 
-       background->priv->change_idle_id = 0;
+  background = GF_DESKTOP_BACKGROUND (user_data);
 
-       background_unrealize (background);
-       background_set_up (background);
+  background_unrealize (background);
+  background_set_up (background);
 
-       gtk_widget_show (background->priv->background);
-       gtk_widget_queue_draw (background->priv->background);
+  gtk_widget_show (background->background);
+  gtk_widget_queue_draw (background->background);
 
-       return G_SOURCE_REMOVE;
+  background->change_idle_id = 0;
+  return G_SOURCE_REMOVE;
 }
 
 static void
-queue_background_change (DesktopBackground *background)
+queue_background_change (GfDesktopBackground *background)
 {
-       DesktopBackgroundPrivate *priv;
-
-       priv = background->priv;
+  if (background->change_idle_id != 0)
+    g_source_remove (background->change_idle_id);
 
-       if (priv->change_idle_id != 0) {
-               g_source_remove (priv->change_idle_id);
-       }
-
-       priv->change_idle_id = g_idle_add (background_changed_cb, background);
+  background->change_idle_id = g_idle_add (background_changed_cb, background);
 }
 
 static void
 desktop_background_changed (GnomeBG  *bg,
                             gpointer  user_data)
 {
-       DesktopBackground *background = DESKTOP_BACKGROUND (user_data);
+  GfDesktopBackground *background;
+
+  background = GF_DESKTOP_BACKGROUND (user_data);
 
-       init_fade (background);
-       queue_background_change (background);
+  init_fade (background);
+  queue_background_change (background);
 }
 
 static void
 desktop_background_transitioned (GnomeBG  *bg,
                                  gpointer  user_data)
 {
-       DesktopBackground *background = DESKTOP_BACKGROUND (user_data);
+  GfDesktopBackground *background;
 
-       init_fade (background);
-       queue_background_change (background);
+  background = GF_DESKTOP_BACKGROUND (user_data);
+
+  init_fade (background);
+  queue_background_change (background);
 }
 
 static gboolean
@@ -381,11 +433,13 @@ desktop_background_change_event (GSettings *settings,
                                  gint       n_keys,
                                  gpointer   user_data)
 {
-       DesktopBackground *background = DESKTOP_BACKGROUND (user_data);
+  GfDesktopBackground *background;
+
+  background = GF_DESKTOP_BACKGROUND (user_data);
 
-       gnome_bg_load_from_preferences (background->priv->bg, background->priv->gnome_settings);
+  gnome_bg_load_from_preferences (background->bg, background->gnome_settings);
 
-       return TRUE;
+  return TRUE;
 }
 
 static void
@@ -393,91 +447,90 @@ size_allocate (GtkWidget     *widget,
                GtkAllocation *allocation,
                gpointer       user_data)
 {
-       DesktopBackground *background = DESKTOP_BACKGROUND (user_data);
-       DesktopBackgroundPrivate *priv = background->priv;
+  GfDesktopBackground *background;
+
+  background = GF_DESKTOP_BACKGROUND (user_data);
 
-       if (priv->width == allocation->width && priv->height == allocation->height) {
-               GdkWindow *window;
-               cairo_pattern_t *pattern;
+  if (background->width == allocation->width &&
+      background->height == allocation->height)
+    {
+      GdkWindow *window;
+      cairo_pattern_t *pattern;
 
-               window = gtk_widget_get_window (priv->background);
-               pattern = cairo_pattern_create_for_surface (priv->surface);
+      window = gtk_widget_get_window (background->background);
+      pattern = cairo_pattern_create_for_surface (background->surface);
 
-               gdk_window_set_background_pattern (window, pattern);
-               cairo_pattern_destroy (pattern);
+      gdk_window_set_background_pattern (window, pattern);
+      cairo_pattern_destroy (pattern);
 
-               return;
-       }
+      return;
+    }
 
-       queue_background_change (user_data);
+  queue_background_change (background);
 }
 
 static void
-desktop_background_finalize (GObject *object)
+gf_desktop_background_finalize (GObject *object)
 {
-       DesktopBackground        *background;
-       DesktopBackgroundPrivate *priv;
+  GfDesktopBackground *background;
 
-       background = DESKTOP_BACKGROUND (object);
-       priv = background->priv;
+  background = GF_DESKTOP_BACKGROUND (object);
 
-       g_signal_handlers_disconnect_by_func (priv->gnome_settings,
-                                             desktop_background_change_event,
-                                             background);
+  g_signal_handlers_disconnect_by_func (background->gnome_settings,
+                                        desktop_background_change_event,
+                                        background);
 
-       g_clear_object (&priv->bg);
-       g_clear_object (&priv->gnome_settings);
+  g_clear_object (&background->bg);
+  g_clear_object (&background->gnome_settings);
 
-       free_surface (background);
-       free_fade (background);
+  free_surface (background);
+  free_fade (background);
 
-       g_clear_object (&priv->gnome_settings);
-       g_clear_object (&priv->background_settings);
+  g_clear_object (&background->gnome_settings);
+  g_clear_object (&background->background_settings);
 
-       gdk_window_remove_filter (NULL, event_filter_func, background);
+  gdk_window_remove_filter (NULL, event_filter_func, background);
 
-       G_OBJECT_CLASS (desktop_background_parent_class)->finalize (object);
+  G_OBJECT_CLASS (gf_desktop_background_parent_class)->finalize (object);
 }
 
 static void
-desktop_background_init (DesktopBackground *background)
+gf_desktop_background_class_init (GfDesktopBackgroundClass *background_class)
 {
-       DesktopBackgroundPrivate *priv;
+  GObjectClass *object_class;
 
-       priv = background->priv = desktop_background_get_instance_private (background);
+  object_class = G_OBJECT_CLASS (background_class);
 
-       priv->bg = gnome_bg_new ();
-       priv->gnome_settings = g_settings_new ("org.gnome.desktop.background");
-       priv->background_settings = g_settings_new ("org.gnome.gnome-flashback.desktop-background");
+  object_class->finalize = gf_desktop_background_finalize;
+}
 
-       g_signal_connect (priv->bg, "changed",
-                         G_CALLBACK (desktop_background_changed), background);
-       g_signal_connect (priv->bg, "transitioned",
-                         G_CALLBACK (desktop_background_transitioned), background);
+static void
+gf_desktop_background_init (GfDesktopBackground *background)
+{
+  background->bg = gnome_bg_new ();
+  background->gnome_settings = g_settings_new (DESKTOP_BG);
+  background->background_settings = g_settings_new (GNOME_FLASHBACK_BG);
 
-       g_signal_connect (priv->gnome_settings, "change-event",
-                         G_CALLBACK (desktop_background_change_event), background);
-       gnome_bg_load_from_preferences (priv->bg, priv->gnome_settings);
+  g_signal_connect (background->bg, "changed",
+                    G_CALLBACK (desktop_background_changed), background);
+  g_signal_connect (background->bg, "transitioned",
+                    G_CALLBACK (desktop_background_transitioned), background);
 
-       priv->background = gf_desktop_window_new ();
-       g_signal_connect (priv->background, "size-allocate",
-                         G_CALLBACK (size_allocate), background);
+  g_signal_connect (background->gnome_settings, "change-event",
+                    G_CALLBACK (desktop_background_change_event), background);
+  gnome_bg_load_from_preferences (background->bg, background->gnome_settings);
 
-       queue_background_change (background);
+  background->background = gf_desktop_window_new ();
+  g_signal_connect (background->background, "size-allocate",
+                    G_CALLBACK (size_allocate), background);
 
-       gdk_window_add_filter (NULL, event_filter_func, background);
-}
-
-static void
-desktop_background_class_init (DesktopBackgroundClass *class)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (class);
+  queue_background_change (background);
 
-       object_class->finalize = desktop_background_finalize;
+  gdk_window_add_filter (NULL, event_filter_func, background);
 }
 
-DesktopBackground *
-desktop_background_new (void)
+GfDesktopBackground *
+gf_desktop_background_new (void)
 {
-       return DESKTOP_BACKGROUND (g_object_new (DESKTOP_BACKGROUND_TYPE, NULL));
+  return g_object_new (GF_TYPE_DESKTOP_BACKGROUND, NULL);
 }
diff --git a/gnome-flashback/libdesktop-background/gf-desktop-background.h 
b/gnome-flashback/libdesktop-background/gf-desktop-background.h
index bb763d9..97a7c1e 100644
--- a/gnome-flashback/libdesktop-background/gf-desktop-background.h
+++ b/gnome-flashback/libdesktop-background/gf-desktop-background.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Alberts Muktupāvels
+ * Copyright (C) 2014 - 2015 Alberts Muktupāvels
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -15,32 +15,18 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef DESKTOP_BACKGROUND_H
-#define DESKTOP_BACKGROUND_H
+#ifndef GF_DESKTOP_BACKGROUND_H
+#define GF_DESKTOP_BACKGROUND_H
 
 #include <glib-object.h>
 
 G_BEGIN_DECLS
 
-#define DESKTOP_BACKGROUND_TYPE     (desktop_background_get_type ())
-#define DESKTOP_BACKGROUND(o)       (G_TYPE_CHECK_INSTANCE_CAST ((o), DESKTOP_BACKGROUND_TYPE, 
DesktopBackground))
-#define DESKTOP_BACKGROUND_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), DESKTOP_BACKGROUND_TYPE, 
DesktopBackgroundClass))
+#define GF_TYPE_DESKTOP_BACKGROUND gf_desktop_background_get_type ()
+G_DECLARE_FINAL_TYPE (GfDesktopBackground, gf_desktop_background,
+                      GF, DESKTOP_BACKGROUND, GObject)
 
-typedef struct _DesktopBackground        DesktopBackground;
-typedef struct _DesktopBackgroundClass   DesktopBackgroundClass;
-typedef struct _DesktopBackgroundPrivate DesktopBackgroundPrivate;
-
-struct _DesktopBackground {
-       GObject                   parent;
-       DesktopBackgroundPrivate *priv;
-};
-
-struct _DesktopBackgroundClass {
-    GObjectClass parent_class;
-};
-
-GType              desktop_background_get_type (void);
-DesktopBackground *desktop_background_new      (void);
+GfDesktopBackground *gf_desktop_background_new (void);
 
 G_END_DECLS
 


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