Enlightenment CVS committal

Author  : moom
Project : e17
Module  : proto

Dir     : e17/proto/etk/src/lib


Modified Files:
        etk_bin.c etk_bin.h etk_box.c etk_notebook.c etk_notebook.h 
        etk_paned.c etk_paned.h 


Log Message:
* Notebook, box and paned now correctly emit "child_added" and 
"child_removed"
* Fix etk_notebook_page_remove() (not tested though)


===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_bin.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- etk_bin.c   13 Aug 2006 22:42:23 -0000      1.13
+++ etk_bin.c   15 Aug 2006 22:26:55 -0000      1.14
@@ -244,7 +244,6 @@
 
    if (!(bin = ETK_BIN(object)) || !bin->child)
       return;
-   /* TODO; warnings? */
    etk_widget_swallow_widget(ETK_WIDGET(bin), "swallow_area", bin->child);
 }
 
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_bin.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- etk_bin.h   13 May 2006 12:04:00 -0000      1.6
+++ etk_bin.h   15 Aug 2006 22:26:55 -0000      1.7
@@ -23,7 +23,7 @@
 #define ETK_IS_BIN(obj)    (ETK_OBJECT_CHECK_TYPE((obj), ETK_BIN_TYPE))
 
 /**
- * @brief @widget The structure of a bin
+ * @brief @widget A container that can contain only one child
  * @structinfo
  */
 struct Etk_Bin
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_box.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- etk_box.c   15 Aug 2006 20:20:43 -0000      1.14
+++ etk_box.c   15 Aug 2006 22:26:55 -0000      1.15
@@ -1,6 +1,8 @@
 /** @file etk_box.c */
 #include "etk_box.h"
 #include <stdlib.h>
+#include "etk_signal.h"
+#include "etk_signal_callback.h"
 #include "etk_utils.h"
 
 /**
@@ -514,6 +516,8 @@
       etk_widget_parent_set_full(widget, NULL, ETK_FALSE);
       etk_widget_size_recalc_queue(box_widget);
       free(cell);
+      
+      etk_signal_emit_by_name("child_removed", ETK_OBJECT(box), NULL, widget);
    }
 }
 
@@ -1040,6 +1044,7 @@
    }
    
    etk_widget_parent_set(child, ETK_WIDGET(box));
+   etk_signal_emit_by_name("child_added", ETK_OBJECT(box), NULL, child);
 }
 
 /* Gets the cell of the box containing the widget */
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_notebook.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -3 -r1.27 -r1.28
--- etk_notebook.c      8 Aug 2006 18:51:22 -0000       1.27
+++ etk_notebook.c      15 Aug 2006 22:26:55 -0000      1.28
@@ -2,10 +2,10 @@
 #include "etk_notebook.h"
 #include <stdlib.h>
 #include <string.h>
-#include "etk_utils.h"
+#include "etk_radio_button.h"
 #include "etk_signal.h"
 #include "etk_signal_callback.h"
-#include "etk_radio_button.h"
+#include "etk_utils.h"
 
 /**
  * @addtogroup Etk_Notebook
@@ -35,6 +35,8 @@
 static void _etk_notebook_child_remove(Etk_Container *container, Etk_Widget 
*widget);
 static Evas_List *_etk_notebook_children_get(Etk_Container *container);
 
+static void _etk_notebook_frame_child_added_cb(Etk_Object *object, Etk_Widget 
*child, void *data);
+static void _etk_notebook_frame_child_removed_cb(Etk_Object *object, 
Etk_Widget *child, void *data);
 static void _etk_notebook_tab_toggled_cb(Etk_Object *object, void *data);
 static void _etk_notebook_tab_bar_focused_cb(Etk_Object *object, void *data);
 static void _etk_notebook_tab_bar_unfocused_cb(Etk_Object *object, void *data);
@@ -129,7 +131,7 @@
 }
 
 /**
- * @brief Creates a new page and inserts it to the notebook at the given 
position
+ * @brief Creates a new page and inserts it to the notebook at a given position
  * @param notebook a notebook
  * @param tab_label the text to set to the tab's label
  * @param page_child the child of the new page. This widget will be shown when 
the page is set as the current one
@@ -162,29 +164,40 @@
  * @brief Removes from the notebook the page corresponding to the index
  * @param notebook a notebook
  * @param page_num the index of the page to remove
+ * @warning The widget of the child of the page will be automatically 
destroyed too.
+ * To avoid this, call etk_notebook_page_child_set(notebook, page_num, NULL); 
before
  */
 void etk_notebook_page_remove(Etk_Notebook *notebook, int page_num)
 {
    Evas_List *l;
-   Etk_Notebook_Page *page;
+   Etk_Notebook_Page *page, *new_current = NULL;
    
    if (!notebook || !(l = evas_list_nth_list(notebook->pages, page_num)))
       return;
-     
+   
    page = l->data;
-   etk_widget_parent_set(page->frame, NULL);
    etk_object_destroy(ETK_OBJECT(page->frame));
-   etk_widget_parent_set(page->tab, NULL);
    etk_object_destroy(ETK_OBJECT(page->tab));
-   free(page);
+   
+   if (notebook->current_page == page)
+   {
+      if (l->next)
+         new_current = l->next->data;
+      else if (l->prev)
+         new_current = l->prev->data;
+   }
+   
    notebook->pages = evas_list_remove_list(notebook->pages, l);
+   free(page);
+   
    
-   if (!notebook->pages)
+   if (notebook->current_page != new_current)
    {
-      notebook->current_page = NULL;
-      ETK_WIDGET(notebook)->focus_order = 
evas_list_free(ETK_WIDGET(notebook)->focus_order);
-      etk_signal_emit(_etk_notebook_signals[ETK_NOTEBOOK_PAGE_CHANGED_SIGNAL], 
ETK_OBJECT(notebook), NULL);
+      etk_toggle_button_active_set(ETK_TOGGLE_BUTTON(new_current->tab), 
ETK_TRUE);
+      notebook->current_page = new_current;
    }
+   
+   etk_widget_size_recalc_queue(ETK_WIDGET(notebook));
 }
 
 /**
@@ -304,7 +317,7 @@
 /**
  * @brief Sets the label of a tab of the notebook
  * @param notebook a notebook
- * @param page_num the index of the page that you want you set the tab label
+ * @param page_num the index of the page you want to set the tab label of
  * @param tab_label the new label of the tab
  */
 void etk_notebook_page_tab_label_set(Etk_Notebook *notebook, int page_num, 
const char *tab_label)
@@ -319,7 +332,7 @@
 /**
  * @brief Gets the label of a tab of the notebook
  * @param notebook a notebook
- * @param page_num the index of the page that you want to get the tab label
+ * @param page_num the index of the page you want to get the tab label of
  * @return Returns the label, or NULL on failure
  */
 const char *etk_notebook_page_tab_label_get(Etk_Notebook *notebook, int 
page_num)
@@ -670,6 +683,26 @@
  *
  **************************/
 
+/* Called when a child is added to a page frame */
+static void _etk_notebook_frame_child_added_cb(Etk_Object *object, Etk_Widget 
*child, void *data)
+{
+   Etk_Object *notebook;
+   
+   if (!(notebook = ETK_OBJECT(data)))
+      return;
+   etk_signal_emit_by_name("child_added", notebook, NULL, child);
+}
+
+/* Called when a child is removed from a page frame */
+static void _etk_notebook_frame_child_removed_cb(Etk_Object *object, 
Etk_Widget *child, void *data)
+{
+   Etk_Object *notebook;
+   
+   if (!(notebook = ETK_OBJECT(data)))
+      return;
+   etk_signal_emit_by_name("child_removed", notebook, NULL, child);
+}
+
 /* Called when a tab is toggled (activated or deactivated) */
 static void _etk_notebook_tab_toggled_cb(Etk_Object *object, void *data)
 {
@@ -801,6 +834,7 @@
    etk_widget_show(new_page->tab);
    etk_signal_connect("toggled", ETK_OBJECT(new_page->tab), 
ETK_CALLBACK(_etk_notebook_tab_toggled_cb), notebook);
    
+   
    if (notebook->tab_bar_visible)
       new_page->frame = etk_widget_new(ETK_BIN_TYPE, "theme_group", "frame", 
NULL);
    else
@@ -808,6 +842,12 @@
    etk_widget_parent_set(new_page->frame, ETK_WIDGET(notebook));
    etk_widget_visibility_locked_set(new_page->frame, ETK_TRUE);
    etk_widget_hide(new_page->frame);
+   
+   etk_signal_connect("child_added", ETK_OBJECT(new_page->frame),
+      ETK_CALLBACK(_etk_notebook_frame_child_added_cb), notebook);
+   etk_signal_connect("child_removed", ETK_OBJECT(new_page->frame),
+      ETK_CALLBACK(_etk_notebook_frame_child_removed_cb), notebook);
+   
    
    etk_bin_child_set(ETK_BIN(new_page->frame), page_child);
    
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_notebook.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -3 -r1.17 -r1.18
--- etk_notebook.h      8 Aug 2006 16:33:01 -0000       1.17
+++ etk_notebook.h      15 Aug 2006 22:26:55 -0000      1.18
@@ -9,12 +9,14 @@
 /** TODO/FIXME list:
  * - Improve the default theme of the tabs
  * - Make the tab bar "swallowable"
- * - Focus the first widget of the page when the current page is changed
+ * - Fix focus problems
+ * - Find a way to access clipped tabs when there are two many tabs (popup 
menus ?)
  */
 
 /**
  * @defgroup Etk_Notebook Etk_Notebook
- * @brief The Etk_Notebook widget is a container that can contain several 
widgets in different pages accessible via tabs
+ * @brief The Etk_Notebook widget is a container that can contain several 
widgets in different pages
+  * accessible through tabs
  * @{
  */
 
@@ -34,7 +36,7 @@
 } Etk_Notebook_Page;
 
 /**
- * @brief @widget The structure of a notebook
+ * @brief @widget A container that can contain several widgets in different 
pages accessible through tabs
  * @structinfo
  */
 struct Etk_Notebook
@@ -54,28 +56,27 @@
 Etk_Type *etk_notebook_type_get();
 Etk_Widget *etk_notebook_new();
 
-int etk_notebook_page_prepend(Etk_Notebook *notebook, const char *tab_label, 
Etk_Widget *page_child);
-int etk_notebook_page_append(Etk_Notebook *notebook, const char *tab_label, 
Etk_Widget *page_child);
-int etk_notebook_page_insert(Etk_Notebook *notebook, const char *tab_label, 
Etk_Widget *page_child, int position);
+int  etk_notebook_page_prepend(Etk_Notebook *notebook, const char *tab_label, 
Etk_Widget *page_child);
+int  etk_notebook_page_append(Etk_Notebook *notebook, const char *tab_label, 
Etk_Widget *page_child);
+int  etk_notebook_page_insert(Etk_Notebook *notebook, const char *tab_label, 
Etk_Widget *page_child, int position);
 void etk_notebook_page_remove(Etk_Notebook *notebook, int page_num);
 
-int etk_notebook_num_pages_get(Etk_Notebook *notebook);
+int  etk_notebook_num_pages_get(Etk_Notebook *notebook);
 void etk_notebook_current_page_set(Etk_Notebook *notebook, int page_num);
-int etk_notebook_current_page_get(Etk_Notebook *notebook);
-int etk_notebook_page_index_get(Etk_Notebook *notebook, Etk_Widget *child);
+int  etk_notebook_current_page_get(Etk_Notebook *notebook);
+int  etk_notebook_page_index_get(Etk_Notebook *notebook, Etk_Widget *child);
 
 int etk_notebook_page_prev(Etk_Notebook *notebook);
 int etk_notebook_page_next(Etk_Notebook *notebook);
 
-void etk_notebook_page_tab_label_set(Etk_Notebook *notebook, int page_num, 
const char *tab_label);
+void        etk_notebook_page_tab_label_set(Etk_Notebook *notebook, int 
page_num, const char *tab_label);
 const char *etk_notebook_page_tab_label_get(Etk_Notebook *notebook, int 
page_num);
-void etk_notebook_page_tab_widget_set(Etk_Notebook *notebook, int page_num, 
Etk_Widget *tab_widget);
+void        etk_notebook_page_tab_widget_set(Etk_Notebook *notebook, int 
page_num, Etk_Widget *tab_widget);
 Etk_Widget *etk_notebook_page_tab_widget_get(Etk_Notebook *notebook, int 
page_num);
-
-void etk_notebook_page_child_set(Etk_Notebook *notebook, int page_num, 
Etk_Widget *child);
+void        etk_notebook_page_child_set(Etk_Notebook *notebook, int page_num, 
Etk_Widget *child);
 Etk_Widget *etk_notebook_page_child_get(Etk_Notebook *notebook, int page_num);
 
-void etk_notebook_tabs_visible_set(Etk_Notebook *notebook, Etk_Bool 
tabs_visible);
+void     etk_notebook_tabs_visible_set(Etk_Notebook *notebook, Etk_Bool 
tabs_visible);
 Etk_Bool etk_notebook_tabs_visible_get(Etk_Notebook *notebook);
 
 /** @} */
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_paned.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- etk_paned.c 28 May 2006 15:56:06 -0000      1.9
+++ etk_paned.c 15 Aug 2006 22:26:55 -0000      1.10
@@ -120,8 +120,8 @@
  * @brief Sets the first child of the paned (the left one for a hpaned, the 
top one for a vpaned)
  * @param paned a paned
  * @param child the child to set
- * @param expand if @a expand == ETK_TRUE, when the paned will be resized, the 
first child will try to expand as much as
- * possible
+ * @param expand if @a expand is ETK_TRUE, when the paned will be resized, the 
child will try to expand
+ * as much as possible
  */
 void etk_paned_child1_set(Etk_Paned *paned, Etk_Widget *child, Etk_Bool expand)
 {
@@ -140,6 +140,8 @@
       etk_widget_parent_set(child, ETK_WIDGET(paned));
       
       etk_widget_raise(paned->separator);
+      
+      etk_signal_emit_by_name("child_added", ETK_OBJECT(paned), NULL, child);
    }
 }
 
@@ -147,8 +149,8 @@
  * @brief Sets the second child of the paned (the right one for a hpaned, the 
bottom one for a vpaned)
  * @param paned a paned
  * @param child the child to set
- * @param expand if @a expand == ETK_TRUE, when the paned will be resized, the 
first child will try to expand as much as
- * possible
+ * @param expand if @a expand is ETK_TRUE, when the paned will be resized, the 
first child will try to expand
+ * as much as possible
  */
 void etk_paned_child2_set(Etk_Paned *paned, Etk_Widget *child, Etk_Bool expand)
 {
@@ -167,6 +169,8 @@
       etk_widget_parent_set(child, ETK_WIDGET(paned));
       
       etk_widget_raise(paned->separator);
+      
+      etk_signal_emit_by_name("child_added", ETK_OBJECT(paned), NULL, child);
    }
 }
 
@@ -464,6 +468,7 @@
 
    etk_widget_parent_set_full(widget, NULL, ETK_FALSE);
    etk_widget_size_recalc_queue(ETK_WIDGET(paned));
+   etk_signal_emit_by_name("child_removed", ETK_OBJECT(paned), NULL, widget);
 }
 
 /* Returns the children of the paned */
@@ -654,8 +659,10 @@
  *
  * @image html widgets/paned.png
  * Etk_Paned is the abstract class for two derived widgets: Etk_HPaned and 
Etk_VPaned.
- * - Etk_HPaned is a paned where the two children are arranged horizontally 
and separated by a draggable vertical separator
- * - Etk_VPaned is a paned where the two children are arranged vertically and 
separated by a draggable horizontal separator
+ * - Etk_HPaned is a paned where the two children are arranged horizontally and
+ * separated by a vertical draggable separator
+ * - Etk_VPaned is a paned where the two children are arranged vertically and
+ * separated by a horizontal draggable separator
  * @n @n
  *
  * \par Object Hierarchy:
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_paned.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- etk_paned.h 28 May 2006 15:56:06 -0000      1.5
+++ etk_paned.h 15 Aug 2006 22:26:55 -0000      1.6
@@ -38,7 +38,7 @@
 #define ETK_IS_VPANED(obj)    (ETK_OBJECT_CHECK_TYPE((obj), ETK_VPANED_TYPE))
 
 /**
- * @brief @widget The structure of a paned
+ * @brief @widget A container that can contain two children separated by a 
draggable separator
  * @structinfo
  */
 struct Etk_Paned
@@ -59,7 +59,7 @@
 };
 
 /**
- * @brief @widget The structure of a hpaned
+ * @brief @widget An horizontal paned
  * @structinfo
  */
 struct Etk_HPaned
@@ -70,7 +70,7 @@
 };
 
 /**
- * @brief @widget The structure of a vpaned
+ * @brief @widget A vertical paned
  * @structinfo
  */
 struct Etk_VPaned



-------------------------------------------------------------------------
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