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..4bc7797 100644 --- a/panel-plugin/xfce-mixer-plugin.c +++ b/panel-plugin/xfce-mixer-plugin.c @@ -191,6 +191,8 @@ static void xfce_mixer_plugin_construct (XfcePanelPlugin *plugin) { XfceMixerPlugin *mixer_plugin; + GstElement *card = NULL; + GstMixerTrack *track = NULL; /* Set up translation domain */ xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); @@ -218,6 +220,20 @@ xfce_mixer_plugin_construct (XfcePanelPlugin *plugin) /* Read config file */ xfce_mixer_plugin_read_config (mixer_plugin); + /* If no device or mixer channel are configured + * try to provide sensible defaults. */ + if (!mixer_plugin->card) + { + card = xfce_mixer_get_default_card(); + xfce_mixer_plugin_set_card (mixer_plugin, card); + } + + if (!mixer_plugin->track) + { + track = xfce_mixer_get_track (card, "Master"); + xfce_mixer_plugin_set_track (mixer_plugin, track); + } + /* Update the plugin if it was already set up */ if (G_LIKELY (GST_IS_MIXER (mixer_plugin->card) && GST_IS_MIXER_TRACK (mixer_plugin->track))) xfce_mixer_plugin_update_track (mixer_plugin);