X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-cell-renderer-button.c;h=e801cc6bf30ba6c1e8e42b7e1d40ee45e6bf8f70;hb=d5a566a2900f69ab51c7dae78cd7810a4204589a;hp=8b9e9076dcd3f61abe9806e3263f309fe5af78cd;hpb=b3fcf4b1644bf4af9b5eb7b0b0f8856c51118128;p=pspp diff --git a/src/ui/gui/psppire-cell-renderer-button.c b/src/ui/gui/psppire-cell-renderer-button.c index 8b9e9076dc..e801cc6bf3 100644 --- a/src/ui/gui/psppire-cell-renderer-button.c +++ b/src/ui/gui/psppire-cell-renderer-button.c @@ -27,8 +27,9 @@ #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 *); @@ -70,15 +71,14 @@ psppire_cell_renderer_button_set_property (GObject *object, 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: @@ -182,17 +182,17 @@ update_style_cache (PsppireCellRendererButton *button, 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) { @@ -205,31 +205,42 @@ psppire_cell_renderer_button_render (GtkCellRenderer *cell, 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, @@ -340,7 +351,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; } @@ -384,8 +405,8 @@ psppire_cell_renderer_button_start_editing (GtkCellRenderer *cell, 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); @@ -397,7 +418,6 @@ 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), "clicked", @@ -470,24 +490,24 @@ psppire_cell_renderer_button_class_init (PsppireCellRendererButtonClass *class) 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)); @@ -528,7 +548,7 @@ psppire_cell_renderer_button_dispose (GObject *obj) if (button->dispose_has_run) return; - + button->dispose_has_run = TRUE; /* When called with NULL, as we are doing here, update_style_cache