[Xfce4-commits] [panel-plugins/xfce4-pulseaudio-plugin] 21/21: Nicer markup code and translation on device menu item

noreply at xfce.org noreply at xfce.org
Sat Sep 23 21:27:47 CEST 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 c0c45aaee537ab3809ab6c43bb5355c6f62d0c9b
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Sat Sep 23 15:09:09 2017 -0400

    Nicer markup code and translation on device menu item
---
 panel-plugin/devicemenuitem.c | 42 ++++++++++++++++++++++++++++++------------
 po/POTFILES.in                |  1 +
 2 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/panel-plugin/devicemenuitem.c b/panel-plugin/devicemenuitem.c
index b627a2e..2b7bfa4 100644
--- a/panel-plugin/devicemenuitem.c
+++ b/panel-plugin/devicemenuitem.c
@@ -56,9 +56,12 @@ G_GNUC_END_IGNORE_DEPRECATIONS
 
 
 /* Static Declarations */
-static void   device_menu_item_finalize         (GObject *object);
-static void   device_menu_item_device_toggled   (DeviceMenuItem   *item,
-                                                 GtkCheckMenuItem *menu_item);
+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,
+                                                    ...);
 
 
 
@@ -121,6 +124,24 @@ 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)
@@ -128,7 +149,7 @@ device_menu_item_set_device_by_name (DeviceMenuItem *item,
   DeviceMenuItemPrivate *priv;
   GList                 *children = NULL;
   GList                 *iter = NULL;
-  gchar                 *markup = NULL;
+  gboolean               markup_set = FALSE;
 
   g_return_if_fail (IS_DEVICE_MENU_ITEM (item));
 
@@ -139,20 +160,17 @@ device_menu_item_set_device_by_name (DeviceMenuItem *item,
   for (iter = children; iter != NULL; iter = g_list_next (iter)) {
     if (g_strcmp0 (name, (gchar *)g_object_get_data (G_OBJECT(iter->data), "name")) == 0)
       {
-        if (markup != NULL)
-          g_free (markup);
-        markup = g_strconcat ("<b>", priv->title, " (", gtk_menu_item_get_label (GTK_MENU_ITEM (iter->data)), ")</b>", NULL);
+        /* 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_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (iter->data), TRUE);
+        markup_set = TRUE;
       } else {
         gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (iter->data), FALSE);
       }
   }
 
-  if (markup == NULL)
-    markup = g_strconcat ("<b>", priv->title, "</b>", NULL);
-
-  gtk_label_set_markup (GTK_LABEL (priv->label), markup);
-  g_free (markup);
+  if (!markup_set)
+    gtk_label_set_markup_printf_escaped (GTK_LABEL (priv->label), "<b>%s</b>", priv->title);
 
   g_list_free (children);
 }
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0cae865..b98bd3f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -7,4 +7,5 @@ panel-plugin/pulseaudio-button.c
 panel-plugin/pulseaudio-volume.c
 panel-plugin/pulseaudio-menu.c
 panel-plugin/pulseaudio-notify.c
+panel-plugin/devicemenuitem.c
 panel-plugin/mprismenuitem.c

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


More information about the Xfce4-commits mailing list