[Xfce4-commits] [apps/xfce4-volumed-pulse] 01/10: Add a hidden xfconf property "icon-style" for enabling symbolic icons
noreply at xfce.org
noreply at xfce.org
Wed Sep 14 03:15:09 CEST 2016
This is an automated email from the git hooks/post-receive script.
bluesabre pushed a commit to branch master
in repository apps/xfce4-volumed-pulse.
commit 3f5e84f150d94321e32768c5ba2097b25e74c406
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date: Sun Sep 11 22:23:08 2016 +0200
Add a hidden xfconf property "icon-style" for enabling symbolic icons
0: normal icons (default), 1: symbolic icons
---
src/main.c | 26 +++++++++++++-------------
src/xvd_data_types.h | 17 +++++++++++++++--
src/xvd_notify.c | 15 +++++----------
src/xvd_xfconf.c | 28 +++++++++++++++++++---------
4 files changed, 52 insertions(+), 34 deletions(-)
diff --git a/src/main.c b/src/main.c
index 5f9a88d..1f53de4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -80,29 +80,30 @@ xvd_daemonize(void)
#endif
}
-static void
+static void
xvd_shutdown(void)
{
xvd_close_pulse (Inst);
-
+
#ifdef HAVE_LIBNOTIFY
xvd_notify_uninit (Inst);
#endif
-
+
xvd_keys_release (Inst);
xvd_xfconf_shutdown (Inst);
-
+
//TODO xvd_instance_free
}
-static void
+static void
xvd_instance_init(XvdInstance *i)
{
i->pa_main_loop = NULL;
i->pulse_context = NULL;
i->sink_index = -1;
i->source_index = -1;
- i->chan = NULL;
+ i->mixer_chan = NULL;
+ i->settings = NULL;
i->loop = NULL;
#ifdef HAVE_LIBNOTIFY
i->gauge_notifications = FALSE;
@@ -111,7 +112,7 @@ xvd_instance_init(XvdInstance *i)
#endif
}
-gint
+gint
main(gint argc, gchar **argv)
{
GError *error = NULL;
@@ -169,7 +170,7 @@ main(gint argc, gchar **argv)
xvd_shutdown ();
return EXIT_FAILURE;
}
-
+
/* Pulse init */
if (!xvd_open_pulse (Inst))
{
@@ -177,19 +178,18 @@ main(gint argc, gchar **argv)
xvd_shutdown ();
return EXIT_FAILURE;
}
-
+
xvd_xfconf_get_vol_step (Inst);
-
+
/* Libnotify init and idle till ready for the main loop */
g_set_application_name (XVD_APPNAME);
#ifdef HAVE_LIBNOTIFY
xvd_notify_init (Inst, XVD_APPNAME);
#endif
-
+
Inst->loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (Inst->loop);
-
+
xvd_shutdown ();
return 0;
}
-
diff --git a/src/xvd_data_types.h b/src/xvd_data_types.h
index dfd33d0..99965a9 100644
--- a/src/xvd_data_types.h
+++ b/src/xvd_data_types.h
@@ -40,9 +40,21 @@
#define XFCONF_MIXER_CHANNEL_NAME "xfce4-mixer"
#define XFCONF_MIXER_VOL_STEP "/volume-step-size"
#define VOL_STEP_DEFAULT_VAL 5
+#define XFCONF_VOLUMED_PULSE_CHANNEL_NAME "xfce4-volumed-pulse"
+#define XFCONF_ICON_STYLE_PROP "/icon-style"
+#define ICONS_STYLE_NORMAL 0
+#define ICONS_STYLE_SYMBOLIC 0
#define XVD_APPNAME "Xfce volume daemon"
+/* Icon names for the various audio notifications */
+#define ICON_AUDIO_VOLUME_MUTED "audio-volume-muted"
+#define ICON_AUDIO_VOLUME_OFF "audio-volume-off"
+#define ICON_AUDIO_VOLUME_LOW "audio-volume-low"
+#define ICON_AUDIO_VOLUME_MEDIUM "audio-volume-medium"
+#define ICON_AUDIO_VOLUME_HIGH "audio-volume-high"
+#define ICON_MICROPHONE_MUTED "microphone-sensitivity-muted"
+#define ICON_MICROPHONE_HIGH "microphone-sensitivity-high"
typedef enum _XvdVolStepDirection
{
@@ -59,11 +71,12 @@ typedef struct {
pa_cvolume volume;
int mute;
int mic_mute;
-
+
/* Xfconf vars */
XfconfChannel *chan;
+ XfconfChannel *settings;
guint vol_step;
-
+
#ifdef HAVE_LIBNOTIFY
/* Libnotify vars */
gboolean gauge_notifications;
diff --git a/src/xvd_notify.c b/src/xvd_notify.c
index 8999627..63a4b1f 100644
--- a/src/xvd_notify.c
+++ b/src/xvd_notify.c
@@ -25,17 +25,8 @@
#include <libnotify/notify.h>
#include "xvd_pulse.h"
-
#include "xvd_notify.h"
-
-/* Icon names for the various audio notifications */
-#define ICON_AUDIO_VOLUME_MUTED "audio-volume-muted"
-#define ICON_AUDIO_VOLUME_OFF "audio-volume-off"
-#define ICON_AUDIO_VOLUME_LOW "audio-volume-low"
-#define ICON_AUDIO_VOLUME_MEDIUM "audio-volume-medium"
-#define ICON_AUDIO_VOLUME_HIGH "audio-volume-high"
-#define ICON_MICROPHONE_MUTED "microphone-sensitivity-muted"
-#define ICON_MICROPHONE_HIGH "microphone-sensitivity-high"
+#include "xvd_xfconf.h"
void
xvd_notify_notification(XvdInstance *Inst,
@@ -54,6 +45,10 @@ xvd_notify_notification(XvdInstance *Inst,
title = g_strdup_printf ("Volume is at %d%c", value, '%');
}
+ if (xfconf_channel_get_uint (Inst->settings, XFCONF_ICON_STYLE_PROP,
+ ICONS_STYLE_NORMAL) == ICONS_STYLE_SYMBOLIC)
+ icon = g_strconcat (icon, "-symbolic", NULL);
+
notify_notification_update (Inst->notification,
title,
NULL,
diff --git a/src/xvd_xfconf.c b/src/xvd_xfconf.c
index 9681880..2969472 100644
--- a/src/xvd_xfconf.c
+++ b/src/xvd_xfconf.c
@@ -20,7 +20,6 @@
#include "xvd_xfconf.h"
-
static void
_xvd_xfconf_reinit_vol_step(XvdInstance *Inst)
{
@@ -28,7 +27,7 @@ _xvd_xfconf_reinit_vol_step(XvdInstance *Inst)
g_debug ("Xfconf reinit: volume step is now %u\n", Inst->vol_step);
}
-static void
+static void
_xvd_xfconf_handle_changes(XfconfChannel *re_channel,
const gchar *re_property_name,
const GValue *re_value,
@@ -36,7 +35,7 @@ _xvd_xfconf_handle_changes(XfconfChannel *re_channel,
{
XvdInstance *Inst = (XvdInstance *)ptr;
g_debug ("Xfconf event on %s\n", re_property_name);
-
+
if (g_strcmp0 (re_property_name, XFCONF_MIXER_VOL_STEP) == 0) {
_xvd_xfconf_reinit_vol_step(Inst);
}
@@ -53,25 +52,36 @@ xvd_xfconf_init(XvdInstance *Inst)
return FALSE;
}
- Inst->chan = xfconf_channel_get (XFCONF_MIXER_CHANNEL_NAME);
- g_signal_connect (G_OBJECT (Inst->chan), "property-changed", G_CALLBACK (_xvd_xfconf_handle_changes), Inst);
+ /* Initialize an xfconf channel for xfce4-volumed-pulse */
+ Inst->settings = xfconf_channel_new (XFCONF_VOLUMED_PULSE_CHANNEL_NAME);
+ if (!xfconf_channel_has_property (Inst->settings, XFCONF_ICON_STYLE_PROP)) {
+ if (!xfconf_channel_set_uint (Inst->settings, XFCONF_ICON_STYLE_PROP,
+ ICONS_STYLE_NORMAL))
+ g_warning ("Couldn't set icon-style property to 0.");
+ }
+
+ Inst->mixer_chan = xfconf_channel_get (XFCONF_MIXER_CHANNEL_NAME);
+ g_signal_connect (G_OBJECT (Inst->mixer_chan), "property-changed", G_CALLBACK (_xvd_xfconf_handle_changes), Inst);
+
return TRUE;
}
-void
+void
xvd_xfconf_get_vol_step(XvdInstance *Inst)
{
- Inst->vol_step = xfconf_channel_get_uint (Inst->chan, XFCONF_MIXER_VOL_STEP, VOL_STEP_DEFAULT_VAL);
+ Inst->vol_step = xfconf_channel_get_uint (Inst->mixer_chan, XFCONF_MIXER_VOL_STEP, VOL_STEP_DEFAULT_VAL);
if (Inst->vol_step > 100) {
g_debug ("%s\n", "The volume step xfconf property is out of range, setting back to default");
Inst->vol_step = VOL_STEP_DEFAULT_VAL;
- xfconf_channel_set_uint (Inst->chan, XFCONF_MIXER_VOL_STEP, VOL_STEP_DEFAULT_VAL);
+ xfconf_channel_set_uint (Inst->mixer_chan, XFCONF_MIXER_VOL_STEP, VOL_STEP_DEFAULT_VAL);
}
g_debug("%s %u\n", "Xfconf volume step:", Inst->vol_step);
}
-void
+void
xvd_xfconf_shutdown(XvdInstance *Inst)
{
+ if(Inst->settings)
+ g_object_unref(Inst->settings);
xfconf_shutdown ();
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list