[Xfce4-commits] [panel-plugins/xfce4-pulseaudio-plugin] 01/08: Allow execution of the mixer from context menu

noreply at xfce.org noreply at xfce.org
Tue Mar 3 23:45:56 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 c153fd53ff2d589412b2c4fcac10aa89e9cf46bf
Author: Guido Berhoerster <guido+xfce at berhoerster.name>
Date:   Mon Mar 2 23:08:21 2015 +0100

    Allow execution of the mixer from context menu
---
 panel-plugin/pulseaudio-dialog.glade |    6 +++---
 panel-plugin/pulseaudio-plugin.c     |   38 ++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/panel-plugin/pulseaudio-dialog.glade b/panel-plugin/pulseaudio-dialog.glade
index 5d3cbed..9f0030e 100644
--- a/panel-plugin/pulseaudio-dialog.glade
+++ b/panel-plugin/pulseaudio-dialog.glade
@@ -151,7 +151,7 @@
                               <object class="GtkLabel" id="label2">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
-                                <property name="label" translatable="yes">Mixer _tool</property>
+                                <property name="label" translatable="yes">Audio _Mixer</property>
                                 <property name="use_underline">True</property>
                               </object>
                               <packing>
@@ -163,7 +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="tooltip_text" translatable="yes">Audio mixer command that can be executed from the context menu, 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>
@@ -184,7 +184,7 @@
                                 <property name="xscale">0</property>
                                 <child>
                                   <object class="GtkButton" id="button-run-mixer">
-                                    <property name="label" translatable="yes">_Run mixer tool...</property>
+                                    <property name="label" translatable="yes">_Run Audio Mixer...</property>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">True</property>
diff --git a/panel-plugin/pulseaudio-plugin.c b/panel-plugin/pulseaudio-plugin.c
index ce026e2..548614b 100644
--- a/panel-plugin/pulseaudio-plugin.c
+++ b/panel-plugin/pulseaudio-plugin.c
@@ -32,6 +32,7 @@
 
 #include <gtk/gtk.h>
 #include <libxfce4util/libxfce4util.h>
+#include <libxfce4ui/libxfce4ui.h>
 #include <libxfce4panel/xfce-panel-plugin.h>
 
 #include "pulseaudio-plugin.h"
@@ -320,9 +321,35 @@ pulseaudio_plugin_mute_pressed (const char            *keystring,
 
 
 static void
+pulseaudio_plugin_mixer_item_activate_cb (PulseaudioPlugin *pulseaudio_plugin,
+                                          GtkMenuItem      *menu_item)
+{
+  const gchar *command;
+  GError      *error = NULL;
+
+  g_return_if_fail (IS_PULSEAUDIO_PLUGIN (pulseaudio_plugin));
+
+  command = pulseaudio_config_get_mixer_name (pulseaudio_plugin->config);
+  if (!xfce_spawn_command_line_on_screen (gtk_widget_get_screen (GTK_WIDGET (menu_item)),
+                                          command, FALSE, FALSE, &error))
+    {
+      xfce_dialog_show_error (NULL, error,
+                              _("Could not execute the command \"%s\". "
+                                "Ensure that either the location of the command "
+                                "is included in the PATH environment variable or "
+                                "that you are providing the full path to the "
+                                "command."), command);
+      g_error_free (error);
+    }
+}
+
+
+static void
 pulseaudio_plugin_construct (XfcePanelPlugin *plugin)
 {
   PulseaudioPlugin *pulseaudio_plugin = PULSEAUDIO_PLUGIN (plugin);
+  GtkWidget        *mixer_menu_item;
+  GtkWidget        *separator;
 
 #ifdef HAVE_IDO
   ido_init();
@@ -359,6 +386,17 @@ pulseaudio_plugin_construct (XfcePanelPlugin *plugin)
   /* volume controller */
   pulseaudio_plugin->volume = pulseaudio_volume_new ();
 
+  /* menu items */
+  separator = gtk_separator_menu_item_new ();
+  xfce_panel_plugin_menu_insert_item (plugin, GTK_MENU_ITEM (separator));
+  gtk_widget_show (separator);
+
+  mixer_menu_item = gtk_menu_item_new_with_mnemonic (_("Run Audio Mi_xer"));
+  xfce_panel_plugin_menu_insert_item (plugin, GTK_MENU_ITEM (mixer_menu_item));
+  g_signal_connect_swapped (G_OBJECT (mixer_menu_item), "activate",
+    G_CALLBACK (pulseaudio_plugin_mixer_item_activate_cb), pulseaudio_plugin);
+  gtk_widget_show (mixer_menu_item);
+
   /* instantiate a button box */
   pulseaudio_plugin->button = pulseaudio_button_new (pulseaudio_plugin->config,
                                                      pulseaudio_plugin->volume);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list