[gtk+/a11y] GtkLabel: factor out two getters
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/a11y] GtkLabel: factor out two getters
- Date: Fri, 24 Jun 2011 05:09:38 +0000 (UTC)
commit cfb746fa9854af1e0d710fd10917fb1f9c51c13f
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jun 23 23:30:57 2011 -0400
GtkLabel: factor out two getters
Make the get_property switch look a little nicer.
We export these functions privately for use in the label
accessible implementation later on.
gtk/gtklabel.c | 43 +++++++++++++++++++++++++++----------------
gtk/gtklabel.h | 2 ++
2 files changed, 29 insertions(+), 16 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 7818048..45a7508 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -465,6 +465,7 @@ static void gtk_label_select_region_index (GtkLabel *label,
gint anchor_index,
gint end_index);
+
static gboolean gtk_label_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling);
static void gtk_label_setup_mnemonic (GtkLabel *label,
@@ -1204,24 +1205,10 @@ gtk_label_get_property (GObject *object,
g_value_set_object (value, (GObject*) priv->mnemonic_widget);
break;
case PROP_CURSOR_POSITION:
- if (priv->select_info && priv->select_info->selectable)
- {
- gint offset = g_utf8_pointer_to_offset (priv->text,
- priv->text + priv->select_info->selection_end);
- g_value_set_int (value, offset);
- }
- else
- g_value_set_int (value, 0);
+ g_value_set_int (value, _gtk_label_get_cursor_position (label));
break;
case PROP_SELECTION_BOUND:
- if (priv->select_info && priv->select_info->selectable)
- {
- gint offset = g_utf8_pointer_to_offset (priv->text,
- priv->text + priv->select_info->selection_anchor);
- g_value_set_int (value, offset);
- }
- else
- g_value_set_int (value, 0);
+ g_value_set_int (value, _gtk_label_get_selection_bound (label));
break;
case PROP_ELLIPSIZE:
g_value_set_enum (value, priv->ellipsize);
@@ -6658,3 +6645,27 @@ gtk_label_query_tooltip (GtkWidget *widget,
keyboard_tip,
tooltip);
}
+
+gint
+_gtk_label_get_cursor_position (GtkLabel *label)
+{
+ GtkLabelPrivate *priv = label->priv;
+
+ if (priv->select_info && priv->select_info->selectable)
+ return g_utf8_pointer_to_offset (priv->text,
+ priv->text + priv->select_info->selection_end);
+
+ return 0;
+}
+
+gint
+_gtk_label_get_selection_bound (GtkLabel *label)
+{
+ GtkLabelPrivate *priv = label->priv;
+
+ if (priv->select_info && priv->select_info->selectable)
+ return g_utf8_pointer_to_offset (priv->text,
+ priv->text + priv->select_info->selection_anchor);
+
+ return 0;
+}
diff --git a/gtk/gtklabel.h b/gtk/gtklabel.h
index f22c84d..38d4052 100644
--- a/gtk/gtklabel.h
+++ b/gtk/gtklabel.h
@@ -169,6 +169,8 @@ gboolean gtk_label_get_track_visited_links (GtkLabel *label);
void _gtk_label_mnemonics_visible_apply_recursively (GtkWidget *widget,
gboolean mnemonics_visible);
+gint _gtk_label_get_cursor_position (GtkLabel *label);
+gint _gtk_label_get_selection_bound (GtkLabel *label);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]