diff options
author | Owen Taylor <otaylor@redhat.com> | 2001-10-22 21:01:47 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2001-10-22 21:01:47 +0000 |
commit | c8b58228d60d187dade6c4a59ad953f4fe44fb98 (patch) | |
tree | 97ed25d9ca083dc16a8c8e9184417ec4a94f5b4c /gtk/gtkentry.c | |
parent | 92d2dc0ba639efbc360a3de34d4a2ae722afa098 (diff) | |
download | gtk+-c8b58228d60d187dade6c4a59ad953f4fe44fb98.tar.gz |
Add cursor-position, selection-bound properties. (#62148, reported by
Mon Oct 22 11:47:47 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtklabel.c: Add cursor-position, selection-bound
properties. (#62148, reported by Padraig O'Briain)
* gtk/gtkentry.c (gtk_entry_class_init): Rename text_position
to cursor_position. (1.3.x addition, text_position is an awful
name.) Make cursor_position read-only to avoid sticky questions
of interaction with selection_bound. (#62636, reported by
Padraig O'Briain)
Diffstat (limited to 'gtk/gtkentry.c')
-rw-r--r-- | gtk/gtkentry.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index d993ad1d88..d12ccf4afd 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -70,7 +70,8 @@ enum { enum { PROP_0, - PROP_TEXT_POSITION, + PROP_CURSOR_POSITION, + PROP_SELECTION_BOUND, PROP_EDITABLE, PROP_MAX_LENGTH, PROP_VISIBILITY, @@ -402,14 +403,24 @@ gtk_entry_class_init (GtkEntryClass *class) class->activate = gtk_entry_real_activate; g_object_class_install_property (gobject_class, - PROP_TEXT_POSITION, - g_param_spec_int ("text_position", - _("Text Position"), - _("The current position of the insertion point"), + PROP_CURSOR_POSITION, + g_param_spec_int ("cursor_position", + _("Cursor Position"), + _("The current position of the insertion cursor in chars."), 0, G_MAXINT, 0, - G_PARAM_READABLE | G_PARAM_WRITABLE)); + G_PARAM_READABLE)); + + g_object_class_install_property (gobject_class, + PROP_SELECTION_BOUND, + g_param_spec_int ("selection_bound", + _("Selection Bound"), + _("The position of the opposite end of the selection from the cursor in chars."), + 0, + G_MAXINT, + 0, + G_PARAM_READABLE)); g_object_class_install_property (gobject_class, PROP_EDITABLE, @@ -775,11 +786,6 @@ gtk_entry_set_property (GObject *object, switch (prop_id) { - case PROP_TEXT_POSITION: - gtk_editable_set_position (GTK_EDITABLE (object), - g_value_get_int (value)); - break; - case PROP_EDITABLE: { gboolean new_value = g_value_get_boolean (value); @@ -821,6 +827,7 @@ gtk_entry_set_property (GObject *object, break; case PROP_SCROLL_OFFSET: + case PROP_CURSOR_POSITION: default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -839,9 +846,12 @@ gtk_entry_get_property (GObject *object, switch (prop_id) { - case PROP_TEXT_POSITION: + case PROP_CURSOR_POSITION: g_value_set_int (value, entry->current_pos); break; + case PROP_SELECTION_BOUND: + g_value_set_int (value, entry->selection_bound); + break; case PROP_EDITABLE: g_value_set_boolean (value, entry->editable); break; @@ -2272,6 +2282,8 @@ gtk_entry_set_positions (GtkEntry *entry, gint selection_bound) { gboolean changed = FALSE; + + g_object_freeze_notify (G_OBJECT (entry)); if (current_pos != -1 && entry->current_pos != current_pos) @@ -2279,7 +2291,7 @@ gtk_entry_set_positions (GtkEntry *entry, entry->current_pos = current_pos; changed = TRUE; - g_object_notify (G_OBJECT (entry), "text_position"); + g_object_notify (G_OBJECT (entry), "cursor_position"); } if (selection_bound != -1 && @@ -2287,8 +2299,12 @@ gtk_entry_set_positions (GtkEntry *entry, { entry->selection_bound = selection_bound; changed = TRUE; + + g_object_notify (G_OBJECT (entry), "selection_bound"); } + g_object_thaw_notify (G_OBJECT (entry)); + if (changed) gtk_entry_recompute (entry); } |