e17/evry: allow plugins to provide their own view

SVN revision: 62327
This commit is contained in:
Hannes Janetzek 2011-08-11 04:14:10 +00:00
parent 52a9416c57
commit d1dd54ef90
3 changed files with 70 additions and 38 deletions

View File

@ -12,7 +12,6 @@
#define SLIDE_LEFT 1
#define SLIDE_RIGHT -1
typedef struct _Evry_View Evry_View;
typedef struct _History Evry_History;
typedef struct _Config Evry_Config;
typedef struct _Evry_Selector Evry_Selector;
@ -120,26 +119,6 @@ struct _Evry_State
Eina_Bool delete_me;
};
struct _Evry_View
{
Evry_View *id;
const char *name;
const char *trigger;
int active;
Evas_Object *o_list;
Evas_Object *o_bar;
Evry_View *(*create) (Evry_View *view, const Evry_State *s, const Evas_Object *swallow);
void (*destroy) (Evry_View *view);
int (*cb_key_down) (Evry_View *view, const Ecore_Event_Key *ev);
int (*update) (Evry_View *view);
void (*clear) (Evry_View *view);
int priority;
Evry_State *state;
};
struct _Tab_View
{
const Evry_State *state;

View File

@ -52,6 +52,7 @@ static void _evry_list_win_show(Evry_Window *win);
static void _evry_list_win_hide(Evry_Window *win);
static void _evry_list_win_update(Evry_State *s);
static int _evry_view_create(Evry_State *s);
static void _evry_view_clear(Evry_State *s);
static int _evry_view_update(Evry_Window *win, Evry_State *s);
static int _evry_view_key_press(Evry_State *s, Ecore_Event_Key *ev);
@ -1192,14 +1193,7 @@ _evry_selector_activate(Evry_Selector *sel, int slide)
_evry_selector_label_set(sel, "e.text.plugin",
EVRY_ITEM(s->cur_item->plugin)->label);
if (!s->view)
{
Evry_View *view = evry_conf->views->data;
s->view = view->create(view, s, win->o_main);
s->view->state = s;
}
if (s->view)
if (_evry_view_create(s))
{
_evry_view_show(win, s->view, slide);
s->view->update(s->view);
@ -2594,23 +2588,46 @@ _evry_view_hide(Evry_Window *win, Evry_View *v, int slide)
}
static int
_evry_view_update(Evry_Window *win, Evry_State *s)
_evry_view_create(Evry_State *s)
{
if (!win->visible) return 0;
Evry_View *view;
if (!s->view)
if (s->view)
return 1;
if (s->plugin && s->plugin->view)
view = s->plugin->view;
else
view = eina_list_data_get(evry_conf->views);
s->view = view->create(view, s, s->selector->win->o_main);
if (s->view)
{
Evry_View *view = evry_conf->views->data;
if (!(s->view = view->create(view, s, win->o_main)))
return 0;
s->view->state = s;
s->view->update(s->view);
return 1;
}
return 0;
}
static int
_evry_view_update(Evry_Window *win, Evry_State *s)
{
if (!win->visible) return 0;
/* TODO check this again !!!!*/
if (s->view)
s->view->update(s->view);
{
s->view->update(s->view);
return 0;
}
if (_evry_view_create(s))
{
s->view->update(s->view);
return 1;
}
return 0;
}
@ -2896,6 +2913,19 @@ _evry_plugin_select(Evry_State *s, Evry_Plugin *p)
}
s->plugin = p;
if ((s->view && s->plugin->view) &&
(s->view->name != s->plugin->view->name))
{
s->view->destroy(s->view);
s->view = NULL;
if (_evry_view_create(s))
{
_evry_view_show(s->selector->win, s->view, 0);
s->view->update(s->view);
}
}
}
static void

View File

@ -11,6 +11,7 @@ typedef struct _History_Item History_Item;
typedef struct _History_Entry History_Entry;
typedef struct _History_Types History_Types;
typedef struct _Evry_State Evry_State;
typedef struct _Evry_View Evry_View;
typedef unsigned int Evry_Type;
@ -199,6 +200,8 @@ struct _Evry_Plugin
/* set theme file to fetch icons from */
const char *theme_path;
Evry_View *view;
/* not to be set by plugin! */
Plugin_Config *config;
unsigned int request;
@ -242,6 +245,26 @@ struct _Plugin_Config
Eina_List *plugins;
};
struct _Evry_View
{
Evry_View *id;
const char *name;
const char *trigger;
int active;
Evas_Object *o_list;
Evas_Object *o_bar;
Evry_View *(*create) (Evry_View *view, const Evry_State *s, const Evas_Object *swallow);
void (*destroy) (Evry_View *view);
int (*cb_key_down) (Evry_View *view, const Ecore_Event_Key *ev);
int (*update) (Evry_View *view);
void (*clear) (Evry_View *view);
int priority;
Evry_State *state;
};
struct _History_Item
{
const char *plugin;