psppire-dictview: Generalize psppire_dict_view_get_var_measurement_stock_id().
[pspp] / src / ui / gui / psppire-cell-renderer-button.c
index ac90984a3d233c35823a86dfde80f2d6e92481d4..703ff3ddfd3056572b168dbc095cc58199bb2cd4 100644 (file)
@@ -292,25 +292,6 @@ psppire_cell_renderer_button_clicked (GtkButton *button,
   g_free (path);
 }
 
-static gboolean
-psppire_cell_renderer_button_focus_out_event (GtkWidget *widget,
-                                              GdkEvent  *event,
-                                              gpointer   data)
-{
-  PsppireCellRendererButton *cell_button = data;
-
-  g_signal_handlers_disconnect_by_func (widget,
-                                        psppire_cell_renderer_button_focus_out_event,
-                                        data);
-  g_signal_handlers_disconnect_by_func (widget,
-                                        psppire_cell_renderer_button_clicked,
-                                        data);
-
-  gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (cell_button), FALSE);
-
-  return FALSE;
-}
-
 #define IDLE_ID_STRING "psppire-cell-renderer-button-idle-id"
 
 static gboolean
@@ -318,8 +299,8 @@ psppire_cell_renderer_button_initial_click (gpointer data)
 {
   GtkButton *button = data;
 
-  gtk_button_clicked (button);
   g_object_steal_data (G_OBJECT (button), IDLE_ID_STRING);
+  gtk_button_clicked (button);
   return FALSE;
 }
 
@@ -359,7 +340,17 @@ psppire_cell_renderer_button_press_event (GtkButton      *button,
       /* Allow right-click events to propagate upward in the widget hierarchy.
          Otherwise right-click menus, that trigger on a button-press-event on
          the containing PsppSheetView, will pop up if the button is rendered as
-         a facade but not if the button widget exists.  */
+         a facade but not if the button widget exists.
+
+         We have to translate the event's data by hand to be relative to the
+         parent window, because the normal GObject signal propagation mechanism
+         won't do it for us.  (This might be a hint that we're doing this
+         wrong.) */
+      gint x, y;
+
+      gdk_window_get_position (event->window, &x, &y);
+      event->x += x;
+      event->y += y;
       g_signal_stop_emission_by_name (button, "button-press-event");
       return FALSE;
     }
@@ -416,12 +407,8 @@ psppire_cell_renderer_button_start_editing (GtkCellRenderer      *cell,
                                       "xalign", xalign,
                                       "yalign", yalign,
                                       "path", path,
-                                      "slash", cell_button->slash,
                                       NULL);
 
-  g_signal_connect (G_OBJECT (cell_button->button), "focus-out-event",
-                    G_CALLBACK (psppire_cell_renderer_button_focus_out_event),
-                    cell);
   g_signal_connect (G_OBJECT (cell_button->button), "clicked",
                     G_CALLBACK (psppire_cell_renderer_button_clicked),
                     cell);