#include "gl/configmake.h"
#include "gl/relocatable.h"
-#include "gettext.h"
-#define _(msgid) gettext (msgid)
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
+#define P_(msgid) (msgid)
static void psppire_cell_renderer_button_dispose (GObject *);
static void psppire_cell_renderer_button_finalize (GObject *);
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;
+ PsppireCellRendererButton *button = PSPPIRE_CELL_RENDERER_BUTTON (cell);
+ gfloat xalign, yalign;
- if (!button->editable || !cell->sensitive)
+ 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,
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
/* 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), "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);
g_object_class_install_property (gobject_class,
PROP_EDITABLE,
g_param_spec_boolean ("editable",
- "Editable",
- "Whether the button may be clicked.",
+ P_("Editable"),
+ P_("Whether the button may be clicked."),
FALSE,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_LABEL,
g_param_spec_string ("label",
- "Label",
- "Text to appear in button.",
+ P_("Label"),
+ P_("Text to appear in button."),
"",
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_SLASH,
g_param_spec_boolean ("slash",
- _("Diagonal slash"),
- _("Whether to draw a diagonal slash across the button."),
+ P_("Diagonal slash"),
+ P_("Whether to draw a diagonal slash across the button."),
FALSE,
G_PARAM_READWRITE));
if (button->dispose_has_run)
return;
-
+
button->dispose_has_run = TRUE;
/* When called with NULL, as we are doing here, update_style_cache