Add Channel structure.

Add functions to create and free Channels.
Create a default channel for new window.

Signed-off-by: Chris Michael <devilhorns@comcast.net>
This commit is contained in:
Chris Michael 2013-12-26 13:22:53 +00:00
parent 7aecccc436
commit 48bee885b6
1 changed files with 104 additions and 0 deletions

View File

@ -8,6 +8,28 @@ struct _Window
Evas_Object *o_bg;
Evas_Object *o_conform;
Evas_Object *o_base;
Eina_List *channels;
Ecore_Job *size_job;
Eina_Bool focused : 1;
};
struct _Channel
{
Window *window;
Evas_Object *o_bg;
Evas_Object *o_base;
Evas_Object *o_grid;
Evas_Object *o_spacer;
int step_x, step_y;
int min_w, min_h;
int req_w, req_h;
Eina_Bool focused : 1;
};
/* local prototypes */
@ -31,9 +53,34 @@ _main_window_cb_del(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UN
_main_window_free(win);
}
static void
_main_channel_free(Channel *chl)
{
/* delete channel textgrid */
if (chl->o_grid) evas_object_del(chl->o_grid);
/* delete channel spacer */
if (chl->o_spacer) evas_object_del(chl->o_spacer);
/* delete channel background */
if (chl->o_bg) evas_object_del(chl->o_bg);
/* delete channel base */
if (chl->o_base) evas_object_del(chl->o_base);
/* free the structure */
free(chl);
}
static void
_main_window_free(Window *win)
{
Channel *chl;
/* destroy channels */
EINA_LIST_FREE(win->channels, chl)
_main_channel_free(chl);
/* delete the base */
if (win->o_base) evas_object_del(win->o_base);
@ -55,6 +102,56 @@ _main_window_free(Window *win)
free(win);
}
static void
_main_channel_theme_reload(Channel *chl)
{
/* TODO: check config for transparency */
edje_object_signal_emit(chl->o_bg, "translucent,off", "express");
edje_object_signal_emit(chl->o_base, "translucent,off", "express");
}
static Channel *
_main_channel_new(Window *win)
{
Channel *chl;
/* try to allocate space for new channel structure */
if (!(chl = calloc(1, sizeof(Channel))))
return NULL;
/* set channel window */
chl->window = win;
/* create channel base object */
chl->o_base = edje_object_add(win->evas);
_theme_apply(chl->o_base, "express/channel");
_theme_reload_enable(chl->o_base);
evas_object_data_set(chl->o_base, "theme_reload_func",
_main_channel_theme_reload);
evas_object_data_set(chl->o_base, "theme_reload_func_data", chl);
evas_object_show(chl->o_base);
/* create channel background object */
chl->o_bg = edje_object_add(win->evas);
evas_object_size_hint_weight_set(chl->o_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_fill_set(chl->o_bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
_theme_apply(chl->o_bg, "express/background");
evas_object_show(chl->o_bg);
_main_channel_theme_reload(chl);
/* TODO: channel text grid */
/* TODO: channel count signal */
/* TODO: swallow textgrid into chl->o_base (channel.content) */
edje_object_part_swallow(chl->o_bg, "background.content", chl->o_base);
win->channels = eina_list_append(win->channels, chl);
return chl;
}
static Window *
_main_window_new(void)
{
@ -108,6 +205,7 @@ EAPI_MAIN int
elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
Window *win;
Channel *chl;
/* create logging domain */
_log_dom = eina_log_domain_register("express", NULL);
@ -135,6 +233,12 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
if (!(win = _main_window_new()))
goto win_new_err;
/* create default channel */
chl = _main_channel_new(win);
edje_object_part_swallow(win->o_base, "base.content", chl->o_bg);
/* TODO: cb_size_hint ? */
/* TODO: win sizing handle ? */
evas_object_resize(win->o_win, 200, 200);
evas_object_show(win->o_win);