[Xfce4-commits] [panel-plugins/xfce4-pulseaudio-plugin] 01/02: Use volume-changed signal to update notifications
noreply at xfce.org
noreply at xfce.org
Sun Jun 7 00:01:52 CEST 2015
This is an automated email from the git hooks/post-receive script.
andrzejr pushed a commit to branch master
in repository panel-plugins/xfce4-pulseaudio-plugin.
commit f528da44c900b25fff530c4f8cbf32eb4a87a719
Author: Andrzej <ndrwrdck at gmail.com>
Date: Sat Jun 6 21:28:51 2015 +0100
Use volume-changed signal to update notifications
---
panel-plugin/pulseaudio-button.c | 2 --
panel-plugin/pulseaudio-notify.c | 19 ++++++++++++++++++-
panel-plugin/pulseaudio-notify.h | 2 --
panel-plugin/pulseaudio-plugin.c | 12 ------------
panel-plugin/pulseaudio-plugin.h | 2 --
panel-plugin/pulseaudio-volume.c | 5 ++++-
6 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/panel-plugin/pulseaudio-button.c b/panel-plugin/pulseaudio-button.c
index 9ccd1bd..032b128 100644
--- a/panel-plugin/pulseaudio-button.c
+++ b/panel-plugin/pulseaudio-button.c
@@ -239,8 +239,6 @@ pulseaudio_button_scroll_event (GtkWidget *widget, GdkEventScroll *event)
pulseaudio_volume_set_volume (button->volume, new_volume);
//g_debug ("dir: %d %f -> %f", event->direction, volume, new_volume);
- pulseaudio_notify (button->plugin);
-
return TRUE;
}
diff --git a/panel-plugin/pulseaudio-notify.c b/panel-plugin/pulseaudio-notify.c
index 6af6234..a6caa23 100644
--- a/panel-plugin/pulseaudio-notify.c
+++ b/panel-plugin/pulseaudio-notify.c
@@ -71,6 +71,8 @@ struct _PulseaudioNotify
gboolean gauge_notifications;
NotifyNotification *notification;
+
+ gulong volume_changed_id;
};
struct _PulseaudioNotifyClass
@@ -102,6 +104,7 @@ pulseaudio_notify_init (PulseaudioNotify *notify)
notify->gauge_notifications = TRUE;
notify->notification = NULL;
+ notify->volume_changed_id = 0;
//g_set_application_name ("Xfce volume control");
notify_init ("Xfce volume control");
@@ -119,7 +122,7 @@ pulseaudio_notify_init (PulseaudioNotify *notify)
g_list_free (caps_list);
}
notify->notification = notify_notification_new ("xfce4-pulseaudio-plugin", NULL, NULL);
- notify_notification_set_timeout (notify->notification, 1500);
+ notify_notification_set_timeout (notify->notification, 2000);
}
@@ -198,6 +201,17 @@ pulseaudio_notify_notify (PulseaudioNotify *notify)
+static void
+pulseaudio_notify_volume_changed (PulseaudioNotify *notify,
+ PulseaudioVolume *volume)
+{
+ g_return_if_fail (IS_PULSEAUDIO_NOTIFY (notify));
+
+ pulseaudio_notify_notify (notify);
+}
+
+
+
PulseaudioNotify *
pulseaudio_notify_new (PulseaudioConfig *config,
PulseaudioVolume *volume)
@@ -211,6 +225,9 @@ pulseaudio_notify_new (PulseaudioConfig *config,
notify->config = config;
notify->volume = volume;
+ notify->volume_changed_id =
+ g_signal_connect_swapped (G_OBJECT (notify->volume), "volume-changed",
+ G_CALLBACK (pulseaudio_notify_volume_changed), notify);
return notify;
}
diff --git a/panel-plugin/pulseaudio-notify.h b/panel-plugin/pulseaudio-notify.h
index 4d05d31..c2e0714 100644
--- a/panel-plugin/pulseaudio-notify.h
+++ b/panel-plugin/pulseaudio-notify.h
@@ -42,8 +42,6 @@ GType pulseaudio_notify_get_type (void) G_GNUC_CONST;
PulseaudioNotify *pulseaudio_notify_new (PulseaudioConfig *config,
PulseaudioVolume *volume);
-void pulseaudio_notify_notify (PulseaudioNotify *notify);
-
G_END_DECLS
#endif /* HAVE_LIBNOTIFY */
diff --git a/panel-plugin/pulseaudio-plugin.c b/panel-plugin/pulseaudio-plugin.c
index bea9571..0696b60 100644
--- a/panel-plugin/pulseaudio-plugin.c
+++ b/panel-plugin/pulseaudio-plugin.c
@@ -306,7 +306,6 @@ pulseaudio_plugin_volume_key_pressed (const char *keystring,
pulseaudio_volume_set_volume (pulseaudio_plugin->volume, MIN (volume + volume_step, MAX (volume, 1.0)));
else if (strcmp (keystring, PULSEAUDIO_PLUGIN_LOWER_VOLUME_KEY) == 0)
pulseaudio_volume_set_volume (pulseaudio_plugin->volume, volume - volume_step);
- pulseaudio_notify (pulseaudio_plugin);
}
@@ -319,21 +318,10 @@ pulseaudio_plugin_mute_pressed (const char *keystring,
pulseaudio_debug ("%s pressed", keystring);
pulseaudio_volume_toggle_muted (pulseaudio_plugin->volume);
- pulseaudio_notify (pulseaudio_plugin);
}
#endif
-void
-pulseaudio_notify (PulseaudioPlugin *pulseaudio_plugin)
-{
-#ifdef HAVE_LIBNOTIFY
- pulseaudio_notify_notify (pulseaudio_plugin->notify);
-#endif
-}
-
-
-
static void
pulseaudio_plugin_construct (XfcePanelPlugin *plugin)
{
diff --git a/panel-plugin/pulseaudio-plugin.h b/panel-plugin/pulseaudio-plugin.h
index 8802bf3..d90205b 100644
--- a/panel-plugin/pulseaudio-plugin.h
+++ b/panel-plugin/pulseaudio-plugin.h
@@ -37,8 +37,6 @@ GType pulseaudio_plugin_get_type (void) G_GNUC_CONST;
void pulseaudio_plugin_register_type (XfcePanelTypeModule *type_module);
-void pulseaudio_notify (PulseaudioPlugin *pulseaudio_plugin);
-
G_END_DECLS
#endif /* !__PULSEAUDIO_PLUGIN_H__ */
diff --git a/panel-plugin/pulseaudio-volume.c b/panel-plugin/pulseaudio-volume.c
index c528909..72f3cfc 100644
--- a/panel-plugin/pulseaudio-volume.c
+++ b/panel-plugin/pulseaudio-volume.c
@@ -245,7 +245,8 @@ pulseaudio_volume_context_state_cb (pa_context *context,
case PA_CONTEXT_FAILED :
case PA_CONTEXT_TERMINATED :
- g_warning ("Disconected from PulseAudio server");
+ g_warning ("Disconected from PulseAudio server.");
+ volume->pa_context = NULL;
break;
case PA_CONTEXT_CONNECTING :
@@ -383,6 +384,7 @@ pulseaudio_volume_set_muted (PulseaudioVolume *volume,
gboolean muted)
{
g_return_if_fail (IS_PULSEAUDIO_VOLUME (volume));
+ g_return_if_fail (volume->pa_context != NULL);
g_return_if_fail (pa_context_get_state (volume->pa_context) == PA_CONTEXT_READY);
if (volume->muted != muted)
@@ -456,6 +458,7 @@ pulseaudio_volume_set_volume (PulseaudioVolume *volume,
gdouble vol_trim;
g_return_if_fail (IS_PULSEAUDIO_VOLUME (volume));
+ g_return_if_fail (volume->pa_context != NULL);
g_return_if_fail (pa_context_get_state (volume->pa_context) == PA_CONTEXT_READY);
vol_max = pulseaudio_config_get_volume_max (volume->config) / 100.0;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list