GParamSpec *pspec)
{
PsppireCellRendererButton *obj = PSPPIRE_CELL_RENDERER_BUTTON (object);
-
switch (prop_id)
{
case PROP_EDITABLE:
obj->editable = g_value_get_boolean (value);
if (obj->editable)
- GTK_CELL_RENDERER (obj)->mode = GTK_CELL_RENDERER_MODE_EDITABLE;
+ g_object_set (obj, "mode", GTK_CELL_RENDERER_MODE_EDITABLE, NULL);
else
- GTK_CELL_RENDERER (obj)->mode = GTK_CELL_RENDERER_MODE_INERT;
+ g_object_set (obj, "mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
break;
case PROP_LABEL:
static void
psppire_cell_renderer_button_render (GtkCellRenderer *cell,
- GdkDrawable *window,
+ cairo_t *cr,
GtkWidget *widget,
- GdkRectangle *background_area,
- GdkRectangle *cell_area,
- GdkRectangle *expose_area,
+ const GdkRectangle *background_area,
+ const GdkRectangle *cell_area,
GtkCellRendererState flags)
{
- PsppireCellRendererButton *button = PSPPIRE_CELL_RENDERER_BUTTON (cell);
GtkStateType state_type;
-
- if (!button->editable || !cell->sensitive)
+ PsppireCellRendererButton *button = PSPPIRE_CELL_RENDERER_BUTTON (cell);
+ gfloat xalign, yalign;
+
+ if (!button->editable || ! gtk_cell_renderer_get_sensitive (cell))
state_type = GTK_STATE_INSENSITIVE;
else if (flags & GTK_CELL_RENDERER_SELECTED)
{
state_type = GTK_STATE_PRELIGHT;
else
{
- if (gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE)
+ if (gtk_widget_get_state_flags (widget) == GTK_STATE_FLAG_INSENSITIVE)
state_type = GTK_STATE_INSENSITIVE;
else
state_type = GTK_STATE_NORMAL;
}
+ gtk_cell_renderer_get_alignment (cell, &xalign, &yalign);
+
+
update_style_cache (button, widget);
- facade_button_render (widget, window, expose_area,
+
+ facade_button_render (widget, cr,
cell_area, button->border_width, button->button_style,
state_type,
button->label_style, button->label, button->xpad,
- button->ypad, cell->xalign, cell->yalign);
+ button->ypad, xalign, yalign);
if (button->slash)
- gdk_draw_line (window, button->button_style->black_gc,
- cell_area->x,
- cell_area->y + cell_area->height,
- cell_area->x + cell_area->width,
- cell_area->y);
+ {
+ cairo_set_line_width (cr, 1.0);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+ cairo_move_to (cr,
+ cell_area->x,
+ cell_area->y + cell_area->height);
+
+ cairo_line_to (cr,
+ cell_area->x + cell_area->width,
+ cell_area->y);
+ cairo_stroke (cr);
+ }
}
static void
psppire_cell_renderer_button_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
- GdkRectangle *cell_area,
+ const GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
/* 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;
}
GdkEvent *event,
GtkWidget *widget,
const gchar *path,
- GdkRectangle *background_area,
- GdkRectangle *cell_area,
+ const GdkRectangle *background_area,
+ const GdkRectangle *cell_area,
GtkCellRendererState flags)
{
PsppireCellRendererButton *cell_button = PSPPIRE_CELL_RENDERER_BUTTON (cell);
"xalign", xalign,
"yalign", yalign,
"path", path,
- "slash", cell_button->slash,
NULL);
g_signal_connect (G_OBJECT (cell_button->button), "clicked",