* More cleanups. I took out everything related only to icon handling
authorcpk <cpk>
Sat, 3 Nov 2001 14:55:21 +0000 (14:55 +0000)
committercpk <cpk@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 3 Nov 2001 14:55:21 +0000 (14:55 +0000)
from the view code, and put it into icons.[ch].

* Added the relative desktop move path from Alan Schmitt.

SVN revision: 5616

30 files changed:
AUTHORS
data/config/behavior/default/actions.db
data/config/behavior/default/grabs.db
data/config/behavior/default/settings.db
data/scripts/build_db.sh
doc/manual.raw
src/Makefile.am
src/actions.c
src/actions.h
src/config.c
src/e.h
src/embed.c
src/file.c
src/file.h
src/fs.c
src/fs.h
src/globals.c [new file with mode: 0644]
src/globals.h [new file with mode: 0644]
src/guides.h
src/icons.c
src/icons.h [new file with mode: 0644]
src/main.c
src/menu.c
src/place.c
src/resist.c
src/scrollbar.c
src/text.c
src/util.h
src/view.c
src/view.h

diff --git a/AUTHORS b/AUTHORS
index 2b3a239..b54297b 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,3 +1,5 @@
 The Rasterman <raster@rasterman.com>
 Christian Kreibich <cK@whoop.org>
 Burra <burra@colorado.edu>
+Graham MacDonald <macdonag@lineone.net>
+Alan Schmitt <alan.schmitt@inria.fr>
index 6ae38d6..851edc4 100644 (file)
Binary files a/data/config/behavior/default/actions.db and b/data/config/behavior/default/actions.db differ
index dbae82e..c2f4045 100644 (file)
Binary files a/data/config/behavior/default/grabs.db and b/data/config/behavior/default/grabs.db differ
index 1e9051d..efbfb7a 100644 (file)
Binary files a/data/config/behavior/default/settings.db and b/data/config/behavior/default/settings.db differ
index 79648b6..54106fb 100755 (executable)
@@ -305,6 +305,22 @@ edb_ed $DB add "/actions/"$NUM"/button"    int 0
 edb_ed $DB add "/actions/"$NUM"/key"       str "F8"
 edb_ed $DB add "/actions/"$NUM"/modifiers" int $MOD_ALT
 NUM=$[ $NUM + 1 ];
+edb_ed $DB add "/actions/"$NUM"/name"      str Key_Binding
+edb_ed $DB add "/actions/"$NUM"/action"    str Desktop_Relative
+edb_ed $DB add "/actions/"$NUM"/params"    str 1
+edb_ed $DB add "/actions/"$NUM"/event"     int 8
+edb_ed $DB add "/actions/"$NUM"/button"    int 0
+edb_ed $DB add "/actions/"$NUM"/key"       str Right 
+edb_ed $DB add "/actions/"$NUM"/modifiers" int 6
+NUM=$[ $NUM + 1 ];
+edb_ed $DB add "/actions/"$NUM"/name"      str Key_Binding
+edb_ed $DB add "/actions/"$NUM"/action"    str Desktop_Relative
+edb_ed $DB add "/actions/"$NUM"/params"    str -1
+edb_ed $DB add "/actions/"$NUM"/event"     int 8
+edb_ed $DB add "/actions/"$NUM"/button"    int 0
+edb_ed $DB add "/actions/"$NUM"/key"       str Left
+edb_ed $DB add "/actions/"$NUM"/modifiers" int 6
+NUM=$[ $NUM + 1 ];
 edb_ed $DB add "/actions/count"       int $NUM
 
 # basic settings
index c6dd0ff..5d3724b 100644 (file)
 !Isrc/fs.h
 !Isrc/guides.h
 !Isrc/iconbar.c
+!Isrc/icons.h
 !Isrc/menu.h
 !Isrc/menu.c
 !Isrc/object.h
index d6c2d96..089b8db 100644 (file)
@@ -39,9 +39,10 @@ enlightenment_SOURCES = \
        fs.h fs.c \
        $(ferite_c) \
        guides.h guides.c \
+       globals.h globals.c \
        icccm.h icccm.c \
        iconbar.h iconbar.c\
-       icons.\
+       icons.h icons.c\
        ipc.h ipc.c \
        keys.h keys.c \
        main.c \
index 0af1d64..1eb72d8 100644 (file)
@@ -108,6 +108,10 @@ static void e_act_desk_start (E_Object *object, E_Action *a, void *data,
 static void e_act_raise_next_start (E_Object *object, E_Action *a, void *data,
                                    int x, int y, int rx, int ry);
 
+static void e_act_desk_rel_start (E_Object *object, E_Action *a, void *data,
+                                 int x, int y, int rx, int ry);
+
+
 static void
 e_action_find(char *action, E_Action_Type act, int button,
              char *key, Ecore_Event_Key_Modifiers mods, E_Object *object)
@@ -622,6 +626,7 @@ e_action_init(void)
    e_action_add_impl("Winodw_Snap", e_act_snap_start, NULL, NULL);
    e_action_add_impl("Window_Zoom", e_act_zoom_start, NULL, NULL);
    e_action_add_impl("Desktop", e_act_desk_start, NULL, NULL);
+   e_action_add_impl("Desktop_Relative", e_act_desk_rel_start, NULL, NULL);
    e_action_add_impl("Window_Next", e_act_raise_next_start, NULL, NULL);
 
    D_RETURN;
@@ -1737,6 +1742,35 @@ e_act_desk_start (E_Object *object, E_Action *a, void *data, int x, int y, int r
 }
 
 
+static void
+e_act_desk_rel_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry)
+{
+   int desk = 0;
+   int desk_max = e_desktops_get_num () - 1;
+
+   D_ENTER;
+   
+   if (a->params)
+     desk = atoi(a->params) + e_desktops_get_current();
+
+   if (desk < 0)
+     desk = desk_max;
+   else if (desk > desk_max)
+     desk = 0;
+
+   e_desktops_goto_desk(desk);
+
+   D_RETURN;
+   UN(object);
+   UN(a);
+   UN(data);
+   UN(x);
+   UN(y);
+   UN(rx);
+   UN(ry);
+}
+
+
 static void 
 e_act_raise_next_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry)
 {
index f8ee967..29a25db 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef E_ACTIONS_H
 #define E_ACTIONS_H
 
-#include "e.h"
 #include "object.h"
 
 typedef struct _E_Action              E_Action;
index 7aaf5e2..c6bc8ae 100644 (file)
@@ -5,16 +5,6 @@
 
 static char cfg_root[] = "";
 
-#define E_CONF(_key, _var, _args...) \
-{ \
-  if (!strcmp(type, _key)) \
-    { \
-      if ((_var)[0]) D_RETURN_(_var); \
-      sprintf((_var), ## _args); \
-      D_RETURN_(_var); \
-    } \
-}
-
 static char cfg_grabs_db[PATH_MAX] = "";
 static char cfg_settings_db[PATH_MAX] = "";
 static char cfg_actions_db[PATH_MAX] = "";
@@ -51,6 +41,17 @@ e_config_get(char *type)
    /*    "%sbehavior/default/grabs.db", e_config_user_dir());         */
    /* notice it would use the user config location instead             */
    /* but for now i'm keeping it as is for development "ease"          */
+
+#define E_CONF(_key, _var, _args...) \
+{ \
+  if (!strcmp(type, _key)) \
+    { \
+      if ((_var)[0]) D_RETURN_(_var); \
+      sprintf((_var), ## _args); \
+      D_RETURN_(_var); \
+    } \
+}
+
    E_CONF("grabs", cfg_grabs_db, 
          "%s/behavior/grabs.db", e_config_user_dir());
    E_CONF("settings", cfg_settings_db,
diff --git a/src/e.h b/src/e.h
index 8630a92..dfd816d 100644 (file)
--- a/src/e.h
+++ b/src/e.h
@@ -97,15 +97,4 @@ printf("%3.3f : %s()\n", __p->total, __p->func); \
 #define E_PROF_DUMP
 #endif
 
-
-/* misc util macros */
-#define INTERSECTS(x, y, w, h, xx, yy, ww, hh) \
-(((x) < ((xx) + (ww))) && \
-((y) < ((yy) + (hh))) && \
-(((x) + (w)) > (xx)) && \
-(((y) + (h)) > (yy)))
-#define SPANS_COMMON(x1, w1, x2, w2) \
-(!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1)))))
-#define UN(_blah) _blah = 0
-
 #endif
index 7ae6dfd..9dc97a9 100644 (file)
@@ -1,5 +1,6 @@
 #include "debug.h"
 #include "embed.h"
+#include "util.h"
 
 typedef struct _Embed Embed_Private;
 
index 1ce3e80..7d1bb36 100644 (file)
@@ -1,3 +1,4 @@
+#include "e.h"
 #include "debug.h"
 #include "file.h"
 #include "util.h"
index 0fb3f48..4bb4c14 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef E_FILE_H
 #define E_FILE_H
 
-#include "e.h"
-
 time_t     e_file_mod_time(char *file);
 int        e_file_exists(char *file);
 int        e_file_is_dir(char *file);
index d31e069..c5c8ac1 100644 (file)
--- a/src/fs.c
+++ b/src/fs.c
@@ -1,6 +1,7 @@
 #include "debug.h"
 #include "fs.h"
 #include "exec.h"
+#include "util.h"
 
 static EfsdConnection     *ec = NULL;
 static Evas_List           fs_handlers = NULL;
index 31f248b..d56f94a 100644 (file)
--- a/src/fs.h
+++ b/src/fs.h
@@ -2,7 +2,6 @@
 #define E_FS_H
 
 #include <libefsd.h>
-#include "e.h"
 
 typedef struct _E_FS_Restarter        E_FS_Restarter;
 
diff --git a/src/globals.c b/src/globals.c
new file mode 100644 (file)
index 0000000..3061d0b
--- /dev/null
@@ -0,0 +1,7 @@
+#include <Evas.h>
+#include <Ecore.h>
+
+
+Ecore_Event_Key_Modifiers mulit_select_mod = ECORE_EVENT_KEY_MODIFIER_SHIFT;
+Ecore_Event_Key_Modifiers range_select_mod = ECORE_EVENT_KEY_MODIFIER_CTRL;
+Evas_List views = NULL;
diff --git a/src/globals.h b/src/globals.h
new file mode 100644 (file)
index 0000000..53aaad9
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef E_GLOBALS_H
+#define E_GLOBALS_H
+
+extern Ecore_Event_Key_Modifiers mulit_select_mod;
+extern Ecore_Event_Key_Modifiers range_select_mod;
+extern Evas_List views;
+
+#endif
index 25176dc..15c4c14 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef E_GUIDES_H
 #define E_GUIDES_H
 
-#include "e.h"
-
 typedef enum e_guides_mode
   {
     E_GUIDES_OPAQUE,    /* configure window border & client */
index 1c816a6..c0109a0 100644 (file)
@@ -1 +1,890 @@
-#include "e.h"
+#include "icons.h"
+#include "debug.h"
+#include "globals.h"
+#include "cursors.h"
+#include "file.h" 
+#include "util.h"
+
+static void e_icon_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
+static void e_icon_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
+static void e_icon_in_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
+static void e_icon_out_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
+static void e_icon_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
+
+
+static void
+e_icon_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
+{
+   E_Icon *ic;
+   Ecore_Event *ev;
+   Ecore_Event_Mouse_Down *e;
+   
+   D_ENTER;
+   
+   ev = e_view_get_current_event();
+   if (!ev) D_RETURN;
+   e = ev->event;
+   ic = _data;
+   ic->view->select.down.x = _x;
+   ic->view->select.down.y = _y;
+   ic->state.clicked = 1;
+   e_icon_update_state(ic);
+   if (_b == 1)
+     {
+       if (e->double_click)
+         {
+            e_icon_exec(ic);
+            ic->state.just_executed = 1;
+         }
+       else
+         {
+            if (!ic->state.selected)
+              {
+                 if ((e->mods & mulit_select_mod))
+                   { 
+                      e_icon_select(ic);
+                   }
+                 else
+                   {
+                      e_view_deselect_all_except(ic);
+                      e_icon_select(ic);
+                   }
+                 ic->state.just_selected = 1;
+              }
+         }
+     }
+   else if (_b == 2)
+     {
+     }
+   else if (_b == 3)
+     {
+     }
+
+   D_RETURN;
+   UN(_e);
+   UN(_o);
+}
+
+static void
+e_icon_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
+{
+   E_Icon *ic;
+   Ecore_Event *ev;
+   Ecore_Event_Mouse_Up *e;
+   
+   D_ENTER;
+   
+   ev = e_view_get_current_event();
+   if (!ev) D_RETURN;
+   e = ev->event;
+   ic = _data;
+   if (ic->view->drag.started)
+     {
+       ic->state.clicked = 0;
+       ic->state.just_selected = 0;
+       e_icon_update_state(ic);
+       ecore_window_destroy(ic->view->drag.win);
+       ic->view->drag.started = 0;
+       D_RETURN;       
+     }
+   if (_b == 1)
+     {
+       if (ic->state.just_executed)
+         {
+            ic->state.just_executed = 0;
+         }
+       else
+         {
+            if ((e->mods & mulit_select_mod))
+              {
+                 if ((ic->state.selected) && (!ic->state.just_selected))
+                   e_icon_deselect(ic);
+              }
+            else
+              {
+                 e_view_deselect_all_except(ic);
+                 e_icon_select(ic);
+              }
+         }
+       ic->state.just_selected = 0;
+     }
+   ic->state.clicked = 0;
+   e_icon_update_state(ic);
+
+   D_RETURN;
+   UN(_e);
+   UN(_o);
+   UN(_x);
+   UN(_y);
+}
+
+static void
+e_icon_in_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
+{
+   E_Icon *ic;
+   
+   D_ENTER;
+   
+   ic = _data;
+   e_cursors_display_in_window(ic->view->win.main, "View_Icon");
+
+   D_RETURN;
+   UN(_e);
+   UN(_o);
+   UN(_b);
+   UN(_x);
+   UN(_y);
+}
+
+static void
+e_icon_out_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
+{
+   E_Icon *ic;
+   
+   ic = _data;
+   e_cursors_display_in_window(ic->view->win.main, "View");
+
+   D_RETURN;
+   UN(_e);
+   UN(_o);
+   UN(_b);
+   UN(_x);
+   UN(_y);
+}
+
+static void
+e_icon_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
+{
+   E_Icon *ic;
+   Ecore_Event *ev;
+   Ecore_Event_Mouse_Move *e;
+   
+   D_ENTER;
+   
+   ev = e_view_get_current_event();
+
+   if (!ev)
+     D_RETURN;
+
+   e = ev->event;
+   ic = _data;
+
+   if (!ic->state.clicked)
+     D_RETURN;
+
+   if (!ic->view->drag.started)
+     {
+       int dx, dy;
+       
+       dx = ic->view->select.down.x - _x;
+       dy = ic->view->select.down.y - _y;
+       if (dx < 0) dx = -dx;
+       if (dy < 0) dy = -dy;
+       if ((dx > 3) || (dy > 3))
+         {
+            Pixmap pmap, mask;
+            Evas_List l;
+            int x, y, xx, yy, rw, rh, downx, downy, wx, wy, ww, wh;
+            
+            /* find extents of icons to be dragged */
+            x = 999999999;
+            y = 999999999;
+            xx = -999999999;
+            yy = -999999999;
+            for (l = views; l; l = l->next)
+              {
+                 E_View *v;
+                 Evas_List ll;
+                 
+                 v = l->data;
+                 D("sel count %i\n", v->sel_count);
+                 if (v->sel_count > 0)
+                   {
+                      for (ll = v->icons; ll; ll = ll->next)
+                        {
+                           E_Icon *ic;
+                           
+                           ic = ll->data;
+                           if (ic->state.selected)
+                             {
+                                int ix, iy, iw, ih;
+                                
+                                ix = ic->view->scroll.x + ic->geom.x + v->location.x;
+                                iy = ic->view->scroll.y + ic->geom.y + v->location.y;
+                                iw = ic->geom.w;
+                                ih = ic->geom.h;
+                                if (ix < x) x = ix;
+                                if (iy < y) y = iy;
+                                if ((ix + iw) > xx) xx = ix + iw;
+                                if ((iy + ih) > yy) yy = iy + ih;
+                             }
+                        }
+                   }
+              }
+            ecore_window_get_geometry(0, NULL, NULL, &rw, &rh);
+            downx = ic->view->select.down.x + ic->view->location.x;
+            downy = ic->view->select.down.y + ic->view->location.y;
+            
+            wx = x;
+            ww = xx - x;
+            if (wx < - (rw - downx)) 
+              {
+                 wx = - (rw - downx);
+                 ww -= (wx - x);
+              }
+            if ((wx + ww) > (rw + downx))
+              ww = (rw + downx) - wx;
+            wy = y;
+            wh = yy - y;
+            if (wy < - (rh - downy)) 
+              {
+                 wy = - (rh - downy);
+                 wh -= (wy - y);
+              }
+            if ((wy + wh) > (rh + downy))
+              wh = (rh + downy) - wy;
+            
+            
+            ic->view->drag.x = wx + ic->view->location.x;
+            ic->view->drag.y = wy + ic->view->location.y;
+            ic->view->drag.offset.x = downx - ic->view->drag.x;
+            ic->view->drag.offset.y = downy - ic->view->drag.y;
+            
+            if ((ww < 1) || (wh < 1)) D_RETURN;
+            ic->view->drag.win = ecore_window_override_new(0, wx, wy, ww, wh);
+            pmap = ecore_pixmap_new(ic->view->drag.win, ww, wh, 0);
+            mask = ecore_pixmap_new(ic->view->drag.win, ww, wh, 1);
+              {
+                 Imlib_Image im;
+                 
+                 im = imlib_create_image(ww, wh);
+                 imlib_context_set_image(im);
+                 imlib_image_set_has_alpha(1);
+                 imlib_context_set_blend(1);
+                 imlib_image_clear();
+                  imlib_context_set_color_modifier(NULL);
+                 imlib_context_set_cliprect(0, 0, 0, 0);
+                 imlib_context_set_angle(0);
+                 
+                 for (l = views; l; l = l->next)
+                   {
+                      E_View *v;
+                      Evas_List ll;
+                      
+                      v = l->data;
+                      if (v->sel_count > 0)
+                        {
+                           for (ll = v->icons; ll; ll = ll->next)                            {
+                                E_Icon *ic;
+                                
+                                ic = ll->data;
+                                if (ic->state.selected)
+                                  {
+                                     double ix, iy;
+                                     int icx, icy;
+                                     Imlib_Image im2;
+                                     char icon[PATH_MAX];
+                                     
+                                     evas_get_geometry(ic->view->evas,
+                                                       ic->obj.icon,
+                                                       &ix, &iy, NULL, NULL);
+                                     icx = ix + v->location.x - wx;
+                                     icy = iy + v->location.y - wy;
+                                     if (!ic->info.icon)
+                                       {
+                                          D("EEEEEEEEEEK %s has no icon\n", ic->file);
+                                          D_RETURN;
+                                       }
+                                     if (ic->state.clicked)
+                                       {
+                                          sprintf(icon, "%s:/icon/clicked", ic->info.icon);
+                                       }
+                                     else if (ic->state.selected)
+                                       {
+                                          sprintf(icon, "%s:/icon/selected", ic->info.icon);
+                                       }
+                                     else
+                                       {
+                                          sprintf(icon, "%s:/icon/normal", ic->info.icon);
+                                       }
+                                     im2 = imlib_load_image(icon);
+                                     if (im2)
+                                       {
+                                          int iw, ih;
+                                          
+                                          imlib_context_set_image(im2);
+                                          iw = imlib_image_get_width();
+                                          ih = imlib_image_get_height();
+                                          imlib_context_set_image(im);
+                                          imlib_blend_image_onto_image(im2, 1,
+                                                                       0, 0, iw, ih,
+                                                                       icx, icy, iw, ih);
+                                          imlib_context_set_image(im2);
+                                          imlib_free_image();
+                                          imlib_context_set_image(im);
+                                       }
+                                     else
+                                       {
+                                          D("eek cant load\n");
+                                       }
+                                  }
+                             }
+                        }
+                   }
+                 imlib_context_set_image(im);
+                 if (ww * wh < (200 * 200)) imlib_context_set_dither_mask(1);
+                 else imlib_context_set_dither_mask(0);
+                 imlib_context_set_dither(1);
+                 imlib_context_set_drawable(pmap);
+                 imlib_context_set_mask(mask);
+                 imlib_context_set_blend(0);
+                 imlib_context_set_color_modifier(NULL);
+                 imlib_render_image_on_drawable(0, 0);
+                 imlib_free_image();
+              }
+            ecore_window_set_background_pixmap(ic->view->drag.win, pmap);
+            ecore_window_set_shape_mask(ic->view->drag.win, mask);
+            ecore_window_ignore(ic->view->drag.win);
+            ecore_window_raise(ic->view->drag.win);
+            ecore_window_show(ic->view->drag.win);
+            ecore_pixmap_free(pmap);
+            ecore_pixmap_free(mask);
+            ic->view->drag.started = 1;
+         }
+     }
+
+   if (ic->view->drag.started)
+     {
+       int x, y;
+       
+       x = _x - ic->view->drag.offset.x;
+       y = _y - ic->view->drag.offset.y;
+       ic->view->drag.x = x;
+       ic->view->drag.y = y;
+       ic->view->drag.update = 1;
+       ic->view->changed = 1;
+     }
+
+   D_RETURN;
+   UN(_e);
+   UN(_o);
+   UN(_b);
+}
+
+
+static void
+e_icon_cleanup(E_Icon *ic)
+{
+   D_ENTER;
+   
+   /* FIXME: free stuff here! this leaks ... */
+
+   e_object_cleanup(E_OBJECT(ic));
+
+   D_RETURN;
+}
+
+E_Icon *
+e_icon_new(void)
+{
+   E_Icon *ic;
+   
+   D_ENTER;
+   
+   ic = NEW(E_Icon, 1);
+   ZERO(ic, E_Icon, 1);
+   
+   e_object_init(E_OBJECT(ic), (E_Cleanup_Func) e_icon_cleanup);
+
+   D_RETURN_(ic);
+}
+
+
+
+E_Icon *
+e_icon_find_by_file(E_View *view, char *file)
+{
+   Evas_List l;
+   
+   D_ENTER;
+   
+   for (l = view->icons; l; l = l->next)
+     {
+       E_Icon *ic;
+       
+       ic = l->data;
+       if ((ic) && (ic->file) && (file) && (!strcmp(ic->file, file)))
+         D_RETURN_(ic);
+     }
+   D_RETURN_(NULL);
+}
+
+void
+e_icon_show(E_Icon *ic)
+{
+   D_ENTER;
+
+   
+   if (ic->state.visible) D_RETURN;
+   ic->state.visible = 1;
+   if (!ic->obj.event1)
+     {
+       ic->obj.event1 = evas_add_rectangle(ic->view->evas);
+       ic->obj.event2 = evas_add_rectangle(ic->view->evas);
+       evas_set_color(ic->view->evas, ic->obj.event1, 0, 0, 0, 0);
+       evas_set_color(ic->view->evas, ic->obj.event2, 0, 0, 0, 0);
+       evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_DOWN, e_icon_down_cb, ic);
+       evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_UP, e_icon_up_cb, ic);
+       evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_IN, e_icon_in_cb, ic);
+       evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_OUT, e_icon_out_cb, ic);
+       evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_MOVE, e_icon_move_cb, ic);
+       evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_DOWN, e_icon_down_cb, ic);
+       evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_UP, e_icon_up_cb, ic);
+       evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_IN, e_icon_in_cb, ic);
+       evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_OUT, e_icon_out_cb, ic);
+       evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_MOVE, e_icon_move_cb, ic);
+     }
+   evas_set_layer(ic->view->evas, ic->obj.icon, 200);
+   e_text_set_layer(ic->obj.text, 200);
+   evas_set_layer(ic->view->evas, ic->obj.event1, 210);
+   evas_set_layer(ic->view->evas, ic->obj.event2, 210);
+   
+   evas_show(ic->view->evas, ic->obj.icon);
+   e_text_show(ic->obj.text);
+   evas_show(ic->view->evas, ic->obj.event1);
+   evas_show(ic->view->evas, ic->obj.event2);
+
+   D_RETURN;
+}
+
+void
+e_icon_hide(E_Icon *ic)
+{
+   D_ENTER;
+   
+   if (!ic->state.visible) D_RETURN;
+   ic->state.visible = 0;
+   evas_hide(ic->view->evas, ic->obj.icon);
+   e_text_hide(ic->obj.text);
+   evas_hide(ic->view->evas, ic->obj.event1);
+   evas_hide(ic->view->evas, ic->obj.event2);
+
+   D_RETURN;
+}
+
+void
+e_icon_apply_xy(E_Icon *ic)
+{
+   D_ENTER;
+   
+   /* threse calc icon extents for: */
+   /*  [I]  */
+   /*  Ig   */
+   /* [txt] */
+   
+   if (ic->geom.text.w > ic->geom.icon.w) ic->geom.w = ic->geom.text.w;
+   else ic->geom.w = ic->geom.icon.w;
+   ic->geom.h = ic->geom.icon.h + ic->geom.text.h + ic->view->spacing.icon.g;
+   
+   evas_resize(ic->view->evas, ic->obj.event1, 
+              ic->geom.icon.w, ic->geom.icon.h);
+   evas_resize(ic->view->evas, ic->obj.event2, 
+              ic->geom.text.w, ic->geom.text.h);
+   evas_move(ic->view->evas, ic->obj.event1,
+            ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.icon.w) / 2),
+            ic->view->scroll.y + ic->geom.y);
+   evas_move(ic->view->evas, ic->obj.event2,
+            ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.text.w) / 2),
+            ic->view->scroll.y + ic->geom.y + ic->geom.icon.h + ic->view->spacing.icon.g);          
+   evas_move(ic->view->evas, ic->obj.icon, 
+            ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.icon.w) / 2), 
+            ic->view->scroll.y + ic->geom.y);
+   e_text_move(ic->obj.text,
+              ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.text.w) / 2), 
+              ic->view->scroll.y + ic->geom.y + ic->geom.icon.h + ic->view->spacing.icon.g);
+   if (ic->obj.sel.under.icon)
+     {
+       int pl, pr, pt, pb;
+       
+       ebits_get_insets(ic->obj.sel.under.icon, &pl, &pr, &pt, &pb);
+       ebits_move(ic->obj.sel.under.icon, 
+                  ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.icon.w) / 2) - pl,
+                  ic->view->scroll.y + ic->geom.y - pt);
+       ebits_resize(ic->obj.sel.under.icon,
+                    ic->geom.icon.w + pl + pr, ic->geom.icon.h + pt + pb);
+       ebits_show(ic->obj.sel.under.icon);
+     }
+   if (ic->obj.sel.under.text)
+     {
+       int pl, pr, pt, pb;
+       
+       ebits_get_insets(ic->obj.sel.under.text, &pl, &pr, &pt, &pb);
+       ebits_move(ic->obj.sel.under.text, 
+                  ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.text.w) / 2) - pl, 
+                  ic->view->scroll.y + ic->geom.y + ic->geom.icon.h + ic->view->spacing.icon.g - pt);
+       ebits_resize(ic->obj.sel.under.text,
+                    ic->geom.text.w + pl  + pr, ic->geom.text.h + pt + pb);
+       ebits_show(ic->obj.sel.under.text);
+     }
+   if (ic->obj.sel.over.icon)
+     {
+       int pl, pr, pt, pb;
+       
+       ebits_get_insets(ic->obj.sel.over.icon, &pl, &pr, &pt, &pb);
+       ebits_move(ic->obj.sel.over.icon, 
+                  ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.icon.w) / 2) - pl,
+                  ic->view->scroll.y + ic->geom.y - pt);
+       ebits_resize(ic->obj.sel.over.icon,
+                    ic->geom.icon.w + pl + pr, ic->geom.icon.h + pt + pb);
+       ebits_show(ic->obj.sel.over.icon);
+     }
+   if (ic->obj.sel.over.text)
+     {
+       int pl, pr, pt, pb;
+       
+       ebits_get_insets(ic->obj.sel.over.text, &pl, &pr, &pt, &pb);
+       ebits_move(ic->obj.sel.over.text, 
+                  ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.text.w) / 2) - pl, 
+                  ic->view->scroll.y + ic->geom.y + ic->geom.icon.h + ic->view->spacing.icon.g - pt);
+       ebits_resize(ic->obj.sel.over.text,
+                    ic->geom.text.w + pl  + pr, ic->geom.text.h + pt + pb);
+       ebits_show(ic->obj.sel.over.text);
+     }
+   if ((ic->geom.x != ic->prev_geom.x) || (ic->geom.y != ic->prev_geom.y))
+     {
+       ic->q.write_xy = 1;
+       e_view_queue_icon_xy_record(ic->view);
+     }
+   if (ic->geom.x != ic->prev_geom.x) ic->view->extents.valid = 0;
+   else if (ic->geom.y != ic->prev_geom.y) ic->view->extents.valid = 0;
+   else if (ic->geom.w != ic->prev_geom.w) ic->view->extents.valid = 0;
+   else if (ic->geom.h != ic->prev_geom.h) ic->view->extents.valid = 0;
+   
+   ic->prev_geom = ic->geom;
+   ic->prev_geom.x = ic->geom.x;
+   ic->prev_geom.y = ic->geom.y;
+   ic->prev_geom.w = ic->geom.w;
+   ic->prev_geom.h = ic->geom.h;
+
+   D_RETURN;
+}
+
+
+void      
+e_icon_check_permissions(E_Icon *ic)
+{
+  D_ENTER;
+
+  if (!ic || !ic->info.mime.base || ic->stat.st_ino == 0)
+    D_RETURN;
+
+  if (!strcmp(ic->info.mime.base, "dir"))
+    {
+      if (e_file_can_exec(&ic->stat))
+       evas_set_color(ic->view->evas, ic->obj.icon, 255, 255, 255, 255);
+      else
+       evas_set_color(ic->view->evas, ic->obj.icon, 128, 128, 128, 128);
+    } 
+
+  D_RETURN;
+}
+
+
+void
+e_icon_initial_show(E_Icon *ic)
+{
+   D_ENTER;
+   
+   /* check if we have enuf info and we havent been shown yet */
+   if (!ic->info.icon) D_RETURN;
+   if (ic->state.visible) D_RETURN;
+   
+   /* first. lets figure out the size of the icon */
+   evas_get_image_size(ic->view->evas, ic->obj.icon, 
+                      &(ic->geom.icon.w), &(ic->geom.icon.h));
+     {
+       double tw, th;
+       
+       e_text_get_geometry(ic->obj.text, NULL, NULL, &tw, &th);
+       ic->geom.text.w = (int)tw;
+       ic->geom.text.h = (int)th;
+     }
+   
+   /* now lets allocate space for it if we need to */
+   ic->geom.x = 999999;
+   ic->geom.y = 999999;
+   
+   /* if needed queue a tiemout for a resort */
+   e_view_queue_resort(ic->view);
+   
+   /* actually show the icon */
+   e_icon_apply_xy(ic);
+   e_icon_show(ic);
+
+   D_RETURN;
+}
+
+void
+e_icon_set_mime(E_Icon *ic, char *base, char *mime)
+{
+   int diff = 0;
+   
+   D_ENTER;
+   
+   if (!ic->info.mime.base) diff = 1;
+   if (!ic->info.mime.type) diff = 1;
+   if ((ic->info.mime.base) && (strcmp(ic->info.mime.base, base))) diff = 1;
+   if ((ic->info.mime.type) && (strcmp(ic->info.mime.base, mime))) diff = 1;
+   if (!diff) D_RETURN;
+   if (ic->info.mime.base) free(ic->info.mime.base);
+   if (ic->info.mime.type) free(ic->info.mime.type);
+   ic->info.mime.base = NULL;
+   ic->info.mime.type = NULL;
+   ic->info.mime.base = strdup(base);
+   ic->info.mime.type = strdup(mime);
+   
+   D("%40s: %s/%s\n", ic->file, base, mime);
+   
+   /* effect changes here */
+   if (ic->info.custom_icon) 
+     {
+       if (ic->info.icon) free(ic->info.icon);
+       ic->info.icon = NULL;
+       ic->info.icon = strdup(ic->info.custom_icon);
+       evas_set_image_file(ic->view->evas, ic->obj.icon, ic->info.custom_icon);
+       e_view_queue_resort(ic->view);  
+       D_RETURN;
+     }
+   /* find an icon */
+     {
+       char icon[PATH_MAX];
+       char type[PATH_MAX];    
+       char *p;
+       int done = 0;
+       
+       strcpy(type, ic->info.mime.type);
+       for (p = type; *p; p++) 
+         {
+            if (*p == '/') *p = '-';
+         }
+       do 
+         {
+            sprintf(icon, "%s/data/icons/%s/%s.db", PACKAGE_DATA_DIR,
+                    ic->info.mime.base, type);
+            if (e_file_exists(icon))
+              {
+                 done = 1;
+                 break;
+              }
+            p = strrchr(type, '-');
+            if (p) *p = 0;
+         }
+       while (p);
+       if (!done)
+         {
+            if (!e_file_exists(icon))
+              {
+                 sprintf(icon, "%s/data/icons/%s/default.db", PACKAGE_DATA_DIR,
+                         ic->info.mime.base);
+                 if (!e_file_exists(icon))
+                   sprintf(icon, "%s/data/icons/unknown/default.db", PACKAGE_DATA_DIR);
+              }
+         }
+       ic->info.icon = strdup(icon);
+     }
+
+   e_icon_update_state(ic);
+
+   D_RETURN;
+}
+
+void
+e_icon_set_link(E_Icon *ic, char *link)
+{
+   D_ENTER;
+   
+   if ((!link) && (ic->info.link))
+     {
+       free(ic->info.link);
+       ic->info.link = NULL;
+       /* effect changes here */
+     }
+   else if (link)
+     {
+       if ((ic->info.link) && (!strcmp(ic->info.link, link)))
+         {
+            free(ic->info.link);
+            ic->info.link = strdup(link);
+            /* effect changes here */
+         }
+     }
+
+   D_RETURN;
+}
+
+
+void
+e_icon_update_state(E_Icon *ic)
+{
+   char icon[PATH_MAX];
+   int iw, ih;
+   int gw, gh;
+   
+   D_ENTER;
+   
+   if (!ic->info.icon)
+     {
+       D("EEEEEEEEEEK %s has no icon\n", ic->file);
+       D_RETURN;
+     }
+   if (ic->state.clicked)
+     {
+       sprintf(icon, "%s:/icon/clicked", ic->info.icon);
+     }
+   else if (ic->state.selected)
+     {
+       sprintf(icon, "%s:/icon/selected", ic->info.icon);
+     }
+   else
+     {
+       sprintf(icon, "%s:/icon/normal", ic->info.icon);
+     }
+   if ((ic->state.selected) && 
+       (!ic->obj.sel.under.icon) && 
+       (!ic->obj.sel.over.icon))
+     {
+       char file[PATH_MAX];
+
+/*     
+       sprintf(file, "%s/file.bits.db", e_config_get("selections"));
+       ic->obj.sel.over.icon = ebits_load(file);
+       sprintf(file, "%s/text.bits.db", e_config_get("selections"));
+       ic->obj.sel.over.text = ebits_load(file);
+ */
+       sprintf(file, "%s/file.bits.db", e_config_get("selections"));
+       ic->obj.sel.under.icon = ebits_load(file);
+       sprintf(file, "%s/text.bits.db", e_config_get("selections"));
+       ic->obj.sel.under.text = ebits_load(file);
+       if (ic->obj.sel.under.icon) 
+         {
+            ebits_add_to_evas(ic->obj.sel.under.icon, ic->view->evas);
+            ebits_set_layer(ic->obj.sel.under.icon, 195);
+         }
+       if (ic->obj.sel.under.text)
+         {
+            ebits_add_to_evas(ic->obj.sel.under.text, ic->view->evas);
+            ebits_set_layer(ic->obj.sel.under.text, 195);
+         }
+       if (ic->obj.sel.over.icon) 
+         {
+            ebits_add_to_evas(ic->obj.sel.over.icon, ic->view->evas);
+            ebits_set_layer(ic->obj.sel.over.icon, 205);
+         }
+       if (ic->obj.sel.over.text)
+         {
+            ebits_add_to_evas(ic->obj.sel.over.text, ic->view->evas);
+            ebits_set_layer(ic->obj.sel.over.text, 205);
+         }
+     }
+   else if ((!ic->state.selected) && 
+           ((ic->obj.sel.under.icon) ||
+            (ic->obj.sel.over.icon)))
+     {
+       if (ic->obj.sel.under.icon) ebits_free(ic->obj.sel.under.icon);
+       if (ic->obj.sel.under.text) ebits_free(ic->obj.sel.under.text);
+       if (ic->obj.sel.over.icon) ebits_free(ic->obj.sel.over.icon);
+       if (ic->obj.sel.over.text) ebits_free(ic->obj.sel.over.text);
+       ic->obj.sel.under.icon = NULL;
+       ic->obj.sel.under.text = NULL;
+       ic->obj.sel.over.icon = NULL;
+       ic->obj.sel.over.text = NULL;
+     }
+   evas_set_image_file(ic->view->evas, ic->obj.icon, icon);
+   evas_get_image_size(ic->view->evas, ic->obj.icon, &iw, &ih);
+   gw = ic->geom.icon.w;
+   gh = ic->geom.icon.h;
+   e_icon_apply_xy(ic);
+   if ((iw == gw) && (ih == gh)) D_RETURN;
+   e_view_queue_resort(ic->view);
+
+   D_RETURN;
+}
+
+
+void
+e_icon_invert_selection(E_Icon *ic)
+{
+   D_ENTER;
+   
+   if (ic->state.selected) e_icon_deselect(ic);
+   else e_icon_select(ic);
+
+   D_RETURN;
+}
+
+void
+e_icon_select(E_Icon *ic)
+{
+   D_ENTER;
+   
+   if (!ic->state.selected)
+     {
+       ic->state.selected = 1;
+       ic->view->sel_count++;
+       e_icon_update_state(ic);
+     }
+
+   D_RETURN;
+}
+
+void
+e_icon_deselect(E_Icon *ic)
+{
+   D_ENTER;
+   
+   if (ic->state.selected)
+     {
+       ic->state.selected = 0;
+       ic->view->sel_count--;
+       e_icon_update_state(ic);
+     }
+
+   D_RETURN;
+}
+
+void
+e_icon_exec(E_Icon *ic)
+{
+   D_ENTER;
+   
+   if (!strcmp(ic->info.mime.base, "dir") &&
+       e_file_can_exec(&ic->stat))
+     {
+       E_View *v;
+       char buf[PATH_MAX];
+       
+       v = e_view_new();
+       v->size.w = 400;
+       v->size.h = 300;
+       v->options.back_pixmap = 0;
+       /* Load default bg then handle bg in metadata */
+       sprintf(buf, "%s/%s/.e_background.bg.db", ic->view->dir, ic->file);
+       v->bg = e_background_load(buf);
+       if (!v->bg)
+         {
+            sprintf(buf, "%s/view.bg.db", e_config_get("backgrounds"));
+            v->bg = e_background_load(buf);
+         }
+       sprintf(buf, "%s/%s", ic->view->dir, ic->file);
+       D("new dir >%s<\n", buf);
+       v->dir = strdup(buf);
+       e_view_realize(v);
+       ecore_window_set_title(v->win.base, ic->file);
+       ecore_window_set_name_class(v->win.base, "FileView", "E");
+       ecore_window_set_min_size(v->win.base, 8, 8);
+     }
+
+   e_icon_deselect(ic);
+
+   D_RETURN;
+}
diff --git a/src/icons.h b/src/icons.h
new file mode 100644 (file)
index 0000000..b887936
--- /dev/null
@@ -0,0 +1,102 @@
+#ifndef E_ICONS_H
+#define E_ICONS_H
+
+#include "view.h"
+#include "text.h"
+
+#ifndef E_ICON_TYPEDEF
+#define E_ICON_TYPEDEF
+typedef struct _E_Icon    E_Icon;
+#endif
+
+#ifndef E_VIEW_TYPEDEF
+#define E_VIEW_TYPEDEF
+typedef struct _E_View    E_View;
+#endif
+
+struct _E_Icon
+{
+   E_Object o;
+   
+   char        *file;
+   struct stat  stat;
+   
+   E_View *view;
+   
+   struct {
+      char *icon;
+      char *custom_icon;
+      char *link;
+      struct {
+        char *base;
+        char *type;
+      } mime;
+   } info;
+   
+   struct {
+      Evas_Object  icon;
+      Evas_Object  event1;
+      Evas_Object  event2;
+      E_Text      *text;
+      struct {
+        struct {
+           Ebits_Object icon;
+           Ebits_Object text;
+        } over, under;
+      } sel;
+   } obj;
+   
+   struct {
+      int hilited;
+      int clicked;
+      int selected;
+      int running;
+      int disabled;
+      int visible;
+      int just_selected;
+      int just_executed;
+   } state;
+   
+   struct {
+      int x, y, w, h;
+      struct {
+        int w, h;
+      } icon;
+      struct {
+        int w, h;
+      } text;
+   } geom, prev_geom;      
+   
+   struct {
+      int write_xy;
+   } q;
+   
+   int     changed;   
+};
+
+
+E_Icon   *e_icon_new(void);
+void      e_icon_update_state(E_Icon *ic);
+void      e_icon_invert_selection(E_Icon *ic);
+void      e_icon_select(E_Icon *ic);
+void      e_icon_deselect(E_Icon *ic);
+
+/**
+ * e_icon_exec - handles execution paths when user activates an icon
+ * @ic:   The activated icon
+ *
+ * This function takes care of opening views when the user activates a
+ * directory, launching commands when an executable is activated etc.
+ */
+void      e_icon_exec(E_Icon *ic);
+
+void      e_icon_initial_show(E_Icon *ic);
+void      e_icon_set_mime(E_Icon *ic, char *base, char *mime);
+void      e_icon_set_link(E_Icon *ic, char *link);
+E_Icon   *e_icon_find_by_file(E_View *view, char *file);
+void      e_icon_show(E_Icon *ic);
+void      e_icon_hide(E_Icon *ic);
+void      e_icon_apply_xy(E_Icon *ic);
+void      e_icon_check_permissions(E_Icon *ic);
+
+#endif
index 6cbbb85..700a32f 100644 (file)
@@ -14,6 +14,7 @@
 #include "view.h"
 #include "place.h"
 #include "iconbar.h"
+#include "util.h"
 
 #ifdef USE_FERITE
 # include "e_ferite.h"
index 43e238c..ab92e34 100644 (file)
@@ -1,6 +1,7 @@
 #include "debug.h"
 #include "menu.h"
 #include "config.h"
+#include "util.h"
 
 static Evas_List open_menus = NULL;         /* List of all open menus */
 static Evas_List menus = NULL;
index 8fe44c1..8426f37 100644 (file)
@@ -3,6 +3,7 @@
 #include "place.h"
 #include "actions.h"
 #include "guides.h"
+#include "util.h"
 
 static void e_mouse_down(Ecore_Event * ev);
 static void e_mouse_up(Ecore_Event * ev);
index 9fe2867..37f7acf 100644 (file)
@@ -2,6 +2,7 @@
 #include "resist.h"
 #include "config.h"
 #include "desktops.h"
+#include "util.h"
 
 void
 e_resist_border(E_Border *b)
index 73eb899..131925c 100644 (file)
@@ -1,6 +1,7 @@
 #include "debug.h"
 #include "scrollbar.h"
 #include "config.h"
+#include "util.h"
 
 static void e_scrollbar_recalc(E_Scrollbar *sb);
 static void e_scrollbar_setup_bits(E_Scrollbar *sb);
index 6a25e90..83543af 100644 (file)
@@ -1,5 +1,6 @@
 #include "debug.h"
 #include "text.h"
+#include "util.h"
 
 E_Text *
 e_text_new(Evas evas, char *text, char *class)
index e00b3da..0d9ee5b 100644 (file)
@@ -16,4 +16,14 @@ __dest = malloc(strlen(__var) + 1); \
 if (__dest) strcpy(__dest, __var); \
 } }
 
+/* misc util macros */
+#define INTERSECTS(x, y, w, h, xx, yy, ww, hh) \
+(((x) < ((xx) + (ww))) && \
+((y) < ((yy) + (hh))) && \
+(((x) + (w)) > (xx)) && \
+(((y) + (h)) > (yy)))
+#define SPANS_COMMON(x1, w1, x2, w2) \
+(!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1)))))
+#define UN(_blah) _blah = 0
+
 #endif
index efdc53b..8153b03 100644 (file)
@@ -3,8 +3,6 @@
 #include "debug.h"
 #include "view.h"
 #include "cursors.h"
-#include "background.h"
-#include "desktops.h"
 #include "config.h"
 #include "border.h"
 #include "menu.h"
 #include "fs.h"
 #include "file.h"
 #include "util.h"
+#include "globals.h"
 
-static Evas_List views = NULL;
 static Ecore_Event *current_ev = NULL;
 
-static Ecore_Event_Key_Modifiers mulit_select_mod = ECORE_EVENT_KEY_MODIFIER_SHIFT;
-static Ecore_Event_Key_Modifiers range_select_mod = ECORE_EVENT_KEY_MODIFIER_CTRL;
-
 static void e_bg_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
 static void e_bg_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
 static void e_bg_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
-static void e_icon_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
-static void e_icon_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
-static void e_icon_in_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
-static void e_icon_out_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
-static void e_icon_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
 static void e_idle(void *data);
 static void e_wheel(Ecore_Event * ev);
 static void e_key_down(Ecore_Event * ev);
@@ -375,7 +365,7 @@ e_bg_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
               {
                  if (ic->state.visible)
                    {
-                      e_view_icon_invert_selection(ic);
+                      e_icon_invert_selection(ic);
                    }
               }
          }
@@ -481,92 +471,6 @@ e_bg_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
    UN(_b);
 }
 
-void
-e_view_icon_update_state(E_Icon *ic)
-{
-   char icon[PATH_MAX];
-   int iw, ih;
-   int gw, gh;
-   
-   D_ENTER;
-   
-   if (!ic->info.icon)
-     {
-       D("EEEEEEEEEEK %s has no icon\n", ic->file);
-       D_RETURN;
-     }
-   if (ic->state.clicked)
-     {
-       sprintf(icon, "%s:/icon/clicked", ic->info.icon);
-     }
-   else if (ic->state.selected)
-     {
-       sprintf(icon, "%s:/icon/selected", ic->info.icon);
-     }
-   else
-     {
-       sprintf(icon, "%s:/icon/normal", ic->info.icon);
-     }
-   if ((ic->state.selected) && 
-       (!ic->obj.sel.under.icon) && 
-       (!ic->obj.sel.over.icon))
-     {
-       char file[PATH_MAX];
-
-/*     
-       sprintf(file, "%s/file.bits.db", e_config_get("selections"));
-       ic->obj.sel.over.icon = ebits_load(file);
-       sprintf(file, "%s/text.bits.db", e_config_get("selections"));
-       ic->obj.sel.over.text = ebits_load(file);
- */
-       sprintf(file, "%s/file.bits.db", e_config_get("selections"));
-       ic->obj.sel.under.icon = ebits_load(file);
-       sprintf(file, "%s/text.bits.db", e_config_get("selections"));
-       ic->obj.sel.under.text = ebits_load(file);
-       if (ic->obj.sel.under.icon) 
-         {
-            ebits_add_to_evas(ic->obj.sel.under.icon, ic->view->evas);
-            ebits_set_layer(ic->obj.sel.under.icon, 195);
-         }
-       if (ic->obj.sel.under.text)
-         {
-            ebits_add_to_evas(ic->obj.sel.under.text, ic->view->evas);
-            ebits_set_layer(ic->obj.sel.under.text, 195);
-         }
-       if (ic->obj.sel.over.icon) 
-         {
-            ebits_add_to_evas(ic->obj.sel.over.icon, ic->view->evas);
-            ebits_set_layer(ic->obj.sel.over.icon, 205);
-         }
-       if (ic->obj.sel.over.text)
-         {
-            ebits_add_to_evas(ic->obj.sel.over.text, ic->view->evas);
-            ebits_set_layer(ic->obj.sel.over.text, 205);
-         }
-     }
-   else if ((!ic->state.selected) && 
-           ((ic->obj.sel.under.icon) ||
-            (ic->obj.sel.over.icon)))
-     {
-       if (ic->obj.sel.under.icon) ebits_free(ic->obj.sel.under.icon);
-       if (ic->obj.sel.under.text) ebits_free(ic->obj.sel.under.text);
-       if (ic->obj.sel.over.icon) ebits_free(ic->obj.sel.over.icon);
-       if (ic->obj.sel.over.text) ebits_free(ic->obj.sel.over.text);
-       ic->obj.sel.under.icon = NULL;
-       ic->obj.sel.under.text = NULL;
-       ic->obj.sel.over.icon = NULL;
-       ic->obj.sel.over.text = NULL;
-     }
-   evas_set_image_file(ic->view->evas, ic->obj.icon, icon);
-   evas_get_image_size(ic->view->evas, ic->obj.icon, &iw, &ih);
-   gw = ic->geom.icon.w;
-   gh = ic->geom.icon.h;
-   e_view_icon_apply_xy(ic);
-   if ((iw == gw) && (ih == gh)) D_RETURN;
-   e_view_queue_resort(ic->view);
-
-   D_RETURN;
-}
 
 void
 e_view_deselect_all(void)
@@ -586,7 +490,7 @@ e_view_deselect_all(void)
             E_Icon *ic;
             
             ic = l->data;
-            e_view_icon_deselect(ic);
+            e_icon_deselect(ic);
          }
      }
 
@@ -612,89 +516,13 @@ e_view_deselect_all_except(E_Icon *not_ic)
             
             ic = l->data;
             if (ic != not_ic)
-              e_view_icon_deselect(ic);
+              e_icon_deselect(ic);
          }
      }
 
    D_RETURN;
 }
 
-void
-e_view_icon_invert_selection(E_Icon *ic)
-{
-   D_ENTER;
-   
-   if (ic->state.selected) e_view_icon_deselect(ic);
-   else e_view_icon_select(ic);
-
-   D_RETURN;
-}
-
-void
-e_view_icon_select(E_Icon *ic)
-{
-   D_ENTER;
-   
-   if (!ic->state.selected)
-     {
-       ic->state.selected = 1;
-       ic->view->sel_count++;
-       e_view_icon_update_state(ic);
-     }
-
-   D_RETURN;
-}
-
-void
-e_view_icon_deselect(E_Icon *ic)
-{
-   D_ENTER;
-   
-   if (ic->state.selected)
-     {
-       ic->state.selected = 0;
-       ic->view->sel_count--;
-       e_view_icon_update_state(ic);
-     }
-
-   D_RETURN;
-}
-
-void
-e_view_icon_exec(E_Icon *ic)
-{
-   D_ENTER;
-   
-   if (!strcmp(ic->info.mime.base, "dir") &&
-       e_file_can_exec(&ic->stat))
-     {
-       E_View *v;
-       char buf[PATH_MAX];
-       
-       v = e_view_new();
-       v->size.w = 400;
-       v->size.h = 300;
-       v->options.back_pixmap = 0;
-       /* Load default bg then handle bg in metadata */
-       sprintf(buf, "%s/%s/.e_background.bg.db", ic->view->dir, ic->file);
-       v->bg = e_background_load(buf);
-       if (!v->bg)
-         {
-            sprintf(buf, "%s/view.bg.db", e_config_get("backgrounds"));
-            v->bg = e_background_load(buf);
-         }
-       sprintf(buf, "%s/%s", ic->view->dir, ic->file);
-       D("new dir >%s<\n", buf);
-       v->dir = strdup(buf);
-       e_view_realize(v);
-       ecore_window_set_title(v->win.base, ic->file);
-       ecore_window_set_name_class(v->win.base, "FileView", "E");
-       ecore_window_set_min_size(v->win.base, 8, 8);
-     }
-   e_view_icon_deselect(ic);
-
-   D_RETURN;
-}
 
 void
 e_view_icons_get_extents(E_View *v, int *min_x, int *min_y, int *max_x, int *max_y)
@@ -760,7 +588,7 @@ e_view_icons_apply_xy(E_View *v)
        E_Icon *ic;
        
        ic = l->data;
-       e_view_icon_apply_xy(ic);
+       e_icon_apply_xy(ic);
      }
 
    D_RETURN;
@@ -893,357 +721,6 @@ e_view_get_position_percentage(E_View *v, double *vx, double *vy)
    D_RETURN;
 }
 
-static void
-e_icon_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
-{
-   E_Icon *ic;
-   Ecore_Event *ev;
-   Ecore_Event_Mouse_Down *e;
-   
-   D_ENTER;
-   
-   ev = e_view_get_current_event();
-   if (!ev) D_RETURN;
-   e = ev->event;
-   ic = _data;
-   ic->view->select.down.x = _x;
-   ic->view->select.down.y = _y;
-   ic->state.clicked = 1;
-   e_view_icon_update_state(ic);
-   if (_b == 1)
-     {
-       if (e->double_click)
-         {
-            e_view_icon_exec(ic);
-            ic->state.just_executed = 1;
-         }
-       else
-         {
-            if (!ic->state.selected)
-              {
-                 if ((e->mods & mulit_select_mod))
-                   { 
-                      e_view_icon_select(ic);
-                   }
-                 else
-                   {
-                      e_view_deselect_all_except(ic);
-                      e_view_icon_select(ic);
-                   }
-                 ic->state.just_selected = 1;
-              }
-         }
-     }
-   else if (_b == 2)
-     {
-     }
-   else if (_b == 3)
-     {
-     }
-
-   D_RETURN;
-   UN(_e);
-   UN(_o);
-}
-
-static void
-e_icon_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
-{
-   E_Icon *ic;
-   Ecore_Event *ev;
-   Ecore_Event_Mouse_Up *e;
-   
-   D_ENTER;
-   
-   ev = e_view_get_current_event();
-   if (!ev) D_RETURN;
-   e = ev->event;
-   ic = _data;
-   if (ic->view->drag.started)
-     {
-       ic->state.clicked = 0;
-       ic->state.just_selected = 0;
-       e_view_icon_update_state(ic);
-       ecore_window_destroy(ic->view->drag.win);
-       ic->view->drag.started = 0;
-       D_RETURN;       
-     }
-   if (_b == 1)
-     {
-       if (ic->state.just_executed)
-         {
-            ic->state.just_executed = 0;
-         }
-       else
-         {
-            if ((e->mods & mulit_select_mod))
-              {
-                 if ((ic->state.selected) && (!ic->state.just_selected))
-                   e_view_icon_deselect(ic);
-              }
-            else
-              {
-                 e_view_deselect_all_except(ic);
-                 e_view_icon_select(ic);
-              }
-         }
-       ic->state.just_selected = 0;
-     }
-   ic->state.clicked = 0;
-   e_view_icon_update_state(ic);
-
-   D_RETURN;
-   UN(_e);
-   UN(_o);
-   UN(_x);
-   UN(_y);
-}
-
-static void
-e_icon_in_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
-{
-   E_Icon *ic;
-   
-   D_ENTER;
-   
-   ic = _data;
-   e_cursors_display_in_window(ic->view->win.main, "View_Icon");
-
-   D_RETURN;
-   UN(_e);
-   UN(_o);
-   UN(_b);
-   UN(_x);
-   UN(_y);
-}
-
-static void
-e_icon_out_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
-{
-   E_Icon *ic;
-   
-   ic = _data;
-   e_cursors_display_in_window(ic->view->win.main, "View");
-
-   D_RETURN;
-   UN(_e);
-   UN(_o);
-   UN(_b);
-   UN(_x);
-   UN(_y);
-}
-
-static void
-e_icon_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
-{
-   E_Icon *ic;
-   Ecore_Event *ev;
-   Ecore_Event_Mouse_Move *e;
-   
-   D_ENTER;
-   
-   ev = e_view_get_current_event();
-   if (!ev) D_RETURN;
-   e = ev->event;
-   ic = _data;
-   if (!ic->state.clicked) D_RETURN;
-   if (!ic->view->drag.started)
-     {
-       int dx, dy;
-       
-       dx = ic->view->select.down.x - _x;
-       dy = ic->view->select.down.y - _y;
-       if (dx < 0) dx = -dx;
-       if (dy < 0) dy = -dy;
-       if ((dx > 3) || (dy > 3))
-         {
-            Pixmap pmap, mask;
-            Evas_List l;
-            int x, y, xx, yy, rw, rh, downx, downy, wx, wy, ww, wh;
-            
-            /* find extents of icons to be dragged */
-            x = 999999999;
-            y = 999999999;
-            xx = -999999999;
-            yy = -999999999;
-            for (l = views; l; l = l->next)
-              {
-                 E_View *v;
-                 Evas_List ll;
-                 
-                 v = l->data;
-                 D("sel count %i\n", v->sel_count);
-                 if (v->sel_count > 0)
-                   {
-                      for (ll = v->icons; ll; ll = ll->next)
-                        {
-                           E_Icon *ic;
-                           
-                           ic = ll->data;
-                           if (ic->state.selected)
-                             {
-                                int ix, iy, iw, ih;
-                                
-                                ix = ic->view->scroll.x + ic->geom.x + v->location.x;
-                                iy = ic->view->scroll.y + ic->geom.y + v->location.y;
-                                iw = ic->geom.w;
-                                ih = ic->geom.h;
-                                if (ix < x) x = ix;
-                                if (iy < y) y = iy;
-                                if ((ix + iw) > xx) xx = ix + iw;
-                                if ((iy + ih) > yy) yy = iy + ih;
-                             }
-                        }
-                   }
-              }
-            ecore_window_get_geometry(0, NULL, NULL, &rw, &rh);
-            downx = ic->view->select.down.x + ic->view->location.x;
-            downy = ic->view->select.down.y + ic->view->location.y;
-            
-            wx = x;
-            ww = xx - x;
-            if (wx < - (rw - downx)) 
-              {
-                 wx = - (rw - downx);
-                 ww -= (wx - x);
-              }
-            if ((wx + ww) > (rw + downx))
-              ww = (rw + downx) - wx;
-            wy = y;
-            wh = yy - y;
-            if (wy < - (rh - downy)) 
-              {
-                 wy = - (rh - downy);
-                 wh -= (wy - y);
-              }
-            if ((wy + wh) > (rh + downy))
-              wh = (rh + downy) - wy;
-            
-            
-            ic->view->drag.x = wx + ic->view->location.x;
-            ic->view->drag.y = wy + ic->view->location.y;
-            ic->view->drag.offset.x = downx - ic->view->drag.x;
-            ic->view->drag.offset.y = downy - ic->view->drag.y;
-            
-            if ((ww < 1) || (wh < 1)) D_RETURN;
-            ic->view->drag.win = ecore_window_override_new(0, wx, wy, ww, wh);
-            pmap = ecore_pixmap_new(ic->view->drag.win, ww, wh, 0);
-            mask = ecore_pixmap_new(ic->view->drag.win, ww, wh, 1);
-              {
-                 Imlib_Image im;
-                 
-                 im = imlib_create_image(ww, wh);
-                 imlib_context_set_image(im);
-                 imlib_image_set_has_alpha(1);
-                 imlib_context_set_blend(1);
-                 imlib_image_clear();
-                  imlib_context_set_color_modifier(NULL);
-                 imlib_context_set_cliprect(0, 0, 0, 0);
-                 imlib_context_set_angle(0);
-                 
-                 for (l = views; l; l = l->next)
-                   {
-                      E_View *v;
-                      Evas_List ll;
-                      
-                      v = l->data;
-                      if (v->sel_count > 0)
-                        {
-                           for (ll = v->icons; ll; ll = ll->next)                            {
-                                E_Icon *ic;
-                                
-                                ic = ll->data;
-                                if (ic->state.selected)
-                                  {
-                                     double ix, iy;
-                                     int icx, icy;
-                                     Imlib_Image im2;
-                                     char icon[PATH_MAX];
-                                     
-                                     evas_get_geometry(ic->view->evas,
-                                                       ic->obj.icon,
-                                                       &ix, &iy, NULL, NULL);
-                                     icx = ix + v->location.x - wx;
-                                     icy = iy + v->location.y - wy;
-                                     if (!ic->info.icon)
-                                       {
-                                          D("EEEEEEEEEEK %s has no icon\n", ic->file);
-                                          D_RETURN;
-                                       }
-                                     if (ic->state.clicked)
-                                       {
-                                          sprintf(icon, "%s:/icon/clicked", ic->info.icon);
-                                       }
-                                     else if (ic->state.selected)
-                                       {
-                                          sprintf(icon, "%s:/icon/selected", ic->info.icon);
-                                       }
-                                     else
-                                       {
-                                          sprintf(icon, "%s:/icon/normal", ic->info.icon);
-                                       }
-                                     im2 = imlib_load_image(icon);
-                                     if (im2)
-                                       {
-                                          int iw, ih;
-                                          
-                                          imlib_context_set_image(im2);
-                                          iw = imlib_image_get_width();
-                                          ih = imlib_image_get_height();
-                                          imlib_context_set_image(im);
-                                          imlib_blend_image_onto_image(im2, 1,
-                                                                       0, 0, iw, ih,
-                                                                       icx, icy, iw, ih);
-                                          imlib_context_set_image(im2);
-                                          imlib_free_image();
-                                          imlib_context_set_image(im);
-                                       }
-                                     else
-                                       {
-                                          D("eek cant load\n");
-                                       }
-                                  }
-                             }
-                        }
-                   }
-                 imlib_context_set_image(im);
-                 if (ww * wh < (200 * 200)) imlib_context_set_dither_mask(1);
-                 else imlib_context_set_dither_mask(0);
-                 imlib_context_set_dither(1);
-                 imlib_context_set_drawable(pmap);
-                 imlib_context_set_mask(mask);
-                 imlib_context_set_blend(0);
-                 imlib_context_set_color_modifier(NULL);
-                 imlib_render_image_on_drawable(0, 0);
-                 imlib_free_image();
-              }
-            ecore_window_set_background_pixmap(ic->view->drag.win, pmap);
-            ecore_window_set_shape_mask(ic->view->drag.win, mask);
-            ecore_window_ignore(ic->view->drag.win);
-            ecore_window_raise(ic->view->drag.win);
-            ecore_window_show(ic->view->drag.win);
-            ecore_pixmap_free(pmap);
-            ecore_pixmap_free(mask);
-            ic->view->drag.started = 1;
-         }
-     }
-   if (ic->view->drag.started)
-     {
-       int x, y;
-       
-       x = _x - ic->view->drag.offset.x;
-       y = _y - ic->view->drag.offset.y;
-       ic->view->drag.x = x;
-       ic->view->drag.y = y;
-       ic->view->drag.update = 1;
-       ic->view->changed = 1;
-     }
-
-   D_RETURN;
-   UN(_e);
-   UN(_o);
-   UN(_b);
-}
 
 static void
 e_idle(void *data)
@@ -1879,220 +1356,6 @@ e_view_filter_file(E_View *v, char *file)
    UN(v);
 }
 
-static void
-e_view_icon_cleanup(E_Icon *ic)
-{
-   D_ENTER;
-   
-   /* FIXME: free stuff here! this leaks ... */
-
-   e_object_cleanup(E_OBJECT(ic));
-
-   D_RETURN;
-}
-
-E_Icon *
-e_view_icon_new(void)
-{
-   E_Icon *ic;
-   
-   D_ENTER;
-   
-   ic = NEW(E_Icon, 1);
-   ZERO(ic, E_Icon, 1);
-   
-   e_object_init(E_OBJECT(ic), (E_Cleanup_Func) e_view_icon_cleanup);
-
-   D_RETURN_(ic);
-}
-
-E_Icon *
-e_view_find_icon_by_file(E_View *view, char *file)
-{
-   Evas_List l;
-   
-   D_ENTER;
-   
-   for (l = view->icons; l; l = l->next)
-     {
-       E_Icon *ic;
-       
-       ic = l->data;
-       if ((ic) && (ic->file) && (file) && (!strcmp(ic->file, file)))
-         D_RETURN_(ic);
-     }
-   D_RETURN_(NULL);
-}
-
-void
-e_view_icon_show(E_Icon *ic)
-{
-   D_ENTER;
-
-   
-   if (ic->state.visible) D_RETURN;
-   ic->state.visible = 1;
-   if (!ic->obj.event1)
-     {
-       ic->obj.event1 = evas_add_rectangle(ic->view->evas);
-       ic->obj.event2 = evas_add_rectangle(ic->view->evas);
-       evas_set_color(ic->view->evas, ic->obj.event1, 0, 0, 0, 0);
-       evas_set_color(ic->view->evas, ic->obj.event2, 0, 0, 0, 0);
-       evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_DOWN, e_icon_down_cb, ic);
-       evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_UP, e_icon_up_cb, ic);
-       evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_IN, e_icon_in_cb, ic);
-       evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_OUT, e_icon_out_cb, ic);
-       evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_MOVE, e_icon_move_cb, ic);
-       evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_DOWN, e_icon_down_cb, ic);
-       evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_UP, e_icon_up_cb, ic);
-       evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_IN, e_icon_in_cb, ic);
-       evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_OUT, e_icon_out_cb, ic);
-       evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_MOVE, e_icon_move_cb, ic);
-     }
-   evas_set_layer(ic->view->evas, ic->obj.icon, 200);
-   e_text_set_layer(ic->obj.text, 200);
-   evas_set_layer(ic->view->evas, ic->obj.event1, 210);
-   evas_set_layer(ic->view->evas, ic->obj.event2, 210);
-   
-   evas_show(ic->view->evas, ic->obj.icon);
-   e_text_show(ic->obj.text);
-   evas_show(ic->view->evas, ic->obj.event1);
-   evas_show(ic->view->evas, ic->obj.event2);
-
-   D_RETURN;
-}
-
-void
-e_view_icon_hide(E_Icon *ic)
-{
-   D_ENTER;
-   
-   if (!ic->state.visible) D_RETURN;
-   ic->state.visible = 0;
-   evas_hide(ic->view->evas, ic->obj.icon);
-   e_text_hide(ic->obj.text);
-   evas_hide(ic->view->evas, ic->obj.event1);
-   evas_hide(ic->view->evas, ic->obj.event2);
-
-   D_RETURN;
-}
-
-void
-e_view_icon_apply_xy(E_Icon *ic)
-{
-   D_ENTER;
-   
-   /* threse calc icon extents for: */
-   /*  [I]  */
-   /*  Ig   */
-   /* [txt] */
-   
-   if (ic->geom.text.w > ic->geom.icon.w) ic->geom.w = ic->geom.text.w;
-   else ic->geom.w = ic->geom.icon.w;
-   ic->geom.h = ic->geom.icon.h + ic->geom.text.h + ic->view->spacing.icon.g;
-   
-   evas_resize(ic->view->evas, ic->obj.event1, 
-              ic->geom.icon.w, ic->geom.icon.h);
-   evas_resize(ic->view->evas, ic->obj.event2, 
-              ic->geom.text.w, ic->geom.text.h);
-   evas_move(ic->view->evas, ic->obj.event1,
-            ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.icon.w) / 2),
-            ic->view->scroll.y + ic->geom.y);
-   evas_move(ic->view->evas, ic->obj.event2,
-            ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.text.w) / 2),
-            ic->view->scroll.y + ic->geom.y + ic->geom.icon.h + ic->view->spacing.icon.g);          
-   evas_move(ic->view->evas, ic->obj.icon, 
-            ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.icon.w) / 2), 
-            ic->view->scroll.y + ic->geom.y);
-   e_text_move(ic->obj.text,
-              ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.text.w) / 2), 
-              ic->view->scroll.y + ic->geom.y + ic->geom.icon.h + ic->view->spacing.icon.g);
-   if (ic->obj.sel.under.icon)
-     {
-       int pl, pr, pt, pb;
-       
-       ebits_get_insets(ic->obj.sel.under.icon, &pl, &pr, &pt, &pb);
-       ebits_move(ic->obj.sel.under.icon, 
-                  ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.icon.w) / 2) - pl,
-                  ic->view->scroll.y + ic->geom.y - pt);
-       ebits_resize(ic->obj.sel.under.icon,
-                    ic->geom.icon.w + pl + pr, ic->geom.icon.h + pt + pb);
-       ebits_show(ic->obj.sel.under.icon);
-     }
-   if (ic->obj.sel.under.text)
-     {
-       int pl, pr, pt, pb;
-       
-       ebits_get_insets(ic->obj.sel.under.text, &pl, &pr, &pt, &pb);
-       ebits_move(ic->obj.sel.under.text, 
-                  ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.text.w) / 2) - pl, 
-                  ic->view->scroll.y + ic->geom.y + ic->geom.icon.h + ic->view->spacing.icon.g - pt);
-       ebits_resize(ic->obj.sel.under.text,
-                    ic->geom.text.w + pl  + pr, ic->geom.text.h + pt + pb);
-       ebits_show(ic->obj.sel.under.text);
-     }
-   if (ic->obj.sel.over.icon)
-     {
-       int pl, pr, pt, pb;
-       
-       ebits_get_insets(ic->obj.sel.over.icon, &pl, &pr, &pt, &pb);
-       ebits_move(ic->obj.sel.over.icon, 
-                  ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.icon.w) / 2) - pl,
-                  ic->view->scroll.y + ic->geom.y - pt);
-       ebits_resize(ic->obj.sel.over.icon,
-                    ic->geom.icon.w + pl + pr, ic->geom.icon.h + pt + pb);
-       ebits_show(ic->obj.sel.over.icon);
-     }
-   if (ic->obj.sel.over.text)
-     {
-       int pl, pr, pt, pb;
-       
-       ebits_get_insets(ic->obj.sel.over.text, &pl, &pr, &pt, &pb);
-       ebits_move(ic->obj.sel.over.text, 
-                  ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.text.w) / 2) - pl, 
-                  ic->view->scroll.y + ic->geom.y + ic->geom.icon.h + ic->view->spacing.icon.g - pt);
-       ebits_resize(ic->obj.sel.over.text,
-                    ic->geom.text.w + pl  + pr, ic->geom.text.h + pt + pb);
-       ebits_show(ic->obj.sel.over.text);
-     }
-   if ((ic->geom.x != ic->prev_geom.x) || (ic->geom.y != ic->prev_geom.y))
-     {
-       ic->q.write_xy = 1;
-       e_view_queue_icon_xy_record(ic->view);
-     }
-   if (ic->geom.x != ic->prev_geom.x) ic->view->extents.valid = 0;
-   else if (ic->geom.y != ic->prev_geom.y) ic->view->extents.valid = 0;
-   else if (ic->geom.w != ic->prev_geom.w) ic->view->extents.valid = 0;
-   else if (ic->geom.h != ic->prev_geom.h) ic->view->extents.valid = 0;
-   
-   ic->prev_geom = ic->geom;
-   ic->prev_geom.x = ic->geom.x;
-   ic->prev_geom.y = ic->geom.y;
-   ic->prev_geom.w = ic->geom.w;
-   ic->prev_geom.h = ic->geom.h;
-
-   D_RETURN;
-}
-
-
-void      
-e_view_icon_check_permissions(E_Icon *ic)
-{
-  D_ENTER;
-
-  if (!ic || !ic->info.mime.base || ic->stat.st_ino == 0)
-    D_RETURN;
-
-  if (!strcmp(ic->info.mime.base, "dir"))
-    {
-      if (e_file_can_exec(&ic->stat))
-       evas_set_color(ic->view->evas, ic->obj.icon, 255, 255, 255, 255);
-      else
-       evas_set_color(ic->view->evas, ic->obj.icon, 128, 128, 128, 128);
-    } 
-
-  D_RETURN;
-}
 
 
 static int
@@ -2160,7 +1423,7 @@ e_view_arrange(E_View *v)
          }
        ic->geom.x = x;
        ic->geom.y = y;
-       e_view_icon_apply_xy(ic);
+       e_icon_apply_xy(ic);
        x += ic->geom.w + v->spacing.icon.s;
      }
    
@@ -2230,137 +1493,6 @@ e_view_queue_resort(E_View *v)
    D_RETURN;
 }
 
-void
-e_view_icon_initial_show(E_Icon *ic)
-{
-   D_ENTER;
-   
-   /* check if we have enuf info and we havent been shown yet */
-   if (!ic->info.icon) D_RETURN;
-   if (ic->state.visible) D_RETURN;
-   
-   /* first. lets figure out the size of the icon */
-   evas_get_image_size(ic->view->evas, ic->obj.icon, 
-                      &(ic->geom.icon.w), &(ic->geom.icon.h));
-     {
-       double tw, th;
-       
-       e_text_get_geometry(ic->obj.text, NULL, NULL, &tw, &th);
-       ic->geom.text.w = (int)tw;
-       ic->geom.text.h = (int)th;
-     }
-   
-   /* now lets allocate space for it if we need to */
-   ic->geom.x = 999999;
-   ic->geom.y = 999999;
-   
-   /* if needed queue a tiemout for a resort */
-   e_view_queue_resort(ic->view);
-   
-   /* actually show the icon */
-   e_view_icon_apply_xy(ic);
-   e_view_icon_show(ic);
-
-   D_RETURN;
-}
-
-void
-e_view_icon_set_mime(E_Icon *ic, char *base, char *mime)
-{
-   int diff = 0;
-   
-   D_ENTER;
-   
-   if (!ic->info.mime.base) diff = 1;
-   if (!ic->info.mime.type) diff = 1;
-   if ((ic->info.mime.base) && (strcmp(ic->info.mime.base, base))) diff = 1;
-   if ((ic->info.mime.type) && (strcmp(ic->info.mime.base, mime))) diff = 1;
-   if (!diff) D_RETURN;
-   if (ic->info.mime.base) free(ic->info.mime.base);
-   if (ic->info.mime.type) free(ic->info.mime.type);
-   ic->info.mime.base = NULL;
-   ic->info.mime.type = NULL;
-   ic->info.mime.base = strdup(base);
-   ic->info.mime.type = strdup(mime);
-   
-   D("%40s: %s/%s\n", ic->file, base, mime);
-   
-   /* effect changes here */
-   if (ic->info.custom_icon) 
-     {
-       if (ic->info.icon) free(ic->info.icon);
-       ic->info.icon = NULL;
-       ic->info.icon = strdup(ic->info.custom_icon);
-       evas_set_image_file(ic->view->evas, ic->obj.icon, ic->info.custom_icon);
-       e_view_queue_resort(ic->view);  
-       D_RETURN;
-     }
-   /* find an icon */
-     {
-       char icon[PATH_MAX];
-       char type[PATH_MAX];    
-       char *p;
-       int done = 0;
-       
-       strcpy(type, ic->info.mime.type);
-       for (p = type; *p; p++) 
-         {
-            if (*p == '/') *p = '-';
-         }
-       do 
-         {
-            sprintf(icon, "%s/data/icons/%s/%s.db", PACKAGE_DATA_DIR,
-                    ic->info.mime.base, type);
-            if (e_file_exists(icon))
-              {
-                 done = 1;
-                 break;
-              }
-            p = strrchr(type, '-');
-            if (p) *p = 0;
-         }
-       while (p);
-       if (!done)
-         {
-            if (!e_file_exists(icon))
-              {
-                 sprintf(icon, "%s/data/icons/%s/default.db", PACKAGE_DATA_DIR,
-                         ic->info.mime.base);
-                 if (!e_file_exists(icon))
-                   sprintf(icon, "%s/data/icons/unknown/default.db", PACKAGE_DATA_DIR);
-              }
-         }
-       ic->info.icon = strdup(icon);
-     }
-
-   e_view_icon_update_state(ic);
-
-   D_RETURN;
-}
-
-void
-e_view_icon_set_link(E_Icon *ic, char *link)
-{
-   D_ENTER;
-   
-   if ((!link) && (ic->info.link))
-     {
-       free(ic->info.link);
-       ic->info.link = NULL;
-       /* effect changes here */
-     }
-   else if (link)
-     {
-       if ((ic->info.link) && (!strcmp(ic->info.link, link)))
-         {
-            free(ic->info.link);
-            ic->info.link = strdup(link);
-            /* effect changes here */
-         }
-     }
-
-   D_RETURN;
-}
 
 void
 e_view_file_added(int id, char *file)
@@ -2378,11 +1510,11 @@ e_view_file_added(int id, char *file)
    e_iconbar_file_add(v, file);
    /* filter files here */
    if (!e_view_filter_file(v, file)) D_RETURN;
-   if (!e_view_find_icon_by_file(v, file))
+   if (!e_icon_find_by_file(v, file))
      {
        E_Icon *ic;
        
-       ic = e_view_icon_new();
+       ic = e_icon_new();
        ic->view = v;
        ic->file = strdup(file);
        ic->changed = 1;
@@ -2410,10 +1542,10 @@ e_view_file_deleted(int id, char *file)
      {
        E_Icon *ic;
        
-       ic = e_view_find_icon_by_file(v, file);
+       ic = e_icon_find_by_file(v, file);
        if (ic)
          {
-            e_view_icon_hide(ic);
+            e_icon_hide(ic);
             e_object_unref(E_OBJECT(ic));
             v->icons = evas_list_remove(v->icons, ic);
             v->changed = 1;
@@ -2441,7 +1573,7 @@ e_view_file_changed(int id, char *file)
      {
        E_Icon *ic;
        
-       ic = e_view_find_icon_by_file(v, file);
+       ic = e_icon_find_by_file(v, file);
        if (ic)
          {
          }
@@ -2467,7 +1599,7 @@ e_view_file_moved(int id, char *file)
      {
        E_Icon *ic;
        
-       ic = e_view_find_icon_by_file(v, file);
+       ic = e_icon_find_by_file(v, file);
        if (ic)
          {
          }
@@ -2881,7 +2013,7 @@ e_view_handle_fs(EfsdEvent *ev)
 
                  if ((v) && (file))
                    {
-                      ic = e_view_find_icon_by_file(v, file);
+                      ic = e_icon_find_by_file(v, file);
                       if ((ic) &&
                           (ev->efsd_reply_event.data))
                         {
@@ -2903,14 +2035,14 @@ e_view_handle_fs(EfsdEvent *ev)
                                 strcpy(mime, "unknown");
                              }
 /*                         D("MIME: %s\n", m);
-*/                         e_view_icon_set_mime(ic, base, mime);
+*/                         e_icon_set_mime(ic, base, mime);
 
                            /* Try to update the GUI according to the file permissions.
                               It's just a try because we need to have the file's stat
                               info as well.  --cK.
                            */
-                           e_view_icon_check_permissions(ic);
-                           e_view_icon_initial_show(ic);
+                           e_icon_check_permissions(ic);
+                           e_icon_initial_show(ic);
                         }
                    }
               }
@@ -2933,12 +2065,12 @@ e_view_handle_fs(EfsdEvent *ev)
 
                  if (v)
                    {
-                     ic = e_view_find_icon_by_file(v, e_file_get_file(efsd_reply_filename(ev)));
+                     ic = e_icon_find_by_file(v, e_file_get_file(efsd_reply_filename(ev)));
 
                      if (ic)
                        {
                          ic->stat = *((struct stat*)efsd_reply_data(ev));
-                         e_view_icon_check_permissions(ic);
+                         e_icon_check_permissions(ic);
                        }                       
                    }
               }
@@ -2959,11 +2091,11 @@ e_view_handle_fs(EfsdEvent *ev)
                  v = e_view_find_by_monitor_id(efsd_reply_id(ev));
                  if ((v) && (file))
                    {
-                      ic = e_view_find_icon_by_file(v, file);
+                      ic = e_icon_find_by_file(v, file);
                       if ((ic) &&
                           (ev->efsd_reply_event.data))
-                        e_view_icon_set_link(ic, (char*)efsd_reply_data(ev));
-                      e_view_icon_initial_show(ic);
+                        e_icon_set_link(ic, (char*)efsd_reply_data(ev));
+                      e_icon_initial_show(ic);
                    }
               }
             break;
index 719aaae..e0fe244 100644 (file)
@@ -5,16 +5,19 @@
 #include "background.h"
 #include "scrollbar.h"
 #include "fs.h"
-#include "text.h"
 #include "iconbar.h"
 #include "object.h"
+#include "icons.h"
 
 #ifndef E_VIEW_TYPEDEF
 #define E_VIEW_TYPEDEF
-typedef struct _E_View                E_View;
+typedef struct _E_View    E_View;
 #endif
 
-typedef struct _E_Icon                E_Icon;
+#ifndef E_ICON_TYPEDEF
+#define E_ICON_TYPEDEF
+typedef struct _E_Icon    E_Icon;
+#endif
 
 #ifndef E_ICONBAR_TYPEDEF
 #define E_ICONBAR_TYPEDEF
@@ -22,7 +25,6 @@ typedef struct _E_Iconbar E_Iconbar;
 #endif
 
 
-
 struct _E_View
 {
    E_Object               o;
@@ -145,66 +147,6 @@ struct _E_View
 };
 
 
-struct _E_Icon
-{
-   E_Object o;
-   
-   char        *file;
-   struct stat  stat;
-   
-   E_View *view;
-   
-   struct {
-      char *icon;
-      char *custom_icon;
-      char *link;
-      struct {
-        char *base;
-        char *type;
-      } mime;
-   } info;
-   
-   struct {
-      Evas_Object  icon;
-      Evas_Object  event1;
-      Evas_Object  event2;
-      E_Text      *text;
-      struct {
-        struct {
-           Ebits_Object icon;
-           Ebits_Object text;
-        } over, under;
-      } sel;
-   } obj;
-   
-   struct {
-      int hilited;
-      int clicked;
-      int selected;
-      int running;
-      int disabled;
-      int visible;
-      int just_selected;
-      int just_executed;
-   } state;
-   
-   struct {
-      int x, y, w, h;
-      struct {
-        int w, h;
-      } icon;
-      struct {
-        int w, h;
-      } text;
-   } geom, prev_geom;      
-   
-   struct {
-      int write_xy;
-   } q;
-   
-   int     changed;   
-};
-
 
 /**
  * e_view_init - View event handlers initialization.
@@ -227,34 +169,13 @@ void      e_view_scroll_by(E_View *v, int sx, int sy);
 void      e_view_scroll_to_percent(E_View *v, double psx, double psy);
 void      e_view_get_viewable_percentage(E_View *v, double *vw, double *vh);
 void      e_view_get_position_percentage(E_View *v, double *vx, double *vy);
-void      e_view_icon_update_state(E_Icon *ic);
-void      e_view_icon_invert_selection(E_Icon *ic);
-void      e_view_icon_select(E_Icon *ic);
-void      e_view_icon_deselect(E_Icon *ic);
 
-/**
- * e_view_icon_exec - handles execution paths when user activates an icon
- * @ic:   The activated icon
- *
- * This function takes care of opening views when the user activates a
- * directory, launching commands when an executable is activated etc.
- */
-void      e_view_icon_exec(E_Icon *ic);
-
-void      e_view_icon_initial_show(E_Icon *ic);
-void      e_view_icon_set_mime(E_Icon *ic, char *base, char *mime);
-void      e_view_icon_set_link(E_Icon *ic, char *link);
-E_Icon   *e_view_icon_new(void);
-E_Icon   *e_view_find_icon_by_file(E_View *view, char *file);
-void      e_view_icon_show(E_Icon *ic);
-void      e_view_icon_hide(E_Icon *ic);
-void      e_view_icon_apply_xy(E_Icon *ic);
-void      e_view_icon_check_permissions(E_Icon *ic);
 void      e_view_resort_alphabetical(E_View *v);
 void      e_view_arrange(E_View *v);
 void      e_view_resort(E_View *v);
-void      e_view_queue_geometry_record(E_View *v);
 void      e_view_geometry_record(E_View *v);    
+void      e_view_queue_geometry_record(E_View *v);
+void      e_view_queue_icon_xy_record(E_View *v);
 void      e_view_queue_resort(E_View *v);
 void      e_view_file_added(int id, char *file);
 void      e_view_file_deleted(int id, char *file);