Modified the procedure to get the widget at a point inside the pannable area when...
authorAlejandro G. Castro <alex@igalia.com>
Tue, 29 Jul 2008 10:50:16 +0000 (10:50 +0000)
committerAlejandro G. Castro <alex@igalia.com>
Tue, 29 Jul 2008 10:50:16 +0000 (10:50 +0000)
* src/hildon-marshalers.list: Modified the marshallers, now we do
not have the widget as a parameter.

* src/hildon-pannable-area.c
(hildon_pannable_area_motion_notify_cb),
(hildon_pannable_area_class_init),
(hildon_pannable_get_child_widget_at):  Removed the widget
parameter from the signal callback. We have also refactored the
emission of the signals.

* src/hildon-pannable-area.h: Added a new method to the API to
calculate a widget at a point inside the pannable area,
hildon_pannable_get_child_widget_at.

* examples/hildon-pannable-area-example-4.c
(horizontal_movement): Modified the example to use the new API,
added condition to control which widget is under the event. This
way we can avoid scrolling laterally over other widgets.

ChangeLog
examples/hildon-pannable-area-example-4.c
src/hildon-marshalers.list
src/hildon-pannable-area.c
src/hildon-pannable-area.h

index 299a551..a672e34 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,32 @@
 2008-07-29  Alejandro G. Castro         <alex@igalia.com>
 
+       Modified the procedure to get the widget at a point inside the
+       pannable area when using the movement type signals. Now the user
+       has to call a function to get the child, that way we just
+       calculate the child in case the user really want to use it and not
+       all the time.
+
+       * src/hildon-marshalers.list: Modified the marshallers, now we do
+       not have the widget as a parameter.
+
+       * src/hildon-pannable-area.c
+       (hildon_pannable_area_motion_notify_cb),
+       (hildon_pannable_area_class_init),
+       (hildon_pannable_get_child_widget_at):  Removed the widget
+       parameter from the signal callback. We have also refactored the
+       emission of the signals.
+
+       * src/hildon-pannable-area.h: Added a new method to the API to
+       calculate a widget at a point inside the pannable area,
+       hildon_pannable_get_child_widget_at.
+
+       * examples/hildon-pannable-area-example-4.c
+       (horizontal_movement): Modified the example to use the new API,
+       added condition to control which widget is under the event. This
+       way we can avoid scrolling laterally over other widgets.
+
+2008-07-29  Alejandro G. Castro         <alex@igalia.com>
+
        * src/hildon-pannable-area.c
        (hildon_pannable_area_motion_notify_cb): Fixed bug handling the
        modes, we stop getting the pointer events due to returning the
index 6b365e1..3d5ae87 100644 (file)
@@ -39,32 +39,34 @@ HiddenColContext *ctx;
 static void
 horizontal_movement (HildonPannableArea *area,
                      HildonPannableAreaMovDirection direction,
-                    GtkWidget *widget, gdouble x, gdouble y,
-                     gpointer user_data)
+                    gdouble x, gdouble y, gpointer user_data)
 {
   GtkTreePath *path;
   GdkRectangle rect;
   gint col_x;
   GtkTreeViewColumn *col = GTK_TREE_VIEW_COLUMN (user_data);
+  GtkWidget *child = hildon_pannable_get_child_widget_at (area, x, y);
 
-  g_print ("widget %p treeview %p\n", widget, ctx->treeview);
+  g_print ("widget %p treeview %p\n", child, ctx->treeview);
 
-  if (direction == HILDON_PANNABLE_AREA_MOV_LEFT) {
+  if (child == ctx->treeview) {
+    if (direction == HILDON_PANNABLE_AREA_MOV_LEFT){
 
-    path = gtk_tree_path_new_first ();
+      path = gtk_tree_path_new_first ();
 
-    gtk_tree_view_get_background_area (GTK_TREE_VIEW (ctx->treeview),
-                                       path, col, &rect);
+      gtk_tree_view_get_background_area (GTK_TREE_VIEW (ctx->treeview),
+                                         path, col, &rect);
 
-    gtk_tree_view_convert_bin_window_to_tree_coords (GTK_TREE_VIEW (ctx->treeview),
-                                                     rect.x, 0, &col_x, NULL);
+      gtk_tree_view_convert_bin_window_to_tree_coords (GTK_TREE_VIEW (ctx->treeview),
+                                                       rect.x, 0, &col_x, NULL);
 
-    gtk_tree_path_free (path);
+      gtk_tree_path_free (path);
 
-    hildon_pannable_area_scroll_to (area, col_x, -1);
-  }
-  else {
-    hildon_pannable_area_scroll_to (area, 0, -1);
+      hildon_pannable_area_scroll_to (area, col_x, -1);
+    }
+    else {
+      hildon_pannable_area_scroll_to (area, 0, -1);
+    }
   }
 
   g_print ("horizontal_movement %lf, %lf\n", x, y);
index d4a7f30..58c0ec6 100644 (file)
@@ -28,4 +28,4 @@ BOOLEAN:INT,INT,INT
 BOOLEAN:POINTER
 VOID:OBJECT
 VOID:VOID
-VOID:INT,OBJECT,DOUBLE,DOUBLE
+VOID:INT,DOUBLE,DOUBLE
index df4bd11..62452d0 100644 (file)
@@ -722,29 +722,17 @@ hildon_pannable_area_motion_notify_cb (GtkWidget * widget,
     priv->moved = TRUE;
 
     if (priv->first_drag) {
-      GdkWindow *window = NULL;
-      GtkWidget *child_widget = NULL;
-
-      window = hildon_pannable_area_get_topmost
-        (gtk_bin_get_child (GTK_BIN (widget))->window,
-         priv->click_x, priv->click_y, NULL, NULL);
-
-      gdk_window_get_user_data (window, (void**) &child_widget);
 
       if (ABS (priv->click_y - event->y) >=
           ABS (priv->click_x - event->x)) {
         gboolean vscroll;
 
-        if (priv->click_y > event->y)
-          g_signal_emit (area,
-                         pannable_area_signals[VERTICAL_MOVEMENT],
-                         0, HILDON_PANNABLE_AREA_MOV_UP, child_widget,
-                         priv->click_x, priv->click_y);
-        else
-          g_signal_emit (area,
-                         pannable_area_signals[VERTICAL_MOVEMENT],
-                         0, HILDON_PANNABLE_AREA_MOV_DOWN, child_widget,
-                         priv->click_x, priv->click_y);
+        g_signal_emit (area,
+                       pannable_area_signals[VERTICAL_MOVEMENT],
+                       0, (priv->click_y > event->y) ?
+                       HILDON_PANNABLE_AREA_MOV_UP :
+                       HILDON_PANNABLE_AREA_MOV_DOWN,
+                       priv->click_x, priv->click_y);
 
         vscroll = (priv->vadjust->upper - priv->vadjust->lower >
                    priv->vadjust->page_size) ? TRUE : FALSE;
@@ -756,16 +744,12 @@ hildon_pannable_area_motion_notify_cb (GtkWidget * widget,
       } else {
         gboolean hscroll;
 
-        if (priv->click_x > event->x)
-          g_signal_emit (area,
-                         pannable_area_signals[HORIZONTAL_MOVEMENT],
-                         0, HILDON_PANNABLE_AREA_MOV_LEFT, child_widget,
-                         priv->click_x, priv->click_y);
-        else
-          g_signal_emit (area,
-                         pannable_area_signals[HORIZONTAL_MOVEMENT],
-                         0, HILDON_PANNABLE_AREA_MOV_RIGHT, child_widget,
-                         priv->click_x, priv->click_y);
+        g_signal_emit (area,
+                       pannable_area_signals[HORIZONTAL_MOVEMENT],
+                       0, (priv->click_x > event->x) ?
+                       HILDON_PANNABLE_AREA_MOV_LEFT :
+                       HILDON_PANNABLE_AREA_MOV_RIGHT,
+                       priv->click_x, priv->click_y);
 
         hscroll = (priv->hadjust->upper - priv->hadjust->lower >
                    priv->hadjust->page_size) ? TRUE : FALSE;
@@ -1831,10 +1815,9 @@ hildon_pannable_area_class_init (HildonPannableAreaClass * klass)
                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                  G_STRUCT_OFFSET (HildonPannableAreaClass, horizontal_movement),
                  NULL, NULL,
-                 _hildon_marshal_VOID__INT_OBJECT_DOUBLE_DOUBLE,
-                 G_TYPE_NONE, 4,
+                 _hildon_marshal_VOID__INT_DOUBLE_DOUBLE,
+                 G_TYPE_NONE, 3,
                   G_TYPE_INT,
-                  GTK_TYPE_WIDGET,
                  G_TYPE_DOUBLE,
                  G_TYPE_DOUBLE);
 
@@ -1844,10 +1827,9 @@ hildon_pannable_area_class_init (HildonPannableAreaClass * klass)
                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                  G_STRUCT_OFFSET (HildonPannableAreaClass, vertical_movement),
                  NULL, NULL,
-                 _hildon_marshal_VOID__INT_OBJECT_DOUBLE_DOUBLE,
-                 G_TYPE_NONE, 4,
+                 _hildon_marshal_VOID__INT_DOUBLE_DOUBLE,
+                 G_TYPE_NONE, 3,
                   G_TYPE_INT,
-                  GTK_TYPE_WIDGET,
                  G_TYPE_DOUBLE,
                  G_TYPE_DOUBLE);
 
@@ -2212,3 +2194,30 @@ hildon_pannable_area_jump_to_child (HildonPannableArea *area, GtkWidget *child)
   if (gtk_widget_translate_coordinates (child, bin_child, 0, 0, &x, &y))
     hildon_pannable_area_jump_to (area, x, y);
 }
+
+/**
+ * hildon_pannable_get_child_widget_at:
+ * @area: A #HildonPannableArea.
+ * @x: horizontal coordinate of the point
+ * @y: vertical coordinate of the point
+ *
+ * Get the widget at the point (x, y) inside the pannable area. In
+ * case no widget found it returns NULL.
+ *
+ * returns: the #GtkWidget if we find a widget, NULL in any other case
+ **/
+GtkWidget*
+hildon_pannable_get_child_widget_at (HildonPannableArea *area,
+                                     gdouble x, gdouble y)
+{
+  GdkWindow *window = NULL;
+  GtkWidget *child_widget = NULL;
+
+  window = hildon_pannable_area_get_topmost
+    (gtk_bin_get_child (GTK_BIN (area))->window,
+     x, y, NULL, NULL);
+
+  gdk_window_get_user_data (window, (void**) &child_widget);
+
+  return child_widget;
+}
index d4b32f3..1f14154 100644 (file)
@@ -121,10 +121,10 @@ struct                                          _HildonPannableAreaClass
 
   void (* horizontal_movement) (HildonPannableArea *area,
                                 HildonPannableAreaIndicatorMode direction,
-                                GtkWidget *widget, gdouble x, gdouble y);
+                                gdouble x, gdouble y);
   void (* vertical_movement) (HildonPannableArea *area,
                               HildonPannableAreaIndicatorMode direction,
-                              GtkWidget *widget, gdouble x, gdouble y);
+                              gdouble x, gdouble y);
 };
 
 GType hildon_pannable_area_get_type             (void);
@@ -143,6 +143,8 @@ void hildon_pannable_area_scroll_to_child       (HildonPannableArea *area,
                                                 GtkWidget *child);
 void hildon_pannable_area_jump_to_child         (HildonPannableArea *area,
                                                  GtkWidget *child);
+GtkWidget* hildon_pannable_get_child_widget_at  (HildonPannableArea *area,
+                                                 gdouble x, gdouble y);
 
 G_END_DECLS