[Xfce4-commits] [xfce/xfce4-power-manager] 09/63: Fix the scale's slider with Gtk3.14

noreply at xfce.org noreply at xfce.org
Sun Mar 22 13:02:04 CET 2015


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

eric pushed a commit to branch master
in repository xfce/xfce4-power-manager.

commit 9854e82312de01630452f01c353af79c755f9fb3
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Thu Mar 5 17:43:54 2015 +0100

    Fix the scale's slider with Gtk3.14
    
    This change was ported from libido upstream:
    http://bazaar.launchpad.net/~indicator-applet-developers/ido/trunk.15.04/revision/187
---
 panel-plugins/power-manager-plugin/scalemenuitem.c |   44 ++++++--------------
 1 file changed, 12 insertions(+), 32 deletions(-)

diff --git a/panel-plugins/power-manager-plugin/scalemenuitem.c b/panel-plugins/power-manager-plugin/scalemenuitem.c
index d16ff74..3a598e4 100644
--- a/panel-plugins/power-manager-plugin/scalemenuitem.c
+++ b/panel-plugins/power-manager-plugin/scalemenuitem.c
@@ -248,40 +248,22 @@ scale_menu_item_init (ScaleMenuItem *self)
 {
 }
 
-
-static void
-scale_menu_item_get_scale_allocation (ScaleMenuItem *menuitem,
-                                      GtkAllocation    *allocation)
-{
-  ScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);
-  GtkAllocation parent_allocation;
-
-  gtk_widget_get_allocation (GTK_WIDGET (menuitem), &parent_allocation);
-  gtk_widget_get_allocation (priv->scale, allocation);
-
-  allocation->x -= parent_allocation.x;
-  allocation->y -= parent_allocation.y;
-}
-
 static gboolean
 scale_menu_item_button_press_event (GtkWidget      *menuitem,
                                     GdkEventButton *event)
 {
   ScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);
   GtkAllocation alloc;
+  gint x, y;
 
   TRACE("entering");
 
-  scale_menu_item_get_scale_allocation (SCALE_MENU_ITEM (menuitem), &alloc);
-
-  event->x -= alloc.x;
-  event->y -= alloc.y;
+  gtk_widget_get_allocation (priv->scale, &alloc);
+  gtk_widget_translate_coordinates (menuitem, priv->scale, event->x, event->y, &x, &y);
 
-  event->x_root -= alloc.x;
-  event->y_root -= alloc.y;
-
-  gtk_widget_event (priv->scale,
-                    ((GdkEvent *)(void*)(event)));
+  if (x > 0 && x < alloc.width && y > 0 && y < alloc.height)
+    gtk_widget_event (priv->scale,
+                      ((GdkEvent *)(void*)(event)));
 
   if (!priv->grabbed)
     {
@@ -319,16 +301,14 @@ scale_menu_item_motion_notify_event (GtkWidget      *menuitem,
   ScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);
   GtkWidget *scale = priv->scale;
   GtkAllocation alloc;
+  gint x, y;
 
-  scale_menu_item_get_scale_allocation (SCALE_MENU_ITEM (menuitem), &alloc);
-
-  event->x -= alloc.x;
-  event->y -= alloc.y;
-
-  event->x_root -= alloc.x;
-  event->y_root -= alloc.y;
+  gtk_widget_get_allocation (priv->scale, &alloc);
+  gtk_widget_translate_coordinates (menuitem, priv->scale, event->x, event->y, &x, &y);
 
-  gtk_widget_event (scale, (GdkEvent*)event);
+  if (priv->grabbed ||
+      (x > 0 && x < alloc.width && y > 0 && y < alloc.height))
+    gtk_widget_event (scale, (GdkEvent*)event);
 
   return TRUE;
 }

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


More information about the Xfce4-commits mailing list