ok folks, here goes. The multiple view stuff as discussed in lenght. I've managed to get metadata back up, views save

their geometry on close. I'll start getting the documentation back in sync and commenting some more. Could anyone
willing to clean up/fix either the iconbar dnd stuff and/or the regular dnd stuff please announce it, so we dont start
duplicating work. Thanks.


SVN revision: 5977
This commit is contained in:
Till Adam 2002-02-25 18:09:13 +00:00
parent abf7d8f0ee
commit 5744b944d6
21 changed files with 1537 additions and 1282 deletions

View File

@ -84,6 +84,9 @@ enlightenment_SOURCES = \
text.h text.c \
util.h util.c \
view.h view.c \
e_file.h e_file.c \
e_view_model.h e_view_model.c \
e_view_machine.h e_view_machine.c \
e.h
enlightenment_LDADD = @evas_libs@ @edb_libs@ @ebits_libs@ @ecore_libs@ @efsd_libs@ @ebg_libs@ @ferite_libs@ -lm -lc $(INTLLIBS)

View File

@ -281,7 +281,7 @@ e_config_load(char *file, char *prefix, E_Config_Base_Type *type)
for (l = type->nodes; l; l = l->next)
{
E_Config_Node *node;
node = l->data;
switch (node->type)

View File

@ -7,6 +7,7 @@
#include "icccm.h"
#include "util.h"
#include "object.h"
#include "e_view_machine.h"
static Evas_List desktops = NULL;
static Window e_base_win = 0;
@ -196,7 +197,6 @@ e_desktops_init_file_display(E_Desktop *desk)
v->size.w = desk->real.w;
v->size.h = desk->real.h;
v->options.back_pixmap = 1;
v->is_desktop = 1;
desk->view = v;
/* fixme: later */
@ -204,11 +204,10 @@ e_desktops_init_file_display(E_Desktop *desk)
/* e_strdup(v->dir, "/dev"); */
/* e_strdup(v->dir, e_file_home()); */
snprintf(buf, PATH_MAX, "%s/desktop/default", e_config_user_dir());
e_strdup(v->dir, buf);
e_view_bg_load(v);
e_view_set_dir(v, buf, 1);
e_view_realize(v);
e_view_populate(v);
ecore_window_hint_set_borderless(v->win.base);
ecore_window_hint_set_sticky(v->win.base, 1);

144
src/e_file.c Normal file
View File

@ -0,0 +1,144 @@
#include "debug.h"
#include "e_file.h"
#include "file.h"
#include "util.h"
static void e_file_cleanup (E_File *f);
static void
e_file_cleanup(E_File *f)
{
D_ENTER;
IF_FREE(f->info.icon);
IF_FREE(f->info.link)
IF_FREE(f->info.custom_icon);
IF_FREE(f->info.mime.base);
IF_FREE(f->info.mime.type);
IF_FREE(f->file);
e_object_cleanup(E_OBJECT(f));
D_RETURN;
}
E_File *
e_file_new(char *file)
{
E_File *f;
D_ENTER;
f = NEW(E_File, 1);
e_object_init(E_OBJECT(f),
(E_Cleanup_Func) e_file_cleanup);
f->info.icon = NULL;
f->info.link = NULL;
f->info.custom_icon = NULL;
f->info.mime.base = NULL;
f->info.mime.type = NULL;
f->file = strdup(file);
D_RETURN_(f);
}
E_File *
e_file_get_by_name(Evas_List l, char *file)
{
Evas_List ll;
E_File *f;
D_ENTER;
for (ll=l;ll;ll=ll->next)
{
f = (E_File*) ll->data;
if (!strcmp(file, f->file))
{
D_RETURN_(f);
}
}
D_RETURN_(NULL);
}
void
e_file_set_mime(E_File *f, char *base, char *mime)
{
char icon[PATH_MAX];
char type[PATH_MAX];
char *p;
D_ENTER;
D("Setting mime: %40s: %s/%s\n", f->file, base, mime);
if ( ((f->info.mime.base) && !(strcmp(f->info.mime.base, base)))
&&((f->info.mime.type) && !(strcmp(f->info.mime.type, mime))))
D_RETURN;
if (f->info.mime.base)
free(f->info.mime.base);
if (f->info.mime.type)
free(f->info.mime.type);
f->info.mime.base = strdup(base);
f->info.mime.type = strdup(mime);
/* effect changes here */
/*
* if (f->info.custom_icon)
* {
* if (f->info.icon)
* free(f->info.icon);
* f->info.icon = strdup(f->info.custom_icon);
* evas_set_image_file(f->view->evas, f->obj.icon, f->info.custom_icon);
* e_view_queue_resort(f->view);
* D_RETURN;
* }
*/
/* find an icon */
strcpy(type, f->info.mime.type);
p=type;
do
{
snprintf(icon, PATH_MAX, "%s/data/icons/%s/%s.db",
PACKAGE_DATA_DIR, f->info.mime.base, type);
p = strrchr(type, '/');
if (p) *p = 0;
}
while (p && !e_file_exists(icon));
/* fallback to base type icon */
if (!e_file_exists(icon))
snprintf(icon, PATH_MAX, "%s/data/icons/%s/default.db",
PACKAGE_DATA_DIR, f->info.mime.base);
/* still no luck fall back to default */
if (!e_file_exists(icon))
snprintf(icon, PATH_MAX, "%s/data/icons/unknown/default.db",
PACKAGE_DATA_DIR);
f->info.icon = strdup(icon);
D_RETURN;
}
void
e_file_set_link(E_File *f, char *link)
{
D_ENTER;
if ((!link) && (f->info.link))
{
free(f->info.link);
f->info.link = NULL;
/* effect changes here */
}
else if (link)
{
if ((f->info.link) && (!strcmp(f->info.link, link)))
{
free(f->info.link);
f->info.link = strdup(link);
/* effect changes here */
}
}
D_RETURN;
}

30
src/e_file.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef E_EFILE_H
#define E_EFILE_H
#include "object.h"
#include <sys/stat.h>
typedef struct _E_File E_File;
struct _E_File
{
E_Object o;
char *file;
struct stat stat;
struct {
char *icon;
char *custom_icon;
char *link;
struct {
char *base;
char *type;
} mime;
} info;
};
E_File *e_file_new(char *file);
E_File *e_file_get_by_name(Evas_List l, char *file);
void e_file_set_mime(E_File *f, char *base, char *mime);
void e_file_set_link(E_File *f, char *link);
#endif

108
src/e_view_machine.c Normal file
View File

@ -0,0 +1,108 @@
#include <Ecore.h>
#include "e_view_machine.h"
#include "e_view_model.h"
#include "util.h"
#include "globals.h"
#include "file.h"
void
e_view_machine_init()
{
D_ENTER;
/* FIXME make this a singleton */
VM= NEW(E_View_Model, 1);
e_view_init();
e_view_model_init();
D_RETURN;
}
void
e_view_machine_register_view(E_View *v)
{
D_ENTER;
/* Add view to the list of views */
VM->views = evas_list_append(VM->views, v);
D_RETURN;
}
void
e_view_machine_unregister_view(E_View *v)
{
D_ENTER;
/* Remove the view from the global list of views
* and from the list of its model. */
VM->views = evas_list_remove(VM->views, v);
v->model->views = evas_list_remove(v->model->views, v);
e_object_unref (E_OBJECT(v->model));
D_RETURN;
}
static E_View_Model *
get_model_from_realpath(char *path)
{
E_View_Model *m;
Evas_List l;
D_ENTER;
if (path)
{
for (l=VM->models; l; l = l->next)
{
m = l->data;
if (!strcmp(m->dir, path))
{
D("Model for this dir already exists\n");
e_object_ref (E_OBJECT(m));
D_RETURN_(m);
}
}
}
D_RETURN_(NULL);
}
void
e_view_machine_get_model(E_View *v, char *path, int is_desktop)
{
E_View_Model *m = NULL;
char *realpath;
char buf[PATH_MAX];
D_ENTER;
realpath = e_file_realpath(path);
if (!(m = get_model_from_realpath(realpath)))
{
D("Model for this dir doesnt 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", realpath);
if (!e_file_exists(buf))
{
if (is_desktop)
{
snprintf(buf, PATH_MAX, "%s/default.bg.db", e_config_get("backgrounds"));
}
else
{
snprintf(buf, PATH_MAX, "%s/view.bg.db", e_config_get("backgrounds"));
}
}
e_strdup(m->bg_file, buf);
m->is_desktop = is_desktop;
}
if (m)
{
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)));
e_strdup(v->name, buf);
D("assigned name to view: %s\n",v->name);
}
else
{
/* FIXME error handling */
}
D_RETURN;
}

16
src/e_view_machine.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef E_VIEW_MACHINE_H
#define E_VIEW_MACHINE_H
#include <Evas.h>
#include "view.h"
struct _e_view_machine
{
Evas_List views;
Evas_List models;
};
typedef struct _e_view_machine E_View_Machine;
void e_view_machine_init();
void e_view_machine_register_view(E_View *v);
void e_view_machine_unregister_view(E_View *v);
void e_view_machine_get_model(E_View *v, char *path, int is_desktop);
#endif

666
src/e_view_model.c Normal file
View File

@ -0,0 +1,666 @@
#include "file.h"
#include "e_view_model.h"
#include "e_view_machine.h"
#include "view.h"
#include "icons.h"
#include "util.h"
#include "libefsd.h"
#include "e_file.h"
#include "globals.h"
static void e_view_model_handle_fs_restart(void *data);
static void e_view_model_handle_fs(EfsdEvent *ev);
static void e_view_model_handle_efsd_event_reply (EfsdEvent *ev);
static void e_view_model_handle_efsd_event_reply_stat (EfsdEvent *ev);
static void e_view_model_handle_efsd_event_reply_readlink (EfsdEvent *ev);
static void e_view_model_handle_efsd_event_reply_getfiletype (EfsdEvent *ev);
static void e_view_model_handle_efsd_event_reply_getmeta (EfsdEvent *ev);
static void e_view_model_cleanup(E_View_Model *m);
static void e_view_model_bg_reload_timeout(int val, void *data);
static void e_view_model_set_default_background(E_View_Model *m);
static void e_view_model_redraw_views(E_View_Model *m);
void
e_view_model_init()
{
D_ENTER;
e_fs_add_event_handler(e_view_model_handle_fs);
D_RETURN;
}
static void
e_view_model_cleanup(E_View_Model *m)
{
D_ENTER;
efsd_stop_monitor(e_fs_get_connection(), m->dir, TRUE);
if (m->restarter)
e_fs_del_restart_handler(m->restarter);
m->restarter = NULL;
VM->models = evas_list_remove(VM->models, m);
e_object_cleanup(E_OBJECT(m));
D_RETURN;
}
E_View_Model *
e_view_model_new ()
{
E_View_Model *m;
D_ENTER;
m = NEW (E_View_Model, 1);
ZERO(m, E_View_Model, 1);
m->dir = NULL;
m->views = NULL;
e_object_init(E_OBJECT(m),
(E_Cleanup_Func) e_view_model_cleanup);
D_RETURN_(m);
}
static void
e_view_model_redraw_views(E_View_Model *m)
{
Evas_List l;
E_View *v;
D_ENTER;
/* set the dirty flag of all views. the next time the idle
* handler calls update_views, they'll be redrawn */
for (l=m->views;l;l=l->next)
{
v = l->data;
v->changed = 1;
}
D_RETURN;
}
static void
e_view_model_set_default_background(E_View_Model *m)
{
char buf[PATH_MAX];
D_ENTER;
IF_FREE(m->bg_file);
if (m->is_desktop)
snprintf(buf, PATH_MAX, "%s/default.bg.db", e_config_get("backgrounds"));
else
snprintf(buf, PATH_MAX, "%s/view.bg.db", e_config_get("backgrounds"));
e_strdup(m->bg_file, buf);
snprintf(buf, PATH_MAX, "background_reload:%s", m->dir);
ecore_add_event_timer(buf, 0.5,
e_view_model_bg_reload_timeout, 0, m);
D_RETURN;
}
static void
e_view_model_handle_fs_restart(void *data)
{
E_View_Model *m;
D_ENTER;
m = data;
D("e_view_model_handle_fs_restart\n");
if (e_fs_get_connection())
{
EfsdOptions *ops;
/* FIXME restart with metadata pending for views */
ops = efsd_ops(3,
efsd_op_get_stat(),
efsd_op_get_filetype(),
efsd_op_list_all());
m->monitor_id = efsd_start_monitor(e_fs_get_connection(), m->dir,
ops, TRUE);
}
D("restarted monitor id (connection = %p), %i for %s\n", e_fs_get_connection(), m->monitor_id, m->dir);
D_RETURN;
}
void
e_view_model_set_dir(E_View_Model *m, char *dir)
{
D_ENTER;
/* stop monitoring old dir */
if ((m->dir) && (m->monitor_id))
{
efsd_stop_monitor(e_fs_get_connection(), m->dir, TRUE);
m->monitor_id = 0;
}
IF_FREE(m->dir);
m->dir = e_file_realpath(dir);
/* start monitoring new dir */
m->restarter = e_fs_add_restart_handler(e_view_model_handle_fs_restart, m);
if (e_fs_get_connection())
{
EfsdOptions *ops;
ops = efsd_ops(3,
efsd_op_get_stat(),
efsd_op_get_filetype(),
efsd_op_list_all());
m->monitor_id = efsd_start_monitor(e_fs_get_connection(), m->dir,
ops, TRUE);
D("monitor id for %s = %i\n", m->dir, m->monitor_id);
}
D_RETURN;
}
static void
e_view_model_handle_fs(EfsdEvent *ev)
{
D_ENTER;
switch (ev->type)
{
case EFSD_EVENT_FILECHANGE:
switch (ev->efsd_filechange_event.changetype)
{
case EFSD_FILE_CREATED:
e_view_model_file_added(ev->efsd_filechange_event.id,
ev->efsd_filechange_event.file);
break;
case EFSD_FILE_EXISTS:
e_view_model_file_added(ev->efsd_filechange_event.id,
ev->efsd_filechange_event.file);
break;
case EFSD_FILE_DELETED:
e_view_model_file_deleted(ev->efsd_filechange_event.id,
ev->efsd_filechange_event.file);
break;
case EFSD_FILE_CHANGED:
e_view_model_file_changed(ev->efsd_filechange_event.id,
ev->efsd_filechange_event.file);
break;
case EFSD_FILE_MOVED:
e_view_model_file_moved(ev->efsd_filechange_event.id,
ev->efsd_filechange_event.file);
break;
case EFSD_FILE_END_EXISTS:
break;
default:
break;
}
break;
case EFSD_EVENT_REPLY:
e_view_model_handle_efsd_event_reply (ev);
break;
default:
break;
}
D_RETURN;
}
static void
e_view_model_handle_efsd_event_reply_getfiletype(EfsdEvent *ev)
{
E_File *f;
char *file;
Evas_List l;
E_View_Model *model;
char *m, *p;
char mime[PATH_MAX], base[PATH_MAX];
D_ENTER;
if (!ev->efsd_reply_event.errorcode == 0)
D_RETURN;
file = NULL;
if ( (file = efsd_event_filename(ev)) )
{
file = e_file_get_file(file);
}
model = e_view_model_find_by_monitor_id(efsd_event_id(ev));
f = e_file_get_by_name(model->files, file);
/* if its not in the list we care about, its filetype is meaningless */
if(!f)
D_RETURN;
m = ev->efsd_reply_event.data;
p = strchr(m, '/');
if (p)
{
strcpy(base, m);
strcpy(mime, p + 1);
p = strchr(base, '/');
*p = 0;
}
else
{
strcpy(base, m);
strcpy(mime, "unknown");
}
e_file_set_mime(f, base, mime);
for (l=model->views;l;l=l->next)
{
E_View *v = (E_View *)l->data;
E_Icon *ic = e_icon_find_by_file(v, f->file);
/* Try to update the GUI.
It's just a try because we need to have the file's stat
info as well. --cK.
*/
e_icon_update_state(ic);
e_icon_initial_show(ic);
}
D_RETURN;
}
static void
e_view_model_handle_efsd_event_reply_stat(EfsdEvent *ev)
{
E_View_Model *m;
E_File *f;
Evas_List l;
D_ENTER;
if (!ev->efsd_reply_event.errorcode == 0)
D_RETURN;
m = e_view_model_find_by_monitor_id(efsd_event_id(ev));
f = e_file_get_by_name(m->files, e_file_get_file(efsd_event_filename(ev)));
/* if its not in the list we care about, return */
if(!f)
D_RETURN;
/* When everything went okay and we can find a model,
set the file stat data for the file and try to update the gui.
It's just a try because we need to have received the filetype
info too. --cK. */
f->stat = *((struct stat*)efsd_event_data(ev));
for (l=m->views;l;l=l->next)
{
E_View *v = (E_View *)l->data;
E_Icon *ic = e_icon_find_by_file(v, f->file);
e_icon_update_state(ic);
e_icon_initial_show(ic);
}
}
static void
e_view_model_handle_efsd_event_reply_readlink(EfsdEvent *ev)
{
E_View_Model *m;
E_File *f;
Evas_List l;
D_ENTER;
if (!ev->efsd_reply_event.errorcode == 0)
D_RETURN;
m = e_view_model_find_by_monitor_id(efsd_event_id(ev));
f = e_file_get_by_name(m->files, e_file_get_file(efsd_event_filename(ev)));
if (f)
{
e_file_set_link(f, (char*)efsd_event_data(ev));
}
for (l=m->views;l;l=l->next)
{
E_View *v = (E_View *)l->data;
E_Icon *ic = e_icon_find_by_file(v, f->file);
e_icon_update_state(ic);
e_icon_initial_show(ic);
}
}
static void
e_view_model_handle_efsd_event_reply_getmeta(EfsdEvent *ev)
{
Evas_List l;
EfsdCmdId cmd;
D_ENTER;
cmd = efsd_event_id(ev);
for (l=VM->views;l;l=l->next)
{
E_View *v;
v = l->data;
/* ignore metadata for desktops */
if(v->model->is_desktop) continue;
if (v->geom_get.x == cmd)
{
v->geom_get.x = 0;
if (efsd_metadata_get_type(ev) == EFSD_INT)
{
if (ev->efsd_reply_event.errorcode == 0)
efsd_metadata_get_int(ev, &(v->location.x));
else
v->location.x = 0;
}
}
else if (v->geom_get.y == cmd)
{
v->geom_get.y = 0;
if (efsd_metadata_get_type(ev) == EFSD_INT)
{
if (ev->efsd_reply_event.errorcode == 0)
efsd_metadata_get_int(ev, &(v->location.y));
else
v->location.y = 0;
}
}
else if (v->geom_get.w == cmd)
{
v->geom_get.w = 0;
if (efsd_metadata_get_type(ev) == EFSD_INT)
{
if (ev->efsd_reply_event.errorcode == 0)
efsd_metadata_get_int(ev, &(v->size.w));
else
v->size.w = 400;
}
}
else if (v->geom_get.h == cmd)
{
v->geom_get.h = 0;
if (ev->efsd_reply_event.errorcode == 0)
{
if (ev->efsd_reply_event.errorcode == 0)
efsd_metadata_get_int(ev, &(v->size.h));
else
v->size.h = 400;
}
}
/* FIXME currently, the bg info is not set via metadata */
/*
* else if (v->getbg == cmd)
* {
* v->getbg = 0;
* if (efsd_metadata_get_type(ev) == EFSD_STRING)
* {
* if (ev->efsd_reply_event.errorcode == 0)
* {
* char buf[PATH_MAX];
*
* IF_FREE(v->model->bg_file);
* e_strdup(v->model->bg_file, efsd_metadata_get_str(ev));
* snprintf(buf, PATH_MAX, "background_reload:%s", v->model->dir);
* ecore_add_event_timer(buf, 0.5, e_view_model_bg_reload_timeout, 0, v->model);
* }
* else
* e_view_model_set_default_background(v->model);
* }
* }
*/
ecore_window_move(v->win.base, v->location.x, v->location.y);
ecore_window_resize(v->win.base, v->size.w, v->size.h);
v->size.force = 1;
/* We have received all metadata we need, display the view */
if ((!v->geom_get.x) &&
(!v->geom_get.y) &&
(!v->geom_get.w) &&
(!v->geom_get.h) &&
(v->geom_get.busy))
{
E_Border *b;
v->geom_get.busy = 0;
if (v->bg)
e_bg_resize(v->bg, v->size.w, v->size.h);
if (v->options.back_pixmap) e_view_update(v);
b = e_border_adopt(v->win.base, 1);
b->client.internal = 1;
e_border_remove_click_grab(b);
}
}
}
static void
e_view_model_handle_efsd_event_reply(EfsdEvent *ev)
{
D_ENTER;
switch (ev->efsd_reply_event.command.type)
{
case EFSD_CMD_REMOVE:
break;
case EFSD_CMD_MOVE:
break;
case EFSD_CMD_SYMLINK:
break;
case EFSD_CMD_LISTDIR:
break;
case EFSD_CMD_MAKEDIR:
break;
case EFSD_CMD_CHMOD:
break;
case EFSD_CMD_GETFILETYPE:
e_view_model_handle_efsd_event_reply_getfiletype(ev);
break;
case EFSD_CMD_STAT:
e_view_model_handle_efsd_event_reply_stat(ev);
break;
case EFSD_CMD_READLINK:
e_view_model_handle_efsd_event_reply_readlink(ev);
break;
case EFSD_CMD_CLOSE:
break;
case EFSD_CMD_SETMETA:
break;
case EFSD_CMD_GETMETA:
e_view_model_handle_efsd_event_reply_getmeta(ev);
break;
case EFSD_CMD_STARTMON_DIR:
break;
case EFSD_CMD_STARTMON_FILE:
break;
case EFSD_CMD_STOPMON_DIR:
break;
case EFSD_CMD_STOPMON_FILE:
break;
default:
break;
}
D_RETURN;
}
static void
e_view_model_ib_reload_timeout(int val, void *data)
{
Evas_List l;
E_View *v;
E_View_Model *m;
D_ENTER;
m = data;
for (l=m->views;l;l=l->next)
{
v = (E_View*) l->data;
e_view_ib_reload(v);
}
D_RETURN;
UN(val);
}
static void
e_view_model_bg_reload_timeout(int val, void *data)
{
Evas_List l;
E_View *v;
E_View_Model *m;
D_ENTER;
m = data;
for (l=m->views;l;l=l->next)
{
v = (E_View*) l->data;
e_view_bg_reload(v);
}
D_RETURN;
UN(val);
}
void
e_view_model_file_added(int id, char *file)
{
Evas_List l;
E_View_Model *m;
E_View *v;
E_File *f;
char buf[PATH_MAX];
D_ENTER;
/* if we get a path - ignore it - its not a file in the dir */
if (!file || file[0] == '/') D_RETURN;
m = e_view_model_find_by_monitor_id(id);
if (!strcmp(file, ".e_background.bg.db"))
{
IF_FREE(m->bg_file);
snprintf(buf, PATH_MAX, "%s/%s", m->dir, file);
e_strdup(m->bg_file, buf);
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)) ||
(!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);
m->files = evas_list_append(m->files, f);
/* tell all views for this dir about the new file */
for (l= m->views;l ;l = l->next)
{
v = l->data;
e_view_file_add(v, f);
}
}
D_RETURN;
}
void
e_view_model_file_deleted(int id, char *file)
{
Evas_List l;
E_File *f;
E_View_Model *m;
D_ENTER;
if (!file || file[0] == '/') D_RETURN;
m = e_view_model_find_by_monitor_id(id);
f = e_file_get_by_name(m->files, file);
m->files = evas_list_remove(m->files, f);
if (!strcmp(file, ".e_background.bg.db"))
{
e_view_model_set_default_background(m);
}
else if ((!strcmp (".e_iconbar.db", file)) ||
(!strcmp (".e_iconbar.bits.db", file)))
{
for (l=m->views;l;l=l->next)
{
E_View *v = (E_View*) l->data;
e_object_unref(E_OBJECT(v->iconbar));
v->iconbar = NULL;
}
}
else if(file[0] != '.')
{
for (l=m->views;l;l=l->next)
{
E_View *v = (E_View*) l->data;
e_view_file_delete(v, f);
}
}
D_RETURN;
}
void
e_view_model_file_changed(int id, char *file)
{
Evas_List l;
E_View_Model *m;
E_File *f;
E_View *v;
char buf[PATH_MAX];
D_ENTER;
if (!file || file[0] == '/') D_RETURN;
m = e_view_model_find_by_monitor_id(id);
f = e_file_get_by_name(m->files, file);
if (!strcmp(file, ".e_background.bg.db"))
{
IF_FREE(m->bg_file);
snprintf(buf, PATH_MAX, "%s/%s", m->dir, file);
e_strdup(m->bg_file, buf);
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)) ||
(!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] != '.')
{
for (l= m->views;l ;l = l->next)
{
v = l->data;
e_view_file_changed(v, f);
}
}
D_RETURN;
}
void
e_view_model_file_moved(int id, char *file)
{
Evas_List l;
E_View_Model *m;
D_ENTER;
if (!file || file[0] == '/') D_RETURN;
m = e_view_model_find_by_monitor_id(id);
for (l=m->views;l;l=l->next)
{
E_View *v = (E_View*) l->data;
E_Icon *ic;
ic = e_icon_find_by_file(v, file);
if (ic)
{
}
}
D_RETURN;
}
E_View_Model *
e_view_model_find_by_monitor_id(int id)
{
E_View_Model *m;
Evas_List l;
D_ENTER;
for (l = VM->models; l; l = l->next)
{
m = l->data;
if (m->monitor_id == id)
D_RETURN_(m);;
}
D_RETURN_(NULL);
}

49
src/e_view_model.h Normal file
View File

@ -0,0 +1,49 @@
#ifndef E_VIEW_MODEL_H
#define E_VIEW_MODEL_H
#include "fs.h"
#include "iconbar.h"
#include <Evas.h>
#ifndef E_VIEW_TYPEDEF
#define E_VIEW_TYPEDEF
typedef struct _E_View E_View;
#endif
#ifndef E_ICON_TYPEDEF
#define E_ICON_TYPEDEF
typedef struct _E_Icon E_Icon;
#endif
#ifndef E_VIEW_MODEL_TYPEDEF
#define E_VIEW_MODEL_TYPEDEF
typedef struct _E_View_Model E_View_Model;
#endif
struct _E_View_Model
{
E_Object o;
char *dir;
Evas_List files;
Evas_Object obj_bg;
char *bg_file;
E_FS_Restarter *restarter;
int monitor_id;
Evas_List views;
int is_desktop;
};
void e_view_model_set_dir(E_View_Model *m, char *dir);
E_View_Model * e_view_model_new();
void e_view_model_init();
E_View_Model * e_view_model_find_by_monitor_id(int id);
void e_view_model_file_added(int id, char *file);
void e_view_model_file_deleted(int id, char *file);
void e_view_model_file_changed(int id, char *file);
void e_view_model_file_moved(int id, char *file);
#endif

View File

@ -1,6 +1,5 @@
#include "debug.h"
#include "epplet.h"
#include "globals.h"
#include "file.h"
#include "observer.h"
#include "desktops.h"

View File

@ -104,7 +104,7 @@ e_file_get_file(char *path)
result++;
else
result = path;
D_RETURN_(result);
}

View File

@ -1,5 +1,8 @@
#ifndef E_FILE_H
#define E_FILE_H
#include <sys/time.h>
#include <sys/stat.h>
#include <Evas.h>
time_t e_file_mod_time(char *file);
int e_file_exists(char *file);

View File

@ -1,7 +1,8 @@
#include <Evas.h>
#include <Ecore.h>
#include "view.h"
#include "e_view_machine.h"
Ecore_Event_Key_Modifiers multi_select_mod = ECORE_EVENT_KEY_MODIFIER_SHIFT;
Ecore_Event_Key_Modifiers range_select_mod = ECORE_EVENT_KEY_MODIFIER_CTRL;
Evas_List views = NULL;
E_View_Machine *VM = NULL;

View File

@ -1,8 +1,6 @@
#ifndef E_GLOBALS_H
#define E_GLOBALS_H
extern Ecore_Event_Key_Modifiers multi_select_mod;
extern Ecore_Event_Key_Modifiers range_select_mod;
extern Evas_List views;
extern E_View_Machine *VM;
#endif

View File

@ -18,7 +18,6 @@ static void e_ib_bit_down_cb (void *data, Ebits_Object o, char *class, int bt,
static void e_ib_bit_up_cb (void *data, Ebits_Object o, char *class, int bt,
int x, int y, int ox, int oy, int ow, int oh);
static void ib_reload_timeout (int val, void *data);
static void ib_scroll_timeout (int val, void *data);
static void ib_timeout (int val, void *data);
static void ib_cancel_launch_timeout (int val, void *data);
@ -165,9 +164,9 @@ e_iconbar_cleanup (E_Iconbar * ib)
if ((ib->view) && (ib->view->evas) && (ib->clip))
evas_del_object (ib->view->evas, ib->clip);
/* delete any timers intended to work on this iconbar */
snprintf (buf, PATH_MAX, "iconbar_reload:%s", ib->view->dir);
snprintf (buf, PATH_MAX, "iconbar_reload:%s", ib->view->name);
ecore_del_event_timer (buf);
snprintf (buf, PATH_MAX, "iconbar_scroll:%s", ib->view->dir);
snprintf (buf, PATH_MAX, "iconbar_scroll:%s", ib->view->name);
ecore_del_event_timer (buf);
/* call the destructor of the base class */
@ -237,7 +236,7 @@ e_iconbar_new (E_View * v)
/* 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->dir);
snprintf (buf, PATH_MAX, "%s/.e_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);
@ -284,7 +283,7 @@ 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->dir);
snprintf (buf, PATH_MAX, "%s/.e_iconbar.bits.db", v->model->dir);
ib->bit = ebits_load (buf);
/* we didn't find one? */
if (!ib->bit)
@ -392,7 +391,7 @@ 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->dir,
snprintf (buf, PATH_MAX, "%s/.e_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);
@ -654,43 +653,6 @@ e_iconbar_fix (E_Iconbar * ib)
D_RETURN;
}
/**
* e_iconbar_file_add - Adds a file to a view
* @v: The view in which a file is added
* @file: Name of the added file
*
* This function is called from the
* view code whenever a file is added to a view. The iconbar code here
* determines if the file add is of interest
* and if it is, in 0.5 secs will do a "reload
*/
void
e_iconbar_file_add (E_View * v, char *file)
{
D_ENTER;
/* is the file of interest ? */
if ((!strcmp (".e_iconbar.db", file)) ||
(!strcmp (".e_iconbar.bits.db", file)))
{
char buf[PATH_MAX];
/* unique timer name */
snprintf (buf, PATH_MAX, "iconbar_reload:%s", v->dir);
/* if we've scrolled or changed icons since. save */
if (v->iconbar
&& (v->iconbar->has_been_scrolled || v->iconbar->changed))
{
e_iconbar_save_out_final (v->iconbar);
}
/* in 0.5 secs call our timout handler */
ecore_add_event_timer (buf, 0.5, ib_reload_timeout, 0, v);
}
D_RETURN;
}
/**
* e_iconbar_file_delete - Function to remove a file from an iconbox.
* @v: The view in which a file is removed
@ -719,37 +681,6 @@ e_iconbar_file_delete (E_View * v, char *file)
D_RETURN;
}
/**
* e_iconbar_file_change - File change update function
* @v: The view in which a file changes
* @file: Name of the changed file
*
* This function gets called whenever a file changes in a view
*/
void
e_iconbar_file_change (E_View * v, char *file)
{
D_ENTER;
/* is the file that changed of interest */
if ((!strcmp (".e_iconbar.db", file)) ||
(!strcmp (".e_iconbar.bits.db", file)))
{
char buf[PATH_MAX];
/* unique timer name */
snprintf (buf, PATH_MAX, "iconbar_reload:%s", v->dir);
/* if we've scrolled since. save */
if (v->iconbar
&& (v->iconbar->has_been_scrolled || v->iconbar->changed))
e_iconbar_save_out_final (v->iconbar);
/* in 0.5 secs call the realod timeout */
ecore_add_event_timer (buf, 0.5, ib_reload_timeout, 0, v);
}
D_RETURN;
}
/**
* e_iconbar_save_out_final - save out final state of iconbar back to disk
* @ib: The iconbar
@ -766,11 +697,10 @@ e_iconbar_save_out_final (E_Iconbar * ib)
if (ib->view)
{
E_DB_File *edb;
Imlib_Image im;
Evas_List l;
int i;
snprintf (buf, PATH_MAX, "%s/.e_iconbar.db", ib->view->dir);
snprintf (buf, PATH_MAX, "%s/.e_iconbar.db", ib->view->model->dir);
D ("%s\n", buf);
if (ib->changed)
@ -801,7 +731,7 @@ e_iconbar_save_out_final (E_Iconbar * ib)
snprintf (buf2, PATH_MAX,
"%s/.e_iconbar.db:/icons/%i/image",
ib->view->dir, i);
ib->view->model->dir, i);
D ("save image\n");
imlib_save_image (buf2);
}
@ -866,43 +796,6 @@ e_iconbar_handle_launch_id (Window win, void *data)
/* static (internal to iconbar use only) callbacks */
/* reload timeout. called whenevr iconbar special files changed/added to */
/* a view */
static void
ib_reload_timeout (int val, void *data)
{
E_View *v;
D_ENTER;
/* get our view pointer */
v = (E_View *) data;
/*
D ("check if jsut saved:\n");
if (v->iconbar->just_saved)
{
D ("just saved\n");
v->iconbar->just_saved = 0;
D_RETURN;
}
*/
/* if we have an iconbar.. well nuke it */
if (e_object_unref (E_OBJECT (v->iconbar)) == 0)
v->iconbar = NULL;
/* try load a new iconbar */
if (!v->iconbar)
v->iconbar = e_iconbar_new (v);
/* if the iconbar loaded and theres an evas - we're realized */
/* so realize the iconbar */
if ((v->iconbar) && (v->evas))
e_iconbar_realize (v->iconbar);
D_RETURN;
UN (val);
}
/* scroll timeout. called to continuously scroll when arrow button down */
static void
ib_scroll_timeout (int val, void *data)
@ -915,7 +808,7 @@ ib_scroll_timeout (int val, void *data)
/* get our iconbar pointer */
ib = (E_Iconbar *) data;
snprintf (buf, PATH_MAX, "iconbar_scroll:%s", ib->view->dir);
snprintf (buf, PATH_MAX, "iconbar_scroll:%s", ib->view->name);
if (val == 0)
ecore_del_event_timer (buf);
else
@ -975,7 +868,7 @@ ib_timeout (int val, void *data)
/* figure out its path */
snprintf (buf, PATH_MAX, "%s/.e_iconbar.db:%s",
ic->iconbar->view->dir, ic->image_path);
ic->iconbar->view->model->dir, ic->image_path);
/* add it */
ic->hi.image = evas_add_image_from_file (ic->iconbar->view->evas,
buf);
@ -989,7 +882,7 @@ ib_timeout (int val, void *data)
/* start at 0 */
val = 0;
}
/* what tame is it ? */
/* what time is it ? */
t = ecore_get_time ();
if (ic->launch_id)
{
@ -1312,7 +1205,7 @@ ib_mouse_in (void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
char buf[PATH_MAX];
/* come up with a unique name for it */
snprintf (buf, PATH_MAX, "iconbar:%s/%s", ic->iconbar->view->dir,
snprintf (buf, PATH_MAX, "iconbar:%s/%s", ic->iconbar->view->name,
ic->image_path);
e_strdup (ic->hi.timer, buf);
/* call the timeout */
@ -1650,7 +1543,7 @@ e_iconbar_icon_move (E_Iconbar_Icon *ic, int x, int y)
ic->iconbar->changed = 1;
e_iconbar_save_out_final(ic->iconbar);
/* ic->iconbar->just_saved = 0;*/
ib_reload_timeout(0, ic->iconbar->view);
e_view_ib_reload(ic->iconbar->view);
}
D_RETURN;
@ -1669,7 +1562,8 @@ e_iconbar_dnd_add_files (E_View *v, E_View *source, int num_files,
D_ENTER;
D("add files: %s\n", source->dir);
#if 0
D("add files: %s\n", source->model->dir);
for (i = 0; i < num_files; i++)
{
char *file = e_file_get_file(strdup(dnd_files[i]));
@ -1681,7 +1575,6 @@ e_iconbar_dnd_add_files (E_View *v, E_View *source, int num_files,
if (!strcmp(ic->info.mime.base, "db"))
{
/* if its an icon db, set the icon */
#if 0
D("db!\n");
for (l = v->iconbar->icons; l; l = l->next)
{
@ -1699,7 +1592,7 @@ e_iconbar_dnd_add_files (E_View *v, E_View *source, int num_files,
v->iconbar->dnd.y < ibic->current.y + ibic->current.h )
{
D("over icon: %s\n", ibic->exec);
snprintf(buf, PATH_MAX, "%s/%s:/icon/normal", ic->view->dir, ic->file);
snprintf(buf, PATH_MAX, "%s/%s:/icon/normal", ic->view->model->dir, ic->file);
D("set icon: %s\n", buf);
ibic->imlib_image = imlib_load_image(buf);
@ -1711,7 +1604,6 @@ e_iconbar_dnd_add_files (E_View *v, E_View *source, int num_files,
}
}
break;
#endif
}
else if (e_file_can_exec (&ic->stat))
{
@ -1743,14 +1635,14 @@ e_iconbar_dnd_add_files (E_View *v, E_View *source, int num_files,
else
D("EEEEEEEEEEEEK: how the hell did this happen?");
D("x: %i, v-dir: %s, ib-dir: %s\n", ibic->iconbar->icon_area.x, v->dir, ibic->iconbar->view->dir);
D("x: %f, v-dir: %s, ib-dir: %s\n", ibic->iconbar->icon_area.x, v->model->dir, ibic->iconbar->view->model->dir);
if (!ic->info.icon) D_RETURN_(NULL);
if (!ic->info.icon) D_RETURN;
snprintf(buf, PATH_MAX, "%s:/icon/normal", ic->info.icon);
ibic->image = evas_add_image_from_file (v->evas, buf);
ibic->imlib_image = imlib_load_image (buf);
ibic->image_path = strdup (ic->info.icon);
snprintf(buf, PATH_MAX, "%s/%s", ic->view->dir, ic->file);
snprintf(buf, PATH_MAX, "%s/%s", ic->view->model->dir, ic->file);
ibic->exec = strdup(buf);
evas_set_clip (v->evas, ibic->image, v->iconbar->clip);
@ -1774,6 +1666,7 @@ e_iconbar_dnd_add_files (E_View *v, E_View *source, int num_files,
e_iconbar_icon_move(ibic, v->iconbar->dnd.x, v