Evas textblock: Replaced style_user_set/get with push/pop/peek.
authortasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 7 Mar 2012 14:02:35 +0000 (14:02 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 7 Mar 2012 14:02:35 +0000 (14:02 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@68952 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
src/lib/Evas.h
src/lib/canvas/evas_object_textblock.c
src/tests/evas_test_textblock.c

index e0396b9..a413064 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 2012-02-23  Cedric Bail
 
        * Remove Software SDL engine.
+
+2012-01-23  Tom Hacohen (TAsn)
+
+       * Textblock: Replaced evas_object_textblock_style_user_set/get
+       with evas_object_textblock_style_user_push/peek/pop.
+       This is used to override the default style set for an evas object.
+       For example, this can be used to nicely change the font and size
+       in a text editor.
index 0f76032..663a469 100644 (file)
@@ -8392,7 +8392,9 @@ EAPI void                         evas_object_textblock_style_set(Evas_Object *o
 EAPI const Evas_Textblock_Style  *evas_object_textblock_style_get(const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
 
 /**
- * Set the objects user style to ts.
+ * Push ts to the top of the user style stack.
+ *
+ * FIXME: API is solid but currently only supports 1 style in the stack.
  *
  * The user style overrides the corresponding elements of the regular style.
  * This is the proper way to do theme overrides in code.
@@ -8402,16 +8404,26 @@ EAPI const Evas_Textblock_Style  *evas_object_textblock_style_get(const Evas_Obj
  * @see evas_object_textblock_style_set
  * @since 1.2.0
  */
-EAPI void                         evas_object_textblock_style_user_set(Evas_Object *obj, Evas_Textblock_Style *ts) EINA_ARG_NONNULL(1);
+EAPI void                         evas_object_textblock_style_user_push(Evas_Object *obj, Evas_Textblock_Style *ts) EINA_ARG_NONNULL(1);
 
 /**
- * Return the user style of an object.
+ * Del the from the top of the user style stack.
+ *
+ * @param obj  the object to get the style from.
+ * @see evas_object_textblock_style_get
+ * @since 1.2.0
+ */
+EAPI void                        evas_object_textblock_style_user_pop(Evas_Object *obj) EINA_ARG_NONNULL(1);
+
+/**
+ * Get (don't remove) the style at the top of the user style stack.
+ *
  * @param obj  the object to get the style from.
  * @return the style of the object.
  * @see evas_object_textblock_style_get
  * @since 1.2.0
  */
-EAPI const Evas_Textblock_Style  *evas_object_textblock_style_user_get(const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI const Evas_Textblock_Style  *evas_object_textblock_style_user_peek(const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
 
 /**
  * @brief Set the "replacement character" to use for the given textblock object.
index 892804b..a5b60f2 100644 (file)
@@ -4669,20 +4669,27 @@ evas_object_textblock_style_get(const Evas_Object *obj)
 }
 
 EAPI void
-evas_object_textblock_style_user_set(Evas_Object *obj, Evas_Textblock_Style *ts)
+evas_object_textblock_style_user_push(Evas_Object *obj, Evas_Textblock_Style *ts)
 {
    TB_HEAD();
    _textblock_style_generic_set(obj, ts, &(o->style_user));
 }
 
 EAPI const Evas_Textblock_Style *
-evas_object_textblock_style_user_get(const Evas_Object *obj)
+evas_object_textblock_style_user_peek(const Evas_Object *obj)
 {
    TB_HEAD_RETURN(NULL);
    return o->style_user;
 }
 
 EAPI void
+evas_object_textblock_style_user_pop(Evas_Object *obj)
+{
+   TB_HEAD();
+   _textblock_style_generic_set(obj, NULL,  &(o->style_user));
+}
+
+EAPI void
 evas_object_textblock_replace_char_set(Evas_Object *obj, const char *ch)
 {
    TB_HEAD();
@@ -9311,7 +9318,10 @@ evas_object_textblock_free(Evas_Object *obj)
 
    evas_object_textblock_clear(obj);
    evas_object_textblock_style_set(obj, NULL);
-   evas_object_textblock_style_user_set(obj, NULL);
+   while (evas_object_textblock_style_user_peek(obj))
+     {
+        evas_object_textblock_style_user_pop(obj);
+     }
    o = (Evas_Object_Textblock *)(obj->object_data);
    free(o->cursor);
    while (o->cursors)
index 88c4ac8..983a2fc 100644 (file)
@@ -2113,7 +2113,7 @@ START_TEST(evas_textblock_size)
         fail_if(!newst);
         evas_textblock_style_set(newst,
               "DEFAULT='left_margin=4 right_margin=4'");
-        evas_object_textblock_style_user_set(tb, newst);
+        evas_object_textblock_style_user_push(tb, newst);
 
         evas_object_textblock_size_formatted_get(tb, &w, &h);
         evas_object_textblock_size_native_get(tb, &nw, &nh);