Enlightenment CVS committal

Author  : moom16
Project : e17
Module  : proto

Dir     : e17/proto/etk/src/lib


Modified Files:
        Makefile.am etk_combobox.c etk_combobox.h etk_menu_window.c 
        etk_tree.c etk_tree.h etk_types.h etk_window.c etk_window.h 


Log Message:
* Fix etk_window_center_on_window
* Fix etk_window_resize
* [API BREAK] When clicking on a row header, the row is sorted asc, and if 
clicking again, sorted desc.
* Some work etk_combobox


===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/Makefile.am,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -3 -r1.30 -r1.31
--- Makefile.am 5 Mar 2006 23:52:58 -0000       1.30
+++ Makefile.am 12 Mar 2006 12:13:02 -0000      1.31
@@ -8,7 +8,7 @@
 DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
 
 INCLUDES       = \
--I. -I$(top_srcdir)/src/lib -Wall -g \
+-I. -I../.. -I$(top_srcdir)/src/lib -Wall -g \
 @EVAS_CFLAGS@ @ECORE_CFLAGS@ @EDJE_CFLAGS@
 
 lib_LTLIBRARIES = libetk.la
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_combobox.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- etk_combobox.c      6 Mar 2006 00:04:43 -0000       1.2
+++ etk_combobox.c      12 Mar 2006 12:13:02 -0000      1.3
@@ -3,6 +3,7 @@
 #include <stdlib.h>
 #include "etk_menu_window.h"
 #include "etk_toggle_button.h"
+#include "etk_label.h"
 #include "etk_utils.h"
 #include "etk_signal.h"
 #include "etk_signal_callback.h"
@@ -14,9 +15,20 @@
 
 static void _etk_combobox_constructor(Etk_Combobox *combobox);
 static void _etk_combobox_destructor(Etk_Combobox *combobox);
+static void _etk_combobox_item_destructor(Etk_Combobox_Item *item);
 static void _etk_combobox_size_request(Etk_Widget *widget, Etk_Size 
*size_requisition);
 static void _etk_combobox_size_allocate(Etk_Widget *widget, Etk_Geometry 
geometry);
-static void _etk_combobox_button_clicked_cb(Etk_Object *object, void *data);
+static void _etk_combobox_window_size_request(Etk_Widget *widget, Etk_Size 
*size_requisition);
+static void _etk_combobox_window_size_allocate(Etk_Widget *widget, 
Etk_Geometry geometry);
+static void _etk_combobox_item_size_allocate(Etk_Widget *widget, Etk_Geometry 
geometry);
+static void _etk_combobox_active_item_size_request(Etk_Widget *widget, 
Etk_Size *size_requisition);
+static void _etk_combobox_active_item_size_allocate(Etk_Widget *widget, 
Etk_Geometry geometry);
+static void _etk_combobox_focus_handler(Etk_Widget *widget);
+static void _etk_combobox_unfocus_handler(Etk_Widget *widget);
+static void _etk_combobox_button_toggled_cb(Etk_Object *object, void *data);
+static void _etk_combobox_window_popped_down_cb(Etk_Object *object, void 
*data);
+static void _etk_combobox_item_enter_cb(Etk_Object *object, void *data);
+static void _etk_combobox_item_leave_cb(Etk_Object *object, void *data);
 
 /**************************
  *
@@ -33,12 +45,32 @@
    static Etk_Type *combobox_type = NULL;
 
    if (!combobox_type)
-      combobox_type = etk_type_new("Etk_Combobox", ETK_WIDGET_TYPE, 
sizeof(Etk_Combobox), ETK_CONSTRUCTOR(_etk_combobox_constructor), 
ETK_DESTRUCTOR(_etk_combobox_destructor));
+   {
+      combobox_type = etk_type_new("Etk_Combobox", ETK_WIDGET_TYPE, 
sizeof(Etk_Combobox),
+         ETK_CONSTRUCTOR(_etk_combobox_constructor), 
ETK_DESTRUCTOR(_etk_combobox_destructor));
+   }
 
    return combobox_type;
 }
 
 /**
+ * @brief Gets the type of an Etk_Combobox_Item
+ * @return Returns the type on an Etk_Combobox_Item
+ */
+Etk_Type *etk_combobox_item_type_get()
+{
+   static Etk_Type *combobox_item_type = NULL;
+
+   if (!combobox_item_type)
+   {
+      combobox_item_type = etk_type_new("Etk_Combobox_Item", ETK_WIDGET_TYPE, 
sizeof(Etk_Combobox_Item),
+         NULL, ETK_DESTRUCTOR(_etk_combobox_item_destructor));
+   }
+
+   return combobox_item_type;
+}
+
+/**
  * @brief Creates a new combobox
  * @return Returns the new combobox widget
  */
@@ -47,6 +79,122 @@
    return etk_widget_new(ETK_COMBOBOX_TYPE, "focusable", ETK_TRUE, 
"focus_on_press", ETK_TRUE, NULL);
 }
 
+/**
+ * @brief Creates a new combobox, adds a unique column that can contain a 
label, and build the combobox
+ * @return Returns the new combobox widget
+ */
+Etk_Widget *etk_combobox_new_default()
+{
+   Etk_Widget *combobox;
+   
+   combobox = etk_combobox_new();
+   etk_combobox_column_add(ETK_COMBOBOX(combobox), ETK_COMBOBOX_LABEL, 100, 
ETK_FALSE);
+   etk_combobox_build(ETK_COMBOBOX(combobox));
+   
+   return combobox;
+}
+
+/**
+ * @brief Adds a column to the combobox. The combobox shouldn't be already be 
built
+ * @param combobox a combobox
+ * @param col_type the type of widget that will be packed in the column
+ * @param size TODO
+ * @param expand TODO
+ */
+void etk_combobox_column_add(Etk_Combobox *combobox, Etk_Combobox_Column_Type 
col_type, int size, Etk_Bool expand)
+{
+   if (!combobox)
+      return;
+   if (combobox->built)
+   {
+      ETK_WARNING("The combobox shouldn't be already built when you add a new 
column");
+      return;
+   }
+   
+   combobox->cols = realloc(combobox->cols, (combobox->num_cols + 1) * 
sizeof(Etk_Combobox_Column *));
+   combobox->cols[combobox->num_cols] = malloc(sizeof(Etk_Combobox_Column));
+   combobox->cols[combobox->num_cols]->type = col_type;
+   combobox->cols[combobox->num_cols]->size = size;
+   combobox->cols[combobox->num_cols]->expand = expand;
+   combobox->num_cols++;
+}
+
+/**
+ * @brief Builds the combobox: to create a combobox with items, first create 
the columns, then build it, @n
+ * and then start to add the items. Items can't be added if the combobox is 
not built
+ * @param combobox the combobox to build
+ */
+void etk_combobox_build(Etk_Combobox *combobox)
+{
+   if (!combobox)
+      return;
+   
+   combobox->active_item_widget = etk_widget_new(ETK_WIDGET_TYPE, 
"pass_events", ETK_TRUE, "visible", ETK_TRUE, NULL);
+   combobox->active_item_widget->size_request = 
_etk_combobox_active_item_size_request;
+   combobox->active_item_widget->size_allocate = 
_etk_combobox_active_item_size_allocate;
+   etk_object_data_set(ETK_OBJECT(combobox->active_item_widget), 
"_Etk_Combobox_Window::Combobox", combobox);
+   etk_container_add(ETK_CONTAINER(combobox->button), 
combobox->active_item_widget);
+   
+   combobox->built = ETK_TRUE;
+}
+
+/**
+ * @brief Appends a new item to the combobox
+ * @param combobox a combobox
+ * @param data the data associated to the item
+ * @param ... TODO
+ * @return Returns the new item
+ * @note Unlike other widgets, the new item will be automatically shown, so 
you won't have to call etk_widget_show() on it. 
+ */
+Etk_Combobox_Item *etk_combobox_item_append(Etk_Combobox *combobox, void 
*data, ...)
+{
+   Etk_Combobox_Item *item;
+   va_list args;
+   int i;
+   
+   if (!combobox)
+      return NULL;
+   if (!combobox->built)
+   {
+      ETK_WARNING("The combobox should be built when you add a new item to 
it");
+      return NULL;
+   }
+   
+   item = ETK_COMBOBOX_ITEM(etk_widget_new(ETK_COMBOBOX_ITEM_TYPE, 
"theme_group", "combobox_item", "visible", ETK_TRUE, NULL));
+   item->combobox = combobox;
+   item->data = data;
+   item->widgets = malloc(sizeof(Etk_Widget *) * combobox->num_cols);
+   ETK_WIDGET(item)->size_allocate = _etk_combobox_item_size_allocate;
+   
+   va_start(args, data);
+   for (i = 0; i < combobox->num_cols; i++)
+   {
+      switch (combobox->cols[i]->type)
+      {
+         case ETK_COMBOBOX_LABEL:
+            item->widgets[i] = etk_label_new(va_arg(args, char *));
+            break;
+         case ETK_COMBOBOX_IMAGE:
+         case ETK_COMBOBOX_OTHER:
+            item->widgets[i] = va_arg(args, Etk_Widget *);
+         default:
+            break;
+      }
+      etk_widget_parent_set(item->widgets[i], ETK_WIDGET(item));
+      etk_widget_show(item->widgets[i]);
+      /* TODO: repeat/pass events?? */
+   }
+   va_end(args);
+   
+   etk_signal_connect("enter", ETK_OBJECT(item), 
ETK_CALLBACK(_etk_combobox_item_enter_cb), NULL);
+   etk_signal_connect("leave", ETK_OBJECT(item), 
ETK_CALLBACK(_etk_combobox_item_leave_cb), NULL);
+   
+   etk_widget_parent_set(ETK_WIDGET(item), ETK_WIDGET(combobox->window));
+   combobox->items = evas_list_append(combobox->items, item);
+   
+   return item;
+}
+
 /**************************
  *
  * Etk specific functions
@@ -59,16 +207,26 @@
    if (!combobox)
       return;
    
-   combobox->button = etk_widget_new(ETK_TOGGLE_BUTTON_TYPE, "theme_group", 
"combobox", "visible", ETK_TRUE, "visibility_locked", ETK_TRUE, NULL);
+   combobox->button = etk_widget_new(ETK_TOGGLE_BUTTON_TYPE, "theme_group", 
"combobox", "visible", ETK_TRUE,
+      "repeat_events", ETK_TRUE, "visibility_locked", ETK_TRUE, NULL);
    etk_widget_parent_set(combobox->button, ETK_WIDGET(combobox));
-   etk_signal_connect("clicked", ETK_OBJECT(combobox->button), 
ETK_CALLBACK(_etk_combobox_button_clicked_cb), combobox);
-   
+   etk_signal_connect("toggled", ETK_OBJECT(combobox->button), 
ETK_CALLBACK(_etk_combobox_button_toggled_cb), combobox);
    
    combobox->window = ETK_MENU_WINDOW(etk_widget_new(ETK_MENU_WINDOW_TYPE, 
"theme_group", "combobox_window", NULL));
-   /* TODO: connect */
-   //etk_signal_connect("popped_up", ETK_OBJECT(menu->window), 
ETK_CALLBACK(_etk_menu_window_popped_up_cb), menu);
-   //etk_signal_connect("popped_down", ETK_OBJECT(menu->window), 
ETK_CALLBACK(_etk_menu_window_popped_down_cb), menu);
+   etk_object_data_set(ETK_OBJECT(combobox->window), 
"_Etk_Combobox_Window::Combobox", combobox);
+   etk_signal_connect("popped_down", ETK_OBJECT(combobox->window), 
ETK_CALLBACK(_etk_combobox_window_popped_down_cb), combobox);
+   ETK_WIDGET(combobox->window)->size_request = 
_etk_combobox_window_size_request;
+   ETK_WIDGET(combobox->window)->size_allocate = 
_etk_combobox_window_size_allocate;
    
+   combobox->active_item_widget = NULL;
+   combobox->num_cols = 0;
+   combobox->cols = NULL;
+   combobox->items = NULL;
+   combobox->item_height = 24;
+   combobox->built = ETK_FALSE;
+   
+   ETK_WIDGET(combobox)->focus = _etk_combobox_focus_handler;
+   ETK_WIDGET(combobox)->unfocus = _etk_combobox_unfocus_handler;
    ETK_WIDGET(combobox)->size_request = _etk_combobox_size_request;
    ETK_WIDGET(combobox)->size_allocate = _etk_combobox_size_allocate;
 }
@@ -76,9 +234,26 @@
 /* Destroys the combobox */
 static void _etk_combobox_destructor(Etk_Combobox *combobox)
 {
+   int i;
+   
    if (!combobox)
       return;
+   
+   for (i = 0; i < combobox->num_cols; i++)
+      free(combobox->cols[i]);
+   free(combobox->cols);
+   
    etk_object_destroy(ETK_OBJECT(combobox->window));
+   /* TODO */
+}
+
+/* Destroys the combobox item */
+static void _etk_combobox_item_destructor(Etk_Combobox_Item *item)
+{
+   if (!item)
+      return;
+   
+   /* TODO */
 }
 
 /* Calculates the ideal size of the combobox */
@@ -91,7 +266,7 @@
    etk_widget_size_request(combobox->button, size_requisition);
 }
 
-/* Resizes the combobox to the size allocation */
+/* Resizes the combobox to the allocated geometry */
 static void _etk_combobox_size_allocate(Etk_Widget *widget, Etk_Geometry 
geometry)
 {
    Etk_Combobox *combobox;
@@ -101,14 +276,139 @@
    etk_widget_size_allocate(combobox->button, geometry);
 }
 
+/* Calculates the ideal size of the combobox window */
+static void _etk_combobox_window_size_request(Etk_Widget *widget, Etk_Size 
*size_requisition)
+{
+   Etk_Combobox *combobox;
+   int i;
+   
+   if (!widget || !size_requisition)
+      return;
+   if (!(combobox = ETK_COMBOBOX(etk_object_data_get(ETK_OBJECT(widget), 
"_Etk_Combobox_Window::Combobox"))))
+      return;
+   
+   size_requisition->w = 0;
+   for (i = 0; i < combobox->num_cols; i++)
+      size_requisition->w += combobox->cols[i]->size;
+   
+   size_requisition->h = evas_list_count(combobox->items) * 
combobox->item_height;
+}
+
+/* Resizes the combobox window to the allocated geometry */
+static void _etk_combobox_window_size_allocate(Etk_Widget *widget, 
Etk_Geometry geometry)
+{
+   Etk_Combobox *combobox;
+   Evas_List *l;
+   
+   if (!widget || !(combobox = 
ETK_COMBOBOX(etk_object_data_get(ETK_OBJECT(widget), 
"_Etk_Combobox_Window::Combobox"))))
+      return;
+   
+   geometry.h = combobox->item_height;
+   for (l = combobox->items; l; l = l->next)
+   {
+      etk_widget_size_allocate(ETK_WIDGET(l->data), geometry);
+      geometry.y += combobox->item_height;
+   }
+}
+
+/* Resizes the combobox item to the allocated geometry */
+static void _etk_combobox_item_size_allocate(Etk_Widget *widget, Etk_Geometry 
geometry)
+{
+   Etk_Combobox_Item *item;
+   Etk_Combobox *combobox;
+   Etk_Geometry child_geometry;
+   int num_expandable_cols = 0;
+   int expandable_width = 0;
+   int total_width = 0;
+   int i;
+   
+   if (!(item = ETK_COMBOBOX_ITEM(widget)) || !(combobox = item->combobox))
+      return;
+   
+   for (i = 0; i < combobox->num_cols; i++)
+   {
+      if (!combobox->cols[i]->expand)
+      {
+         num_expandable_cols++;
+         expandable_width += combobox->cols[i]->size;
+      }
+      total_width += combobox->cols[i]->size;
+   }
+   
+   child_geometry.x = geometry.x;
+   child_geometry.y = geometry.y;
+   child_geometry.h = geometry.h;
+   for (i = 0; i < combobox->num_cols; i++)
+   {
+      if (num_expandable_cols == 0)
+      {
+         if (i != combobox->num_cols - 1)
+            child_geometry.w = combobox->cols[i]->size;
+         else
+            child_geometry.w = geometry.w - (child_geometry.x - geometry.x);
+      }
+      else
+         child_geometry.w = (combobox->cols[i]->size / expandable_width) * 
(geometry.w - (total_width - expandable_width));
+      
+      if (item->widgets[i])
+         etk_widget_size_allocate(item->widgets[i], child_geometry);
+      child_geometry.x += child_geometry.w;
+   }
+}
+
+/* Calculates the ideal size of the active item of the combobox (the item in 
the combobox button */
+static void _etk_combobox_active_item_size_request(Etk_Widget *widget, 
Etk_Size *size_requisition)
+{
+   Etk_Combobox *combobox;
+   int i;
+   
+   if (!widget || !size_requisition)
+      return;
+   if (!(combobox = ETK_COMBOBOX(etk_object_data_get(ETK_OBJECT(widget), 
"_Etk_Combobox_Window::Combobox"))))
+      return;
+   
+   size_requisition->w = 0;
+   size_requisition->h = 0;
+   for (i = 0; i < combobox->num_cols; i++)
+   {
+      if (combobox->cols[i]->type != ETK_COMBOBOX_OTHER)
+         size_requisition->w += combobox->cols[i]->size;
+   }
+}
+
+/* TODO: doc */
+static void _etk_combobox_active_item_size_allocate(Etk_Widget *widget, 
Etk_Geometry geometry)
+{
+}
+
 /**************************
  *
  * Callbacks and handlers
  *
  **************************/
 
-/* Called when the combobox button is clicked */
-static void _etk_combobox_button_clicked_cb(Etk_Object *object, void *data)
+/* Default handler for the "focus" handler */
+static void _etk_combobox_focus_handler(Etk_Widget *widget)
+{
+   Etk_Combobox *combobox;
+   
+   if (!(combobox = ETK_COMBOBOX(widget)))
+      return;
+   etk_widget_theme_object_signal_emit(combobox->button, "focus");
+}
+
+/* Default handler for the "unfocus" handler */
+static void _etk_combobox_unfocus_handler(Etk_Widget *widget)
+{
+   Etk_Combobox *combobox;
+   
+   if (!(combobox = ETK_COMBOBOX(widget)))
+      return;
+   etk_widget_theme_object_signal_emit(combobox->button, "unfocus");
+}
+
+/* Called when the combobox button is toggled */
+static void _etk_combobox_button_toggled_cb(Etk_Object *object, void *data)
 {
    int tx, ty;
    int bx, by, bw, bh;
@@ -118,9 +418,35 @@
    if (!(combobox = ETK_COMBOBOX(data)) || !(toplevel = 
etk_widget_toplevel_parent_get(combobox->button)))
       return;
    
-   etk_toplevel_widget_geometry_get(toplevel, &tx, &ty, NULL, NULL);
-   etk_widget_geometry_get(combobox->button, &bx, &by, &bw, &bh);
-   etk_menu_window_popup_at_xy(combobox->window, tx + bx, ty + by + bh);
+   if (etk_toggle_button_active_get(ETK_TOGGLE_BUTTON(combobox->button)))
+   {
+      etk_toplevel_widget_geometry_get(toplevel, &tx, &ty, NULL, NULL);
+      etk_widget_geometry_get(combobox->button, &bx, &by, &bw, &bh);
+      etk_menu_window_popup_at_xy(combobox->window, tx + bx, ty + by + bh);
+      etk_window_resize(ETK_WINDOW(combobox->window), bw, 0);
+   }
+}
+
+/* Called when the combobox window is popped down */
+static void _etk_combobox_window_popped_down_cb(Etk_Object *object, void *data)
+{
+   Etk_Combobox *combobox;
+   
+   if (!(combobox = ETK_COMBOBOX(data)))
+      return;
+   etk_toggle_button_active_set(ETK_TOGGLE_BUTTON(combobox->button), 
ETK_FALSE);
+}
+
+/* Called when the mouse enters the item */
+static void _etk_combobox_item_enter_cb(Etk_Object *object, void *data)
+{
+   etk_widget_theme_object_signal_emit(ETK_WIDGET(object), "select");
+}
+
+/* Called when the mouse leaves the item */
+static void _etk_combobox_item_leave_cb(Etk_Object *object, void *data)
+{
+   etk_widget_theme_object_signal_emit(ETK_WIDGET(object), "unselect");
 }
 
 /**************************
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_combobox.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- etk_combobox.h      6 Mar 2006 00:04:43 -0000       1.2
+++ etk_combobox.h      12 Mar 2006 12:13:02 -0000      1.3
@@ -3,6 +3,8 @@
 #define _ETK_COMBOBOX_H_
 
 #include "etk_widget.h"
+#include <stdarg.h>
+#include <Evas.h>
 #include "etk_types.h"
 
 /**
@@ -17,10 +19,45 @@
 /** @brief Check if the object is an Etk_Combobox */
 #define ETK_IS_COMBOBOX(obj)    (ETK_OBJECT_CHECK_TYPE((obj), 
ETK_COMBOBOX_TYPE))
 
+/** @brief Gets the type of a combobox item */
+#define ETK_COMBOBOX_ITEM_TYPE       (etk_combobox_item_type_get())
+/** @brief Casts the object to an Etk_Combobox_Item */
+#define ETK_COMBOBOX_ITEM(obj)       (ETK_OBJECT_CAST((obj), 
ETK_COMBOBOX_ITEM_TYPE, Etk_Combobox_Item))
+/** @brief Check if the object is an Etk_Combobox_Item */
+#define ETK_IS_COMBOBOX_ITEM(obj)    (ETK_OBJECT_CHECK_TYPE((obj), 
ETK_COMBOBOX_ITEM_TYPE))
+
+/* TODO: doc */
+typedef enum _Etk_Combobox_Column_Type
+{
+   ETK_COMBOBOX_LABEL,
+   ETK_COMBOBOX_IMAGE,
+   ETK_COMBOBOX_OTHER
+} Etk_Combobox_Column_Type;
+
+/* TODO: doc */
+struct _Etk_Combobox_Column
+{
+   Etk_Combobox_Column_Type type;
+   Etk_Bool expand;
+   int size;
+};
+
+/* TODO: doc */
+struct _Etk_Combobox_Item
+{
+   /* private: */
+   /* Inherit from Etk_Widget */
+   Etk_Widget widget;
+   
+   Etk_Combobox *combobox;
+   Etk_Widget **widgets;
+   void *data;
+};
+
 /**
  * @struct Etk_Combobox
  * @param A combobox is a button that pops up a window with a list of options 
when you click on it
-*/
+ */
 struct _Etk_Combobox
 {
    /* private: */
@@ -28,11 +65,28 @@
    Etk_Widget widget;
    
    Etk_Widget *button;
+   Etk_Widget *active_item_widget;
    Etk_Menu_Window *window;
+   
+   int num_cols;   
+   Etk_Combobox_Column **cols;
+   
+   Evas_List *items;
+   int item_height;
+   
+   Etk_Bool built;
 };
 
 Etk_Type *etk_combobox_type_get();
+Etk_Type *etk_combobox_item_type_get();
+
 Etk_Widget *etk_combobox_new();
+Etk_Widget *etk_combobox_new_default();
+
+void etk_combobox_column_add(Etk_Combobox *combobox, Etk_Combobox_Column_Type 
col_type, int size, Etk_Bool expand);
+void etk_combobox_build(Etk_Combobox *combobox);
+
+Etk_Combobox_Item *etk_combobox_item_append(Etk_Combobox *combobox, void 
*data, ...);
 
 /** @} */
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_menu_window.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- etk_menu_window.c   4 Mar 2006 23:29:47 -0000       1.1
+++ etk_menu_window.c   12 Mar 2006 12:13:02 -0000      1.2
@@ -182,10 +182,12 @@
 {
    if (!menu_window)
       return;
-      
+   
    etk_window_decorated_set(ETK_WINDOW(menu_window), ETK_FALSE);
    etk_window_skip_taskbar_hint_set(ETK_WINDOW(menu_window), ETK_TRUE);
    etk_window_skip_pager_hint_set(ETK_WINDOW(menu_window), ETK_TRUE);
+   /* TODO */
+   ecore_x_netwm_window_type_set(ETK_WINDOW(menu_window)->x_window, 
ECORE_X_WINDOW_TYPE_MENU);
 }
 
 /**************************
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_tree.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -3 -r1.55 -r1.56
--- etk_tree.c  6 Mar 2006 22:49:12 -0000       1.55
+++ etk_tree.c  12 Mar 2006 12:13:02 -0000      1.56
@@ -556,18 +556,16 @@
 }
 
 /**
- * @brief Sets the sorting function for a columb
+ * @brief Sets the sorting function for a column
  * @param col a tree column
  * @param compare_cb the sorting comparator
- * @param ascendant wether we want ascending or descending results
- * @param data a pointer to user data
+ * @param data a pointer to user data, it will be passed to compare_cb
  */
-void etk_tree_col_sort_func_set(Etk_Tree_Col *col, int (*compare_cb)(Etk_Tree 
*tree, Etk_Tree_Row *row1, Etk_Tree_Row *row2, Etk_Tree_Col *col, void *data), 
Etk_Bool ascendant, void *data)
+void etk_tree_col_sort_func_set(Etk_Tree_Col *col, int (*compare_cb)(Etk_Tree 
*tree, Etk_Tree_Row *row1, Etk_Tree_Row *row2, Etk_Tree_Col *col, void *data), 
void *data)
 {  
-   if(!col)
-     return;
+   if (!col)
+      return;
    col->sort.compare_cb = compare_cb;
-   col->sort.ascendant = ascendant;
    col->sort.data = data;
 }
 
@@ -889,6 +887,9 @@
    tree->root.last_child = r;
    free(heap);
    
+   tree->last_sorted_col = col;
+   tree->last_sorted_ascendant = ascendant;
+   
    etk_widget_redraw_queue(ETK_WIDGET(tree->grid));
 }
 
@@ -1529,6 +1530,8 @@
    tree->column_to_resize = NULL;
    tree->resize_pointer_shown = ETK_FALSE;
    tree->headers_visible = ETK_TRUE;
+   tree->last_sorted_col = NULL;
+   tree->last_sorted_ascendant = ETK_FALSE;
 
    tree->root.tree = tree;
    tree->root.parent = NULL;
@@ -1701,7 +1704,6 @@
    tree_col->clip = NULL;
    tree_col->separator = NULL;
    tree_col->sort.compare_cb = NULL;
-   tree_col->sort.ascendant = ETK_TRUE;
    tree_col->sort.data = NULL;      
 }
 
@@ -2183,8 +2185,13 @@
       col->tree->column_to_resize = NULL;
    else
    {
-      if(col->sort.compare_cb)
-       etk_tree_sort(col->tree, col->sort.compare_cb, col->sort.ascendant, 
col, col->sort.data);
+      if (col->sort.compare_cb)
+      {
+         if (col->tree->last_sorted_col == col)
+            etk_tree_sort(col->tree, col->sort.compare_cb, 
!col->tree->last_sorted_ascendant, col, col->sort.data);
+         else
+            etk_tree_sort(col->tree, col->sort.compare_cb, ETK_TRUE, col, 
col->sort.data);
+      }
    }
 }
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_tree.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- etk_tree.h  27 Feb 2006 02:28:18 -0000      1.19
+++ etk_tree.h  12 Mar 2006 12:13:02 -0000      1.20
@@ -85,7 +85,10 @@
    
    Etk_Tree_Row root;
    Etk_Tree_Row *last_selected;
-   int           num_selected_rows;
+   int num_selected_rows;
+   
+   Etk_Tree_Col *last_sorted_col;
+   Etk_Bool last_sorted_ascendant;
 
    Evas_Object *headers_clip;
    Evas_List *rows_widgets;
@@ -136,58 +139,58 @@
 
    Etk_Widget *header;
    
-   struct {
+   struct
+   {
       int (*compare_cb)(Etk_Tree *tree, Etk_Tree_Row *row1, Etk_Tree_Row 
*row2, Etk_Tree_Col *col, void *data);
-      Etk_Bool ascendant;
       void *data;
    } sort;
 };
 
-Etk_Type   *etk_tree_type_get();
+Etk_Type *etk_tree_type_get();
 Etk_Widget *etk_tree_new();
 
-void          etk_tree_mode_set(Etk_Tree *tree, Etk_Tree_Mode mode);
+void etk_tree_mode_set(Etk_Tree *tree, Etk_Tree_Mode mode);
 Etk_Tree_Mode etk_tree_mode_get(Etk_Tree *tree);
 
-Etk_Type     *etk_tree_col_type_get();
+Etk_Type *etk_tree_col_type_get();
 Etk_Tree_Col *etk_tree_col_new(Etk_Tree *tree, const char *title, 
Etk_Tree_Model *model, int width);
 
-int           etk_tree_num_cols_get(Etk_Tree *tree);
+int etk_tree_num_cols_get(Etk_Tree *tree);
 Etk_Tree_Col *etk_tree_nth_col_get(Etk_Tree *tree, int nth);
-void          etk_tree_headers_visible_set(Etk_Tree *tree, Etk_Bool 
headers_visible);
-Etk_Bool      etk_tree_headers_visible_get(Etk_Tree *tree);
+void etk_tree_headers_visible_set(Etk_Tree *tree, Etk_Bool headers_visible);
+Etk_Bool etk_tree_headers_visible_get(Etk_Tree *tree);
 
-void        etk_tree_col_title_set(Etk_Tree_Col *col, const char *title);
+void etk_tree_col_title_set(Etk_Tree_Col *col, const char *title);
 const char *etk_tree_col_title_get(Etk_Tree_Col *col);
-void        etk_tree_col_width_set(Etk_Tree_Col *col, int width);
-int         etk_tree_col_width_get(Etk_Tree_Col *col);
-void        etk_tree_col_min_width_set(Etk_Tree_Col *col, int min_width);
-int         etk_tree_col_min_width_get(Etk_Tree_Col *col);
-void        etk_tree_col_resizable_set(Etk_Tree_Col *col, Etk_Bool resizable);
-Etk_Bool    etk_tree_col_resizable_get(Etk_Tree_Col *col);
-void        etk_tree_col_expand_set(Etk_Tree_Col *col, Etk_Bool expand);
-Etk_Bool    etk_tree_col_expand_get(Etk_Tree_Col *col);
-void        etk_tree_col_visible_set(Etk_Tree_Col *col, Etk_Bool visible);
-Etk_Bool    etk_tree_col_visible_get(Etk_Tree_Col *col);
-void        etk_tree_col_reorder(Etk_Tree_Col *col, int new_place);
-int         etk_tree_col_place_get(Etk_Tree_Col *col);
-void        etk_tree_col_sort_func_set(Etk_Tree_Col *col, int 
(*compare_cb)(Etk_Tree *tree, Etk_Tree_Row *row1, Etk_Tree_Row *row2, 
Etk_Tree_Col *col, void *data), Etk_Bool ascendant, void *data);
+void etk_tree_col_width_set(Etk_Tree_Col *col, int width);
+int etk_tree_col_width_get(Etk_Tree_Col *col);
+void etk_tree_col_min_width_set(Etk_Tree_Col *col, int min_width);
+int etk_tree_col_min_width_get(Etk_Tree_Col *col);
+void etk_tree_col_resizable_set(Etk_Tree_Col *col, Etk_Bool resizable);
+Etk_Bool etk_tree_col_resizable_get(Etk_Tree_Col *col);
+void etk_tree_col_expand_set(Etk_Tree_Col *col, Etk_Bool expand);
+Etk_Bool etk_tree_col_expand_get(Etk_Tree_Col *col);
+void etk_tree_col_visible_set(Etk_Tree_Col *col, Etk_Bool visible);
+Etk_Bool etk_tree_col_visible_get(Etk_Tree_Col *col);
+void etk_tree_col_reorder(Etk_Tree_Col *col, int new_place);
+int etk_tree_col_place_get(Etk_Tree_Col *col);
+void etk_tree_col_sort_func_set(Etk_Tree_Col *col, int (*compare_cb)(Etk_Tree 
*tree, Etk_Tree_Row *row1, Etk_Tree_Row *row2, Etk_Tree_Col *col, void *data), 
void *data);
 
 void etk_tree_build(Etk_Tree *tree);
 void etk_tree_freeze(Etk_Tree *tree);
 void etk_tree_thaw(Etk_Tree *tree);
 
-void     etk_tree_row_height_set(Etk_Tree *tree, int row_height);
-int      etk_tree_row_height_get(Etk_Tree *tree);
-void     etk_tree_multiple_select_set(Etk_Tree *tree, Etk_Bool 
multiple_select);
+void etk_tree_row_height_set(Etk_Tree *tree, int row_height);
+int etk_tree_row_height_get(Etk_Tree *tree);
+void etk_tree_multiple_select_set(Etk_Tree *tree, Etk_Bool multiple_select);
 Etk_Bool etk_tree_multiple_select_get(Etk_Tree *tree);
-void     etk_tree_select_all(Etk_Tree *tree);
-void     etk_tree_unselect_all(Etk_Tree *tree);
+void etk_tree_select_all(Etk_Tree *tree);
+void etk_tree_unselect_all(Etk_Tree *tree);
 
 Etk_Tree_Row *etk_tree_append(Etk_Tree *tree, ...);
 Etk_Tree_Row *etk_tree_append_to_row(Etk_Tree_Row *row, ...);
-void          etk_tree_row_del(Etk_Tree_Row *row);
-void          etk_tree_clear(Etk_Tree *tree);
+void etk_tree_row_del(Etk_Tree_Row *row);
+void etk_tree_clear(Etk_Tree *tree);
 
 void etk_tree_sort(Etk_Tree *tree, int (*compare_cb)(Etk_Tree *tree, 
Etk_Tree_Row *row1, Etk_Tree_Row *row2, Etk_Tree_Col *col, void *data), 
Etk_Bool ascendant, Etk_Tree_Col *col, void *data);
 
@@ -198,19 +201,19 @@
 Etk_Tree_Row *etk_tree_prev_row_get(Etk_Tree_Row *row, Etk_Bool 
walking_through_hierarchy, Etk_Bool include_collapsed_children);
 Etk_Tree_Row *etk_tree_next_row_get(Etk_Tree_Row *row, Etk_Bool 
walking_through_hierarchy, Etk_Bool include_collapsed_children);
 
-void  etk_tree_row_fields_set(Etk_Tree_Row *row, ...);
-void  etk_tree_row_fields_set_valist(Etk_Tree_Row *row, va_list args);
-void  etk_tree_row_fields_get(Etk_Tree_Row *row, ...);
-void  etk_tree_row_fields_get_valist(Etk_Tree_Row *row, va_list args);
-void  etk_tree_row_data_set(Etk_Tree_Row *row, void *data);
-void  etk_tree_row_data_set_full(Etk_Tree_Row *row, void *data, void 
(*free_cb)(void *data));
+void etk_tree_row_fields_set(Etk_Tree_Row *row, ...);
+void etk_tree_row_fields_set_valist(Etk_Tree_Row *row, va_list args);
+void etk_tree_row_fields_get(Etk_Tree_Row *row, ...);
+void etk_tree_row_fields_get_valist(Etk_Tree_Row *row, va_list args);
+void etk_tree_row_data_set(Etk_Tree_Row *row, void *data);
+void etk_tree_row_data_set_full(Etk_Tree_Row *row, void *data, void 
(*free_cb)(void *data));
 void *etk_tree_row_data_get(Etk_Tree_Row *row);
 
-void          etk_tree_row_scroll_to(Etk_Tree_Row *row, Etk_Bool 
center_the_row);
-void          etk_tree_row_select(Etk_Tree_Row *row);
-void          etk_tree_row_unselect(Etk_Tree_Row *row);
+void etk_tree_row_scroll_to(Etk_Tree_Row *row, Etk_Bool center_the_row);
+void etk_tree_row_select(Etk_Tree_Row *row);
+void etk_tree_row_unselect(Etk_Tree_Row *row);
 Etk_Tree_Row *etk_tree_selected_row_get(Etk_Tree *tree);
-Evas_List    *etk_tree_selected_rows_get(Etk_Tree *tree);
+Evas_List *etk_tree_selected_rows_get(Etk_Tree *tree);
 
 void etk_tree_row_expand(Etk_Tree_Row *row);
 void etk_tree_row_collapse(Etk_Tree_Row *row);
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_types.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -3 -r1.33 -r1.34
--- etk_types.h 4 Mar 2006 23:29:47 -0000       1.33
+++ etk_types.h 12 Mar 2006 12:13:02 -0000      1.34
@@ -103,6 +103,7 @@
 typedef struct _Etk_Menu_Item_Check Etk_Menu_Item_Check;
 typedef struct _Etk_Menu_Item_Radio Etk_Menu_Item_Radio;
 typedef struct _Etk_Combobox Etk_Combobox;
+typedef struct _Etk_Combobox_Column Etk_Combobox_Column;
 typedef struct _Etk_Combobox_Item Etk_Combobox_Item;
 typedef struct _Etk_Statusbar Etk_Statusbar;
 typedef struct _Etk_Filechooser_Widget Etk_Filechooser_Widget;
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_window.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -3 -r1.17 -r1.18
--- etk_window.c        8 Mar 2006 22:12:56 -0000       1.17
+++ etk_window.c        12 Mar 2006 12:13:02 -0000      1.18
@@ -172,7 +172,9 @@
       return;
    
    ecore_evas_size_min_get(window->ecore_evas, &min_w, &min_h);
-   ecore_evas_resize(window->ecore_evas, ETK_MAX(w, min_w), ETK_MAX(h, min_h));
+   window->width = ETK_MAX(w, min_w);
+   window->height = ETK_MAX(h, min_h);
+   ecore_evas_resize(window->ecore_evas, window->width, window->height);
 }
 
 /**
@@ -187,7 +189,12 @@
 {
    if (!window)
       return;
-   ecore_evas_geometry_get(window->ecore_evas, x, y, w, h);
+   
+   ecore_evas_geometry_get(window->ecore_evas, x, y, NULL, NULL);
+   if (w)
+      *w = window->width;
+   if (h)
+      *h = window->height;
 }
 
 /**
@@ -207,20 +214,32 @@
    {
       window_to_center->center = ETK_TRUE;
       window_to_center->center_on_window = window;
-      /* TODO: what if "window" is destroyed meanwhile ?? */
-      /*if (window)
-         etk_object_weak_pointer_add(ETK_OBJECT(window), 
&window_to_center->center_window);*/
+      if (window)
+         etk_object_weak_pointer_add(ETK_OBJECT(window), (void 
**)(&window_to_center->center_on_window));
    }
    else
    {
-      /* TODO: what if window->wait_size_request == TRUE ?? */
       if (window)
-         ecore_evas_geometry_get(window->ecore_evas, &x, &y, &w, &h);
+      {
+         etk_window_geometry_get(window, &x, &y, &w, &h);
+         if (window->wait_size_request)
+         {
+            Etk_Size size_requisition;
+            
+            etk_widget_size_request(ETK_WIDGET(window), &size_requisition);
+            w = size_requisition.w;
+            h = size_requisition.h;
+         }
+      }
       else
-         /* TODO: will it work with multiscreen? */
-         ecore_x_window_geometry_get(ecore_x_window_root_first_get(), &x, &y, 
&w, &h);
+      {
+         Ecore_X_Window root;
+         
+         for (root = window_to_center->x_window; 
ecore_x_window_parent_get(root) != 0; root = ecore_x_window_parent_get(root));
+         ecore_x_window_geometry_get(root, &x, &y, &w, &h);
+      }
       
-      ecore_evas_geometry_get(window_to_center->ecore_evas, NULL, NULL, &cw, 
&ch);
+      etk_window_geometry_get(window_to_center, NULL, NULL, &cw, &ch);
       ecore_evas_move(window_to_center->ecore_evas, x + (w - cw) / 2, y + (h - 
ch) / 2);
    }
 }
@@ -232,12 +251,13 @@
 void etk_window_move_to_mouse(Etk_Window *window)
 {
    int x, y;
+   Ecore_X_Window root;
    
    if (!window)
       return;
    
-   /* TODO: will it work with multiscreen? */
-   ecore_x_pointer_xy_get(ecore_x_window_root_first_get(), &x, &y);
+   for (root = window->x_window; ecore_x_window_parent_get(root) != 0; root = 
ecore_x_window_parent_get(root));
+   ecore_x_pointer_xy_get(root, &x, &y);
    etk_window_move(window, x, y);
 }
 
@@ -420,28 +440,6 @@
 }
 
 /**
- * @brief Raises the window
- * @param window a window
- */
-void etk_window_raise(Etk_Window *window)
-{
-   if (!window)
-      return;
-   ecore_evas_raise(window->ecore_evas);
-}
-
-/**
- * @brief Lowers the window
- * @param window a window
- */
-void etk_window_lower(Etk_Window *window)
-{
-   if (!window)
-      return;
-   ecore_evas_lower(window->ecore_evas);
-}
-
-/**
  * @brief Sets wheter the window is decorated
  * @param window a window
  * @param decorated if @a decorated is ETK_FALSE, the border of the window 
will be hidden
@@ -663,6 +661,8 @@
 
    window->ecore_evas = ecore_evas_software_x11_new(0, 0, 0, 0, 0, 0);
    window->x_window = ecore_evas_software_x11_window_get(window->ecore_evas);
+   window->width = 0;
+   window->height = 0; 
    window->wait_size_request = ETK_TRUE;
    window->center = ETK_FALSE;
    window->center_on_window = NULL;
@@ -693,7 +693,10 @@
 {
    if (!window)
       return;
+   
    ecore_evas_free(window->ecore_evas);
+   if (window->center_on_window)
+      etk_object_weak_pointer_remove(ETK_OBJECT(window->center_on_window), 
(void **)(&window->center_on_window));
 }
 
 /* Sets the property whose id is "property_id" to the value "value" */
@@ -824,8 +827,10 @@
 
    if (!(window = ETK_WINDOW(ecore_evas_data_get(ecore_evas, "etk_window"))))
       return;
+   
+   ecore_evas_geometry_get(ecore_evas, NULL, NULL, &window->width, 
&window->height);
    etk_signal_emit(_etk_window_signals[ETK_WINDOW_RESIZE_SIGNAL], 
ETK_OBJECT(window), NULL);
-   etk_widget_redraw_queue(ETK_WIDGET(window));      
+   etk_widget_redraw_queue(ETK_WIDGET(window));
 }
 
 /* Called when the window is focused in */
@@ -877,14 +882,15 @@
 /* Called when a size request signal is emitted */
 static void _etk_window_size_request_cb(Etk_Window *window, Etk_Size 
*requisition, void *data)
 {
-   int w, h;
-
    if (window && requisition && requisition->w >= 0 && requisition->h >= 0)
    {
-      ecore_evas_geometry_get(window->ecore_evas, NULL, NULL, &w, &h);
-      if (w < requisition->w || h < requisition->h)
-         ecore_evas_resize(window->ecore_evas, ETK_MAX(w, requisition->w), 
ETK_MAX(h, requisition->h));
       ecore_evas_size_min_set(window->ecore_evas, requisition->w, 
requisition->h);
+      if (window->width < requisition->w || window->height < requisition->h)
+      {
+         window->width = ETK_MAX(window->width, requisition->w);
+         window->height = ETK_MAX(window->height, requisition->h);
+         ecore_evas_resize(window->ecore_evas, window->width, window->height);
+      }
       
       if (window->wait_size_request)
       {
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_window.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- etk_window.h        8 Mar 2006 22:12:56 -0000       1.8
+++ etk_window.h        12 Mar 2006 12:13:02 -0000      1.9
@@ -32,6 +32,9 @@
    Ecore_Evas *ecore_evas;
    Ecore_X_Window x_window;
    
+   int width;
+   int height;
+   
    Etk_Bool (*delete_event)(Etk_Window *window);
    Etk_Bool wait_size_request;
    Etk_Bool center;
@@ -71,9 +74,6 @@
 void etk_window_unfocus(Etk_Window *window);
 Etk_Bool etk_window_is_focused(Etk_Window *window);
 
-void etk_window_raise(Etk_Window *window);
-void etk_window_lower(Etk_Window *window);
-
 void etk_window_decorated_set(Etk_Window *window, Etk_Bool decorated);
 Etk_Bool etk_window_decorated_get(Etk_Window *window);
 void etk_window_shaped_set(Etk_Window *window, Etk_Bool shaped);




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to