Enlightenment CVS committal

Author  : moom
Project : e17
Module  : proto

Dir     : e17/proto/etk/src/lib


Modified Files:
        etk_textblock.c etk_textblock.h etk_widget.c 


Log Message:
* [Textblock] Fix a bug that appeared when we deleted a line of the 
textblock (see estickies)


===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_textblock.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -3 -r1.26 -r1.27
--- etk_textblock.c     4 Aug 2006 19:58:49 -0000       1.26
+++ etk_textblock.c     20 Aug 2006 20:41:20 -0000      1.27
@@ -77,6 +77,7 @@
 static void _etk_tb_constructor(Etk_Textblock *tb);
 static void _etk_tb_destructor(Etk_Textblock *tb);
 
+static void _etk_textblock_node_printf(Etk_Textblock_Node *node, int n_tabs);
 static Etk_Textblock_Node *_etk_textblock_node_new(Etk_Textblock_Node *parent, 
Etk_Textblock_Node *prev, Etk_Textblock_Node_Type node_type, 
Etk_Textblock_Tag_Type tag_type);
 static Etk_Textblock_Node *_etk_textblock_node_free(Etk_Textblock_Node *node);
 static void _etk_textblock_node_type_set(Etk_Textblock_Node *node, 
Etk_Textblock_Node_Type node_type, Etk_Textblock_Tag_Type tag_type);
@@ -651,7 +652,7 @@
    Etk_Textblock_Iter *it;
    Etk_Textblock_Node *start_line, *end_line, *line;
    Etk_Textblock_Node *start_paragraph, *end_paragraph, *paragraph;
-   Etk_Textblock_Node *n;
+   Etk_Textblock_Node *n, *new_node;
    Evas_List *l;
    Etk_Bool done;
    
@@ -732,7 +733,8 @@
          {
             if (it->node == start_iter->node && it->pos <= start_iter->pos)
                continue;
-            else if (it != end_iter && it->node == end_iter->node && it->pos > 
end_iter->pos)
+            
+            if (it != end_iter && it->node == end_iter->node && it->pos > 
end_iter->pos)
             {
                it->index -= end_iter->index;
                it->pos -= end_iter->pos;
@@ -747,6 +749,24 @@
    /* Merge the start and the end lines, and remove the other lines */
    if (start_line != end_line)
    {
+      /* Make sure the start line node has at least one child */
+      if (etk_string_length_get(start_line->text) > 0)
+      {
+         new_node = _etk_textblock_node_new(start_line, NULL, 
ETK_TEXTBLOCK_NODE_NORMAL, ETK_TEXTBLOCK_TAG_DEFAULT);
+         new_node->text = start_line->text;
+         new_node->unicode_length = start_line->unicode_length;
+         start_line->text = NULL;
+         start_line->unicode_length = 0;
+         
+         for (l = tb->iters; l; l = l->next)
+         {
+            it = l->data;
+            if (it->node == start_line)
+               it->node = new_node;
+         }
+      }
+      
+      /* Add the children of the end line node to the start line node */
       while (end_line->children)
          _etk_textblock_node_attach(end_line->children, start_line, 
start_line->last_child);
       
@@ -1295,6 +1315,30 @@
       *w = tw / len;
 }
 
+/**
+ * @brief Prints the textblock hierarchy for debug
+ * TODO: etk_textblock_printf(): Remove this function
+ */
+void etk_textblock_printf(Etk_Textblock *tb)
+{
+   Evas_List *l;
+   Etk_Textblock_Object_SD *sd;
+   
+   if (!tb)
+      return;
+   
+   printf("TEXTBLOCK PRINTF\n"
+          "----------------\n");
+   _etk_textblock_node_printf(&tb->root, -1);
+   printf("\n");
+   for (l = tb->evas_objects; l; l = l->next)
+   {
+      sd = evas_object_smart_data_get(l->data);
+      printf("Iterator node: %d %d | %s\n", sd->cursor->node->type, 
sd->cursor->node->tag.type,
+         etk_string_get(sd->cursor->node->text) ? 
etk_string_get(sd->cursor->node->text) : "NULL");
+   }
+}
+
 /**************************
  *
  * Etk specific functions
@@ -2401,9 +2445,9 @@
       ETK_WARNING("The iterator is not attached to a textblock node");
       return ETK_FALSE;
    }
-   else if (iter->node->children)
+   else if (iter->node->type == ETK_TEXTBLOCK_NODE_ROOT)
    {
-      ETK_WARNING("The node of the iterator is not a leaf");
+      ETK_WARNING("The iterator can't be attached to the root node");
       return ETK_FALSE;
    }
    else if (iter->node->type == ETK_TEXTBLOCK_NODE_PARAGRAPH)
@@ -2411,9 +2455,9 @@
       ETK_WARNING("The iterator can't be attached to a paragraph node");
       return ETK_FALSE;
    }
-   else if (iter->node->type == ETK_TEXTBLOCK_NODE_ROOT)
+   else if (iter->node->children)
    {
-      ETK_WARNING("The iterator can't be attached to the root node");
+      ETK_WARNING("The node of the iterator is not a leaf");
       return ETK_FALSE;
    }
    else if (iter->pos < 0 || iter->pos > iter->node->unicode_length ||
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_textblock.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -3 -r1.15 -r1.16
--- etk_textblock.h     27 Jul 2006 00:40:40 -0000      1.15
+++ etk_textblock.h     20 Aug 2006 20:41:20 -0000      1.16
@@ -249,6 +249,7 @@
 int etk_textblock_unicode_length_get(const char *unicode_string);
 Etk_Bool etk_textblock_is_white_char(int c);
 void etk_textblock_char_size_get(Evas *evas, const char *font_face, int 
font_size, int *w, int *h);
+void etk_textblock_printf(Etk_Textblock *tb);
 
 /** @} */
  
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_widget.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -3 -r1.73 -r1.74
--- etk_widget.c        19 Aug 2006 19:18:03 -0000      1.73
+++ etk_widget.c        20 Aug 2006 20:41:20 -0000      1.74
@@ -394,7 +394,7 @@
  * @param theme_file the path of the .edj theme-file. If NULL, it will use the 
theme-file of its theme-parent
  * (or parent if it is has no theme-parent). If none of its theme-parents has 
a non-null theme-file, it will use the
  * current theme-file of Etk. @n
- * Children of the widget will automatically inherit this theme-file if they 
have no theme-file already set
+ * Children of the widget will automatically inherit this theme-file if their 
theme-file is NULL
  */
 void etk_widget_theme_file_set(Etk_Widget *widget, const char *theme_file)
 {
@@ -414,9 +414,9 @@
 /**
  * @brief Gets the theme-file of the widget. See etk_widget_theme_file_set() 
for more infos about theme-file
  * @param widget a widget
- * @return Returns the theme-file used by the widget (if NULL, it uses the 
theme-file of its parent)
- * @note To get the theme-file really used by the widget, you have to walk 
through the theme-parents of the widget @n
- * until you find the first theme-parent that uses a non-null theme-file. This 
is the theme-file used of the widget. @n
+ * @return Returns the theme-file used by the widget (if NULL, it uses the 
theme-file of its theme-parent)
+ * @note To get the theme-file really used by the widget, you have to walk 
through the theme-parents of the widget
+ * until you find the first theme-parent that uses a non-null theme-file. This 
is the theme-file used by the widget. @n
  * If no theme-parent has a non-null theme-file, then it uses the current 
theme-file of Etk, that you can get with
  * etk_theme_widget_theme_get()
  */
@@ -515,8 +515,8 @@
  * @param widget a widget
  * @param parent the new parent
  * @param remove_from_container if @a remove_from_container is ETK_TRUE and if 
the parent of the widget is a container,
- * the remove_child() function of the container parent will be called. So @a 
remove_from_container should most of the
- * time be set to ETK_TRUE, except when etk_widget_parent_set_full() is called 
from the remove_child() function of a
+ * the child_remove() function of the parent container will be called. So @a 
remove_from_container should most of the
+ * time be set to ETK_TRUE, except when etk_widget_parent_set_full() is called 
from the child_remove() function of a
  * container, in order to avoid an infinite loop.
  * @widget_implementation
  * @note If you want to add a widget to a container, use etk_container_add() 
instead!
@@ -577,7 +577,7 @@
 
 /**
  * @brief Sets whether the widget should have an event object. An event object 
is a simple invisible rectangle that
- * grabs the mouse events. It can be useful for example if you want to know 
when a container with no theme object
+ * grabs the mouse events. It is useful for example if you want to know when a 
container with no theme object
  * (a table, a box, ...) is clicked. @n
  * If a widget already has a theme object, then this function has no effect 
since the theme object is already used to
  * grab the mouse events
@@ -629,7 +629,8 @@
 /**
  * @brief Sets whether the widget should repeat the mouse events it receives
  * @param widget a widget
- * @param repeat_mouse_events if @a repeat_mouse_events is ETK_TRUE, the 
parent widget will also receive the mouse events
+ * @param repeat_mouse_events if @a repeat_mouse_events is ETK_TRUE, the parent
+ * widget will also receive the mouse events
  */
 void etk_widget_repeat_mouse_events_set(Etk_Widget *widget, Etk_Bool 
repeat_mouse_events)
 {



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to