From a708bdfd42c9db3965a2d0c36ca3902ba540baa2 Mon Sep 17 00:00:00 2001 From: cpk Date: Sat, 3 Nov 2001 14:55:21 +0000 Subject: [PATCH] * More cleanups. I took out everything related only to icon handling from the view code, and put it into icons.[ch]. * Added the relative desktop move path from Alan Schmitt. SVN revision: 5616 --- AUTHORS | 2 + data/config/behavior/default/actions.db | Bin 86016 -> 114688 bytes data/config/behavior/default/grabs.db | Bin 12288 -> 12288 bytes data/config/behavior/default/settings.db | Bin 12288 -> 12288 bytes data/scripts/build_db.sh | 16 + doc/manual.raw | 1 + src/Makefile.am | 3 +- src/actions.c | 34 + src/actions.h | 1 - src/config.c | 21 +- src/e.h | 11 - src/embed.c | 1 + src/file.c | 1 + src/file.h | 2 - src/fs.c | 1 + src/fs.h | 1 - src/globals.c | 7 + src/globals.h | 8 + src/guides.h | 2 - src/icons.c | 891 +++++++++++++++++++++- src/icons.h | 102 +++ src/main.c | 1 + src/menu.c | 1 + src/place.c | 1 + src/resist.c | 1 + src/scrollbar.c | 1 + src/text.c | 1 + src/util.h | 10 + src/view.c | 910 +---------------------- src/view.h | 95 +-- 30 files changed, 1121 insertions(+), 1005 deletions(-) create mode 100644 src/globals.c create mode 100644 src/globals.h create mode 100644 src/icons.h diff --git a/AUTHORS b/AUTHORS index 2b3a239aa..b54297b7c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,5 @@ The Rasterman Christian Kreibich Burra +Graham MacDonald +Alan Schmitt diff --git a/data/config/behavior/default/actions.db b/data/config/behavior/default/actions.db index 6ae38d604bbef5ea6710ae79d8fee288f67fb4e1..851edc4cc0582e5f569a690ac646ea86221f99ee 100644 GIT binary patch delta 1007 zcmaJ=YeK?^bQ!me*FAMfPcKQD$OLbU`z%egsA=TeU1V-DfaJ(xRXu z)J|bkb`y%qK>Gv)gGes-PV4U^laZn%ETtIxJ1x92^F60i& zH1!@{$1XgNZFm@W<4z1>6)wXiSco$*6J0n8W&AFGkt1@y{78PFhb_xxp7kP&e@U4l z(5HV+b+M8Ol8REo2a3=WdPrC45}l%x)J$PoORK4r7E?Y=r*ul95hPIrpW`jOffuk7 zkKjSvf%WJ|AC}@G%tKZ8roRLJJ7VT#*)RCS?6i2liC?Th-Z{06*Qo7=Vky9t9B$kL zJ0S!Cy(_2JY-RpxjY+DvQu7C@Lu#I+>TyD}E zi%`yFA+2`!CAS*%)_OOEST6gkl7$I|Wl{!Lmb4q^K@m)X4E<{Q8Z-ac zZ($z(DdJ4X^YE@@r@o=$>}bPWsh2Ck?Z&6@5UxS5ej=Cx|EAm*QN-QcCcFM?i?URV z7UoLd9_oY3a1KtxerSPu2MZkl=1FN@+CN|-%7qOh${GCc9jY_2aZS@>`W0R+m^R7s~m1 zk+&S!SVT+03H)@wb>XR~voqFWxT=*maSu3MYGlF2^EBxR5)aq1YPjyQD=QfHi+ zV$?M@PNT<2se`112=&t=dO$bm3UyKkiSM$F#KRJQo?^00_&afBpsrfu-KkR+4rwF} zHR5zg-^6G5L<97Sp3xm4*Dd6Z(^1+>yJ$1j&`MfC3#fo5QznfeqM!J!r^dn#$z88( OEM|Bo`zKiP)oyziLRUkxqORH}XT1<|Y(LR~mnn)FFAmyv1v$PF80Y(zJ8 zGdt9uE(UE@pk9nRfki{i|BzLFVA!FT)a;rVNBdEPgPYL z2q9)2{D)D$EjlYkT&t;JGVHQ&u$J5w@UD%0x zaTjjH4Y&%e_#1vg5$53;JchfFff2Y0afm@L1fUZ-q<`%vCPH-;;)wm6n6gE*v(q#w z-q_RH!Zcl}tp|!C;uux-leAEs!kA(SHo(rv`_8Ef;T%d6EIHj zaek9umq`zB;cd6cy!UXK;v>g|>Km00W-}Gy`=UkmA0Mk!JftMl@MYs7TVQY5Ynchx zGU2nE#r8|hvUIVjOKBq?g*tmpW{Z267H0Yre$3Z5=yBnON{4wBH*msB>?@mN1(_+j zm|kwx-ZQ$59qJ373Jsm?=)Dl78s)T7RIkCweVo2rN8Ot0q_Oe?+{4{6xirpdC>@NR Yr{wNB{r; diff --git a/data/config/behavior/default/grabs.db b/data/config/behavior/default/grabs.db index dbae82edb35b8d0493255a8497d2be595a4dc5d3..c2f40453c5f7cd5026458ac7b60ddf94fc324966 100644 GIT binary patch delta 32 kcmZojXh@i_m!I)3KLZ#rvs*vDS+Utr!G?b`hrkbc0Hi<()Bpeg delta 32 kcmZojXh@i_m!J8cDFYaA2wAUR)U?@9!G?b`hrkbc0HhxYtN;K2 diff --git a/data/config/behavior/default/settings.db b/data/config/behavior/default/settings.db index 1e9051d6f0b2081a6a5d23dc199771ed76a3d43f..efbfb7aafaec0f14dde3436a32c889a96cc01c0c 100644 GIT binary patch delta 34 mcmZojXh@i_m!I)37XuhDvs*vDS-$b2Ise1}*3BFOKjZparams) + 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) { diff --git a/src/actions.h b/src/actions.h index f8ee9671c..29a25db97 100644 --- a/src/actions.h +++ b/src/actions.h @@ -1,7 +1,6 @@ #ifndef E_ACTIONS_H #define E_ACTIONS_H -#include "e.h" #include "object.h" typedef struct _E_Action E_Action; diff --git a/src/config.c b/src/config.c index 7aaf5e211..c6bc8aeab 100644 --- a/src/config.c +++ b/src/config.c @@ -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 8630a9274..dfd816d5f 100644 --- 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 diff --git a/src/embed.c b/src/embed.c index 7ae6dfd64..9dc97a971 100644 --- a/src/embed.c +++ b/src/embed.c @@ -1,5 +1,6 @@ #include "debug.h" #include "embed.h" +#include "util.h" typedef struct _Embed Embed_Private; diff --git a/src/file.c b/src/file.c index 1ce3e8063..7d1bb3651 100644 --- a/src/file.c +++ b/src/file.c @@ -1,3 +1,4 @@ +#include "e.h" #include "debug.h" #include "file.h" #include "util.h" diff --git a/src/file.h b/src/file.h index 0fb3f4886..4bb4c141a 100644 --- a/src/file.h +++ b/src/file.h @@ -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); diff --git a/src/fs.c b/src/fs.c index d31e06903..c5c8ac168 100644 --- 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; diff --git a/src/fs.h b/src/fs.h index 31f248b34..d56f94a8e 100644 --- a/src/fs.h +++ b/src/fs.h @@ -2,7 +2,6 @@ #define E_FS_H #include -#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 index 000000000..3061d0b19 --- /dev/null +++ b/src/globals.c @@ -0,0 +1,7 @@ +#include +#include + + +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 index 000000000..53aaad953 --- /dev/null +++ b/src/globals.h @@ -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 diff --git a/src/guides.h b/src/guides.h index 25176dcc2..15c4c143b 100644 --- a/src/guides.h +++ b/src/guides.h @@ -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 */ diff --git a/src/icons.c b/src/icons.c index 1c816a6a0..c0109a065 100644 --- a/src/icons.c +++ b/src/icons.c @@ -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 index 000000000..b8879360f --- /dev/null +++ b/src/icons.h @@ -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 diff --git a/src/main.c b/src/main.c index 6cbbb8509..700a32f19 100644 --- a/src/main.c +++ b/src/main.c @@ -14,6 +14,7 @@ #include "view.h" #include "place.h" #include "iconbar.h" +#include "util.h" #ifdef USE_FERITE # include "e_ferite.h" diff --git a/src/menu.c b/src/menu.c index 43e238c78..ab92e343b 100644 --- a/src/menu.c +++ b/src/menu.c @@ -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; diff --git a/src/place.c b/src/place.c index 8fe44c1c9..8426f3746 100644 --- a/src/place.c +++ b/src/place.c @@ -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); diff --git a/src/resist.c b/src/resist.c index 9fe28678e..37f7acf0a 100644 --- a/src/resist.c +++ b/src/resist.c @@ -2,6 +2,7 @@ #include "resist.h" #include "config.h" #include "desktops.h" +#include "util.h" void e_resist_border(E_Border *b) diff --git a/src/scrollbar.c b/src/scrollbar.c index 73eb89949..131925cfc 100644 --- a/src/scrollbar.c +++ b/src/scrollbar.c @@ -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); diff --git a/src/text.c b/src/text.c index 6a25e90af..83543af68 100644 --- a/src/text.c +++ b/src/text.c @@ -1,5 +1,6 @@ #include "debug.h" #include "text.h" +#include "util.h" E_Text * e_text_new(Evas evas, char *text, char *class) diff --git a/src/util.h b/src/util.h index e00b3dad6..0d9ee5b6b 100644 --- a/src/util.h +++ b/src/util.h @@ -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 diff --git a/src/view.c b/src/view.c index efdc53b97..8153b036e 100644 --- a/src/view.c +++ b/src/view.c @@ -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" @@ -12,21 +10,13 @@ #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; diff --git a/src/view.h b/src/view.h index 719aaaeb7..e0fe2448a 100644 --- a/src/view.h +++ b/src/view.h @@ -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);