[Vala] cannot convert to a pointer type error when passing Gdk.MotionEvent

12 views
Skip to first unread message

Axel FILMORE

unread,
Mar 28, 2012, 5:38:16 PM3/28/12
to vala...@gnome.org
Hi there,

I can't get the following code to compile with Vala :

private bool on_motion_notify (Gdk.EventMotion evt) {
Gtk.drag_begin (this,
target_list,
Gdk.DragAction.COPY
| Gdk.DragAction.MOVE
| Gdk.DragAction.LINK,
1,
(Gdk.Event) evt);
}

I get the error "cannot convert to a pointer type"

Here's the generated code :

static gboolean desktop_window_on_motion_notify (DesktopWindow* self,
GdkEventMotion* evt) {
GdkEventMotion _tmp19_;
_tmp19_ = *evt;
gtk_drag_begin ((GtkWidget*) self, _tmp18_,
(GDK_ACTION_COPY | GDK_ACTION_MOVE) | GDK_ACTION_LINK, 1, (GdkEvent*)
_tmp19_);
}

I should get something like this :
static gboolean desktop_window_on_motion_notify (DesktopWindow* self,
GdkEventMotion* evt) {
GdkEventMotion* _tmp19_;
_tmp19_ = evt;
gtk_drag_begin ((GtkWidget*) self, _tmp18_,
(GDK_ACTION_COPY | GDK_ACTION_MOVE) | GDK_ACTION_LINK, 1, (GdkEvent*)
_tmp19_);
}

That seems to be the same issue than reported here :
https://mail.gnome.org/archives/vala-list/2009-August/msg00007.html

Is it something wrong I'm doing ?
Does anybody know a workaround ?

Regards.


--
Axel FILMORE

_______________________________________________
vala-list mailing list
vala...@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list

Eric Gregory

unread,
Mar 28, 2012, 5:51:16 PM3/28/12
to Axel FILMORE, vala...@gnome.org
On Wed, Mar 28, 2012 at 2:38 PM, Axel FILMORE <axel.f...@gmail.com>wrote:

> Hi there,
>
> I can't get the following code to compile with Vala :
>
> private bool on_motion_notify (Gdk.EventMotion evt) {
> Gtk.drag_begin (this,
> target_list,
> Gdk.DragAction.COPY
> | Gdk.DragAction.MOVE
> | Gdk.DragAction.LINK,
> 1,
> (Gdk.Event) evt);
> }
>

Unlike in C, in Vala Gdk.Event is a class and Gdk.EventMotion is a struct.

You might check this thread for a user who had a similar issue:
http://www.mail-archive.com/vala...@gnome.org/msg08105.html

- Eric

Axel FILMORE

unread,
Mar 28, 2012, 6:01:45 PM3/28/12
to Eric Gregory, vala...@gnome.org
Thanks a lot, it works just fine :-)

private bool on_motion_notify (Gdk.EventMotion evt) {

Gdk.Event* real_e = (Gdk.Event*)(&evt);

Gtk.drag_begin (this,
target_list,
Gdk.DragAction.COPY
| Gdk.DragAction.MOVE
| Gdk.DragAction.LINK,
1,
(Gdk.Event) evt);
}

I tried all sort of things, like Gdk.Event? event = (Gdk.Event*) evt;
but none worked.

Thanks again. :-)

Reply all
Reply to author
Forward
0 new messages