[glade] Fixed bug detecting widget including margins



commit 8f20c634f9f63ae866e432357eff77422c9cab8e
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date:   Thu Nov 3 19:08:03 2011 -0300

    Fixed bug detecting widget including margins

 ChangeLog                     |    4 +++-
 gladeui/glade-design-layout.c |   19 +++++++------------
 2 files changed, 10 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c8df621..772bf44 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
 2011-11-03  Juan Pablo Ugarte <juanpablougarte gmail com>
 
-	* gladeui/glade-design-layout.c: Added workaround for child bg bug on Adwaita theme.
+	* gladeui/glade-design-layout.c:
+	  o Added workaround for child bg bug on Adwaita theme.
+	  o Fixed bug detecting widget including margins
 	
 	* gladeui/glade-design-view.c: cleaned up glade_design_view_style_updated()
 	  to make it use new style context instead of modifying its own. 
diff --git a/gladeui/glade-design-layout.c b/gladeui/glade-design-layout.c
index 431adac..6814d53 100644
--- a/gladeui/glade-design-layout.c
+++ b/gladeui/glade-design-layout.c
@@ -381,7 +381,7 @@ glade_design_layout_motion_notify_event (GtkWidget *widget, GdkEventMotion *ev)
       case ACTIVITY_MARGINS:
         {
           gboolean shift = ev->state & GDK_SHIFT_MASK;
-          gboolean snap = ev->state & GDK_MOD1_MASK;
+          gboolean snap = ev->state & GDK_CONTROL_MASK;
           GtkWidget *selection = priv->selection;
           Margins margin = priv->margin;
 
@@ -471,25 +471,20 @@ static void
 glade_design_layout_find_inside_container (GtkWidget                *widget,
                                            GladeFindInContainerData *data)
 {
-  GtkAllocation allocation;
-  gint x, y, l, t;
+  gint x, y, w, h;
 
   if (data->gwidget || !gtk_widget_get_mapped (widget))
     return;
 
   gtk_widget_translate_coordinates (data->toplevel, widget, data->x, data->y,
                                     &x, &y);
-  gtk_widget_get_allocation (widget, &allocation);
-
+  
   /* Margins are not part of the widget allocation */
-  l = gtk_widget_get_margin_left (widget);
-  t = gtk_widget_get_margin_top (widget);
-
-  allocation.width += gtk_widget_get_margin_right (widget) + l;
-  allocation.height += gtk_widget_get_margin_bottom (widget) + t;
+  w = gtk_widget_get_allocated_width (widget) + gtk_widget_get_margin_right (widget);
+  h = gtk_widget_get_allocated_height (widget) + gtk_widget_get_margin_bottom (widget);
 
-  if (x >= (0-l) && x < allocation.width &&
-      y >= (0-t) && y < allocation.height)
+  if (x >= (0 - gtk_widget_get_margin_left (widget)) && x < w &&
+      y >= (0 - gtk_widget_get_margin_top (widget)) && y < h)
     {
       if (GLADE_IS_PLACEHOLDER (widget))
         data->placeholder = widget;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]