[gnome-flashback] sound-applet: pass GvcMixerControl to GvcStreamStatusIcon



commit 95715e2cc6572109bd368f7372ec898b33be2f2b
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Aug 16 17:10:47 2019 +0300

    sound-applet: pass GvcMixerControl to GvcStreamStatusIcon

 gnome-flashback/libsound-applet/gf-sound-applet.c  | 48 ++++++++--------------
 .../libsound-applet/gvc-stream-status-icon.c       | 39 +++++++++++++-----
 .../libsound-applet/gvc-stream-status-icon.h       |  3 +-
 3 files changed, 49 insertions(+), 41 deletions(-)
---
diff --git a/gnome-flashback/libsound-applet/gf-sound-applet.c 
b/gnome-flashback/libsound-applet/gf-sound-applet.c
index abd1728..1cb20bf 100644
--- a/gnome-flashback/libsound-applet/gf-sound-applet.c
+++ b/gnome-flashback/libsound-applet/gf-sound-applet.c
@@ -221,33 +221,6 @@ on_control_stream_removed (GvcMixerControl *control,
   maybe_show_status_icons (applet);
 }
 
-static void
-gf_sound_applet_constructed (GObject *object)
-{
-  GfSoundApplet *applet;
-
-  applet = GF_SOUND_APPLET (object);
-
-  G_OBJECT_CLASS (gf_sound_applet_parent_class)->constructed (object);
-
-  applet->control = gvc_mixer_control_new ("GNOME Volume Control Applet");
-
-  g_signal_connect (applet->control, "state-changed",
-                    G_CALLBACK (on_control_state_changed), applet);
-  g_signal_connect (applet->control, "default-sink-changed",
-                    G_CALLBACK (on_control_default_sink_changed), applet);
-  g_signal_connect (applet->control, "default-source-changed",
-                    G_CALLBACK (on_control_default_source_changed), applet);
-  g_signal_connect (applet->control, "stream-added",
-                    G_CALLBACK (on_control_stream_added), applet);
-  g_signal_connect (applet->control, "stream-removed",
-                    G_CALLBACK (on_control_stream_removed), applet);
-
-  gvc_mixer_control_open (applet->control);
-
-  maybe_show_status_icons (applet);
-}
-
 static void
 gf_sound_applet_dispose (GObject *object)
 {
@@ -269,7 +242,6 @@ gf_sound_applet_class_init (GfSoundAppletClass *applet_class)
 
   object_class = G_OBJECT_CLASS (applet_class);
 
-  object_class->constructed = gf_sound_applet_constructed;
   object_class->dispose = gf_sound_applet_dispose;
 }
 
@@ -278,8 +250,21 @@ gf_sound_applet_init (GfSoundApplet *applet)
 {
   GvcStreamStatusIcon *icon;
 
+  applet->control = gvc_mixer_control_new ("GNOME Volume Control Applet");
+
+  g_signal_connect (applet->control, "state-changed",
+                    G_CALLBACK (on_control_state_changed), applet);
+  g_signal_connect (applet->control, "default-sink-changed",
+                    G_CALLBACK (on_control_default_sink_changed), applet);
+  g_signal_connect (applet->control, "default-source-changed",
+                    G_CALLBACK (on_control_default_source_changed), applet);
+  g_signal_connect (applet->control, "stream-added",
+                    G_CALLBACK (on_control_stream_added), applet);
+  g_signal_connect (applet->control, "stream-removed",
+                    G_CALLBACK (on_control_stream_removed), applet);
+
   /* Output icon */
-  icon = gvc_stream_status_icon_new (NULL, output_icons);
+  icon = gvc_stream_status_icon_new (applet->control, output_icons);
   gvc_stream_status_icon_set_display_name (icon, _("Output"));
 
   G_GNUC_BEGIN_IGNORE_DEPRECATIONS
@@ -289,7 +274,7 @@ gf_sound_applet_init (GfSoundApplet *applet)
   applet->output_status_icon = icon;
 
   /* Input icon */
-  icon = gvc_stream_status_icon_new (NULL, input_icons);
+  icon = gvc_stream_status_icon_new (applet->control, input_icons);
   gvc_stream_status_icon_set_display_name (icon, _("Input"));
 
   G_GNUC_BEGIN_IGNORE_DEPRECATIONS
@@ -297,6 +282,9 @@ gf_sound_applet_init (GfSoundApplet *applet)
   G_GNUC_END_IGNORE_DEPRECATIONS
 
   applet->input_status_icon = icon;
+
+  gvc_mixer_control_open (applet->control);
+  maybe_show_status_icons (applet);
 }
 
 GfSoundApplet *
diff --git a/gnome-flashback/libsound-applet/gvc-stream-status-icon.c 
b/gnome-flashback/libsound-applet/gvc-stream-status-icon.c
index d1dd2df..3ec78bf 100644
--- a/gnome-flashback/libsound-applet/gvc-stream-status-icon.c
+++ b/gnome-flashback/libsound-applet/gvc-stream-status-icon.c
@@ -34,19 +34,22 @@
 
 struct GvcStreamStatusIconPrivate
 {
-        char          **icon_names;
-        GvcMixerStream *mixer_stream;
-        GtkWidget      *dock;
-        GtkWidget      *bar;
-        guint           current_icon;
-        char           *display_name;
-        gboolean        thaw;
+        GvcMixerControl  *mixer_control;
+
+        char            **icon_names;
+        GvcMixerStream   *mixer_stream;
+        GtkWidget        *dock;
+        GtkWidget        *bar;
+        guint             current_icon;
+        char             *display_name;
+        gboolean          thaw;
 };
 
 enum
 {
         PROP_0,
         PROP_DISPLAY_NAME,
+        PROP_MIXER_CONTROL,
         PROP_MIXER_STREAM,
         PROP_ICON_NAMES,
 };
@@ -557,6 +560,9 @@ gvc_stream_status_icon_set_property (GObject       *object,
         GvcStreamStatusIcon *self = GVC_STREAM_STATUS_ICON (object);
 
         switch (prop_id) {
+        case PROP_MIXER_CONTROL:
+                self->priv->mixer_control = g_value_dup_object (value);
+                break;
         case PROP_MIXER_STREAM:
                 gvc_stream_status_icon_set_mixer_stream (self, g_value_get_object (value));
                 break;
@@ -582,6 +588,9 @@ gvc_stream_status_icon_get_property (GObject     *object,
         GvcStreamStatusIconPrivate *priv = self->priv;
 
         switch (prop_id) {
+        case PROP_MIXER_CONTROL:
+                g_value_set_object (value, priv->mixer_control);
+                break;
         case PROP_MIXER_STREAM:
                 g_value_set_object (value, priv->mixer_stream);
                 break;
@@ -684,6 +693,8 @@ gvc_stream_status_icon_dispose (GObject *object)
 {
         GvcStreamStatusIcon *icon = GVC_STREAM_STATUS_ICON (object);
 
+        g_clear_object (&icon->priv->mixer_control);
+
         if (icon->priv->dock != NULL) {
                 gtk_widget_destroy (icon->priv->dock);
                 icon->priv->dock = NULL;
@@ -708,6 +719,14 @@ gvc_stream_status_icon_class_init (GvcStreamStatusIconClass *klass)
         object_class->set_property = gvc_stream_status_icon_set_property;
         object_class->get_property = gvc_stream_status_icon_get_property;
 
+        g_object_class_install_property (object_class,
+                                         PROP_MIXER_CONTROL,
+                                         g_param_spec_object ("mixer-control",
+                                                              "mixer control",
+                                                              "mixer control",
+                                                              GVC_TYPE_MIXER_CONTROL,
+                                                              G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
+
         g_object_class_install_property (object_class,
                                          PROP_MIXER_STREAM,
                                          g_param_spec_object ("mixer-stream",
@@ -788,12 +807,12 @@ gvc_stream_status_icon_finalize (GObject *object)
 }
 
 GvcStreamStatusIcon *
-gvc_stream_status_icon_new (GvcMixerStream *stream,
-                            const char    **icon_names)
+gvc_stream_status_icon_new (GvcMixerControl  *control,
+                            const char      **icon_names)
 {
         GObject *icon;
         icon = g_object_new (GVC_TYPE_STREAM_STATUS_ICON,
-                             "mixer-stream", stream,
+                             "mixer-control", control,
                              "icon-names", icon_names,
                              NULL);
         return GVC_STREAM_STATUS_ICON (icon);
diff --git a/gnome-flashback/libsound-applet/gvc-stream-status-icon.h 
b/gnome-flashback/libsound-applet/gvc-stream-status-icon.h
index 6fe7dfe..1d51fdd 100644
--- a/gnome-flashback/libsound-applet/gvc-stream-status-icon.h
+++ b/gnome-flashback/libsound-applet/gvc-stream-status-icon.h
@@ -19,6 +19,7 @@
 #define __GVC_STREAM_STATUS_ICON_H
 
 #include <glib-object.h>
+#include "gvc-mixer-control.h"
 #include "gvc-mixer-stream.h"
 
 G_BEGIN_DECLS
@@ -45,7 +46,7 @@ typedef struct
 
 GType                 gvc_stream_status_icon_get_type            (void);
 
-GvcStreamStatusIcon * gvc_stream_status_icon_new                 (GvcMixerStream      *stream,
+GvcStreamStatusIcon * gvc_stream_status_icon_new                 (GvcMixerControl     *control,
                                                                   const char         **icon_names);
 
 void                  gvc_stream_status_icon_set_icon_names      (GvcStreamStatusIcon *icon,


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