diff options
author | Matthias Clasen <mclasen@redhat.com> | 2011-06-23 23:30:57 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2011-07-05 16:08:07 -0400 |
commit | 889b2714d5276a361fad191668a1a6f51b171ddf (patch) | |
tree | 857dbcf29ec8165e69ccc80e1e79f802d9527fd7 /gtk/gtklabel.c | |
parent | 504c0fdc277fea075524170e777e54d696d39b32 (diff) | |
download | gtk+-889b2714d5276a361fad191668a1a6f51b171ddf.tar.gz |
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.
Diffstat (limited to 'gtk/gtklabel.c')
-rw-r--r-- | gtk/gtklabel.c | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 7818048db7..45a7508605 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; +} |