From f6bedd0d5e4c8f7b2fc0726a9c4908416d7f8c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sun, 12 Apr 2020 10:40:21 +0200 Subject: [PATCH] label: Remove a11y-only properties Update them manually instead. --- gtk/a11y/gtklabelaccessible.c | 58 ++++++++++++++-------------- gtk/a11y/gtklabelaccessibleprivate.h | 2 + gtk/gtklabel.c | 32 ++------------- 3 files changed, 35 insertions(+), 57 deletions(-) diff --git a/gtk/a11y/gtklabelaccessible.c b/gtk/a11y/gtklabelaccessible.c index da9f83f292..9ac1cd5a13 100644 --- a/gtk/a11y/gtklabelaccessible.c +++ b/gtk/a11y/gtklabelaccessible.c @@ -399,32 +399,6 @@ check_for_selection_change (GtkLabelAccessible *accessible, return ret_val; } -static void -gtk_label_accessible_notify_gtk (GObject *obj, - GParamSpec *pspec) -{ - GtkWidget *widget = GTK_WIDGET (obj); - AtkObject* atk_obj = gtk_widget_get_accessible (widget); - GtkLabelAccessible *accessible; - - accessible = GTK_LABEL_ACCESSIBLE (atk_obj); - - if (g_strcmp0 (pspec->name, "cursor-position") == 0) - { - g_signal_emit_by_name (atk_obj, "text-caret-moved", - _gtk_label_get_cursor_position (GTK_LABEL (widget))); - if (check_for_selection_change (accessible, GTK_LABEL (widget))) - g_signal_emit_by_name (atk_obj, "text-selection-changed"); - } - else if (g_strcmp0 (pspec->name, "selection-bound") == 0) - { - if (check_for_selection_change (accessible, GTK_LABEL (widget))) - g_signal_emit_by_name (atk_obj, "text-selection-changed"); - } - else - GTK_WIDGET_ACCESSIBLE_CLASS (gtk_label_accessible_parent_class)->notify_gtk (obj, pspec); -} - /* atkobject.h */ static AtkStateSet * @@ -574,7 +548,6 @@ gtk_label_accessible_class_init (GtkLabelAccessibleClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); AtkObjectClass *class = ATK_OBJECT_CLASS (klass); - GtkWidgetAccessibleClass *widget_class = GTK_WIDGET_ACCESSIBLE_CLASS (klass); object_class->finalize = gtk_label_accessible_finalize; @@ -585,12 +558,39 @@ gtk_label_accessible_class_init (GtkLabelAccessibleClass *klass) class->get_n_children = gtk_label_accessible_get_n_children; class->ref_child = gtk_label_accessible_ref_child; - - widget_class->notify_gtk = gtk_label_accessible_notify_gtk; } /* 'Public' API {{{2 */ + +void +_gtk_label_accessible_selection_bound_changed (GtkLabel *label) +{ + AtkObject *obj; + + obj = _gtk_widget_peek_accessible (GTK_WIDGET (label)); + if (obj == NULL) + return; + + if (check_for_selection_change (GTK_LABEL_ACCESSIBLE (obj), label)) + g_signal_emit_by_name (obj, "text-selection-changed"); +} + +void +_gtk_label_accessible_cursor_position_changed (GtkLabel *label) +{ + AtkObject *obj; + + obj = _gtk_widget_peek_accessible (GTK_WIDGET (label)); + if (obj == NULL) + return; + + g_signal_emit_by_name (obj, "text-caret-moved", _gtk_label_get_cursor_position (label)); + + if (check_for_selection_change (GTK_LABEL_ACCESSIBLE (obj), label)) + g_signal_emit_by_name (obj, "text-selection-changed"); +} + void _gtk_label_accessible_text_deleted (GtkLabel *label) { diff --git a/gtk/a11y/gtklabelaccessibleprivate.h b/gtk/a11y/gtklabelaccessibleprivate.h index a4c61c2461..bd8e8ca0cb 100644 --- a/gtk/a11y/gtklabelaccessibleprivate.h +++ b/gtk/a11y/gtklabelaccessibleprivate.h @@ -26,6 +26,8 @@ void _gtk_label_accessible_text_deleted (GtkLabel *label); void _gtk_label_accessible_text_inserted (GtkLabel *label); void _gtk_label_accessible_update_links (GtkLabel *label); void _gtk_label_accessible_focus_link_changed (GtkLabel *label); +void _gtk_label_accessible_selection_bound_changed (GtkLabel *label); +void _gtk_label_accessible_cursor_position_changed (GtkLabel *label); G_END_DECLS diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 9d90c06f4c..cf11967b8f 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -397,8 +397,6 @@ enum { PROP_SELECTABLE, PROP_MNEMONIC_KEYVAL, PROP_MNEMONIC_WIDGET, - PROP_CURSOR_POSITION, - PROP_SELECTION_BOUND, PROP_ELLIPSIZE, PROP_WIDTH_CHARS, PROP_SINGLE_LINE_MODE, @@ -876,22 +874,6 @@ gtk_label_class_init (GtkLabelClass *class) GTK_TYPE_WIDGET, GTK_PARAM_READWRITE); - label_props[PROP_CURSOR_POSITION] = - g_param_spec_int ("cursor-position", - P_("Cursor Position"), - P_("The current position of the insertion cursor in chars"), - 0, G_MAXINT, - 0, - GTK_PARAM_READABLE); - - label_props[PROP_SELECTION_BOUND] = - g_param_spec_int ("selection-bound", - P_("Selection Bound"), - P_("The position of the opposite end of the selection from the cursor in chars"), - 0, G_MAXINT, - 0, - GTK_PARAM_READABLE); - /** * GtkLabel:ellipsize: * @@ -1269,12 +1251,6 @@ gtk_label_get_property (GObject *object, case PROP_MNEMONIC_WIDGET: g_value_set_object (value, (GObject*) priv->mnemonic_widget); break; - case PROP_CURSOR_POSITION: - g_value_set_int (value, _gtk_label_get_cursor_position (label)); - break; - case PROP_SELECTION_BOUND: - g_value_set_int (value, _gtk_label_get_selection_bound (label)); - break; case PROP_ELLIPSIZE: g_value_set_enum (value, priv->ellipsize); break; @@ -4775,8 +4751,8 @@ gtk_label_set_selectable (GtkLabel *label, { g_object_freeze_notify (G_OBJECT (label)); g_object_notify_by_pspec (G_OBJECT (label), label_props[PROP_SELECTABLE]); - g_object_notify_by_pspec (G_OBJECT (label), label_props[PROP_CURSOR_POSITION]); - g_object_notify_by_pspec (G_OBJECT (label), label_props[PROP_SELECTION_BOUND]); + _gtk_label_accessible_selection_bound_changed (label); + _gtk_label_accessible_cursor_position_changed (label); g_object_thaw_notify (G_OBJECT (label)); gtk_widget_queue_draw (GTK_WIDGET (label)); } @@ -4874,9 +4850,9 @@ gtk_label_select_region_index (GtkLabel *label, g_object_freeze_notify (G_OBJECT (label)); if (priv->select_info->selection_anchor != anchor_index) - g_object_notify_by_pspec (G_OBJECT (label), label_props[PROP_SELECTION_BOUND]); + _gtk_label_accessible_selection_bound_changed (label); if (priv->select_info->selection_end != end_index) - g_object_notify_by_pspec (G_OBJECT (label), label_props[PROP_CURSOR_POSITION]); + _gtk_label_accessible_cursor_position_changed (label); priv->select_info->selection_anchor = anchor_index; priv->select_info->selection_end = end_index;