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



commit f42548112448327c379c042e405930c56f36110d
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Aug 16 17:39:40 2019 +0300

    sound-applet: pass GvcMixerControl to GvcChannelBar

 gnome-flashback/libsound-applet/gvc-channel-bar.c  | 71 ++++++++++++++++------
 gnome-flashback/libsound-applet/gvc-channel-bar.h  | 56 +++++++++--------
 .../libsound-applet/gvc-stream-status-icon.c       |  2 +-
 3 files changed, 84 insertions(+), 45 deletions(-)
---
diff --git a/gnome-flashback/libsound-applet/gvc-channel-bar.c 
b/gnome-flashback/libsound-applet/gvc-channel-bar.c
index e90730d..8fe5a89 100644
--- a/gnome-flashback/libsound-applet/gvc-channel-bar.c
+++ b/gnome-flashback/libsound-applet/gvc-channel-bar.c
@@ -40,30 +40,33 @@
 
 struct GvcChannelBarPrivate
 {
-        GtkOrientation orientation;
-        GtkWidget     *scale_box;
-        GtkWidget     *start_box;
-        GtkWidget     *end_box;
-        GtkWidget     *image;
-        GtkWidget     *low_image;
-        GtkWidget     *scale;
-        GtkWidget     *high_image;
-        GtkAdjustment *adjustment;
-        GtkAdjustment *zero_adjustment;
-        gboolean       is_muted;
-        char          *icon_name;
-        char          *low_icon_name;
-        char          *high_icon_name;
-        GtkSizeGroup  *size_group;
-        gboolean       symmetric;
-        gboolean       click_lock;
-        gboolean       is_amplified;
-        guint32        base_volume;
+        GvcMixerControl *mixer_control;
+
+        GtkOrientation   orientation;
+        GtkWidget       *scale_box;
+        GtkWidget       *start_box;
+        GtkWidget       *end_box;
+        GtkWidget       *image;
+        GtkWidget       *low_image;
+        GtkWidget       *scale;
+        GtkWidget       *high_image;
+        GtkAdjustment   *adjustment;
+        GtkAdjustment   *zero_adjustment;
+        gboolean         is_muted;
+        char            *icon_name;
+        char            *low_icon_name;
+        char            *high_icon_name;
+        GtkSizeGroup    *size_group;
+        gboolean         symmetric;
+        gboolean         click_lock;
+        gboolean         is_amplified;
+        guint32          base_volume;
 };
 
 enum
 {
         PROP_0,
+        PROP_MIXER_CONTROL,
         PROP_ORIENTATION,
         PROP_IS_MUTED,
 };
@@ -548,6 +551,9 @@ gvc_channel_bar_set_property (GObject       *object,
         GvcChannelBar *self = GVC_CHANNEL_BAR (object);
 
         switch (prop_id) {
+        case PROP_MIXER_CONTROL:
+                self->priv->mixer_control = g_value_dup_object (value);
+                break;
         case PROP_ORIENTATION:
                 gvc_channel_bar_set_orientation (self, g_value_get_enum (value));
                 break;
@@ -570,6 +576,9 @@ gvc_channel_bar_get_property (GObject     *object,
         GvcChannelBarPrivate *priv = self->priv;
 
         switch (prop_id) {
+        case PROP_MIXER_CONTROL:
+                g_value_set_object (value, priv->mixer_control);
+                break;
         case PROP_ORIENTATION:
                 g_value_set_enum (value, priv->orientation);
                 break;
@@ -599,16 +608,37 @@ gvc_channel_bar_constructor (GType                  type,
         return object;
 }
 
+static void
+gvc_channel_bar_dispose (GObject *object)
+{
+        GvcChannelBar *channel_bar;
+
+        channel_bar = GVC_CHANNEL_BAR (object);
+
+        g_clear_object (&channel_bar->priv->mixer_control);
+
+        G_OBJECT_CLASS (gvc_channel_bar_parent_class)->dispose (object);
+}
+
 static void
 gvc_channel_bar_class_init (GvcChannelBarClass *klass)
 {
         GObjectClass   *object_class = G_OBJECT_CLASS (klass);
 
         object_class->constructor = gvc_channel_bar_constructor;
+        object_class->dispose = gvc_channel_bar_dispose;
         object_class->finalize = gvc_channel_bar_finalize;
         object_class->set_property = gvc_channel_bar_set_property;
         object_class->get_property = gvc_channel_bar_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_ORIENTATION,
                                          g_param_spec_enum ("orientation",
@@ -704,10 +734,11 @@ gvc_channel_bar_finalize (GObject *object)
 }
 
 GtkWidget *
-gvc_channel_bar_new (void)
+gvc_channel_bar_new (GvcMixerControl *mixer_control)
 {
         GObject *bar;
         bar = g_object_new (GVC_TYPE_CHANNEL_BAR,
+                            "mixer-control", mixer_control,
                             "orientation", GTK_ORIENTATION_HORIZONTAL,
                             NULL);
         return GTK_WIDGET (bar);
diff --git a/gnome-flashback/libsound-applet/gvc-channel-bar.h 
b/gnome-flashback/libsound-applet/gvc-channel-bar.h
index 9c88e3e..71abf44 100644
--- a/gnome-flashback/libsound-applet/gvc-channel-bar.h
+++ b/gnome-flashback/libsound-applet/gvc-channel-bar.h
@@ -19,6 +19,7 @@
 #define __GVC_CHANNEL_BAR_H
 
 #include <glib-object.h>
+#include "gvc-mixer-control.h"
 
 G_BEGIN_DECLS
 
@@ -42,36 +43,43 @@ typedef struct
         GtkBoxClass           parent_class;
 } GvcChannelBarClass;
 
-GType               gvc_channel_bar_get_type            (void);
+GType           gvc_channel_bar_get_type           (void);
 
-GtkWidget *         gvc_channel_bar_new                 (void);
+GtkWidget      *gvc_channel_bar_new                (GvcMixerControl *mixer_control);
 
-void                gvc_channel_bar_set_icon_name       (GvcChannelBar *bar,
-                                                         const char    *icon_name);
-void                gvc_channel_bar_set_low_icon_name   (GvcChannelBar *bar,
-                                                         const char    *icon_name);
-void                gvc_channel_bar_set_high_icon_name  (GvcChannelBar *bar,
-                                                         const char    *icon_name);
+void            gvc_channel_bar_set_icon_name      (GvcChannelBar   *bar,
+                                                    const char      *icon_name);
 
-void                gvc_channel_bar_set_orientation     (GvcChannelBar *bar,
-                                                         GtkOrientation orientation);
-GtkOrientation      gvc_channel_bar_get_orientation     (GvcChannelBar *bar);
+void            gvc_channel_bar_set_low_icon_name  (GvcChannelBar   *bar,
+                                                    const char      *icon_name);
 
-GtkAdjustment *     gvc_channel_bar_get_adjustment      (GvcChannelBar *bar);
+void            gvc_channel_bar_set_high_icon_name (GvcChannelBar   *bar,
+                                                    const char      *icon_name);
 
-gboolean            gvc_channel_bar_get_is_muted        (GvcChannelBar *bar);
-void                gvc_channel_bar_set_is_muted        (GvcChannelBar *bar,
-                                                         gboolean       is_muted);
-void                gvc_channel_bar_set_size_group      (GvcChannelBar *bar,
-                                                         GtkSizeGroup  *group,
-                                                         gboolean       symmetric);
-void                gvc_channel_bar_set_is_amplified    (GvcChannelBar *bar,
-                                                         gboolean amplified);
-void                gvc_channel_bar_set_base_volume     (GvcChannelBar *bar,
-                                                         guint32        base_volume);
+void            gvc_channel_bar_set_orientation    (GvcChannelBar   *bar,
+                                                    GtkOrientation   orientation);
 
-gboolean            gvc_channel_bar_scroll              (GvcChannelBar  *bar,
-                                                         GdkEventScroll *event);
+GtkOrientation  gvc_channel_bar_get_orientation    (GvcChannelBar   *bar);
+
+GtkAdjustment  *gvc_channel_bar_get_adjustment     (GvcChannelBar   *bar);
+
+gboolean        gvc_channel_bar_get_is_muted       (GvcChannelBar   *bar);
+
+void            gvc_channel_bar_set_is_muted       (GvcChannelBar   *bar,
+                                                    gboolean         is_muted);
+
+void            gvc_channel_bar_set_size_group     (GvcChannelBar   *bar,
+                                                    GtkSizeGroup    *group,
+                                                    gboolean         symmetric);
+
+void            gvc_channel_bar_set_is_amplified   (GvcChannelBar   *bar,
+                                                    gboolean         amplified);
+
+void            gvc_channel_bar_set_base_volume    (GvcChannelBar   *bar,
+                                                    guint32          base_volume);
+
+gboolean        gvc_channel_bar_scroll             (GvcChannelBar   *bar,
+                                                    GdkEventScroll  *event);
 
 G_END_DECLS
 
diff --git a/gnome-flashback/libsound-applet/gvc-stream-status-icon.c 
b/gnome-flashback/libsound-applet/gvc-stream-status-icon.c
index 9eff811..0a2e743 100644
--- a/gnome-flashback/libsound-applet/gvc-stream-status-icon.c
+++ b/gnome-flashback/libsound-applet/gvc-stream-status-icon.c
@@ -652,7 +652,7 @@ gvc_stream_status_icon_constructor (GType                  type,
         gtk_container_set_border_width (GTK_CONTAINER (box), 2);
         gtk_container_add (GTK_CONTAINER (frame), box);
 
-        icon->priv->bar = gvc_channel_bar_new ();
+        icon->priv->bar = gvc_channel_bar_new (icon->priv->mixer_control);
         gvc_channel_bar_set_orientation (GVC_CHANNEL_BAR (icon->priv->bar),
                                          GTK_ORIENTATION_VERTICAL);
 


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