goocanvas r40 - in trunk: . demo src
- From: damon svn gnome org
- To: svn-commits-list gnome org
- Subject: goocanvas r40 - in trunk: . demo src
- Date: Sun, 15 Mar 2009 14:06:47 +0000 (UTC)
Author: damon
Date: Sun Mar 15 14:06:46 2009
New Revision: 40
URL: http://svn.gnome.org/viewvc/goocanvas?rev=40&view=rev
Log:
2009-03-15 Gian Mario Tagliaretti <gianmt gnome org>
(Committed by Damon with a few changes.)
* src/goocanvasitem.h (struct _GooCanvasItemIface): added
scroll_event() signals on items.
* src/goocanvasitem.c: implemented "scroll_event" signals on items.
* src/goocanvas.c: implemented "scroll_event" signals on items.
* demo/demo.c: added test for above. #566110
Modified:
trunk/ChangeLog
trunk/demo/demo.c
trunk/src/goocanvas.c
trunk/src/goocanvasitem.c
trunk/src/goocanvasitem.h
Modified: trunk/demo/demo.c
==============================================================================
--- trunk/demo/demo.c (original)
+++ trunk/demo/demo.c Sun Mar 15 14:06:46 2009
@@ -386,6 +386,25 @@
static gboolean
+on_scroll (GooCanvasItem *item,
+ GooCanvasItem *target,
+ GdkEventScroll *event,
+ gpointer data)
+{
+#if 0
+ g_print ("received 'scroll-event' signal\n");
+#endif
+
+ if (event->direction == GDK_SCROLL_UP)
+ goo_canvas_item_scale (item, 1.1, 1.1);
+ else if (event->direction == GDK_SCROLL_DOWN)
+ goo_canvas_item_scale (item, 0.909, 0.909);
+ else return FALSE;
+
+ return TRUE;
+}
+
+static gboolean
on_button_release (GooCanvasItem *item,
GooCanvasItem *target,
GdkEventButton *event,
@@ -404,7 +423,6 @@
return TRUE;
}
-
static gboolean
on_background_button_press (GooCanvasItem *item,
GooCanvasItem *target,
@@ -1098,6 +1116,7 @@
cairo_pattern_destroy (pattern);
goo_canvas_points_unref (points);
setup_item_signals (polyline1);
+
points = goo_canvas_points_new (14);
points->coords[0] = 270.0;
@@ -1158,6 +1177,9 @@
NULL);
setup_item_signals (item);
+ g_signal_connect (group, "scroll_event",
+ G_CALLBACK (on_scroll), NULL);
+
return group;
}
Modified: trunk/src/goocanvas.c
==============================================================================
--- trunk/src/goocanvas.c (original)
+++ trunk/src/goocanvas.c Sun Mar 15 14:06:46 2009
@@ -2773,6 +2773,15 @@
crossing_event->state = event->crossing.state;
break;
+ case GDK_SCROLL:
+ crossing_event->time = event->scroll.time;
+ crossing_event->x = event->scroll.x;
+ crossing_event->y = event->scroll.y;
+ crossing_event->x_root = event->scroll.x_root;
+ crossing_event->y_root = event->scroll.y_root;
+ crossing_event->state = event->scroll.state;
+ break;
+
default:
/* It must be a button press/release event. */
crossing_event->time = event->button.time;
@@ -2888,6 +2897,12 @@
x_root = &event.crossing.x_root;
y_root = &event.crossing.y_root;
break;
+ case GDK_SCROLL:
+ x = &event.scroll.x;
+ y = &event.scroll.y;
+ x_root = &event.scroll.x_root;
+ y_root = &event.scroll.y_root;
+ break;
default:
/* It must be a button press/release event. */
x = &event.button.x;
@@ -3099,6 +3114,14 @@
GtkAdjustment *adj;
gdouble delta, new_value;
+ if (event->window == canvas->canvas_window)
+ {
+ /* See if the current item wants the scroll event. */
+ update_pointer_item (canvas, (GdkEvent*) event);
+ if (emit_pointer_event (canvas, "scroll_event", (GdkEvent*) event))
+ return TRUE;
+ }
+
if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_DOWN)
adj = canvas->vadjustment;
else
Modified: trunk/src/goocanvasitem.c
==============================================================================
--- trunk/src/goocanvasitem.c (original)
+++ trunk/src/goocanvasitem.c Sun Mar 15 14:06:46 2009
@@ -48,6 +48,7 @@
GRAB_BROKEN_EVENT,
CHILD_NOTIFY,
ANIMATION_FINISHED,
+ SCROLL_EVENT,
LAST_SIGNAL
};
@@ -391,6 +392,31 @@
G_TYPE_NONE, 1,
G_TYPE_BOOLEAN);
+ /**
+ * GooCanvasItem::scroll-event
+ * @item: the item that received the signal.
+ * @target_item: the target of the event.
+ * @event: the event data, with coordinates translated to canvas
+ * coordinates.
+ *
+ * Emitted when a button in the 4 to 7 range is pressed. Wheel mice are
+ * usually configured to generate button press events for buttons 4 and 5
+ * when the wheel is turned in an item.
+ *
+ * Returns: %TRUE to stop the signal emission, or %FALSE to let it
+ * continue.
+ */
+ canvas_item_signals[SCROLL_EVENT] =
+ g_signal_new ("scroll_event",
+ iface_type,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GooCanvasItemIface,
+ scroll_event),
+ goo_canvas_boolean_handled_accumulator, NULL,
+ goo_canvas_marshal_BOOLEAN__OBJECT_BOXED,
+ G_TYPE_BOOLEAN, 2,
+ GOO_TYPE_CANVAS_ITEM,
+ GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
g_object_interface_install_property (g_iface,
g_param_spec_object ("parent",
Modified: trunk/src/goocanvasitem.h
==============================================================================
--- trunk/src/goocanvasitem.h (original)
+++ trunk/src/goocanvasitem.h Sun Mar 15 14:06:46 2009
@@ -128,6 +128,8 @@
* @grab_broken_event: signal emitted when a grab that the item has is lost.
* @child_notify: signal emitted when a child property is changed.
* @animation_finished: signal emitted when the item's animation has finished.
+ * @scroll_event: signal emitted when the mouse wheel is activated within
+ * the item.
*
* #GooCanvasItemIFace holds the virtual methods that make up the
* #GooCanvasItem interface.
@@ -292,6 +294,10 @@
void (* animation_finished) (GooCanvasItem *item,
gboolean stopped);
+ gboolean (* scroll_event) (GooCanvasItem *item,
+ GooCanvasItem *target,
+ GdkEventScroll *event);
+
/*< private >*/
/* Padding for future expansion */
@@ -299,7 +305,6 @@
void (*_goo_canvas_reserved2) (void);
void (*_goo_canvas_reserved3) (void);
void (*_goo_canvas_reserved4) (void);
- void (*_goo_canvas_reserved5) (void);
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]