[gnome-flashback] sound-applet: move code from init & constructor to constructed



commit f3693eef25e5b3eddb0909db75dba57abb8cc1a2
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Aug 16 18:16:31 2019 +0300

    sound-applet: move code from init & constructor to constructed

 gnome-flashback/libsound-applet/gvc-channel-bar.c | 119 ++++++++++------------
 1 file changed, 56 insertions(+), 63 deletions(-)
---
diff --git a/gnome-flashback/libsound-applet/gvc-channel-bar.c 
b/gnome-flashback/libsound-applet/gvc-channel-bar.c
index 7f50828..f78b867 100644
--- a/gnome-flashback/libsound-applet/gvc-channel-bar.c
+++ b/gnome-flashback/libsound-applet/gvc-channel-bar.c
@@ -559,21 +559,66 @@ gvc_channel_bar_get_property (GObject     *object,
         }
 }
 
-static GObject *
-gvc_channel_bar_constructor (GType                  type,
-                             guint                  n_construct_properties,
-                             GObjectConstructParam *construct_params)
+static void
+gvc_channel_bar_constructed (GObject *object)
 {
-        GObject       *object;
-        GvcChannelBar *self;
+        GvcChannelBar *bar;
+        GtkWidget *frame;
+
+        bar = GVC_CHANNEL_BAR (object);
+        G_OBJECT_CLASS (gvc_channel_bar_parent_class)->constructed (object);
+
+        bar->priv->base_volume = ADJUSTMENT_MAX_NORMAL;
+        bar->priv->low_icon_name = g_strdup ("audio-volume-low");
+        bar->priv->high_icon_name = g_strdup ("audio-volume-high");
 
-        object = G_OBJECT_CLASS (gvc_channel_bar_parent_class)->constructor (type, n_construct_properties, 
construct_params);
+        bar->priv->orientation = GTK_ORIENTATION_VERTICAL;
+        bar->priv->adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0,
+                                                                    0.0,
+                                                                    ADJUSTMENT_MAX_NORMAL,
+                                                                    ADJUSTMENT_MAX_NORMAL/100.0,
+                                                                    ADJUSTMENT_MAX_NORMAL/10.0,
+                                                                    0.0));
+        g_object_ref_sink (bar->priv->adjustment);
 
-        self = GVC_CHANNEL_BAR (object);
+        bar->priv->zero_adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0,
+                                                                         0.0,
+                                                                         ADJUSTMENT_MAX_NORMAL,
+                                                                         ADJUSTMENT_MAX_NORMAL/100.0,
+                                                                         ADJUSTMENT_MAX_NORMAL/10.0,
+                                                                         0.0));
+        g_object_ref_sink (bar->priv->zero_adjustment);
 
-        update_mute_switch (self);
+        g_signal_connect (bar->priv->zero_adjustment,
+                          "value-changed",
+                          G_CALLBACK (on_zero_adjustment_value_changed),
+                          bar);
 
-        return object;
+        bar->priv->low_image = gtk_image_new_from_icon_name ("audio-volume-low",
+                                                             GTK_ICON_SIZE_MENU);
+        gtk_style_context_add_class (gtk_widget_get_style_context (bar->priv->low_image), "dim-label");
+        gtk_widget_set_no_show_all (bar->priv->low_image, TRUE);
+        bar->priv->high_image = gtk_image_new_from_icon_name ("audio-volume-high",
+                                                              GTK_ICON_SIZE_MENU);
+        gtk_style_context_add_class (gtk_widget_get_style_context (bar->priv->high_image), "dim-label");
+        gtk_widget_set_no_show_all (bar->priv->high_image, TRUE);
+
+        bar->priv->image = gtk_image_new ();
+        gtk_widget_set_no_show_all (bar->priv->image, TRUE);
+
+        /* frame */
+        frame = gtk_frame_new (NULL);
+        gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+        gtk_box_pack_start (GTK_BOX (bar), frame, TRUE, TRUE, 0);
+        gtk_widget_show_all (frame);
+
+        /* box with scale */
+        bar->priv->scale_box = _scale_box_new (bar);
+
+        gtk_container_add (GTK_CONTAINER (frame), bar->priv->scale_box);
+        gtk_widget_show_all (frame);
+
+        update_mute_switch (bar);
 }
 
 static void
@@ -593,7 +638,7 @@ gvc_channel_bar_class_init (GvcChannelBarClass *klass)
 {
         GObjectClass   *object_class = G_OBJECT_CLASS (klass);
 
-        object_class->constructor = gvc_channel_bar_constructor;
+        object_class->constructed = gvc_channel_bar_constructed;
         object_class->dispose = gvc_channel_bar_dispose;
         object_class->finalize = gvc_channel_bar_finalize;
         object_class->set_property = gvc_channel_bar_set_property;
@@ -627,59 +672,7 @@ gvc_channel_bar_class_init (GvcChannelBarClass *klass)
 static void
 gvc_channel_bar_init (GvcChannelBar *bar)
 {
-        GtkWidget *frame;
-
         bar->priv = gvc_channel_bar_get_instance_private (bar);
-
-        bar->priv->base_volume = ADJUSTMENT_MAX_NORMAL;
-        bar->priv->low_icon_name = g_strdup ("audio-volume-low");
-        bar->priv->high_icon_name = g_strdup ("audio-volume-high");
-
-        bar->priv->orientation = GTK_ORIENTATION_VERTICAL;
-        bar->priv->adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0,
-                                                                    0.0,
-                                                                    ADJUSTMENT_MAX_NORMAL,
-                                                                    ADJUSTMENT_MAX_NORMAL/100.0,
-                                                                    ADJUSTMENT_MAX_NORMAL/10.0,
-                                                                    0.0));
-        g_object_ref_sink (bar->priv->adjustment);
-
-        bar->priv->zero_adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0,
-                                                                         0.0,
-                                                                         ADJUSTMENT_MAX_NORMAL,
-                                                                         ADJUSTMENT_MAX_NORMAL/100.0,
-                                                                         ADJUSTMENT_MAX_NORMAL/10.0,
-                                                                         0.0));
-        g_object_ref_sink (bar->priv->zero_adjustment);
-
-        g_signal_connect (bar->priv->zero_adjustment,
-                          "value-changed",
-                          G_CALLBACK (on_zero_adjustment_value_changed),
-                          bar);
-
-        bar->priv->low_image = gtk_image_new_from_icon_name ("audio-volume-low",
-                                                             GTK_ICON_SIZE_MENU);
-        gtk_style_context_add_class (gtk_widget_get_style_context (bar->priv->low_image), "dim-label");
-        gtk_widget_set_no_show_all (bar->priv->low_image, TRUE);
-        bar->priv->high_image = gtk_image_new_from_icon_name ("audio-volume-high",
-                                                              GTK_ICON_SIZE_MENU);
-        gtk_style_context_add_class (gtk_widget_get_style_context (bar->priv->high_image), "dim-label");
-        gtk_widget_set_no_show_all (bar->priv->high_image, TRUE);
-
-        bar->priv->image = gtk_image_new ();
-        gtk_widget_set_no_show_all (bar->priv->image, TRUE);
-
-        /* frame */
-        frame = gtk_frame_new (NULL);
-        gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
-        gtk_box_pack_start (GTK_BOX (bar), frame, TRUE, TRUE, 0);
-        gtk_widget_show_all (frame);
-
-        /* box with scale */
-        bar->priv->scale_box = _scale_box_new (bar);
-
-        gtk_container_add (GTK_CONTAINER (frame), bar->priv->scale_box);
-        gtk_widget_show_all (frame);
 }
 
 static void


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