Switched the layout over to using one bits file for layout, separate ones for element graphics (scrollbars / iconbars / etc). This allows more flexible (and cleaner) layout.

Instead of /path/.e_iconbar.bits.db, now uses /path/.e_layout/iconbar.bits.db.
Custom scrollbars can be placed in the .e_layout directory as well.

I should probably move the background db into here also, any objections?

So, to get your iconbar again, move the .e_iconbar[.bits].db to .e_layout/iconbar[.bits].db


SVN revision: 6034
This commit is contained in:
rephorm 2002-03-04 22:00:16 +00:00 committed by rephorm
parent 9777a14e73
commit ce6d128739
8 changed files with 491 additions and 154 deletions

View File

@ -80,6 +80,7 @@ enlightenment_SOURCES = \
e_file.h e_file.c \
e_view_model.h e_view_model.c \
e_view_machine.h e_view_machine.c \
view_layout.h view_layout.c \
e.h
enlightenment_LDADD = @evas_libs@ @edb_libs@ @ebits_libs@ @ecore_libs@ @efsd_libs@ @ebg_libs@ @ferite_libs@ -lm -lc $(INTLLIBS)

View File

@ -22,6 +22,7 @@ static char cfg_cursors_dir[PATH_MAX] = "";
static char cfg_backgrounds_dir[PATH_MAX] = "";
static char cfg_fonts_dir[PATH_MAX] = "";
static char cfg_epplets_dir[PATH_MAX] = "";
static char cfg_layout_dir[PATH_MAX] = "";
char *
e_config_get(char *type)
@ -73,9 +74,13 @@ e_config_get(char *type)
E_CONF("images", cfg_images_dir, PACKAGE_DATA_DIR "/data/images/");
E_CONF("cursors", cfg_cursors_dir, PACKAGE_DATA_DIR "/data/cursors/");
E_CONF("backgrounds", cfg_backgrounds_dir,
PACKAGE_DATA_DIR "/data/backgrounds/");
E_CONF("fonts", cfg_fonts_dir, PACKAGE_DATA_DIR "/data/fonts/");
E_CONF("epplets", cfg_epplets_dir, PACKAGE_DATA_DIR "/data/epplets/");
PACKAGE_DATA_DIR"/data/backgrounds/");
E_CONF("fonts", cfg_fonts_dir,
PACKAGE_DATA_DIR"/data/fonts/");
E_CONF("epplets", cfg_epplets_dir,
PACKAGE_DATA_DIR"/data/epplets/");
E_CONF("layout", cfg_layout_dir,
PACKAGE_DATA_DIR"/data/layout/");
D_RETURN_("");
}

View File

@ -580,12 +580,12 @@ e_view_model_file_added(int id, char *file)
snprintf(buf, PATH_MAX, "background_reload:%s", m->dir);
ecore_add_event_timer(buf, 0.5, e_view_model_bg_reload_timeout, 0, m);
}
else if ((!strcmp(".e_iconbar.db", file)) ||
/*else if ((!strcmp(".e_iconbar.db", file)) ||
(!strcmp(".e_iconbar.bits.db", file)))
{
snprintf(buf, PATH_MAX, "iconbar_reload:%s", m->dir);
ecore_add_event_timer(buf, 0.5, e_view_model_ib_reload_timeout, 0, m);
}
}*/
else if (file[0] != '.')
{
f = e_file_new(file);
@ -620,7 +620,7 @@ e_view_model_file_deleted(int id, char *file)
{
e_view_model_set_default_background(m);
}
else if ((!strcmp(".e_iconbar.db", file)) ||
/*else if ((!strcmp(".e_iconbar.db", file)) ||
(!strcmp(".e_iconbar.bits.db", file)))
{
for (l = m->views; l; l = l->next)
@ -630,7 +630,7 @@ e_view_model_file_deleted(int id, char *file)
e_object_unref(E_OBJECT(v->iconbar));
v->iconbar = NULL;
}
}
}*/
else if (file[0] != '.')
{
for (l = m->views; l; l = l->next)

View File

@ -5,6 +5,7 @@
#include "border.h"
#include "file.h"
#include "icons.h"
#include "view_layout.h"
static E_Config_Base_Type *cf_iconbar = NULL;
static E_Config_Base_Type *cf_iconbar_icon = NULL;
@ -146,6 +147,7 @@ e_iconbar_cleanup(E_Iconbar * ib)
/* free up our ebits */
if (ib->bit)
ebits_free(ib->bit);
/* if we have any icons... */
if (ib->icons)
{
@ -234,9 +236,10 @@ e_iconbar_new(E_View * v)
D_ENTER;
D("new iconbar\n");
/* first we want to load the iconbar data itself - ie the config info */
/* for what icons we have and what they execute */
snprintf(buf, PATH_MAX, "%s/.e_iconbar.db", v->model->dir);
snprintf(buf, PATH_MAX, "%s/.e_layout/iconbar.db", v->model->dir);
/* use the config system to simply load up the db and start making */
/* structs and lists and stuff for us... we told it how to in init */
ib = e_config_load(buf, "", cf_iconbar);
@ -255,7 +258,10 @@ e_iconbar_new(E_View * v)
e_db_flush();
/* no iconbar config loaded ? return NULL */
if (!ib)
D_RETURN_(NULL);
{
D("no config loaded, return null\n");
D_RETURN_(NULL);
}
/* now that the config system has doe the loading. we need to init the */
/* object and set up ref counts and free method */
@ -283,11 +289,13 @@ e_iconbar_new(E_View * v)
/* now we need to load up a bits file that tells us where in the view the */
/* iconbar is meant to go. same place. just a slightly different name */
snprintf(buf, PATH_MAX, "%s/.e_iconbar.bits.db", v->model->dir);
snprintf(buf, PATH_MAX, "%s/.e_layout/iconbar.bits.db", v->model->dir);
ib->bit = ebits_load(buf);
/* we didn't find one? */
if (!ib->bit)
{
D("bits not loaded, cleanup and return null\n");
/* unref the iconbar (and thus it will get freed and all icons in it */
e_object_unref(E_OBJECT(ib));
/* return NULL - no iconbar worth doing here if we don't know where */
@ -308,6 +316,7 @@ e_iconbar_new(E_View * v)
/* aaah. our nicely constructed iconbar data struct with all the goodies */
/* we need. return it. she's ready for use. */
D("iconbar created!\n");
D_RETURN_(ib);
}
@ -373,9 +382,10 @@ void
e_iconbar_realize(E_Iconbar * ib)
{
Evas_List l;
double x, y, w, h;
D_ENTER;
D("realize iconbar\n");
/* create clip object */
ib->clip = evas_add_rectangle(ib->view->evas);
evas_set_color(ib->view->evas, ib->clip, 255, 255, 255, 255);
@ -390,8 +400,8 @@ e_iconbar_realize(E_Iconbar * ib)
/* the path of the key to the image memebr - that is actually */
/* a lump of image data inlined in the iconbar db - so the icons */
/* themselves follow the iconbar wherever it goes */
snprintf(buf, PATH_MAX, "%s/.e_iconbar.db:%s", ib->view->model->dir,
ic->image_path);
snprintf(buf, PATH_MAX, "%s/.e_layout/iconbar.db:%s",
ib->view->model->dir, ic->image_path);
/* add the icon image object */
ic->image = evas_add_image_from_file(ib->view->evas, buf);
/* add an imlib image so we can save it later */
@ -439,7 +449,7 @@ e_iconbar_realize(E_Iconbar * ib)
/* but fixes the iconbar so its the size of the view, in the right */
/* place and arranges the icons in their right spots */
e_iconbar_fix(ib);
D("realized!\n");
D_RETURN;
}
@ -501,16 +511,24 @@ void
e_iconbar_fix(E_Iconbar * ib)
{
Evas_List l;
double x, y, w, h;
double ix, iy, aw, ah;
D_ENTER;
/* move the ebit to 0,0 */
ebits_move(ib->bit, 0, 0);
/* resize it to fill the whole view. the internal geometry of the */
/* ebit itself will determine where things woudl go. we just tell */
/* the ebit where in the canvas its allowed to exist */
ebits_resize(ib->bit, ib->view->size.w, ib->view->size.h);
/* get geometry from layout */
if (!e_view_layout_get_element_geometry(ib->view->layout, "Iconbar",
&x, &y, &w, &h))
{
D("Error: no geometry for iconbar, must not exist, clean it up.\n");
e_object_unref(ib);
D_RETURN;
}
D("iconbar fix: %f, %f, %f, %f\n", x, y, w, h);
/* move and resize iconbar to geometry specified in layout */
ebits_move(ib->bit, x, y);
ebits_resize(ib->bit, w, h);
/* show it. harmless to do this all the time */
ebits_show(ib->bit);
/* tell the view we belong to something may have changed so it can draw */
@ -664,8 +682,7 @@ e_iconbar_file_delete(E_View * v, char *file)
D_ENTER;
/* is the file of interest */
if ((!strcmp(".e_iconbar.db", file)) ||
(!strcmp(".e_iconbar.bits.db", file)))
if ((!strcmp("iconbar.db", file)) || (!strcmp("iconbar.bits.db", file)))
{
/* if we have an iconbar.. delete it - because its files have been */
/* nuked. no need to keep it around. */
@ -1705,6 +1722,21 @@ ib_child_handle(Ecore_Event * ev)
D_RETURN;
}
void
e_iconbar_update_geometry(E_Iconbar * ib)
{
double x, y, w, h;
D_ENTER;
if (e_view_layout_get_element_geometry(ib->view->layout, "Iconbar",
&x, &y, &w, &h))
{
ebits_move(ib->bit, x, y);
ebits_resize(ib->bit, w, h);
}
}
E_Rect *
e_iconbar_get_resist_rect(E_Iconbar * ib)
{

View File

@ -2,6 +2,7 @@
#include "scrollbar.h"
#include "config.h"
#include "util.h"
#include "view.h"
static void e_scrollbar_recalc(E_Scrollbar * sb);
static void e_scrollbar_setup_bits(E_Scrollbar * sb);
@ -79,21 +80,55 @@ e_scrollbar_setup_bits(E_Scrollbar * sb)
if (sb->direction == 1)
{
snprintf(buf, PATH_MAX, "%s/scroll_base_v.bits.db",
e_config_get("scrollbars"));
/* load from the current dir's layout */
snprintf(buf, PATH_MAX, "%s/.e_layout/scroll_base_v.bits.db", sb->dir);
sb->base = ebits_load(buf);
snprintf(buf, PATH_MAX, "%s/scroll_bar_v.bits.db",
e_config_get("scrollbars"));
/* if not loaded, load defaults */
if (!sb->base)
{
snprintf(buf, PATH_MAX, "%s/scroll_base_v.bits.db",
e_config_get("scrollbars"));
sb->base = ebits_load(buf);
}
/* load from current dir's layout */
snprintf(buf, PATH_MAX, "%s/.e_layout/scroll_bar_v.bits.db", sb->dir);
sb->bar = ebits_load(buf);
/* if not loaded, load defaults */
if (!sb->bar)
{
snprintf(buf, PATH_MAX, "%s/scroll_bar_v.bits.db",
e_config_get("scrollbars"));
sb->bar = ebits_load(buf);
}
}
else
{
snprintf(buf, PATH_MAX, "%s/scroll_base_h.bits.db",
e_config_get("scrollbars"));
/* load from the current dir's layout */
snprintf(buf, PATH_MAX, "%s/.e_layout/scroll_base_h.bits.db", sb->dir);
sb->base = ebits_load(buf);
snprintf(buf, PATH_MAX, "%s/scroll_bar_h.bits.db",
e_config_get("scrollbars"));
/* if not loaded, load defaults */
if (!sb->base)
{
snprintf(buf, PATH_MAX, "%s/scroll_base_h.bits.db",
e_config_get("scrollbars"));
sb->base = ebits_load(buf);
}
/* load from current dir's layout */
snprintf(buf, PATH_MAX, "%s/.e_layout/scroll_bar_h.bits.db", sb->dir);
sb->bar = ebits_load(buf);
/* if not loaded, load defaults */
if (!sb->bar)
{
snprintf(buf, PATH_MAX, "%s/scroll_bar_h.bits.db",
e_config_get("scrollbars"));
sb->bar = ebits_load(buf);
}
}
if (sb->base)
{
@ -335,6 +370,7 @@ e_sb_bar_down_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y,
sb->down_y = y;
sb->mouse_x = x;
sb->mouse_y = y;
sb->view->changed = 1;
D_RETURN;
UN(o);
@ -360,6 +396,8 @@ e_sb_bar_up_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y,
sb->mouse_down = 0;
else
D_RETURN;
sb->view->changed = 1;
D_RETURN;
UN(o);
@ -473,7 +511,7 @@ e_sb_scroll_timer(int val, void *data)
}
E_Scrollbar *
e_scrollbar_new(void)
e_scrollbar_new(E_View * v)
{
E_Scrollbar *sb;
@ -484,6 +522,9 @@ e_scrollbar_new(void)
e_object_init(E_OBJECT(sb), (E_Cleanup_Func) e_scrollbar_cleanup);
sb->view = v;
e_strdup(sb->dir, v->model->dir);
sb->range = 1.0;
sb->max = 1.0;
sb->w = 12;

View File

@ -1,7 +1,19 @@
#ifndef E_SCROLLBAR_H
#define E_SCROLLBAR_H
#include "e.h"
#include "object.h"
#include "view.h"
#ifndef E_SCROLLBAR_TYPEDEF
#define E_SCROLLBAR_TYPEDEF
typedef struct _E_Scrollbar E_Scrollbar;
#endif
#ifndef E_VIEW_TYPEDEF
#define E_VIEW_TYPEDEF
typedef struct _E_View E_View;
#endif
struct _E_Scrollbar
{
@ -12,8 +24,8 @@ struct _E_Scrollbar
double max;
double range;
E_View *view;
char *dir;
Evas evas;
Ebits_Object bar;
@ -47,7 +59,7 @@ struct _E_Scrollbar
void *func_data;
};
E_Scrollbar *e_scrollbar_new(void);
E_Scrollbar *e_scrollbar_new(E_View * v);
void e_scrollbar_add_to_evas(E_Scrollbar * sb, Evas evas);
void e_scrollbar_show(E_Scrollbar * sb);
void e_scrollbar_hide(E_Scrollbar * sb);
@ -73,3 +85,5 @@ double e_scrollbar_get_range(E_Scrollbar * sb);
double e_scrollbar_get_max(E_Scrollbar * sb);
void e_scrollbar_get_geometry(E_Scrollbar * sb, double *x,
double *y, double *w, double *h);
#endif

View File

@ -333,7 +333,7 @@ e_bg_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
if (!(ev->mods & (multi_select_mod | range_select_mod)))
{
v->select.last_count = v->select.count;
e_view_deselect_all(v);
e_view_deselect_all();
}
if (_b == 1)
@ -554,35 +554,53 @@ e_bg_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
}
void
e_view_deselect_all(E_View * v)
e_view_deselect_all(void)
{
Evas_List l;
Evas_List ll;
D_ENTER;
for (l = v->icons; l; l = l->next)
{
E_Icon *ic;
ic = l->data;
e_icon_deselect(ic);
for (ll = VM->views; ll; ll = ll->next)
{
Evas_List l;
E_View *v;
v = ll->data;
for (l = v->icons; l; l = l->next)
{
E_Icon *ic;
ic = l->data;
e_icon_deselect(ic);
}
}
D_RETURN;
}
void
e_view_deselect_all_except(E_Icon * not_ic)
{
Evas_List l;
Evas_List ll;
D_ENTER;
for (l = not_ic->view->icons; l; l = l->next)
{
E_Icon *ic;
ic = l->data;
if (ic != not_ic)
e_icon_deselect(ic);
for (ll = VM->views; ll; ll = ll->next)
{
Evas_List l;
E_View *v;
v = ll->data;
for (l = v->icons; l; l = l->next)
{
E_Icon *ic;
ic = l->data;
if (ic != not_ic)
e_icon_deselect(ic);
}
}
D_RETURN;
}
@ -667,7 +685,6 @@ e_view_icons_apply_xy(E_View * v)
ic = l->data;
e_icon_apply_xy(ic);
}
v->changed = 1;
D_RETURN;
}
@ -697,6 +714,7 @@ e_view_scroll_to(E_View * v, int sx, int sy)
e_view_icons_apply_xy(v);
if (v->bg)
e_bg_set_scroll(v->bg, v->scroll.x, v->scroll.y);
v->changed = 1;
D_RETURN;
}
@ -902,14 +920,17 @@ static void
e_configure(Ecore_Event * ev)
{
Ecore_Event_Window_Configure *e;
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_base_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.base)
{
/* win, root, x, y, w, h, wm_generated */
D("Configure for view: %s\n", v->name);
@ -954,8 +975,30 @@ e_configure(Ecore_Event * ev)
evas_set_output_size(v->evas, v->size.w, v->size.h);
e_view_scroll_to(v, v->scroll.x, v->scroll.y);
e_view_arrange(v);
if (v->layout)
e_view_layout_update(v->layout);
/* FIXME */
//e_view_queue_geometry_record(v);
{
double x, y, w, h;
if (e_view_layout_get_element_geometry(v->layout,
"Scrollbar_H",
&x, &y, &w, &h));
{
e_scrollbar_move(v->scrollbar.h, x, y);
e_scrollbar_resize(v->scrollbar.h, w, h);
}
if (e_view_layout_get_element_geometry(v->layout,
"Scrollbar_V",
&x, &y, &w, &h));
{
e_scrollbar_move(v->scrollbar.v, x, y);
e_scrollbar_resize(v->scrollbar.v, w, h);
}
}
e_scrollbar_move(v->scrollbar.v,
v->size.w - v->scrollbar.v->w, 0);
e_scrollbar_resize(v->scrollbar.v, v->scrollbar.v->w,
@ -968,6 +1011,7 @@ e_configure(Ecore_Event * ev)
}
}
}
D_RETURN;
}
@ -975,16 +1019,21 @@ static void
e_property(Ecore_Event * ev)
{
Ecore_Event_Window_Configure *e;
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_base_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.base)
{
}
}
D_RETURN;
}
@ -992,16 +1041,21 @@ static void
e_unmap(Ecore_Event * ev)
{
Ecore_Event_Window_Unmap *e;
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_base_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.base)
{
}
}
D_RETURN;
}
@ -1009,16 +1063,21 @@ static void
e_visibility(Ecore_Event * ev)
{
Ecore_Event_Window_Unmap *e;
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_base_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.base)
{
}
}
D_RETURN;
}
@ -1026,16 +1085,21 @@ static void
e_focus_in(Ecore_Event * ev)
{
Ecore_Event_Window_Focus_In *e;
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_base_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.base)
{
}
}
D_RETURN;
}
@ -1043,16 +1107,21 @@ static void
e_focus_out(Ecore_Event * ev)
{
Ecore_Event_Window_Focus_Out *e;
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_base_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.base)
{
}
}
D_RETURN;
}
@ -1060,17 +1129,23 @@ static void
e_delete(Ecore_Event * ev)
{
Ecore_Event_Window_Delete *e;
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_base_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.base)
{
e_object_unref(E_OBJECT(v));
D_RETURN;
}
}
D_RETURN;
}
@ -1084,23 +1159,28 @@ e_dnd_status(Ecore_Event * ev)
Ecore_Event_Dnd_Drop_Status *e;
/*
* * typedef struct _ecore_event_dnd_drop_status
* * {
* * Window win, root, source_win;
* * int x, y, w, h;
* * int copy, link, move, private;
* * int all_position_msgs;
* * int ok;
* * } Ecore_Event_Dnd_Drop_Status;
* typedef struct _ecore_event_dnd_drop_status
* {
* Window win, root, source_win;
* int x, y, w, h;
* int copy, link, move, private;
* int all_position_msgs;
* int ok;
* } Ecore_Event_Dnd_Drop_Status;
*/
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_base_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.base)
{
if (dnd_pending_mode != E_DND_DELETED &&
dnd_pending_mode != E_DND_COPIED)
{
@ -1113,11 +1193,14 @@ e_dnd_status(Ecore_Event * ev)
else
dnd_pending_mode = E_DND_ASK;
}
ecore_window_dnd_ok(e->ok);
v->changed = 1;
v->drag.icon_hide = 1;
}
}
D_RETURN;
}
@ -1125,16 +1208,21 @@ static void
e_wheel(Ecore_Event * ev)
{
Ecore_Event_Wheel *e;
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_main_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.main)
{
}
}
D_RETURN;
}
@ -1142,14 +1230,17 @@ static void
e_key_down(Ecore_Event * ev)
{
Ecore_Event_Key_Down *e;
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_main_window(e->win))
|| (v = e_view_machine_get_view_by_base_window(e->win)))
E_View *v;
v = l->data;
if ((e->win == v->win.base) || (e->win == v->win.main))
{
if (!strcmp(e->key, "Up"))
{
@ -1183,8 +1274,10 @@ e_key_down(Ecore_Event * ev)
{
}
}
D_RETURN;
}
}
D_RETURN;
}
@ -1192,16 +1285,19 @@ static void
e_key_up(Ecore_Event * ev)
{
Ecore_Event_Key_Up *e;
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
if (e && e->win)
D_RETURN;
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_main_window(e->win)))
{
}
E_View *v;
v = l->data;
}
D_RETURN;
}
@ -1209,14 +1305,18 @@ static void
e_mouse_down(Ecore_Event * ev)
{
Ecore_Event_Mouse_Down *e;
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
current_ev = ev;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_main_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.main)
{
int focus_mode;
@ -1231,6 +1331,7 @@ e_mouse_down(Ecore_Event * ev)
}
}
current_ev = NULL;
D_RETURN;
}
@ -1238,19 +1339,26 @@ static void
e_mouse_up(Ecore_Event * ev)
{
Ecore_Event_Mouse_Up *e;
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
current_ev = ev;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_main_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.main)
{
evas_event_button_up(v->evas, e->x, e->y, e->button);
current_ev = NULL;
D_RETURN;
}
}
current_ev = NULL;
D_RETURN;
}
@ -1258,19 +1366,26 @@ static void
e_mouse_move(Ecore_Event * ev)
{
Ecore_Event_Mouse_Move *e;
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
current_ev = ev;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_main_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.main)
{
evas_event_move(v->evas, e->x, e->y);
current_ev = NULL;
D_RETURN;
}
}
current_ev = NULL;
D_RETURN;
}
@ -1278,19 +1393,25 @@ static void
e_mouse_in(Ecore_Event * ev)
{
Ecore_Event_Window_Enter *e;
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
current_ev = ev;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_main_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.main)
{
if (v->model->is_desktop)
{
evas_event_enter(v->evas);
}
current_ev = NULL;
D_RETURN;
}
}
current_ev = NULL;
@ -1302,16 +1423,22 @@ static void
e_mouse_out(Ecore_Event * ev)
{
Ecore_Event_Window_Leave *e;
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
current_ev = ev;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_main_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.main)
{
evas_event_leave(v->evas);
current_ev = NULL;
D_RETURN;
}
}
current_ev = NULL;
@ -1323,20 +1450,25 @@ static void
e_window_expose(Ecore_Event * ev)
{
Ecore_Event_Window_Expose *e;
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
current_ev = ev;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_main_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.main)
{
if (!(v->pmap))
evas_update_rect(v->evas, e->x, e->y, e->w, e->h);
v->changed = 1;
D_RETURN;
}
}
D_RETURN;
}
@ -1507,6 +1639,41 @@ e_view_queue_resort(E_View * v)
D_RETURN;
}
E_View *
e_view_find_by_window(Window win)
{
Evas_List l;
D_ENTER;
for (l = VM->views; l; l = l->next)
{
E_View *v;
v = l->data;
if (v->win.base == win)
D_RETURN_(v);
}
D_RETURN_(NULL);
}
void
e_view_close_all(void)
{
D_ENTER;
while (VM->views)
{
E_View *v;
v = VM->views->data;
e_object_unref(E_OBJECT(v));
}
D_RETURN;
}
static void
e_view_cleanup(E_View * v)
{
@ -1517,13 +1684,13 @@ e_view_cleanup(E_View * v)
* not via a timeout, because we will destroy the object after this.*/
e_view_geometry_record(v);
e_view_machine_unregister_view(v);
if (v->iconbar)
{
e_iconbar_save_out_final(v->iconbar);
/*e_iconbar_save_out_final(v->iconbar); */
e_object_unref(E_OBJECT(v->iconbar));
}
if (v->bg)
e_bg_free(v->bg);
if (v->scrollbar.h)
e_object_unref(E_OBJECT(v->scrollbar.h));
if (v->scrollbar.v)
@ -1533,9 +1700,8 @@ e_view_cleanup(E_View * v)
snprintf(name, PATH_MAX, "resort_timer.%s", v->name);
ecore_del_event_timer(name);
/* unregister with the underlying model and the global list of views */
e_view_model_unregister_view(v);
e_view_machine_unregister_view(v);
if (v->layout)
e_object_unref(v->layout);
/* FIXME: clean up the rest!!! this leaks ... */
/* Call the destructor of the base class */
@ -1572,6 +1738,7 @@ e_view_new(void)
v->options.back_pixmap = 0;
#endif
#endif
v->select.lock = 0;
v->select.config.grad_size.l = 8;
v->select.config.grad_size.r = 8;
v->select.config.grad_size.t = 8;
@ -1615,7 +1782,9 @@ e_view_set_dir(E_View * v, char *path, int is_desktop)
if (!(m = e_view_machine_model_lookup(path)))
{
D("Model for this dir doesn't exist, make a new one\n");
m = e_view_model_new();
VM->models = evas_list_append(VM->models, m);
e_view_model_set_dir(m, path);
snprintf(buf, PATH_MAX, "%s/.e_background.bg.db", m->dir);
@ -1638,7 +1807,8 @@ e_view_set_dir(E_View * v, char *path, int is_desktop)
if (m)
{
e_view_model_register_view(m, v);
v->model = m;
v->model->views = evas_list_append(v->model->views, v);
/* FIXME do a real naming scheme here */
snprintf(buf, PATH_MAX, "%s:%d", v->model->dir,
e_object_get_usecount(E_OBJECT(v->model)));
@ -1705,7 +1875,6 @@ e_view_realize(E_View * v)
evas_get_visual(v->evas), evas_get_colormap(v->evas));
ecore_window_set_background_pixmap(v->win.main, v->pmap);
}
if (v->bg)
{
e_bg_add_to_evas(v->bg, v->evas);
@ -1720,7 +1889,25 @@ e_view_realize(E_View * v)
e_bg_show(v->bg);
}
v->scrollbar.v = e_scrollbar_new();
/* load the layout */
v->layout = e_view_layout_new(v);
if (v->layout)
e_view_layout_realize(v->layout);
/* set the file area spacing, if in layout */
/* FIXME: the icon layout should probably be totally redone */
{
double x, y, w, h;
if (e_view_layout_get_element_geometry(v->layout, "Icons",
&x, &y, &w, &h));
v->spacing.window.l = x;
v->spacing.window.r = v->size.w - (x + w);
v->spacing.window.t = y;
v->spacing.window.b = v->size.h - (y + h);
}
v->scrollbar.v = e_scrollbar_new(v);
e_scrollbar_set_change_func(v->scrollbar.v, e_view_scrollbar_v_change_cb, v);
e_scrollbar_set_direction(v->scrollbar.v, 1);
e_scrollbar_add_to_evas(v->scrollbar.v, v->evas);
@ -1729,7 +1916,7 @@ e_view_realize(E_View * v)
e_scrollbar_set_range(v->scrollbar.v, 1.0);
e_scrollbar_set_max(v->scrollbar.v, 1.0);
v->scrollbar.h = e_scrollbar_new();
v->scrollbar.h = e_scrollbar_new(v);
e_scrollbar_set_change_func(v->scrollbar.h, e_view_scrollbar_h_change_cb, v);
e_scrollbar_set_direction(v->scrollbar.h, 0);
e_scrollbar_add_to_evas(v->scrollbar.h, v->evas);
@ -1738,12 +1925,23 @@ e_view_realize(E_View * v)
e_scrollbar_set_range(v->scrollbar.h, 1.0);
e_scrollbar_set_max(v->scrollbar.h, 1.0);
e_scrollbar_move(v->scrollbar.v, v->size.w - v->scrollbar.v->w, 0);
e_scrollbar_resize(v->scrollbar.v, v->scrollbar.v->w,
v->size.h - v->scrollbar.h->h);
e_scrollbar_move(v->scrollbar.h, 0, v->size.h - v->scrollbar.h->h);
e_scrollbar_resize(v->scrollbar.h, v->size.w - v->scrollbar.v->w,
v->scrollbar.h->h);
{
double x, y, w, h;
if (e_view_layout_get_element_geometry(v->layout, "Scrollbar_H",
&x, &y, &w, &h));
{
e_scrollbar_move(v->scrollbar.h, x, y);
e_scrollbar_resize(v->scrollbar.h, w, h);
}
if (e_view_layout_get_element_geometry(v->layout, "Scrollbar_V",
&x, &y, &w, &h));
{
e_scrollbar_move(v->scrollbar.v, x, y);
e_scrollbar_resize(v->scrollbar.v, w, h);
}
}
/* I support dnd */
ecore_window_dnd_advertise(v->win.base);
@ -1755,7 +1953,7 @@ e_view_realize(E_View * v)
if (v->iconbar)
{
e_iconbar_realize(v->iconbar);
e_iconbar_set_view_window_spacing(v->iconbar);
/*e_iconbar_set_view_window_spacing(v->iconbar); */
}
e_view_bg_reload(v);
@ -1854,6 +2052,7 @@ e_view_update(E_View * v)
evas_render(v->evas);
v->changed = 0;
D_RETURN;
}
@ -2056,6 +2255,7 @@ e_dnd_data_request(Ecore_Event * ev)
* Atom destination_atom;
* } Ecore_Event_Dnd_Data_Request;
*/
Evas_List l;
E_View *v;
Evas_List ll;
char *data = NULL;
@ -2084,8 +2284,12 @@ e_dnd_data_request(Ecore_Event * ev)
* }
*/
e = ev->event;
if (!(v = e_view_machine_get_view_by_base_window(e->win)))
D_RETURN;
for (l = VM->views; l; l = l->next)
{
v = l->data;
if (e->win == v->win.base)
break;
}
if (e->uri_list)
{
@ -2196,14 +2400,17 @@ e_dnd_drop_end(Ecore_Event * ev)
* * Window win, root, source_win;
* * } Ecore_Event_Dnd_Drop_End;
*/
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_base_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.base)
{
if (v_dnd_source)
{
@ -2220,9 +2427,12 @@ e_dnd_drop_end(Ecore_Event * ev)
v_dnd_source->changed = 1;
v_dnd_source->drag.icon_show = 1;
}
e_dnd_drop_request_free();
D_RETURN;
}
}
D_RETURN;
}
@ -2232,19 +2442,23 @@ e_dnd_drop_position(Ecore_Event * ev)
Ecore_Event_Dnd_Drop_Position *e;
/*
* * typedef struct _ecore_event_dnd_drop_position
* * {
* * Window win, root, source_win;
* * int x, y;
* * } Ecore_Event_Dnd_Drop_Position;
* typedef struct _ecore_event_dnd_drop_position
* {
* Window win, root, source_win;
* int x, y;
* } Ecore_Event_Dnd_Drop_Position;
*/
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_base_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.base)
{
if (v->iconbar)
{
@ -2270,8 +2484,10 @@ e_dnd_drop_position(Ecore_Event * ev)
v->size.w, v->size.h);
/* todo - cache window extents, don't send again within these extents. */
D_RETURN;
}
}
D_RETURN;
}
@ -2286,25 +2502,32 @@ e_dnd_drop(Ecore_Event * ev)
* Window win, root, source_win;
* } Ecore_Event_Dnd_Drop;
*/
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_base_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.base)
{
/* Dropped! Handle data */
/* Same view or same underlying dir? Mark to skip action */
if (e->win == e->source_win || v->model == v_dnd_source->model)
v_dnd_source->drag.matching_drop_attempt = 1;
v->drag.matching_drop_attempt = 1;
/* Perform the action... */
e_dnd_handle_drop(v);
ecore_window_dnd_send_finished(v->win.base, e->source_win);
e_dnd_drop_request_free();
D_RETURN;
}
}
D_RETURN;
}
@ -2322,13 +2545,17 @@ e_dnd_drop_request(Ecore_Event * ev)
* int copy, link, move;
* } Ecore_Event_Dnd_Drop_Request;
*/
E_View *v;
Evas_List l;
D_ENTER;
e = ev->event;
if (e && e->win)
for (l = VM->views; l; l = l->next)
{
if ((v = e_view_machine_get_view_by_base_window(e->win)))
E_View *v;
v = l->data;
if (e->win == v->win.base)
{
/* if it exists, we already have the data... */
if ((!dnd_files) && (e->num_files > 0))
@ -2344,9 +2571,9 @@ e_dnd_drop_request(Ecore_Event * ev)
dnd_num_files = e->num_files;
/* if the dnd source is e itself then dont use the event mode */
if ((v ==
e_view_machine_get_view_by_base_window(e->source_win)))
if (e_view_find_by_window(e->source_win))
{
v = e_view_find_by_window(e->source_win);
dnd_pending_mode = v->drag.drop_mode;
}
else
@ -2361,8 +2588,10 @@ e_dnd_drop_request(Ecore_Event * ev)
dnd_pending_mode = E_DND_ASK;
}
}
D_RETURN;
}
}
D_RETURN;
}

View File

@ -9,6 +9,7 @@
#include "object.h"
#include "e_view_model.h"
#include "e_file.h"
#include "view_layout.h"
#ifndef E_VIEW_TYPEDEF
#define E_VIEW_TYPEDEF
@ -30,6 +31,17 @@ typedef struct _E_Iconbar E_Iconbar;
typedef struct _E_View_Model E_View_Model;
#endif
#ifndef E_VIEW_LAYOUT_TYPEDEF
#define E_VIEW_LAYOUT_TYPEDEF
typedef struct _E_View_Layout E_View_Layout;
typedef struct _E_View_Layout_Element E_View_Layout_Element;
#endif
#ifndef E_SCROLLBAR_TYPEDEF
#define E_SCROLLBAR_TYPEDEF
typedef struct _E_Scrollbar E_Scrollbar;
#endif
typedef enum
{
E_DND_NONE,
@ -112,6 +124,9 @@ struct _E_View
struct
{
int on;
/* we set this in all other views of our view_model
* when the first icon in a view is selected. */
int lock;
/* The number of selected icons. */
int count;
/* The number of icons we selected the last time.
@ -124,7 +139,6 @@ struct _E_View
int x, y;
}
down;
struct
{
struct
@ -156,7 +170,6 @@ struct _E_View
obj;
}
select;
struct
{
int started;
@ -182,6 +195,7 @@ struct _E_View
extents;
E_Background bg;
E_View_Layout *layout;
struct
{
@ -222,7 +236,7 @@ struct _E_View
void e_view_init(void);
void e_view_selection_update(E_View * v);
void e_view_deselect_all(E_View * v);
void e_view_deselect_all(void);
void e_view_deselect_all_except(E_Icon * not_ic);
Ecore_Event *e_view_get_current_event(void);
int e_view_filter_file(E_View * v, char *file);
@ -244,6 +258,7 @@ void e_view_resort(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);
E_View *e_view_find_by_window(Window win);
/**
* e_view_new - Creates a new view object