X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-button-editable.c;h=f77e3ce21711263f8eff489e28dd756b6bae2986;hb=ecad37996f533d5cd8348ad68659470e821f5ebd;hp=f7028f5f5b5659de58d876c9bdcb95d13927e960;hpb=8f843c3a5e905c7f233d436b684a7d8fd958bd6c;p=pspp diff --git a/src/ui/gui/psppire-button-editable.c b/src/ui/gui/psppire-button-editable.c index f7028f5f5b..f77e3ce217 100644 --- a/src/ui/gui/psppire-button-editable.c +++ b/src/ui/gui/psppire-button-editable.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2011, 2012 Free Software Foundation, Inc. + Copyright (C) 2011, 2012, 2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ #include #define _(msgid) gettext (msgid) #define N_(msgid) msgid +#define P_(STRING) STRING /* GtkCellEditable interface. */ static void gtk_cell_editable_interface_init (GtkCellEditableIface *iface); @@ -41,7 +42,7 @@ enum { PROP_0, PROP_PATH, - PROP_SLASH + PROP_EDITING_CANCELED }; static void @@ -59,8 +60,7 @@ psppire_button_editable_set_property (GObject *object, obj->path = g_value_dup_string (value); break; - case PROP_SLASH: - psppire_button_editable_set_slash (obj, g_value_get_boolean (value)); + case PROP_EDITING_CANCELED: break; default: @@ -83,8 +83,8 @@ psppire_button_editable_get_property (GObject *object, g_value_set_string (value, obj->path); break; - case PROP_SLASH: - g_value_set_boolean (value, psppire_button_editable_get_slash (obj)); + case PROP_EDITING_CANCELED: + g_value_set_boolean (value, FALSE); break; default: @@ -94,14 +94,13 @@ psppire_button_editable_get_property (GObject *object, } static void -psppire_button_editable_dispose (GObject *gobject) +psppire_button_editable_finalize (GObject *gobject) { PsppireButtonEditable *obj = PSPPIRE_BUTTON_EDITABLE (gobject); g_free (obj->path); - obj->path = NULL; - G_OBJECT_CLASS (psppire_button_editable_parent_class)->dispose (gobject); + G_OBJECT_CLASS (psppire_button_editable_parent_class)->finalize (gobject); } static gboolean @@ -110,34 +109,12 @@ psppire_button_editable_button_release (GtkWidget *widget, { if (event->button == 1) { - g_signal_emit_by_name (widget, "button-release-event", event, NULL); + g_signal_emit_by_name (widget, "released", event, NULL); } return TRUE; } -static gboolean -psppire_button_editable_expose_event (GtkWidget *widget, - GdkEventExpose *event) -{ - GtkWidgetClass *widget_class; - GtkStyle *style = gtk_widget_get_style (widget); - GtkAllocation allocation; - gboolean retval; - - widget_class = GTK_WIDGET_CLASS (psppire_button_editable_parent_class); - retval = widget_class->expose_event (widget, event); - - gtk_widget_get_allocation (widget, &allocation); - if (PSPPIRE_BUTTON_EDITABLE (widget)->slash) - gdk_draw_line (gtk_widget_get_window (widget), style->black_gc, - allocation.x, - allocation.y + allocation.height, - allocation.x + allocation.width, - allocation.y); - return retval; -} - static void psppire_button_editable_class_init (PsppireButtonEditableClass *class) { @@ -149,34 +126,27 @@ psppire_button_editable_class_init (PsppireButtonEditableClass *class) gobject_class->set_property = psppire_button_editable_set_property; gobject_class->get_property = psppire_button_editable_get_property; - gobject_class->dispose = psppire_button_editable_dispose; + gobject_class->finalize = psppire_button_editable_finalize; widget_class->button_release_event = psppire_button_editable_button_release; - widget_class->expose_event = psppire_button_editable_expose_event; g_object_class_install_property (gobject_class, PROP_PATH, g_param_spec_string ("path", - _("TreeView path"), - _("The path to the row in the GtkTreeView, as a string"), + P_("TreeView path"), + P_("The path to the row in the GtkTreeView, as a string"), "", 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."), - FALSE, - G_PARAM_READWRITE)); - + g_object_class_override_property (gobject_class, + PROP_EDITING_CANCELED, + "editing-canceled"); } static void psppire_button_editable_init (PsppireButtonEditable *obj) { obj->path = g_strdup (""); - obj->slash = FALSE; } PsppireButtonEditable * @@ -185,24 +155,6 @@ psppire_button_editable_new (void) return PSPPIRE_BUTTON_EDITABLE (g_object_new (PSPPIRE_TYPE_BUTTON_EDITABLE, NULL)); } -void -psppire_button_editable_set_slash (PsppireButtonEditable *button, - gboolean slash) -{ - g_return_if_fail (button != NULL); - if ((button->slash != 0) != (slash != 0)) - { - button->slash = slash; - gtk_widget_queue_draw (GTK_WIDGET (button)); - } -} - -gboolean -psppire_button_editable_get_slash (const PsppireButtonEditable *button) -{ - g_return_val_if_fail (button != NULL, FALSE); - return button->slash; -} /* GtkCellEditable interface. */