[Xfce4-commits] [panel-plugins/xfce4-pulseaudio-plugin] 01/01: Added a tooltip

noreply at xfce.org noreply at xfce.org
Tue Feb 17 22:03:15 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 50c66c9069305f2258b2a5800bf2623364158cd7
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Tue Feb 17 21:03:04 2015 +0000

    Added a tooltip
---
 panel-plugin/pulseaudio-button.c |   27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/panel-plugin/pulseaudio-button.c b/panel-plugin/pulseaudio-button.c
index 3a8d1c3..15d940d 100644
--- a/panel-plugin/pulseaudio-button.c
+++ b/panel-plugin/pulseaudio-button.c
@@ -25,6 +25,15 @@
 
 
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_MATH_H
+#include <math.h>
+#endif
+
+
 #include <glib.h>
 #include <gtk/gtk.h>
 #include <libxfce4panel/libxfce4panel.h>
@@ -150,6 +159,8 @@ pulseaudio_button_init (PulseaudioButton *button)
   gtk_container_add (GTK_CONTAINER (button), button->image);
   gtk_widget_show (button->image);
 
+  g_object_set (G_OBJECT (button), "has-tooltip", TRUE, NULL);
+
   pulseaudio_button_update (button, TRUE);
 
   //button->align_box = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
@@ -287,13 +298,16 @@ static void
 pulseaudio_button_update (PulseaudioButton *button,
                           gboolean          force_update)
 {
-  guint   idx;
-  gdouble volume;
+  guint     idx;
+  gdouble   volume;
+  gboolean  muted;
+  gchar    *tip_text;
 
   g_return_if_fail (IS_PULSEAUDIO_BUTTON (button));
 
   volume = pulseaudio_volume_get_volume (button->volume);
-  if (pulseaudio_volume_get_muted (button->volume))
+  muted = pulseaudio_volume_get_muted (button->volume);
+  if (muted)
     idx = V_MUTED;
   else if (volume <= 0.0)
     idx = V_MUTED;
@@ -304,6 +318,13 @@ pulseaudio_button_update (PulseaudioButton *button,
   else
     idx = V_HIGH;
 
+  if (muted)
+    tip_text = g_strdup_printf (("Volume %d%% (muted)"), (gint) round (volume * 100));
+  else
+    tip_text = g_strdup_printf (("Volume %d%%"), (gint) round (volume * 100));
+  gtk_widget_set_tooltip_text (GTK_WIDGET (button), tip_text);
+  g_free (tip_text);
+
   if (force_update || button->pixbuf_idx != idx)
     {
       button->pixbuf_idx = idx;

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


More information about the Xfce4-commits mailing list