[gnome-flashback] sound-applet: rename GvcApplet to GfSoundApplet
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] sound-applet: rename GvcApplet to GfSoundApplet
- Date: Mon, 7 Sep 2015 00:02:29 +0000 (UTC)
commit 2a45b1d07f44c1d237adc9249e458a6cc254abaa
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Sep 7 02:49:01 2015 +0300
sound-applet: rename GvcApplet to GfSoundApplet
gnome-flashback/flashback-application.c | 6 +-
gnome-flashback/libsound-applet/gf-sound-applet.c | 404 ++++++++++-----------
gnome-flashback/libsound-applet/gf-sound-applet.h | 33 +--
3 files changed, 208 insertions(+), 235 deletions(-)
---
diff --git a/gnome-flashback/flashback-application.c b/gnome-flashback/flashback-application.c
index 16f1353..b7a7e3f 100644
--- a/gnome-flashback/flashback-application.c
+++ b/gnome-flashback/flashback-application.c
@@ -56,7 +56,7 @@ struct _FlashbackApplication
FlashbackShell *shell;
GfBluetoothApplet *bluetooth;
GfPowerApplet *power;
- GvcApplet *applet;
+ GfSoundApplet *sound;
FlashbackWorkarounds *workarounds;
};
@@ -147,7 +147,7 @@ settings_changed (GSettings *settings,
SETTING_CHANGED (shell, "shell", flashback_shell_new)
SETTING_CHANGED (bluetooth, "bluetooth-applet", gf_bluetooth_applet_new)
SETTING_CHANGED (power, "power-applet", gf_power_applet_new)
- SETTING_CHANGED (applet, "sound-applet", gvc_applet_new)
+ SETTING_CHANGED (sound, "sound-applet", gf_sound_applet_new)
SETTING_CHANGED (workarounds, "workarounds", flashback_workarounds_new)
#undef SETTING_CHANGED
@@ -184,7 +184,7 @@ flashback_application_finalize (GObject *object)
g_clear_object (&application->shell);
g_clear_object (&application->bluetooth);
g_clear_object (&application->power);
- g_clear_object (&application->applet);
+ g_clear_object (&application->sound);
g_clear_object (&application->workarounds);
G_OBJECT_CLASS (flashback_application_parent_class)->finalize (object);
diff --git a/gnome-flashback/libsound-applet/gf-sound-applet.c
b/gnome-flashback/libsound-applet/gf-sound-applet.c
index b6bd0ee..abd1728 100644
--- a/gnome-flashback/libsound-applet/gf-sound-applet.c
+++ b/gnome-flashback/libsound-applet/gf-sound-applet.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 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
@@ -33,282 +34,273 @@
#include "gvc-mixer-control.h"
#include "gvc-stream-status-icon.h"
-#define GVC_APPLET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_APPLET, GvcAppletPrivate))
-
-#define SCALE_SIZE 128
-
-static const char *output_icon_names[] = {
- "audio-volume-muted",
- "audio-volume-low",
- "audio-volume-medium",
- "audio-volume-high",
- NULL
-};
-
-static const char *input_icon_names[] = {
- "microphone-sensitivity-muted",
- "microphone-sensitivity-low",
- "microphone-sensitivity-medium",
- "microphone-sensitivity-high",
- NULL
+static const gchar *output_icons[] =
+{
+ "audio-volume-muted",
+ "audio-volume-low",
+ "audio-volume-medium",
+ "audio-volume-high",
+ NULL
};
-struct GvcAppletPrivate
+static const gchar *input_icons[] =
{
- GvcStreamStatusIcon *input_status_icon;
- GvcStreamStatusIcon *output_status_icon;
- GvcMixerControl *control;
+ "microphone-sensitivity-muted",
+ "microphone-sensitivity-low",
+ "microphone-sensitivity-medium",
+ "microphone-sensitivity-high",
+ NULL
};
-static void gvc_applet_finalize (GObject *object);
-
-G_DEFINE_TYPE (GvcApplet, gvc_applet, G_TYPE_OBJECT)
-
-static void
-maybe_show_status_icons (GvcApplet *applet)
+struct _GfSoundApplet
{
- gboolean show;
- GvcMixerStream *stream;
- GSList *source_outputs, *l;
-
- show = TRUE;
- stream = gvc_mixer_control_get_default_sink (applet->priv->control);
- if (stream == NULL) {
- show = FALSE;
- }
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- gtk_status_icon_set_visible (GTK_STATUS_ICON (applet->priv->output_status_icon), show);
- G_GNUC_END_IGNORE_DEPRECATIONS
-
- show = FALSE;
- stream = gvc_mixer_control_get_default_source (applet->priv->control);
- source_outputs = gvc_mixer_control_get_source_outputs (applet->priv->control);
- if (stream != NULL && source_outputs != NULL) {
- /* Check that we're not trying to add the peak detector
- * as an application doing recording */
- for (l = source_outputs ; l ; l = l->next) {
- GvcMixerStream *s = l->data;
- const char *id;
-
- id = gvc_mixer_stream_get_application_id (s);
- if (id == NULL) {
- show = TRUE;
- break;
- }
-
- if (!g_str_equal (id, "org.gnome.VolumeControl") &&
- !g_str_equal (id, "org.PulseAudio.pavucontrol")) {
- show = TRUE;
- break;
- }
- }
- }
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- gtk_status_icon_set_visible (GTK_STATUS_ICON (applet->priv->input_status_icon), show);
- G_GNUC_END_IGNORE_DEPRECATIONS
-
- g_slist_free (source_outputs);
-}
+ GObject parent;
-void
-gvc_applet_start (GvcApplet *applet)
-{
- g_return_if_fail (GVC_IS_APPLET (applet));
+ GvcStreamStatusIcon *input_status_icon;
+ GvcStreamStatusIcon *output_status_icon;
+ GvcMixerControl *control;
+};
- maybe_show_status_icons (applet);
-}
+G_DEFINE_TYPE (GfSoundApplet, gf_sound_applet, G_TYPE_OBJECT)
static void
-gvc_applet_dispose (GObject *object)
+maybe_show_status_icons (GfSoundApplet *applet)
{
- GvcApplet *applet = GVC_APPLET (object);
-
- if (applet->priv->control != NULL) {
- g_object_unref (applet->priv->control);
- applet->priv->control = NULL;
+ gboolean show;
+ GvcMixerStream *stream;
+ GSList *source_outputs;
+ GSList *l;
+
+ show = TRUE;
+ stream = gvc_mixer_control_get_default_sink (applet->control);
+
+ if (stream == NULL)
+ show = FALSE;
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ gtk_status_icon_set_visible (GTK_STATUS_ICON (applet->output_status_icon), show);
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
+ show = FALSE;
+ stream = gvc_mixer_control_get_default_source (applet->control);
+ source_outputs = gvc_mixer_control_get_source_outputs (applet->control);
+
+ if (stream != NULL && source_outputs != NULL)
+ {
+ for (l = source_outputs ; l ; l = l->next)
+ {
+ GvcMixerStream *s;
+ const gchar *id;
+
+ s = (GvcMixerStream *) l->data;
+ id = gvc_mixer_stream_get_application_id (s);
+
+ if (id == NULL)
+ {
+ show = TRUE;
+ break;
+ }
+
+ if (!g_str_equal (id, "org.gnome.VolumeControl") &&
+ !g_str_equal (id, "org.PulseAudio.pavucontrol"))
+ {
+ show = TRUE;
+ break;
+ }
}
+ }
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ gtk_status_icon_set_visible (GTK_STATUS_ICON (applet->input_status_icon), show);
+ G_GNUC_END_IGNORE_DEPRECATIONS
- G_OBJECT_CLASS (gvc_applet_parent_class)->dispose (object);
+ g_slist_free (source_outputs);
}
static void
-update_default_source (GvcApplet *applet)
+update_default_sink (GfSoundApplet *applet)
{
- GvcMixerStream *stream;
-
- stream = gvc_mixer_control_get_default_source (applet->priv->control);
- if (stream != NULL) {
- gvc_stream_status_icon_set_mixer_stream (applet->priv->input_status_icon,
- stream);
- maybe_show_status_icons(applet);
- } else {
- g_debug ("Unable to get default source, or no source available");
- }
+ GvcMixerStream *stream;
+
+ stream = gvc_mixer_control_get_default_sink (applet->control);
+
+ if (stream != NULL)
+ {
+ gvc_stream_status_icon_set_mixer_stream (applet->output_status_icon, stream);
+ maybe_show_status_icons (applet);
+ }
+ else
+ {
+ g_warning ("Unable to get default sink");
+ }
}
static void
-update_default_sink (GvcApplet *applet)
+update_default_source (GfSoundApplet *applet)
{
- GvcMixerStream *stream;
-
- stream = gvc_mixer_control_get_default_sink (applet->priv->control);
- if (stream != NULL) {
- gvc_stream_status_icon_set_mixer_stream (applet->priv->output_status_icon,
- stream);
- maybe_show_status_icons(applet);
- } else {
- g_warning ("Unable to get default sink");
- }
+ GvcMixerStream *stream;
+
+ stream = gvc_mixer_control_get_default_source (applet->control);
+
+ if (stream != NULL)
+ {
+ gvc_stream_status_icon_set_mixer_stream (applet->input_status_icon, stream);
+ maybe_show_status_icons (applet);
+ }
+ else
+ {
+ g_debug ("Unable to get default source, or no source available");
+ }
}
static void
on_control_state_changed (GvcMixerControl *control,
GvcMixerControlState new_state,
- GvcApplet *applet)
+ gpointer user_data)
{
- if (new_state == GVC_STATE_READY) {
- update_default_sink (applet);
- update_default_source (applet);
- } else if (new_state == GVC_STATE_CONNECTING) {
- g_debug ("Connecting...");
- }
+ GfSoundApplet *applet;
+
+ applet = GF_SOUND_APPLET (user_data);
+
+ if (new_state == GVC_STATE_READY)
+ {
+ update_default_sink (applet);
+ update_default_source (applet);
+ }
+ else
+ {
+ g_debug ("Connecting...");
+ }
}
static void
on_control_default_sink_changed (GvcMixerControl *control,
guint id,
- GvcApplet *applet)
+ gpointer user_data)
{
- update_default_sink (applet);
+ GfSoundApplet *applet;
+
+ applet = GF_SOUND_APPLET (user_data);
+
+ maybe_show_status_icons (applet);
}
static void
on_control_default_source_changed (GvcMixerControl *control,
guint id,
- GvcApplet *applet)
+ gpointer user_data)
{
- update_default_source (applet);
-}
+ GfSoundApplet *applet;
-static void
-on_control_stream_removed (GvcMixerControl *control,
- guint id,
- GvcApplet *applet)
-{
- maybe_show_status_icons (applet);
+ applet = GF_SOUND_APPLET (user_data);
+
+ maybe_show_status_icons (applet);
}
static void
on_control_stream_added (GvcMixerControl *control,
guint id,
- GvcApplet *applet)
+ gpointer user_data)
{
- maybe_show_status_icons (applet);
-}
+ GfSoundApplet *applet;
-static GObject *
-gvc_applet_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_params)
-{
- GObject *object;
- GvcApplet *self;
-
- object = G_OBJECT_CLASS (gvc_applet_parent_class)->constructor (type, n_construct_properties,
construct_params);
-
- self = GVC_APPLET (object);
-
- self->priv->control = gvc_mixer_control_new ("GNOME Volume Control Applet");
- g_signal_connect (self->priv->control,
- "state-changed",
- G_CALLBACK (on_control_state_changed),
- self);
- g_signal_connect (self->priv->control,
- "default-sink-changed",
- G_CALLBACK (on_control_default_sink_changed),
- self);
- g_signal_connect (self->priv->control,
- "default-source-changed",
- G_CALLBACK (on_control_default_source_changed),
- self);
- g_signal_connect (self->priv->control,
- "stream-added",
- G_CALLBACK (on_control_stream_added),
- self);
- g_signal_connect (self->priv->control,
- "stream-removed",
- G_CALLBACK (on_control_stream_removed),
- self);
-
- gvc_mixer_control_open (self->priv->control);
-
- return object;
+ applet = GF_SOUND_APPLET (user_data);
+
+ maybe_show_status_icons (applet);
}
static void
-gvc_applet_class_init (GvcAppletClass *klass)
+on_control_stream_removed (GvcMixerControl *control,
+ guint id,
+ gpointer user_data)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GfSoundApplet *applet;
- object_class->finalize = gvc_applet_finalize;
- object_class->dispose = gvc_applet_dispose;
- object_class->constructor = gvc_applet_constructor;
+ applet = GF_SOUND_APPLET (user_data);
- g_type_class_add_private (klass, sizeof (GvcAppletPrivate));
+ maybe_show_status_icons (applet);
}
static void
-gvc_applet_init (GvcApplet *applet)
+gf_sound_applet_constructed (GObject *object)
{
- applet->priv = GVC_APPLET_GET_PRIVATE (applet);
-
- applet->priv->output_status_icon = gvc_stream_status_icon_new (NULL,
- output_icon_names);
- gvc_stream_status_icon_set_display_name (applet->priv->output_status_icon,
- _("Output"));
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- gtk_status_icon_set_title (GTK_STATUS_ICON (applet->priv->output_status_icon),
- _("Sound Output Volume"));
- G_GNUC_END_IGNORE_DEPRECATIONS
-
- applet->priv->input_status_icon = gvc_stream_status_icon_new (NULL,
- input_icon_names);
- gvc_stream_status_icon_set_display_name (applet->priv->input_status_icon,
- _("Input"));
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- gtk_status_icon_set_title (GTK_STATUS_ICON (applet->priv->input_status_icon),
- _("Microphone Volume"));
- G_GNUC_END_IGNORE_DEPRECATIONS
+ 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
-gvc_applet_finalize (GObject *object)
+gf_sound_applet_dispose (GObject *object)
{
- GvcApplet *applet;
+ GfSoundApplet *applet;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GVC_IS_APPLET (object));
+ applet = GF_SOUND_APPLET (object);
- applet = GVC_APPLET (object);
+ g_clear_object (&applet->output_status_icon);
+ g_clear_object (&applet->input_status_icon);
+ g_clear_object (&applet->control);
- g_return_if_fail (applet->priv != NULL);
+ G_OBJECT_CLASS (gf_sound_applet_parent_class)->dispose (object);
+}
+static void
+gf_sound_applet_class_init (GfSoundAppletClass *applet_class)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (applet_class);
- G_OBJECT_CLASS (gvc_applet_parent_class)->finalize (object);
+ object_class->constructed = gf_sound_applet_constructed;
+ object_class->dispose = gf_sound_applet_dispose;
}
-GvcApplet *
-gvc_applet_new (void)
+static void
+gf_sound_applet_init (GfSoundApplet *applet)
{
- GObject *applet;
+ GvcStreamStatusIcon *icon;
- applet = g_object_new (GVC_TYPE_APPLET, NULL);
+ /* Output icon */
+ icon = gvc_stream_status_icon_new (NULL, output_icons);
+ gvc_stream_status_icon_set_display_name (icon, _("Output"));
- gvc_applet_start (GVC_APPLET (applet));
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ gtk_status_icon_set_title (GTK_STATUS_ICON (icon), _("Sound Output Volume"));
+ G_GNUC_END_IGNORE_DEPRECATIONS
- return GVC_APPLET (applet);
+ applet->output_status_icon = icon;
+
+ /* Input icon */
+ icon = gvc_stream_status_icon_new (NULL, input_icons);
+ gvc_stream_status_icon_set_display_name (icon, _("Input"));
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ gtk_status_icon_set_title (GTK_STATUS_ICON (icon), _("Microphone Volume"));
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
+ applet->input_status_icon = icon;
+}
+
+GfSoundApplet *
+gf_sound_applet_new (void)
+{
+ return g_object_new (GF_TYPE_SOUND_APPLET, NULL);
}
diff --git a/gnome-flashback/libsound-applet/gf-sound-applet.h
b/gnome-flashback/libsound-applet/gf-sound-applet.h
index 3d6e576..aa6d867 100644
--- a/gnome-flashback/libsound-applet/gf-sound-applet.h
+++ b/gnome-flashback/libsound-applet/gf-sound-applet.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 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,38 +16,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef __GVC_APPLET_H
-#define __GVC_APPLET_H
+#ifndef GF_SOUND_APPLET_H
+#define GF_SOUND_APPLET_H
#include <glib-object.h>
G_BEGIN_DECLS
-#define GVC_TYPE_APPLET (gvc_applet_get_type ())
-#define GVC_APPLET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_APPLET, GvcApplet))
-#define GVC_APPLET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_APPLET, GvcAppletClass))
-#define GVC_IS_APPLET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_APPLET))
-#define GVC_IS_APPLET_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_APPLET))
-#define GVC_APPLET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_APPLET, GvcAppletClass))
+#define GF_TYPE_SOUND_APPLET gf_sound_applet_get_type ()
+G_DECLARE_FINAL_TYPE (GfSoundApplet, gf_sound_applet, GF, SOUND_APPLET, GObject)
-typedef struct GvcAppletPrivate GvcAppletPrivate;
-
-typedef struct
-{
- GObject parent;
- GvcAppletPrivate *priv;
-} GvcApplet;
-
-typedef struct
-{
- GObjectClass parent_class;
-} GvcAppletClass;
-
-GType gvc_applet_get_type (void);
-
-GvcApplet * gvc_applet_new (void);
-void gvc_applet_start (GvcApplet *applet);
+GfSoundApplet *gf_sound_applet_new (void);
G_END_DECLS
-#endif /* __GVC_APPLET_H */
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]