Storing and retrieving events
- From: Russell Shaw <rjshaw iprimus com au>
- To: gtk-app-devel-list gnome org
- Subject: Storing and retrieving events
- Date: Sun, 28 Sep 2003 21:20:45 +1000
Hi,
I have a popup menu that works by calling this function:
gboolean
button_press_cb(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
{
gtk_menu_popup(GTK_MENU(popup),NULL,NULL,NULL,NULL,event->button,event->time);
}
This causes the popup menu "activate" callback function to be called
properly when invoked.
However, now i need to get the same popup invoked from button_click_cb()
that is called by using g_timeout_add() in button_press_cb().
The popup menu works ok, but the callback function for the popup menu
"activate" signal is never called.
typedef struct {
GdkEventButton *event;
GtkWidget *widget;
} button_msg_t;
button_msg_t button_msg;
// this function is called first to set a time for button_click_cb() to be called
gboolean
button_press_cb(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
{
button_msg.event=(GdkEventButton*)gdk_event_copy((GdkEvent*)event);
button_msg.widget=gtk_widget_ref(widget);
GdkDisplay *disp=gtk_widget_get_display(widget);
click_id=g_timeout_add(disp->double_click_time,button_click_cb,(gpointer)(&button_msg));
return TRUE;
}
gboolean button_click_cb(gpointer data)
{
// contents of "event" and "widget" have been verified
GdkEventButton *event=((button_msg_t*)data)->event;
GtkWidget *widget=((button_msg_t*)data)->widget;
gtk_menu_popup(GTK_MENU(popup),NULL,NULL,NULL,NULL,event->button,event->time);
gdk_event_free((GdkEvent*)event);
gtk_widget_unref(widget);
...
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]