From 5558a52357ad7871aa2f66901032f6abb18485a5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Jadi?= Date: Thu, 25 Jul 2013 15:34:02 +0200 Subject: [PATCH] * src/xwidget.c (xwidget_init_view): Pass the view rather than the model to the callback for "clicked" event so we can retrive the frame and remove an old TODO. (buttonclick_handler): Get the frame from the window. --- src/xwidget.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/xwidget.c b/src/xwidget.c index eebb17d1aed..80cfd8355df 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -331,29 +331,25 @@ xwidget_hidden(struct xwidget_view *xv) static void buttonclick_handler (GtkWidget * widget, gpointer data) { - Lisp_Object xw; - XSETXWIDGET(xw, (struct xwidget *) data); + Lisp_Object xwidget_view, xwidget; + XSETXWIDGET_VIEW (xwidget_view, (struct xwidget_view *) data); + xwidget = Fxwidget_view_model (xwidget_view); struct input_event event; - Lisp_Object frame; - FRAME_PTR f = NULL; //(FRAME_PTR) g_object_get_data (G_OBJECT (XXWIDGET (xw)->widget), XG_FRAME_DATA); //TODO - printf ("button clicked xw:%d '%s'\n", xw, XXWIDGET (xw)->title); + Lisp_Object frame = Fwindow_frame (Fxwidget_view_window (xwidget_view)); + FRAME_PTR f = XFRAME (frame); + printf ("button clicked xw:%d '%s'\n", XXWIDGET (xwidget), XXWIDGET (xwidget)->title); EVENT_INIT (event); event.kind = XWIDGET_EVENT; - XSETFRAME (frame, f); - - event.frame_or_window = Qnil; //frame; //how to get the frame here? - + event.frame_or_window = frame; event.arg = Qnil; - event.arg = Fcons (xw, event.arg); + event.arg = Fcons (xwidget, event.arg); event.arg = Fcons (intern ("buttonclick"), event.arg); kbd_buffer_store_event (&event); - - } @@ -961,7 +957,6 @@ xwidget_init_view (struct xwidget *xww, struct glyph_string *s, int x, int y) { - //TODO temp code replace with lisp list struct xwidget_view *xv = allocate_xwidget_view(); Lisp_Object val; GdkColor color; @@ -977,7 +972,7 @@ xwidget_init_view (struct xwidget *xww, { xv->widget = gtk_button_new_with_label (XSTRING(xww->title)->data); g_signal_connect (G_OBJECT (xv->widget), "clicked", - G_CALLBACK (buttonclick_handler), xww); //the model rather than the view + G_CALLBACK (buttonclick_handler), xv); // the view rather than the model } else if (EQ(xww->type, Qtoggle)) { xv->widget = gtk_toggle_button_new_with_label (XSTRING(xww->title)->data); //xv->widget = gtk_entry_new ();//temp hack to experiment with key propagation TODO entry widget is useful for testing -- 2.39.2