[PATCH] xfce-mixer-applet: default device/track
Mark Pustjens
pustjens at dds.nl
Mon Aug 9 14:10:21 CEST 2010
Hi List,
If found that by default no device and track are selected when adding a
mixer applet by manually editing the configuration. This happens for
example when you want systemwide configuration using /etc/xdg/xfce/panel.
If you add the applet using the gui method you get a configuration dialog
when adding, and this problem does not occur.
This patch attempts to select a default device and mixer track when
nothing was configured.
The patch was made against git but tested against xfce-mixer 4.6.1.
Please let me know what you think.
Greetings/Groetjes
Mark Pustjens
--
diff --git a/libxfce4mixer/libxfce4mixer.c b/libxfce4mixer/libxfce4mixer.c
index 69746c0..9fe79c4 100644
--- a/libxfce4mixer/libxfce4mixer.c
+++ b/libxfce4mixer/libxfce4mixer.c
@@ -127,6 +127,26 @@ xfce_mixer_get_card (const gchar *name)
+GstElement *
+xfce_mixer_get_default_card (void)
+{
+ GstElement *element = NULL;
+ GList *iter;
+ gchar *card_name;
+
+ g_return_val_if_fail (refcount > 0, NULL);
+
+ iter = g_list_first (mixers);
+
+ if (iter) {
+ element = iter->data;
+ }
+
+ return element;
+}
+
+
+
const gchar *
xfce_mixer_get_card_display_name (GstElement *card)
{
diff --git a/libxfce4mixer/libxfce4mixer.h b/libxfce4mixer/libxfce4mixer.h
index e19b463..7b47fae 100644
--- a/libxfce4mixer/libxfce4mixer.h
+++ b/libxfce4mixer/libxfce4mixer.h
@@ -37,6 +37,7 @@ void xfce_mixer_shutdown (void);
GList *xfce_mixer_get_cards (void);
GstElement *xfce_mixer_get_card (const gchar *name);
+GstElement *xfce_mixer_get_default_card (void);
const gchar *xfce_mixer_get_card_internal_name (GstElement *card);
const gchar *xfce_mixer_get_card_display_name (GstElement *card);
void xfce_mixer_select_card (GstElement *card);
diff --git a/panel-plugin/xfce-mixer-plugin.c b/panel-plugin/xfce-mixer-plugin.c
index af26ba2..d458bfc 100644
--- a/panel-plugin/xfce-mixer-plugin.c
+++ b/panel-plugin/xfce-mixer-plugin.c
@@ -474,8 +474,18 @@ xfce_mixer_plugin_read_config (XfceMixerPlugin *mixer_plugin)
command = xfce_rc_read_entry (rc, "command", command);
/* Get card and track */
- card = xfce_mixer_get_card (card_name);
- track = xfce_mixer_get_track (card, track_name);
+ if (card_name) {
+ card = xfce_mixer_get_card (card_name);
+ } else {
+ card = xfce_mixer_get_default_card();
+ }
+
+ if (track_name) {
+ /* Control the master mixer channel by default */
+ track = xfce_mixer_get_track (card, "Master");
+ } else {
+ track = xfce_mixer_get_track (card, track_name);
+ }
/* Update plugin values */
xfce_mixer_plugin_set_card (mixer_plugin, card);
More information about the Xfce4-dev
mailing list