[Xfce4-commits] [panel-plugins/xfce4-pulseaudio-plugin] 01/01: Simplify device menus, move below volume controls and hide if only 1 item

noreply at xfce.org noreply at xfce.org
Thu Nov 23 02:14:49 CET 2017


This is an automated email from the git hooks/post-receive script.

b   l   u   e   s   a   b   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository panel-plugins/xfce4-pulseaudio-plugin.

commit 826033cd9189ef4a9301fa4d5a4d8e7fd597a45c
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Wed Nov 22 20:14:43 2017 -0500

    Simplify device menus, move below volume controls and hide if only 1 item
---
 panel-plugin/devicemenuitem.c  | 25 ++---------------
 panel-plugin/pulseaudio-menu.c | 64 +++++++++++++++++++++++-------------------
 2 files changed, 37 insertions(+), 52 deletions(-)

diff --git a/panel-plugin/devicemenuitem.c b/panel-plugin/devicemenuitem.c
index 2b7bfa4..0032f3e 100644
--- a/panel-plugin/devicemenuitem.c
+++ b/panel-plugin/devicemenuitem.c
@@ -59,9 +59,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS
 static void   device_menu_item_finalize            (GObject *object);
 static void   device_menu_item_device_toggled      (DeviceMenuItem   *item,
                                                     GtkCheckMenuItem *menu_item);
-static void   gtk_label_set_markup_printf_escaped  (GtkLabel    *label,
-                                                    const gchar *format,
-                                                    ...);
 
 
 
@@ -124,24 +121,6 @@ device_menu_item_add_device (DeviceMenuItem *item,
 
 
 
-static void
-gtk_label_set_markup_printf_escaped (GtkLabel    *label,
-                                     const gchar *format,
-                                     ...)
-{
-  va_list args;
-  gchar *str;
-
-  va_start (args, format);
-  str = g_markup_vprintf_escaped (format, args);
-  gtk_label_set_markup (label, str);
-  va_end (args);
-
-  g_free (str);
-}
-
-
-
 void
 device_menu_item_set_device_by_name (DeviceMenuItem *item,
                                      const gchar    *name)
@@ -161,7 +140,7 @@ device_menu_item_set_device_by_name (DeviceMenuItem *item,
     if (g_strcmp0 (name, (gchar *)g_object_get_data (G_OBJECT(iter->data), "name")) == 0)
       {
         /* TRANSLATORS: <b>{Input/Output} ({Device Name})</b> */
-        gtk_label_set_markup_printf_escaped (GTK_LABEL (priv->label), _("<b>%s (%s)</b>"), priv->title, gtk_menu_item_get_label (GTK_MENU_ITEM (iter->data)));
+        gtk_label_set_markup (GTK_LABEL (priv->label), gtk_menu_item_get_label (GTK_MENU_ITEM (iter->data)));
         gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (iter->data), TRUE);
         markup_set = TRUE;
       } else {
@@ -170,7 +149,7 @@ device_menu_item_set_device_by_name (DeviceMenuItem *item,
   }
 
   if (!markup_set)
-    gtk_label_set_markup_printf_escaped (GTK_LABEL (priv->label), "<b>%s</b>", priv->title);
+    gtk_label_set_markup (GTK_LABEL (priv->label), priv->title);
 
   g_list_free (children);
 }
diff --git a/panel-plugin/pulseaudio-menu.c b/panel-plugin/pulseaudio-menu.c
index 8ae0afc..e1c5e58 100644
--- a/panel-plugin/pulseaudio-menu.c
+++ b/panel-plugin/pulseaudio-menu.c
@@ -443,19 +443,6 @@ pulseaudio_menu_new (PulseaudioVolume *volume,
   /* Output Devices */
   sources = pulseaudio_volume_get_output_list (menu->volume);
   if (g_list_length (sources) > 0) {
-    device_mi = device_menu_item_new_with_label (_("Output"));
-
-    for (GList *list = sources; list != NULL; list = g_list_next (list)) {
-      device_menu_item_add_device (DEVICE_MENU_ITEM (device_mi), (gchar *)list->data, pulseaudio_volume_get_output_by_name (menu->volume, list->data));
-    }
-
-    device_menu_item_set_device_by_name (DEVICE_MENU_ITEM (device_mi), pulseaudio_volume_get_default_output (menu->volume));
-    gtk_widget_show (device_mi);
-
-    g_signal_connect_swapped (G_OBJECT (device_mi), "device-changed", G_CALLBACK (pulseaudio_menu_default_output_changed), menu);
-
-    gtk_menu_shell_append (GTK_MENU_SHELL (menu), device_mi);
-
     /* output volume slider */
     menu->output_scale = scale_menu_item_new_with_range (0.0, volume_max, 1.0);
     scale_menu_item_set_base_icon_name (SCALE_MENU_ITEM (menu->output_scale), "audio-volume");
@@ -467,6 +454,22 @@ pulseaudio_menu_new (PulseaudioVolume *volume,
     gtk_widget_show_all (menu->output_scale);
     gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu->output_scale);
 
+    /* output device items */
+    if (g_list_length (sources) > 1) {
+      device_mi = device_menu_item_new_with_label(_("Output"));
+      for (GList *list = sources; list != NULL; list = g_list_next(list))
+      {
+        device_menu_item_add_device(DEVICE_MENU_ITEM(device_mi), (gchar *)list->data, pulseaudio_volume_get_output_by_name(menu->volume, list->data));
+      }
+
+      device_menu_item_set_device_by_name(DEVICE_MENU_ITEM(device_mi), pulseaudio_volume_get_default_output(menu->volume));
+      gtk_widget_show(device_mi);
+
+      g_signal_connect_swapped(G_OBJECT(device_mi), "device-changed", G_CALLBACK(pulseaudio_menu_default_output_changed), menu);
+
+      gtk_menu_shell_append(GTK_MENU_SHELL(menu), device_mi);
+    }
+
     /* separator */
     mi = gtk_separator_menu_item_new ();
     gtk_widget_show (mi);
@@ -477,19 +480,6 @@ pulseaudio_menu_new (PulseaudioVolume *volume,
   /* Input Devices */
   sources = pulseaudio_volume_get_input_list (menu->volume);
   if (g_list_length (sources) > 0) {
-    device_mi = device_menu_item_new_with_label (_("Input"));
-
-    for (GList *list = sources; list != NULL; list = g_list_next (list)) {
-      device_menu_item_add_device (DEVICE_MENU_ITEM (device_mi), (gchar *)list->data, pulseaudio_volume_get_input_by_name (menu->volume, list->data));
-    }
-
-    device_menu_item_set_device_by_name (DEVICE_MENU_ITEM (device_mi), pulseaudio_volume_get_default_input (menu->volume));
-    gtk_widget_show (device_mi);
-
-    g_signal_connect_swapped (G_OBJECT (device_mi), "device-changed", G_CALLBACK (pulseaudio_menu_default_input_changed), menu);
-
-    gtk_menu_shell_append (GTK_MENU_SHELL (menu), device_mi);
-
     /* input volume slider */
     menu->input_scale = scale_menu_item_new_with_range (0.0, volume_max, 1.0);
     scale_menu_item_set_base_icon_name (SCALE_MENU_ITEM (menu->input_scale), "microphone-sensitivity");
@@ -501,10 +491,26 @@ pulseaudio_menu_new (PulseaudioVolume *volume,
     gtk_widget_show_all (menu->input_scale);
     gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu->input_scale);
 
+    /* input device items */
+    if (g_list_length(sources) > 1) {
+      device_mi = device_menu_item_new_with_label(_("Input"));
+      for (GList *list = sources; list != NULL; list = g_list_next(list))
+      {
+        device_menu_item_add_device(DEVICE_MENU_ITEM(device_mi), (gchar *)list->data, pulseaudio_volume_get_input_by_name(menu->volume, list->data));
+      }
+
+      device_menu_item_set_device_by_name(DEVICE_MENU_ITEM(device_mi), pulseaudio_volume_get_default_input(menu->volume));
+      gtk_widget_show(device_mi);
+
+      g_signal_connect_swapped(G_OBJECT(device_mi), "device-changed", G_CALLBACK(pulseaudio_menu_default_input_changed), menu);
+
+      gtk_menu_shell_append(GTK_MENU_SHELL(menu), device_mi);
+    }
+
     /* separator */
-    mi = gtk_separator_menu_item_new ();
-    gtk_widget_show (mi);
-    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+    mi = gtk_separator_menu_item_new();
+    gtk_widget_show(mi);
+    gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
   }
 
   /* MPRIS2 */

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


More information about the Xfce4-commits mailing list