forked from enlightenment/enlightenment
shuffle around registering/unregistering of views and view models as per cK's
suggestion remove unneeded function remove comments for obvious one liners SVN revision: 6008
This commit is contained in:
parent
4302d0b872
commit
e45338be4d
|
@ -22,11 +22,26 @@ e_view_machine_init()
|
|||
D_RETURN;
|
||||
}
|
||||
|
||||
void
|
||||
e_view_machine_register_view_model (E_View_Model *m)
|
||||
{
|
||||
D_ENTER;
|
||||
VM->models = evas_list_append(VM->models, m);
|
||||
D_RETURN;
|
||||
}
|
||||
|
||||
void
|
||||
e_view_machine_unregister_view_model(E_View_Model *m)
|
||||
{
|
||||
D_ENTER;
|
||||
VM->models = evas_list_remove(VM->models, m);
|
||||
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;
|
||||
}
|
||||
|
@ -35,28 +50,20 @@ 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;
|
||||
}
|
||||
|
||||
void
|
||||
e_view_machine_close_all_views(void)
|
||||
{
|
||||
Evas_List l,ll;
|
||||
Evas_List l;
|
||||
D_ENTER;
|
||||
/* Copy the list of views and unregister them */
|
||||
for (l=VM->views;l;l=l->next)
|
||||
{
|
||||
ll = evas_list_append(ll, l->data);
|
||||
}
|
||||
for (l=ll;l;l=l->next)
|
||||
{
|
||||
E_View *v = l->data;
|
||||
e_view_machine_unregister_view(v);
|
||||
e_object_unref (E_OBJECT(v->model));
|
||||
}
|
||||
D_RETURN;
|
||||
}
|
||||
|
@ -83,8 +90,6 @@ e_view_machine_model_lookup(char *path)
|
|||
D("Model for this dir already exists\n");
|
||||
|
||||
IF_FREE(realpath);
|
||||
|
||||
e_object_ref (E_OBJECT(m));
|
||||
D_RETURN_(m);
|
||||
}
|
||||
}
|
||||
|
@ -120,3 +125,4 @@ e_view_machine_get_view_by_base_window(Window win)
|
|||
}
|
||||
D_RETURN_(NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,9 @@ typedef struct _e_view_machine E_View_Machine;
|
|||
void e_view_machine_init(void);
|
||||
void e_view_machine_register_view(E_View *v);
|
||||
void e_view_machine_unregister_view(E_View *v);
|
||||
void e_view_machine_register_view_model(E_View_Model *m);
|
||||
void e_view_machine_unregister_view_model(E_View_Model *m);
|
||||
|
||||
void e_view_machine_close_all_views(void);
|
||||
E_View_Model *e_view_machine_model_lookup(char *path);
|
||||
E_View *e_view_machine_get_view_by_main_window(Window win);
|
||||
|
|
|
@ -19,7 +19,6 @@ 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(void)
|
||||
|
@ -42,7 +41,7 @@ e_view_model_cleanup(E_View_Model *m)
|
|||
e_fs_del_restart_handler(m->restarter);
|
||||
|
||||
m->restarter = NULL;
|
||||
VM->models = evas_list_remove(VM->models, m);
|
||||
e_view_machine_unregister_view_model(m);
|
||||
|
||||
e_object_cleanup(E_OBJECT(m));
|
||||
|
||||
|
@ -64,27 +63,26 @@ e_view_model_new (void)
|
|||
e_object_init(E_OBJECT(m),
|
||||
(E_Cleanup_Func) e_view_model_cleanup);
|
||||
|
||||
e_view_machine_register_view_model(m);
|
||||
D_RETURN_(m);
|
||||
}
|
||||
|
||||
static void
|
||||
e_view_model_redraw_views(E_View_Model *m)
|
||||
void
|
||||
e_view_model_register_view(E_View_Model *m, E_View *v)
|
||||
{
|
||||
Evas_List l;
|
||||
E_View *v;
|
||||
D_ENTER;
|
||||
v->model = m;
|
||||
m->views = evas_list_append(m->views, v);
|
||||
e_object_ref (E_OBJECT(v->model));
|
||||
D_RETURN;
|
||||
}
|
||||
|
||||
if (!m)
|
||||
D_RETURN;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
void
|
||||
e_view_model_unregister_view(E_View *v)
|
||||
{
|
||||
D_ENTER;
|
||||
v->model->views = evas_list_remove(v->model->views, v);
|
||||
e_object_unref (E_OBJECT(v->model));
|
||||
D_RETURN;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,8 @@ void e_view_model_set_dir(E_View_Model *m, char *dir);
|
|||
|
||||
E_View_Model * e_view_model_new(void);
|
||||
void e_view_model_init(void);
|
||||
void e_view_model_register_view(E_View_Model *m,E_View *v);
|
||||
void e_view_model_unregister_view(E_View *v);
|
||||
|
||||
E_View_Model * e_view_model_find_by_monitor_id(int id);
|
||||
|
||||
|
|
10
src/view.c
10
src/view.c
|
@ -1457,8 +1457,6 @@ 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);
|
||||
|
@ -1472,6 +1470,9 @@ 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);
|
||||
/* FIXME: clean up the rest!!! this leaks ... */
|
||||
|
||||
/* Call the destructor of the base class */
|
||||
|
@ -1551,9 +1552,7 @@ 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);
|
||||
|
@ -1574,8 +1573,7 @@ e_view_set_dir(E_View *v, char *path, int is_desktop)
|
|||
|
||||
if (m)
|
||||
{
|
||||
v->model = m;
|
||||
v->model->views = evas_list_append(v->model->views, v);
|
||||
e_view_model_register_view(m, 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);
|
||||
|
|
Loading…
Reference in New Issue