[clutter/wip/master-next: 4/23] text: Add :cursor-position and deprecate :position



commit aed79c1d99698b56d3c254dad76981e09f515130
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Thu Jul 5 16:23:52 2012 +0100

    text: Add :cursor-position and deprecate :position
    
    The :position property on ClutterText clashes with the same property on
    ClutterActor; it's also badly named, given that it represents the
    cursor's position inside the text; finally, it does not match its
    accessors, violating the API style conventions.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=679457

 clutter/clutter-text.c |   39 ++++++++++++++++++++++++++++++++++-----
 1 files changed, 34 insertions(+), 5 deletions(-)
---
diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c
index 33f3999..043c444 100644
--- a/clutter/clutter-text.c
+++ b/clutter/clutter-text.c
@@ -236,7 +236,7 @@ enum
   PROP_LINE_WRAP_MODE,
   PROP_JUSTIFY,
   PROP_ELLIPSIZE,
-  PROP_POSITION,
+  PROP_POSITION, /* XXX:2.0 - remove */
   PROP_SELECTION_BOUND,
   PROP_SELECTION_COLOR,
   PROP_SELECTION_COLOR_SET,
@@ -244,6 +244,7 @@ enum
   PROP_CURSOR_COLOR,
   PROP_CURSOR_COLOR_SET,
   PROP_CURSOR_SIZE,
+  PROP_CURSOR_POSITION,
   PROP_EDITABLE,
   PROP_SELECTABLE,
   PROP_ACTIVATABLE,
@@ -1069,7 +1070,11 @@ clutter_text_delete_selection (ClutterText *self)
 
   /* Not required to be guarded by g_object_freeze/thaw_notify */
   if (priv->position != old_position)
-    g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_POSITION]);
+    {
+      /* XXX:2.0 - remove */
+      g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_POSITION]);
+      g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_CURSOR_POSITION]);
+    }
 
   if (priv->selection_bound != old_selection)
     g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_SELECTION_BOUND]);
@@ -1212,7 +1217,8 @@ clutter_text_set_property (GObject      *gobject,
       clutter_text_set_ellipsize (self, g_value_get_enum (value));
       break;
 
-    case PROP_POSITION:
+    case PROP_POSITION: /* XXX:2.0: remove */
+    case PROP_CURSOR_POSITION:
       clutter_text_set_cursor_position (self, g_value_get_int (value));
       break;
 
@@ -1320,7 +1326,8 @@ clutter_text_get_property (GObject    *gobject,
       g_value_set_int (value, priv->cursor_size);
       break;
 
-    case PROP_POSITION:
+    case PROP_POSITION: /* XXX:2.0 - remove */
+    case PROP_CURSOR_POSITION:
       g_value_set_int (value, priv->position);
       break;
 
@@ -3523,17 +3530,37 @@ clutter_text_class_init (ClutterTextClass *klass)
    * The current input cursor position. -1 is taken to be the end of the text
    *
    * Since: 1.0
+   *
+   * Deprecated: 1.12: Use ClutterText:cursor-position instead.
    */
   pspec = g_param_spec_int ("position",
                             P_("Cursor Position"),
                             P_("The cursor position"),
                             -1, G_MAXINT,
                             -1,
-                            CLUTTER_PARAM_READWRITE);
+                            G_PARAM_READWRITE |
+                            G_PARAM_STATIC_STRINGS |
+                            G_PARAM_DEPRECATED);
   obj_props[PROP_POSITION] = pspec;
   g_object_class_install_property (gobject_class, PROP_POSITION, pspec);
 
   /**
+   * ClutterText:cursor-position:
+   *
+   * The current input cursor position. -1 is taken to be the end of the text
+   *
+   * Since: 1.12
+   */
+  pspec = g_param_spec_int ("cursor-position",
+                            P_("Cursor Position"),
+                            P_("The cursor position"),
+                            -1, G_MAXINT,
+                            -1,
+                            CLUTTER_PARAM_READWRITE);
+  obj_props[PROP_CURSOR_POSITION] = pspec;
+  g_object_class_install_property (gobject_class, PROP_CURSOR_POSITION, pspec);
+
+  /**
    * ClutterText:selection-bound:
    *
    * The current input cursor position. -1 is taken to be the end of the text
@@ -5647,7 +5674,9 @@ clutter_text_set_cursor_position (ClutterText *self,
 
   clutter_text_queue_redraw (CLUTTER_ACTOR (self));
 
+  /* XXX:2.0 - remove */
   g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_POSITION]);
+  g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_CURSOR_POSITION]);
 }
 
 /**



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]