[gnome-settings-daemon/wip/benzea/cleanups-and-small-fixes: 40/51] sound: Use G_DECLARE_FINAL_TYPE for GsdSoundManager



commit f7c4530764d4f7a2e66b923c09c5bfd0053bb7ac
Author: Benjamin Berg <bberg redhat com>
Date:   Wed Feb 20 18:24:14 2019 +0100

    sound: Use G_DECLARE_FINAL_TYPE for GsdSoundManager

 plugins/sound/gsd-sound-manager.c | 47 ++++++++++++++++++---------------------
 plugins/sound/gsd-sound-manager.h | 22 ++----------------
 2 files changed, 24 insertions(+), 45 deletions(-)
---
diff --git a/plugins/sound/gsd-sound-manager.c b/plugins/sound/gsd-sound-manager.c
index e1a38ce3..5fdb0625 100644
--- a/plugins/sound/gsd-sound-manager.c
+++ b/plugins/sound/gsd-sound-manager.c
@@ -37,10 +37,10 @@
 #include "gsd-sound-manager.h"
 #include "gnome-settings-profile.h"
 
-#define GSD_SOUND_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_SOUND_MANAGER, 
GsdSoundManagerPrivate))
-
-struct GsdSoundManagerPrivate
+struct _GsdSoundManager
 {
+        GObject    parent;
+
         GSettings *settings;
         GList     *monitors;
         guint      timeout;
@@ -178,7 +178,7 @@ static gboolean
 flush_cb (GsdSoundManager *manager)
 {
         flush_cache ();
-        manager->priv->timeout = 0;
+        manager->timeout = 0;
         return FALSE;
 }
 
@@ -186,13 +186,13 @@ static void
 trigger_flush (GsdSoundManager *manager)
 {
 
-        if (manager->priv->timeout)
-                g_source_remove (manager->priv->timeout);
+        if (manager->timeout)
+                g_source_remove (manager->timeout);
 
         /* We delay the flushing a bit so that we can coalesce
          * multiple changes into a single cache flush */
-        manager->priv->timeout = g_timeout_add (500, (GSourceFunc) flush_cb, manager);
-        g_source_set_name_by_id (manager->priv->timeout, "[gnome-settings-daemon] flush_cb");
+        manager->timeout = g_timeout_add (500, (GSourceFunc) flush_cb, manager);
+        g_source_set_name_by_id (manager->timeout, "[gnome-settings-daemon] flush_cb");
 }
 
 static void
@@ -206,8 +206,8 @@ settings_changed_cb (GSettings       *settings,
 static void
 register_config_callback (GsdSoundManager *manager)
 {
-       manager->priv->settings = g_settings_new ("org.gnome.desktop.sound");
-       g_signal_connect (G_OBJECT (manager->priv->settings), "changed",
+       manager->settings = g_settings_new ("org.gnome.desktop.sound");
+       g_signal_connect (G_OBJECT (manager->settings), "changed",
                          G_CALLBACK (settings_changed_cb), manager);
 }
 
@@ -240,7 +240,7 @@ register_directory_callback (GsdSoundManager *manager,
         if (m != NULL) {
                 g_signal_connect (m, "changed", G_CALLBACK (file_monitor_changed_cb), manager);
 
-                manager->priv->monitors = g_list_prepend (manager->priv->monitors, m);
+                manager->monitors = g_list_prepend (manager->monitors, m);
 
                 succ = TRUE;
         }
@@ -290,20 +290,20 @@ gsd_sound_manager_stop (GsdSoundManager *manager)
 {
         g_debug ("Stopping sound manager");
 
-        if (manager->priv->settings != NULL) {
-                g_object_unref (manager->priv->settings);
-                manager->priv->settings = NULL;
+        if (manager->settings != NULL) {
+                g_object_unref (manager->settings);
+                manager->settings = NULL;
         }
 
-        if (manager->priv->timeout) {
-                g_source_remove (manager->priv->timeout);
-                manager->priv->timeout = 0;
+        if (manager->timeout) {
+                g_source_remove (manager->timeout);
+                manager->timeout = 0;
         }
 
-        while (manager->priv->monitors) {
-                g_file_monitor_cancel (G_FILE_MONITOR (manager->priv->monitors->data));
-                g_object_unref (manager->priv->monitors->data);
-                manager->priv->monitors = g_list_delete_link (manager->priv->monitors, 
manager->priv->monitors);
+        while (manager->monitors) {
+                g_file_monitor_cancel (G_FILE_MONITOR (manager->monitors->data));
+                g_object_unref (manager->monitors->data);
+                manager->monitors = g_list_delete_link (manager->monitors, manager->monitors);
         }
 }
 
@@ -326,14 +326,11 @@ gsd_sound_manager_class_init (GsdSoundManagerClass *klass)
 
         object_class->dispose = gsd_sound_manager_dispose;
         object_class->finalize = gsd_sound_manager_finalize;
-
-        g_type_class_add_private (klass, sizeof (GsdSoundManagerPrivate));
 }
 
 static void
 gsd_sound_manager_init (GsdSoundManager *manager)
 {
-        manager->priv = GSD_SOUND_MANAGER_GET_PRIVATE (manager);
 }
 
 static void
@@ -346,7 +343,7 @@ gsd_sound_manager_finalize (GObject *object)
 
         sound_manager = GSD_SOUND_MANAGER (object);
 
-        g_return_if_fail (sound_manager->priv);
+        g_return_if_fail (sound_manager);
 
         G_OBJECT_CLASS (gsd_sound_manager_parent_class)->finalize (object);
 }
diff --git a/plugins/sound/gsd-sound-manager.h b/plugins/sound/gsd-sound-manager.h
index 7f14d7c0..de25e045 100644
--- a/plugins/sound/gsd-sound-manager.h
+++ b/plugins/sound/gsd-sound-manager.h
@@ -26,26 +26,8 @@
 G_BEGIN_DECLS
 
 #define GSD_TYPE_SOUND_MANAGER         (gsd_sound_manager_get_type ())
-#define GSD_SOUND_MANAGER(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_SOUND_MANAGER, 
GsdSoundManager))
-#define GSD_SOUND_MANAGER_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), GSD_TYPE_SOUND_MANAGER, 
GsdSoundManagerClass))
-#define GSD_IS_SOUND_MANAGER(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_SOUND_MANAGER))
-#define GSD_IS_SOUND_MANAGER_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_SOUND_MANAGER))
-#define GSD_SOUND_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_SOUND_MANAGER, 
GsdSoundManagerClass))
-
-typedef struct GsdSoundManagerPrivate GsdSoundManagerPrivate;
-
-typedef struct
-{
-        GObject parent;
-        GsdSoundManagerPrivate *priv;
-} GsdSoundManager;
-
-typedef struct
-{
-        GObjectClass parent_class;
-} GsdSoundManagerClass;
-
-GType gsd_sound_manager_get_type (void) G_GNUC_CONST;
+
+G_DECLARE_FINAL_TYPE (GsdSoundManager, gsd_sound_manager, GSD, SOUND_MANAGER, GObject)
 
 GsdSoundManager *gsd_sound_manager_new (void);
 gboolean gsd_sound_manager_start (GsdSoundManager *manager, GError **error);


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