Enlightenment CVS committal

Author  : moom16
Project : e17
Module  : proto

Dir     : e17/proto/etk/src/lib


Modified Files:
        etk_dnd.c etk_dnd.h etk_main.c etk_main.h etk_widget.c 
        etk_widget.h etk_window.c etk_window.h 


Log Message:
* Clean and fix some bugs of the dnd code
* API change: xdnd-->dnd to make it more portable


===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_dnd.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- etk_dnd.c   10 Feb 2006 00:59:08 -0000      1.2
+++ etk_dnd.c   11 Feb 2006 10:27:14 -0000      1.3
@@ -1,25 +1,14 @@
 /** @file etk_dnd.c */
 #include "etk_dnd.h"
-#include <locale.h>
-#include <string.h>
 #include <stdlib.h>
+#include <string.h>
 #include <Ecore.h>
 #include <Ecore_X.h>
-#include <Ecore_Job.h>
-#include <Ecore_Evas.h>
-#include <Evas.h>
-#include <Edje.h>
-#include "etk_type.h"
-#include "etk_signal.h"
-#include "etk_object.h"
-#include "etk_toplevel_widget.h"
-#include "etk_utils.h"
-#include "etk_theme.h"
+#include "etk_main.h"
+#include "etk_widget.h"
 #include "etk_window.h"
 #include "config.h"
 
-#if HAVE_ECORE_X
-
 /* Some notes for when we're developing this:
  * Signals:
  * - source:
@@ -33,107 +22,119 @@
  * 
  */
 
-extern Evas_List *_etk_main_toplevel_widgets;
+#define ETK_DND_INSIDE(x, y, xx, yy, ww, hh) (((x) < ((xx) + (ww))) && ((y) < 
((yy) + (hh))) && ((x) >= (xx)) && ((y) >= (yy)))
 
 static Etk_Widget *_etk_dnd_widget = NULL;
 static Etk_Widget *_etk_selection_widget = NULL;
-Evas_List  *_etk_dnd_widgets = NULL;
-Evas_List  *_etk_dnd_handlers = NULL;
-
-#define E_INSIDE(x, y, xx, yy, ww, hh) (((x) < ((xx) + (ww))) && ((y) < ((yy) 
+ (hh))) && ((x) >= (xx)) && ((y) >= (yy)))
+static Evas_List  *_etk_dnd_handlers = NULL;
 
+#if HAVE_ECORE_X
 static void _etk_xdnd_container_get_widgets_at(Etk_Toplevel_Widget *top, int 
x, int y, int offx, int offy, Evas_List **list);
-static int  _etk_xdnd_enter_handler(void *data, int type, void *event);
-static int  _etk_xdnd_position_handler(void *data, int type, void *event);
-static int  _etk_xdnd_drop_handler(void *data, int type, void *event);
-static int  _etk_xdnd_leave_handler(void *data, int type, void *event);
-static int  _etk_xdnd_selection_handler(void *data, int type, void *event);
-           
-int etk_dnd_init()
+static int _etk_xdnd_enter_handler(void *data, int type, void *event);
+static int _etk_xdnd_position_handler(void *data, int type, void *event);
+static int _etk_xdnd_drop_handler(void *data, int type, void *event);
+static int _etk_xdnd_leave_handler(void *data, int type, void *event);
+static int _etk_xdnd_selection_handler(void *data, int type, void *event);
+#endif
+
+/**************************
+ *
+ * Implementation
+ *
+ **************************/
+ 
+/**
+ * @brief Inits the drag and drop system
+ * @return Returns ETK_TRUE on success, ETK_FALSE on failure
+ */
+Etk_Bool etk_dnd_init()
 {
-   if(!ecore_x_init(NULL))
-     return 0;
+   if (_etk_dnd_handlers)
+      return ETK_TRUE;
    
-   _etk_dnd_handlers = evas_list_append(_etk_dnd_handlers,
-    ecore_event_handler_add(ECORE_X_EVENT_XDND_ENTER, 
-                           _etk_xdnd_enter_handler, NULL));
-                                       
-   _etk_dnd_handlers = evas_list_append(_etk_dnd_handlers,
-    ecore_event_handler_add(ECORE_X_EVENT_XDND_POSITION, 
-                           _etk_xdnd_position_handler, NULL));
-   
-   _etk_dnd_handlers = evas_list_append(_etk_dnd_handlers,
-    ecore_event_handler_add(ECORE_X_EVENT_XDND_DROP, 
-                           _etk_xdnd_drop_handler, NULL));
-   
-   _etk_dnd_handlers = evas_list_append(_etk_dnd_handlers,
-    ecore_event_handler_add(ECORE_X_EVENT_XDND_LEAVE, 
-                           _etk_xdnd_leave_handler, NULL));
-   
-   _etk_dnd_handlers = evas_list_append(_etk_dnd_handlers,
-    ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, 
-                           _etk_xdnd_selection_handler, NULL));
+#if HAVE_ECORE_X
+   _etk_dnd_handlers = evas_list_append(_etk_dnd_handlers, 
ecore_event_handler_add(ECORE_X_EVENT_XDND_ENTER, _etk_xdnd_enter_handler, 
NULL));
+   _etk_dnd_handlers = evas_list_append(_etk_dnd_handlers, 
ecore_event_handler_add(ECORE_X_EVENT_XDND_POSITION, 
_etk_xdnd_position_handler, NULL));
+   _etk_dnd_handlers = evas_list_append(_etk_dnd_handlers, 
ecore_event_handler_add(ECORE_X_EVENT_XDND_DROP, _etk_xdnd_drop_handler, NULL));
+   _etk_dnd_handlers = evas_list_append(_etk_dnd_handlers, 
ecore_event_handler_add(ECORE_X_EVENT_XDND_LEAVE, _etk_xdnd_leave_handler, 
NULL));
+   _etk_dnd_handlers = evas_list_append(_etk_dnd_handlers, 
ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, 
_etk_xdnd_selection_handler, NULL));
+#endif
    
    return 1;
 }
 
-int etk_dnd_shutdown()
+/**
+ * @brief Shutdowns the drag and drop system
+ */
+void etk_dnd_shutdown()
 {
-   while(_etk_dnd_handlers)
-     {
-       ecore_event_handler_del(_etk_dnd_handlers->data);
-       _etk_dnd_handlers = evas_list_remove(_etk_dnd_handlers, 
-                                            _etk_dnd_handlers->data);
-     }
-   
-   return ecore_x_shutdown();
+#if HAVE_ECORE_X
+   while (_etk_dnd_handlers)
+   {
+      ecore_event_handler_del(_etk_dnd_handlers->data);
+      _etk_dnd_handlers = evas_list_remove(_etk_dnd_handlers, 
_etk_dnd_handlers->data);
+   }
 }
 
+/* TODO: doc */
 void etk_selection_text_request(Etk_Widget *widget)
 {
+#if HAVE_ECORE_X
    Ecore_X_Window win;
    
-   if(!ETK_IS_WINDOW(widget->toplevel_parent))
+   if (!widget || !ETK_IS_WINDOW(widget->toplevel_parent))
      return;
    
    win = ETK_WINDOW(widget->toplevel_parent)->x_window;
    _etk_selection_widget = widget;
    ecore_x_selection_clipboard_request(win, 
ECORE_X_SELECTION_TARGET_UTF8_STRING);
+#endif
 }
 
-void etk_selection_text_set(Etk_Widget *widget, char *data)
+/* TODO: doc */
+void etk_selection_text_set(Etk_Widget *widget, const char *data)
 {
+#if HAVE_ECORE_X
    Ecore_X_Window win;
    
-   if(!ETK_IS_WINDOW(widget->toplevel_parent))
-     return;
+   if (!widget || !ETK_IS_WINDOW(widget->toplevel_parent) || !data)
+      return;
    
    win = ETK_WINDOW(widget->toplevel_parent)->x_window;
-
-   ecore_x_selection_clipboard_set(win, data, strlen(data) + 1);
+   ecore_x_selection_clipboard_set(win, (char *)data, strlen(data) + 1);
+#endif
 }
 
+/**************************
+ *
+ * Private functions
+ *
+ **************************/
+
+#if HAVE_ECORE_X
 /* Search the container recursively for the widget that accepts xdnd */
 static void _etk_xdnd_container_get_widgets_at(Etk_Toplevel_Widget *top, int 
x, int y, int offx, int offy, Evas_List **list)
 {
    Evas_List *l;
-     
-   for(l = _etk_dnd_widgets; l; l = l->next)
-     {
-       Etk_Widget *widget;
-       
-       if(!(widget = ETK_WIDGET(l->data)))
-         continue;
-       
-       if(E_INSIDE(x, y, 
-                   widget->inner_geometry.x + offx,
-                   widget->inner_geometry.y + offy,
-                   widget->inner_geometry.w, 
-                   widget->inner_geometry.h))    
-         *list = evas_list_append(*list, widget);        
-     }   
+   int wx, wy, ww, wh;
+   
+   if (!top || !list)
+      return;
+   
+   for (l = etk_widget_dnd_aware_widgets_get(); l; l = l->next)
+   {
+      Etk_Widget *widget;
+      
+      if (!(widget = ETK_WIDGET(l->data)) || 
etk_widget_toplevel_parent_get(widget) != top)
+         continue;
+      
+      etk_widget_geometry_get(widget, &wx, &wy, &ww, &wh);
+      if (ETK_DND_INSIDE(x, y, wx + offx, wy + offy, ww, wh))
+        *list = evas_list_append(*list, widget);
+   }
 }
 
+/* TODO: doc */
 static int _etk_xdnd_enter_handler(void *data, int type, void *event)
 {
    Ecore_X_Event_Xdnd_Enter *ev;
@@ -142,12 +143,13 @@
    ev = event;
    
 //   printf("enter window!\n");
-//     for (i = 0; i < ev->num_types; i++)
-//       printf("type: %s\n", ev->types[i]);   
+//   for (i = 0; i < ev->num_types; i++)
+//      printf("type: %s\n", ev->types[i]);
    
    return 1;
 }
 
+/* TODO: doc */
 static int _etk_xdnd_position_handler(void *data, int type, void *event)
 {
    Ecore_X_Event_Xdnd_Position *ev;
@@ -156,82 +158,86 @@
    Evas_List *children = NULL;
    Etk_Widget *widget;
    int x = 0, y = 0;
+   int wx, wy, ww, wh;
    
    ev = event;
 
    //printf("position!\n");
    
    /* loop top level widgets (windows) */
-   for(l = _etk_main_toplevel_widgets; l; l = l->next)
-     {   
-       if (!(window = ETK_WINDOW(l->data)))
-         continue;
-       
-       /* if this isnt the active window, dont waste time */
-       if(ev->win != window->x_window)
-         continue;       
+   for (l = etk_main_toplevel_widgets_get(); l; l = l->next)
+   {
+      if (!ETK_IS_WINDOW(l->data))
+         continue;
+      window = ETK_WINDOW(l->data);
+       
+      /* if this isnt the active window, dont waste time */
+      if (ev->win != window->x_window)
+         continue;       
        
-       ecore_evas_geometry_get(window->ecore_evas, &x, &y, NULL, NULL);
+      ecore_evas_geometry_get(window->ecore_evas, &x, &y, NULL, NULL);
 
-       /* find the widget we want to drop on */
-       _etk_xdnd_container_get_widgets_at(ETK_TOPLEVEL_WIDGET(window), 
ev->position.x, ev->position.y, x, y, &children);
-       
-       /* check if we're leaving a widget */
-       if(_etk_dnd_widget)
-         {
-            if(!E_INSIDE(ev->position.x, ev->position.y, 
-                         _etk_dnd_widget->geometry.x + x, 
_etk_dnd_widget->geometry.y + y,
-                         _etk_dnd_widget->geometry.w, 
_etk_dnd_widget->geometry.h))
-              {
-                 etk_widget_drag_leave(_etk_dnd_widget);
-                 _etk_dnd_widget = NULL;
-              }
-         }     
-       
-       break;
-     }   
+      /* find the widget we want to drop on */
+      _etk_xdnd_container_get_widgets_at(ETK_TOPLEVEL_WIDGET(window), 
ev->position.x, ev->position.y, x, y, &children);
+      
+      /* check if we're leaving a widget */
+      if (_etk_dnd_widget)
+      {
+         etk_widget_geometry_get(_etk_dnd_widget, &wx, &wy, &ww, &wh);
+         if (!ETK_DND_INSIDE(ev->position.x, ev->position.y, wx + x, wy + y, 
ww, wh))
+         {
+            etk_widget_drag_leave(_etk_dnd_widget);
+            _etk_dnd_widget = NULL;
+         }
+      }
+      
+      break;
+   }
    
    /* if we found a widget, emit signals */
-   if(children != NULL)
-     { 
-       Ecore_X_Rectangle rect;
-       
-       widget = (evas_list_last(children))->data;
-       _etk_dnd_widget = widget;
-       /* TODO: filter types according to what widget wants */
-       rect.x = widget->inner_geometry.x;
-       rect.y = widget->inner_geometry.y;
-       rect.width = widget->inner_geometry.w;
-       rect.height = widget->inner_geometry.h; 
-       ecore_x_dnd_send_status(1, 1, rect, ECORE_X_DND_ACTION_PRIVATE);
-       
-       etk_widget_drag_motion(widget);
-     }
+   if (children != NULL)
+   {   
+      Ecore_X_Rectangle rect;
+      
+      widget = (evas_list_last(children))->data;
+      etk_widget_geometry_get(widget, &wx, &wy, &ww, &wh);
+      _etk_dnd_widget = widget;
+      /* TODO: filter types according to what widget wants */
+      rect.x = wx;
+      rect.y = wy;
+      rect.width = ww;
+      rect.height = wh;        
+      ecore_x_dnd_send_status(1, 1, rect, ECORE_X_DND_ACTION_PRIVATE);
+      
+      etk_widget_drag_motion(widget);
+   }
    else
-     {
-       /* tell the source we wont accept it here */
-       Ecore_X_Rectangle rect;
-       
-       rect.x = 0;
-       rect.y = 0;
-       rect.width = 0;
-       rect.height = 0;
-       ecore_x_dnd_send_status(0, 1, rect, ECORE_X_DND_ACTION_PRIVATE);
-     }
+   {
+      /* tell the source we wont accept it here */
+      Ecore_X_Rectangle rect;
+      
+      rect.x = 0;
+      rect.y = 0;
+      rect.width = 0;
+      rect.height = 0;
+      ecore_x_dnd_send_status(0, 1, rect, ECORE_X_DND_ACTION_PRIVATE);
+   }
    return 1;
 }
 
+/* TODO: doc */
 static int _etk_xdnd_drop_handler(void *data, int type, void *event)
 {
    Ecore_X_Event_Xdnd_Drop *ev;
    
    //printf("drop\n");
    ev = event;
-      
+   
    ecore_x_selection_xdnd_request(ev->win, "text/uri-list");
    return 1;
 }
 
+/* TODO: doc */
 static int _etk_xdnd_leave_handler(void *data, int type, void *event)
 {
    //printf("leave window\n");
@@ -239,6 +245,7 @@
    return 1;
 }
 
+/* TODO: doc */
 static int _etk_xdnd_selection_handler(void *data, int type, void *event)
 {
    Ecore_X_Event_Selection_Notify *ev;
@@ -251,97 +258,96 @@
    //printf("selection\n"); 
    ev = event;
    switch (ev->selection) 
-     {
+   {
       case ECORE_X_SELECTION_PRIMARY:
-       if (!strcmp(ev->target, ECORE_X_SELECTION_TARGET_TARGETS)) 
-         {
-            /* printf("primary: %s\n", ev->target); */
-            targets = ev->data;
-            /* 
-            for (i = 0; i < targets->num_targets; i++)
+         if (!strcmp(ev->target, ECORE_X_SELECTION_TARGET_TARGETS)) 
+        {
+           /* printf("primary: %s\n", ev->target); */
+           targets = ev->data;
+           /* 
+           for (i = 0; i < targets->num_targets; i++)
               printf("target: %s\n", targets->targets[i]);
-            */
-         } 
-       else 
-         {
-            text = ev->data;
-            /* printf("primary: %s %s\n", ev->target, text->text); */
-         }
-       break;
-       
+           */
+         } 
+        else 
+        {
+           text = ev->data;
+           /* printf("primary: %s %s\n", ev->target, text->text); */
+        }
+        break;
+      
       case ECORE_X_SELECTION_SECONDARY:
-       sel = ev->data;
+         sel = ev->data;
         /* printf("secondary: %s %s\n", ev->target, sel->data); */
-       break;
-       
+         break;
+      
       case ECORE_X_SELECTION_XDND:
         /* printf("xdnd: %s\n", ev->target); */
 
-       files = ev->data;
-       
-       if(!_etk_dnd_widget || files->num_files < 1)
-         break;        
-       
-       /* free old data, should this be done here? */
-       for (i = 0; i < _etk_dnd_widget->xdnd_files_num; i++)
-         {
-            if(_etk_dnd_widget->xdnd_files[i])
-              free(_etk_dnd_widget->xdnd_files[i]);         
-         }
-       
-       if(_etk_dnd_widget->xdnd_files)
-         free(_etk_dnd_widget->xdnd_files);        
+        files = ev->data;
        
-       _etk_dnd_widget->xdnd_files = calloc(files->num_files, sizeof(char*));
-               
-       /* printf("num_files: %d\n", files->num_files); */
+        if (!_etk_dnd_widget || files->num_files < 1)
+            break;     
        
-       /* Fill in the drop data into the widget */
-       _etk_dnd_widget->xdnd_files_num = files->num_files;
-       for (i = 0; i < files->num_files; i++)
-         {
-            /* printf("file: %s\n", files->files[i]); */
-            _etk_dnd_widget->xdnd_files[i] = strdup(files->files[i]);
-         }
+        /* free old data, should this be done here? */
+        for (i = 0; i < _etk_dnd_widget->dnd_files_num; i++)
+            free(_etk_dnd_widget->dnd_files[i]);
+         free(_etk_dnd_widget->dnd_files);         
+       
+         _etk_dnd_widget->dnd_files = calloc(files->num_files, sizeof(char*));
+         
+         /* printf("num_files: %d\n", files->num_files); */
+       
+         /* Fill in the drop data into the widget */
+         _etk_dnd_widget->dnd_files_num = files->num_files;
+         for (i = 0; i < files->num_files; i++)
+        {
+           /* printf("file: %s\n", files->files[i]); */
+           _etk_dnd_widget->dnd_files[i] = strdup(files->files[i]);
+        }
+       
+         /* emit the drop signal so the widget can react */
+         etk_widget_drag_drop(_etk_dnd_widget);
+         _etk_dnd_widget = NULL;
        
-       /* emit the drop signal so the widget can react */
-       etk_widget_drag_drop(_etk_dnd_widget);
-       _etk_dnd_widget = NULL;
-       
-       ecore_x_dnd_send_finished();
-       break;
+         ecore_x_dnd_send_finished();
+         break;
        
       case ECORE_X_SELECTION_CLIPBOARD:
-       if (!strcmp(ev->target, ECORE_X_SELECTION_TARGET_TARGETS)) 
-         {
-            Etk_Event_Selection_Get event;
-            Etk_Selection_Data_Targets _targets;
-            
-            event.content = ETK_SELECTION_CONTENT_TARGETS;
-
-            targets = ev->data;
-            
-            _targets.num_targets = targets->num_targets;
-            _targets.targets = targets->targets;
-            
-            //printf("clipboard: %s\n", ev->target);
-            //for (i = 0; i < targets->num_targets; i++)
-            //  printf("target: %s\n", targets->targets[i]);
-         } 
-       else 
-         {
-            Etk_Event_Selection_Get event;
-            
-            text = ev->data;
-            //printf("clipboard: %s %s\n", ev->target, text->text);
-            event.data = text->text;
-            event.content = ETK_SELECTION_CONTENT_TEXT;
-            etk_widget_selection_get(_etk_selection_widget, &event);
-         }
-       break;
-     }
+         if (!strcmp(ev->target, ECORE_X_SELECTION_TARGET_TARGETS)) 
+        {
+           Etk_Event_Selection_Get event;
+           Etk_Selection_Data_Targets _targets;
+           
+           event.content = ETK_SELECTION_CONTENT_TARGETS;
+
+           targets = ev->data;
+           
+            _targets.num_targets = targets->num_targets;
+           _targets.targets = targets->targets;
+           
+           //printf("clipboard: %s\n", ev->target);
+           //for (i = 0; i < targets->num_targets; i++)
+           //  printf("target: %s\n", targets->targets[i]);
+         } 
+         else 
+        {
+           Etk_Event_Selection_Get event;
+           
+           text = ev->data;
+           //printf("clipboard: %s %s\n", ev->target, text->text);
+           event.data = text->text;
+           event.content = ETK_SELECTION_CONTENT_TEXT;
+           etk_widget_selection_get(_etk_selection_widget, &event);
+        }
+        break;
+         
+      default:
+         break;
+   }
    
    return 1;
 }
+#endif
 
 #endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_dnd.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- etk_dnd.h   10 Feb 2006 00:59:08 -0000      1.2
+++ etk_dnd.h   11 Feb 2006 10:27:14 -0000      1.3
@@ -2,7 +2,7 @@
 #ifndef _ETK_DND_H_
 #define _ETK_DND_H_
 
-#include "etk_widget.h"
+#include "etk_types.h"
 
 #define ETK_SELECTION_TARGET_TARGETS "TARGETS"
 #define ETK_SELECTION_TARGET_TEXT "TEXT"
@@ -14,8 +14,8 @@
 struct _Etk_Event_Selection_Get
 {   
    void *data;
-   
-   enum {
+   enum
+   {
       ETK_SELECTION_CONTENT_NONE,
       ETK_SELECTION_CONTENT_TEXT,
       ETK_SELECTION_CONTENT_FILES,
@@ -26,14 +26,15 @@
 
 struct _Etk_Selection_Data_Targets
 {
-   char     **targets;
-   int        num_targets;
+   char **targets;
+   int num_targets;
 };
 
-int  etk_dnd_init();  
-int  etk_dnd_shutdown();
+Etk_Bool etk_dnd_init();  
+void etk_dnd_shutdown();
+
 void etk_selection_text_request(Etk_Widget *widget);
-void etk_selection_text_set(Etk_Widget *widget, char *data);
+void etk_selection_text_set(Etk_Widget *widget, const char *data);
   
 /** @} */
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_main.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- etk_main.c  11 Feb 2006 00:28:33 -0000      1.14
+++ etk_main.c  11 Feb 2006 10:27:14 -0000      1.15
@@ -1,6 +1,5 @@
 /** @file etk_main.c */
 #include "etk_main.h"
-#include "etk_dnd.h"
 #include <locale.h>
 #include <Ecore.h>
 #include <Ecore_X.h>
@@ -14,6 +13,7 @@
 #include "etk_toplevel_widget.h"
 #include "etk_utils.h"
 #include "etk_theme.h"
+#include "etk_dnd.h"
 #include "config.h"
 
 /**
@@ -25,9 +25,7 @@
 static void _etk_main_size_request_recursive(Etk_Widget *widget);
 static void _etk_main_size_allocate_recursive(Etk_Widget *widget, Etk_Bool 
is_top_level);
 
-/* we need this in etk_dnd */
-Evas_List *_etk_main_toplevel_widgets = NULL;
-
+static Evas_List *_etk_main_toplevel_widgets = NULL;
 static Etk_Bool _etk_main_running = ETK_FALSE;
 static Etk_Bool _etk_main_initialized = ETK_FALSE;
 static Ecore_Job *_etk_main_iterate_job = NULL;
@@ -62,18 +60,23 @@
       ETK_WARNING("Ecore_Evas initialization failed!");
       return ETK_FALSE;
    }
+#if HAVE_ECORE_X
+   if (!ecore_x_init(NULL))
+   {
+      ETK_WARNING("Ecore_X initialization failed!");
+      return ETK_FALSE;
+   }
+#endif
    if (!edje_init())
    {
       ETK_WARNING("Edje initialization failed!");
       return ETK_FALSE;
    }
-#if HAVE_ECORE_X
    if (!etk_dnd_init())
    {
-      ETK_WARNING("Etk_dnd and Ecore_X initialzation failed!");
+      ETK_WARNING("Etk_dnd initialization failed!");
       return ETK_FALSE;
    }
-#endif
    etk_theme_init();
 
    /* Gettext */
@@ -185,6 +188,15 @@
    _etk_main_toplevel_widgets = evas_list_remove(_etk_main_toplevel_widgets, 
widget);
 }
 
+/**
+ * @brief Gets the list of the created toplevel widgets
+ * @return Returns the list of the created toplevel widgets
+ */
+Evas_List *etk_main_toplevel_widgets_get()
+{
+   return _etk_main_toplevel_widgets;
+}
+
 /**************************
  *
  * Private functions
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_main.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- etk_main.h  1 Oct 2005 16:29:45 -0000       1.1
+++ etk_main.h  11 Feb 2006 10:27:14 -0000      1.2
@@ -2,6 +2,7 @@
 #ifndef _ETK_MAIN_H_
 #define _ETK_MAIN_H_
 
+#include <Evas.h>
 #include "etk_types.h"
 
 /**
@@ -19,6 +20,7 @@
 
 void etk_main_toplevel_widget_add(Etk_Toplevel_Widget *widget);
 void etk_main_toplevel_widget_remove(Etk_Toplevel_Widget *widget);
+Evas_List *etk_main_toplevel_widgets_get();
 
 /** @} */
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_widget.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -3 -r1.23 -r1.24
--- etk_widget.c        11 Feb 2006 00:28:35 -0000      1.23
+++ etk_widget.c        11 Feb 2006 10:27:14 -0000      1.24
@@ -21,8 +21,6 @@
  * @{
  */
 
-extern Evas_List *_etk_dnd_widgets;
-
 typedef struct _Etk_Widget_Member_Object
 {
    Evas_Object *object;
@@ -141,6 +139,7 @@
 static Etk_Bool _etk_widget_propagate_event = ETK_TRUE;
 static Etk_Bool _etk_widget_intercept_show_hide = ETK_TRUE;
 static Evas_Smart *_etk_widget_event_object_smart = NULL;
+static Evas_List *_etk_widget_dnd_widgets;
 
 /**************************
  *
@@ -1398,7 +1397,68 @@
    return widget->clip;
 }
 
-#if HAVE_ECORE_X
+/**
+ * @brief Sets whether the widget is dnd aware or not
+ * @param widget a widget
+ * @param on ETK_TRUE to enable dnd, ETK_FALSE to disable it
+ */
+void etk_widget_dnd_aware_set(Etk_Widget *widget, Etk_Bool on)
+{
+   if (!widget)
+      return;
+   
+   if (on)
+   {
+      widget->accepts_dnd = ETK_TRUE;
+      _etk_widget_dnd_widgets = evas_list_append(_etk_widget_dnd_widgets, 
widget);
+   }
+   else
+   {
+      widget->accepts_dnd = ETK_FALSE;
+      _etk_widget_dnd_widgets = evas_list_remove(_etk_widget_dnd_widgets, 
widget);
+   }
+}
+
+/**
+ * @brief Checks whether the widget is dnd aware
+ * @param widget a widget
+ * @return Returns ETK_TRUE if the widget is dnd aware, ETK_FALSE otherwise
+ */
+Etk_Bool etk_widget_dnd_aware_get(Etk_Widget *widget)
+{
+   if (!widget)
+      return ETK_FALSE;
+   return widget->accepts_dnd;
+}
+
+/**
+ * @brief Gets the list of the files dropped on the widget
+ * @param widget a widget
+ * @param on ETK_TRUE to enable dnd, ETK_FALSE to disable it
+ */
+const char **etk_widget_dnd_files_get(Etk_Widget *widget, int *num_files)
+{
+   if (!widget || !widget->accepts_dnd || !widget->dnd_files)
+   {
+      if (num_files)
+         num_files = 0;
+      return NULL;
+   }
+   
+   if (num_files)
+      *num_files = widget->dnd_files_num;
+   return (const char **)widget->dnd_files;
+}
+
+/**
+ * @brief Gets the list of the dnd-aware widgets
+ * @return Returns the list of the dnd-aware widgets
+ */
+Evas_List *etk_widget_dnd_aware_widgets_get()
+{
+   return _etk_widget_dnd_widgets;
+}
+
 /**
  * @brief Sends the "drag_drop" signal
  * @param widget a widget
@@ -1443,8 +1503,6 @@
    etk_signal_emit(_etk_widget_signals[ETK_WIDGET_SELECTION_GET_SIGNAL], 
ETK_OBJECT(widget), NULL, event);
 }
 
-#endif
-
 /**************************
  *
  * Etk specific functions
@@ -1514,11 +1572,9 @@
    widget->need_redraw = ETK_FALSE;
    widget->need_theme_min_size_recalc = ETK_FALSE;
    widget->swallowed = ETK_FALSE;
-#if HAVE_ECORE_X
-   widget->accepts_xdnd = ETK_FALSE;
-   widget->xdnd_files = NULL;
-   widget->xdnd_files_num = 0;
-#endif
+   widget->accepts_dnd = ETK_FALSE;
+   widget->dnd_files = NULL;
+   widget->dnd_files_num = 0;
 
    etk_signal_connect_full(_etk_widget_signals[ETK_WIDGET_MOUSE_IN_SIGNAL], 
ETK_OBJECT(widget), ETK_CALLBACK(_etk_widget_signal_mouse_in_cb), NULL, 
ETK_FALSE, ETK_FALSE);
    etk_signal_connect_full(_etk_widget_signals[ETK_WIDGET_MOUSE_OUT_SIGNAL], 
ETK_OBJECT(widget), ETK_CALLBACK(_etk_widget_signal_mouse_out_cb), NULL, 
ETK_FALSE, ETK_FALSE);
@@ -1529,6 +1585,8 @@
 /* Destroys the widget */
 static void _etk_widget_destructor(Etk_Widget *widget)
 {
+   int i;
+   
    if (!widget)
       return;
 
@@ -1543,6 +1601,10 @@
       etk_widget_parent_set(widget, NULL);
    }
    
+   for (i = 0; i < widget->dnd_files_num; i++)
+      free(widget->dnd_files[i]);
+   free(widget->dnd_files);
+   
    free(widget->theme_file);
    free(widget->theme_group);
 }
@@ -2012,40 +2074,6 @@
       _etk_widget_key_up_cb(widget->parent, evas, NULL, event_info);
 }
 
-#if HAVE_ECORE_X
-void etk_widget_xdnd_set(Etk_Widget *widget, Etk_Bool on)
-{
-   if(on)
-     {
-       widget->accepts_xdnd = 1;
-       _etk_dnd_widgets = evas_list_append(_etk_dnd_widgets, widget);
-     }
-   else
-     {
-       widget->accepts_xdnd = 0;
-       _etk_dnd_widgets = evas_list_remove(_etk_dnd_widgets, widget);
-     }
-}
-
-Etk_Bool etk_widget_xdnd_get(Etk_Widget *widget)
-{
-   if(widget->accepts_xdnd) return ETK_TRUE;
-
-   return ETK_FALSE;
-}
-
-const char **etk_widget_xdnd_files_get(Etk_Widget *widget, int *num_files)
-{
-   if(!widget->accepts_xdnd || widget->xdnd_files == NULL)
-     return NULL;
-   
-   if(num_files)
-     *num_files = widget->xdnd_files_num;
-     
-   return (const char **)widget->xdnd_files;
-}
-#endif
-
 /**************************
  *
  * Private functions
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_widget.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- etk_widget.h        11 Feb 2006 00:28:35 -0000      1.16
+++ etk_widget.h        11 Feb 2006 10:27:14 -0000      1.17
@@ -189,12 +189,10 @@
    unsigned char need_size_recalc : 1;
    unsigned char need_redraw : 1;
    unsigned char need_theme_min_size_recalc : 1;
-//#if HAVE_ECORE_X   
-   unsigned char accepts_xdnd : 1;   
+   unsigned char accepts_dnd : 1;
    
-   char **xdnd_files;
-   int    xdnd_files_num;
-//#endif
+   char **dnd_files;
+   int dnd_files_num;
 };
 
 Etk_Type *etk_widget_type_get();
@@ -268,16 +266,16 @@
 void etk_widget_clip_unset(Etk_Widget *widget);
 Evas_Object *etk_widget_clip_get(Etk_Widget *widget);
 
-//#if HAVE_ECORE_X
-void          etk_widget_xdnd_set(Etk_Widget *widget, Etk_Bool on);
-Etk_Bool      etk_widget_xdnd_get(Etk_Widget *widget);
-const char  **etk_widget_xdnd_files_get(Etk_Widget *e, int *num_files);
-void          etk_widget_drag_drop(Etk_Widget *widget);
-void          etk_widget_drag_motion(Etk_Widget *widget);
-void          etk_widget_drag_leave(Etk_Widget *widget);
+void etk_widget_dnd_aware_set(Etk_Widget *widget, Etk_Bool on);
+Etk_Bool etk_widget_dnd_aware_get(Etk_Widget *widget);
+Evas_List *etk_widget_dnd_aware_widgets_get();
+const char **etk_widget_dnd_files_get(Etk_Widget *e, int *num_files);
+
+void etk_widget_drag_drop(Etk_Widget *widget);
+void etk_widget_drag_motion(Etk_Widget *widget);
+void etk_widget_drag_leave(Etk_Widget *widget);
 
-void          etk_widget_selection_get(Etk_Widget *widget, 
Etk_Event_Selection_Get *event);
-//#endif
+void etk_widget_selection_get(Etk_Widget *widget, Etk_Event_Selection_Get 
*event);
 
 /** @} */
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_window.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- etk_window.c        8 Feb 2006 12:49:38 -0000       1.10
+++ etk_window.c        11 Feb 2006 10:27:14 -0000      1.11
@@ -8,7 +8,7 @@
 #include "etk_utils.h"
 #include "etk_signal.h"
 #include "etk_signal_callback.h"
-#include "../../config.h"
+#include "config.h"
 
 /**
  * @addtogroup Etk_Window
@@ -437,32 +437,28 @@
 }
 
 /**
- * @brief A utility function to use as a callback for the "delete_event" 
signal. It will hide the window and return ETK_TRUE to prevent the program to 
quit
- * @param window the window to hide
- * @param data the data passed when the signal is emitted - unused
- * @return Return ETK_TRUE so the the program won't quit
+ * @brief Sets whether the window is dnd-aware (true by default)
+ * @param window a window
+ * @param on ETK_TTUE if to set the window dnd-aware
  */
-Etk_Bool etk_window_hide_on_delete(Etk_Object *window, void *data)
+void etk_window_xdnd_aware_set(Etk_Window *window, Etk_Bool on)
 {
-   etk_widget_hide(ETK_WIDGET(window));
-   return ETK_TRUE;
+#if HAVE_ECORE_X
+   ecore_x_dnd_aware_set(window->x_window, on);
+#endif
 }
 
-#if HAVE_ECORE_X
 /**
  * @brief A utility function to use as a callback for the "delete_event" 
signal. It will hide the window and return ETK_TRUE to prevent the program to 
quit
  * @param window the window to hide
  * @param data the data passed when the signal is emitted - unused
  * @return Return ETK_TRUE so the the program won't quit
  */
-void etk_window_xdnd_aware_set(Etk_Window *window, Etk_Bool on)
+Etk_Bool etk_window_hide_on_delete(Etk_Object *window, void *data)
 {
-   if(on)
-     ecore_x_dnd_aware_set(window->x_window, 1);
-   else
-     ecore_x_dnd_aware_set(window->x_window, 0);
+   etk_widget_hide(ETK_WIDGET(window));
+   return ETK_TRUE;
 }
-#endif
 
 /**************************
  *
@@ -481,22 +477,21 @@
    window->ecore_evas = ecore_evas_software_x11_new(NULL, 0, 0, 0, 0, 0);
    window->x_window = ecore_evas_software_x11_window_get(window->ecore_evas);
    
+/* TODO: free!! */
 #if HAVE_ECORE_X      
-     {   
-       const char *types[] = { "*" };
-       char **drop_types;
-       int i;
-       
-       ecore_x_dnd_aware_set(window->x_window, 1);     
-       
-       drop_types = calloc(1, sizeof(char *));
-       
-       for (i = 0; i < 1; i++)
-         drop_types[i] = strdup(types[i]);
-       
-       ecore_x_dnd_types_set(window->x_window, drop_types , 1);        
-     }
-   
+   {
+      const char *types[] = { "*" };
+      char **drop_types;
+      int i;
+      
+      ecore_x_dnd_aware_set(window->x_window, 1);      
+      drop_types = calloc(1, sizeof(char *));
+      
+      for (i = 0; i < 1; i++)
+         drop_types[i] = strdup(types[i]);
+      
+      ecore_x_dnd_types_set(window->x_window, drop_types , 1); 
+   }
 #endif   
    
    ETK_TOPLEVEL_WIDGET(window)->evas = ecore_evas_get(window->ecore_evas);
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_window.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- etk_window.h        2 Dec 2005 21:57:55 -0000       1.4
+++ etk_window.h        11 Feb 2006 10:27:14 -0000      1.5
@@ -63,6 +63,8 @@
 void etk_window_skip_pager_hint_set(Etk_Window *window, Etk_Bool 
skip_pager_hint);
 Etk_Bool etk_window_skip_pager_hint_get(Etk_Window *window);
 
+void etk_window_dnd_aware_set(Etk_Window *window, Etk_Bool on);
+
 Etk_Bool etk_window_hide_on_delete(Etk_Object *window, void *data);
 
 /** @} */




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to