[Xfce4-commits] [panel-plugins/xfce4-pulseaudio-plugin] 01/01: Run mixer application when plugin button is clicked.
noreply at xfce.org
noreply at xfce.org
Wed Feb 18 01:16:05 CET 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 d68d6b8f31eb75d9240e8d30670b25ec3f1e3c30
Author: Andrzej <ndrwrdck at gmail.com>
Date: Wed Feb 18 00:15:56 2015 +0000
Run mixer application when plugin button is clicked.
Wired up a "mixer-name" property.
---
panel-plugin/pulseaudio-button.c | 14 +++++++++
panel-plugin/pulseaudio-config.c | 40 +++++++++++++++++++++++-
panel-plugin/pulseaudio-config.h | 1 +
panel-plugin/pulseaudio-dialog.c | 57 +++++++++++++++++++++++++++++++++-
panel-plugin/pulseaudio-dialog.glade | 1 +
5 files changed, 111 insertions(+), 2 deletions(-)
diff --git a/panel-plugin/pulseaudio-button.c b/panel-plugin/pulseaudio-button.c
index 4087de9..0399442 100644
--- a/panel-plugin/pulseaudio-button.c
+++ b/panel-plugin/pulseaudio-button.c
@@ -220,9 +220,23 @@ pulseaudio_button_button_release (GtkWidget *widget,
GdkEventButton *event)
{
PulseaudioButton *button = PULSEAUDIO_BUTTON (widget);
+ GError *error = NULL;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
+ if(event->button == 1) /* left button */
+ {
+ if (!xfce_spawn_command_line_on_screen (gtk_widget_get_screen (widget),
+ pulseaudio_config_get_mixer_name (button->config),
+ FALSE, FALSE, &error))
+ {
+ xfce_dialog_show_error (NULL, error, ("Failed to execute command \"%s\"."),
+ pulseaudio_config_get_mixer_name (button->config));
+ g_error_free (error);
+ }
+ return TRUE;
+ }
+
if (event->button == 2) /* middle button */
{
pulseaudio_volume_toggle_muted (button->volume);
diff --git a/panel-plugin/pulseaudio-config.c b/panel-plugin/pulseaudio-config.c
index a4cfaad..a3b9703 100644
--- a/panel-plugin/pulseaudio-config.c
+++ b/panel-plugin/pulseaudio-config.c
@@ -47,6 +47,7 @@
#define DEFAULT_ENABLE_KEYBOARD_SHORTCUTS TRUE
#define DEFAULT_VOLUME_STEP 6
+#define DEFAULT_MIXER_NAME "pavucontrol"
@@ -74,6 +75,7 @@ struct _PulseaudioConfig
gboolean enable_keyboard_shortcuts;
guint volume_step;
+ gchar *mixer_name;
};
@@ -83,6 +85,7 @@ enum
PROP_0,
PROP_ENABLE_KEYBOARD_SHORTCUTS,
PROP_VOLUME_STEP,
+ PROP_MIXER_NAME,
N_PROPERTIES,
};
@@ -127,6 +130,15 @@ pulseaudio_config_class_init (PulseaudioConfigClass *klass)
+ g_object_class_install_property (gobject_class,
+ PROP_MIXER_NAME,
+ g_param_spec_string ("mixer-name",
+ NULL, NULL,
+ DEFAULT_MIXER_NAME,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+
pulseaudio_config_signals[CONFIGURATION_CHANGED] =
g_signal_new (g_intern_static_string ("configuration-changed"),
G_TYPE_FROM_CLASS (gobject_class),
@@ -143,6 +155,7 @@ pulseaudio_config_init (PulseaudioConfig *config)
{
config->enable_keyboard_shortcuts = DEFAULT_ENABLE_KEYBOARD_SHORTCUTS;
config->volume_step = DEFAULT_VOLUME_STEP;
+ config->mixer_name = g_strdup (DEFAULT_MIXER_NAME);
}
@@ -150,9 +163,10 @@ pulseaudio_config_init (PulseaudioConfig *config)
static void
pulseaudio_config_finalize (GObject *object)
{
- //PulseaudioConfig *config = PULSEAUDIO_CONFIG (object);
+ PulseaudioConfig *config = PULSEAUDIO_CONFIG (object);
xfconf_shutdown();
+ g_free (config->mixer_name);
G_OBJECT_CLASS (pulseaudio_config_parent_class)->finalize (object);
}
@@ -177,6 +191,10 @@ pulseaudio_config_get_property (GObject *object,
g_value_set_uint (value, config->volume_step);
break;
+ case PROP_MIXER_NAME:
+ g_value_set_string (value, config->mixer_name);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -217,6 +235,11 @@ pulseaudio_config_set_property (GObject *object,
}
break;
+ case PROP_MIXER_NAME:
+ g_free (config->mixer_name);
+ config->mixer_name = g_value_dup_string (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -248,6 +271,17 @@ pulseaudio_config_get_volume_step (PulseaudioConfig *config)
+const gchar *
+pulseaudio_config_get_mixer_name (PulseaudioConfig *config)
+{
+ g_return_val_if_fail (IS_PULSEAUDIO_CONFIG (config), DEFAULT_MIXER_NAME);
+
+ return config->mixer_name;
+}
+
+
+
+
PulseaudioConfig *
pulseaudio_config_new (const gchar *property_base)
{
@@ -269,6 +303,10 @@ pulseaudio_config_new (const gchar *property_base)
xfconf_g_property_bind (channel, property, G_TYPE_UINT, config, "volume-step");
g_free (property);
+ property = g_strconcat (property_base, "/mixer-name", NULL);
+ xfconf_g_property_bind (channel, property, G_TYPE_STRING, config, "mixer-name");
+ g_free (property);
+
g_object_notify (G_OBJECT (config), "enable-keyboard-shortcuts");
g_signal_emit (G_OBJECT (config), pulseaudio_config_signals [CONFIGURATION_CHANGED], 0);
}
diff --git a/panel-plugin/pulseaudio-config.h b/panel-plugin/pulseaudio-config.h
index 26c7603..4a6b385 100644
--- a/panel-plugin/pulseaudio-config.h
+++ b/panel-plugin/pulseaudio-config.h
@@ -40,6 +40,7 @@ PulseaudioConfig *pulseaudio_config_new (const gchar
gboolean pulseaudio_config_get_enable_keyboard_shortcuts (PulseaudioConfig *config);
guint pulseaudio_config_get_volume_step (PulseaudioConfig *config);
+const gchar *pulseaudio_config_get_mixer_name (PulseaudioConfig *config);
G_END_DECLS
diff --git a/panel-plugin/pulseaudio-dialog.c b/panel-plugin/pulseaudio-dialog.c
index eba304a..5b4f8e4 100644
--- a/panel-plugin/pulseaudio-dialog.c
+++ b/panel-plugin/pulseaudio-dialog.c
@@ -53,6 +53,9 @@
static void pulseaudio_dialog_build (PulseaudioDialog *dialog);
static void pulseaudio_dialog_help_button_clicked (PulseaudioDialog *dialog,
GtkWidget *button);
+static void pulseaudio_dialog_mixer_name_changed (PulseaudioDialog *dialog);
+static void pulseaudio_dialog_run_mixer (PulseaudioDialog *dialog,
+ GtkWidget *widget);
@@ -91,6 +94,43 @@ pulseaudio_dialog_init (PulseaudioDialog *dialog)
+static void
+pulseaudio_dialog_mixer_name_changed (PulseaudioDialog *dialog)
+{
+ GObject *object;
+ gchar *path;
+
+ g_return_if_fail (GTK_IS_BUILDER (dialog));
+ g_return_if_fail (IS_PULSEAUDIO_CONFIG (dialog->config));
+
+ object = gtk_builder_get_object (GTK_BUILDER (dialog), "button-run-mixer");
+ g_return_if_fail (GTK_IS_BUTTON (object));
+ path = g_find_program_in_path (pulseaudio_config_get_mixer_name (dialog->config));
+ gtk_widget_set_sensitive (GTK_WIDGET (object), path != NULL);
+ g_free (path);
+}
+
+
+
+static void
+pulseaudio_dialog_run_mixer (PulseaudioDialog *dialog,
+ GtkWidget *widget)
+{
+ GError *error = NULL;
+
+ g_return_if_fail (IS_PULSEAUDIO_DIALOG (dialog));
+ g_return_if_fail (GTK_IS_BUTTON (widget));
+
+ if (!xfce_spawn_command_line_on_screen (gtk_widget_get_screen (widget),
+ pulseaudio_config_get_mixer_name (dialog->config),
+ FALSE, FALSE, &error))
+ {
+ xfce_dialog_show_error (NULL, error, ("Failed to execute command \"%s\"."),
+ pulseaudio_config_get_mixer_name (dialog->config));
+ g_error_free (error);
+ }
+}
+
static void
pulseaudio_dialog_build (PulseaudioDialog *dialog)
@@ -123,11 +163,26 @@ pulseaudio_dialog_build (PulseaudioDialog *dialog)
dialog);
object = gtk_builder_get_object (builder, "checkbutton-keyboard-shortcuts");
- g_return_if_fail (GTK_IS_WIDGET (object));
+ g_return_if_fail (GTK_IS_CHECK_BUTTON (object));
g_object_bind_property (G_OBJECT (dialog->config), "enable-keyboard-shortcuts",
G_OBJECT (object), "active",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+ object = gtk_builder_get_object (builder, "entry-mixer-name");
+ g_return_if_fail (GTK_IS_ENTRY (object));
+ g_object_bind_property (G_OBJECT (dialog->config), "mixer-name",
+ G_OBJECT (object), "text",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+ object = gtk_builder_get_object (builder, "button-run-mixer");
+ g_return_if_fail (GTK_IS_BUTTON (object));
+ g_signal_connect_swapped (G_OBJECT (dialog->config), "notify::mixer-name",
+ G_CALLBACK (pulseaudio_dialog_mixer_name_changed),
+ dialog);
+ pulseaudio_dialog_mixer_name_changed (dialog);
+ g_signal_connect_swapped (G_OBJECT (object), "clicked",
+ G_CALLBACK (pulseaudio_dialog_run_mixer), dialog);
+
}
else
{
diff --git a/panel-plugin/pulseaudio-dialog.glade b/panel-plugin/pulseaudio-dialog.glade
index f7035cf..5d3cbed 100644
--- a/panel-plugin/pulseaudio-dialog.glade
+++ b/panel-plugin/pulseaudio-dialog.glade
@@ -163,6 +163,7 @@
<object class="GtkEntry" id="entry-mixer-name">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="tooltip_text" translatable="yes">Name of the audio mixer application to start when the plugin button is pressed. E.g. "pavucontrol", "unity-control-center sound".</property>
<property name="invisible_char">•</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list