Add callbacks for channel next & prev
Signed-off-by: Chris Michael <devilhorns@comcast.net>
This commit is contained in:
parent
ec853e9a25
commit
7e9bc95162
285
src/bin/main.c
285
src/bin/main.c
|
@ -43,6 +43,9 @@ static void _main_window_free(Window *win);
|
|||
static Channel *_main_window_focused_channel_get(Window *win);
|
||||
static Eina_Bool _main_window_size_walk(Window *win, int *w, int *h);
|
||||
|
||||
/* local variables */
|
||||
static Ecore_Timer *_flush_tmr = NULL;
|
||||
|
||||
/* external variables */
|
||||
int _log_dom = -1;
|
||||
|
||||
|
@ -178,6 +181,26 @@ _main_channel_focus_show(Channel *chl)
|
|||
evas_object_show(chl->o_bg);
|
||||
}
|
||||
|
||||
static Channel *
|
||||
_main_channel_previous_get(Channel *chl)
|
||||
{
|
||||
Eina_List *l;
|
||||
|
||||
l = eina_list_data_find_list(chl->window->channels, chl);
|
||||
if ((l) && (l->prev)) return l->prev->data;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Channel *
|
||||
_main_channel_next_get(Channel *chl)
|
||||
{
|
||||
Eina_List *l;
|
||||
|
||||
l = eina_list_data_find_list(chl->window->channels, chl);
|
||||
if ((l) && (l->next)) return l->next->data;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_selector_selected(void *data, Evas_Object *obj EINA_UNUSED, void *event)
|
||||
{
|
||||
|
@ -231,103 +254,6 @@ _cb_selector_ending(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_U
|
|||
edje_object_signal_emit(win->o_sel_bg, "end", "express");
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_chlcount_go(void *data, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Channel *chl, *ch;
|
||||
Window *win;
|
||||
Eina_List *l;
|
||||
double z = 1.0;
|
||||
int count = 0;
|
||||
|
||||
if (!(chl = data)) return;
|
||||
if (!(win = chl->window)) return;
|
||||
|
||||
evas_object_hide(chl->o_bg);
|
||||
|
||||
/* create selector background */
|
||||
win->o_sel_bg = edje_object_add(win->evas);
|
||||
_theme_apply(win->o_sel_bg, "express/selector/background");
|
||||
if (_ex_cfg->gui.translucent)
|
||||
edje_object_signal_emit(win->o_sel_bg, "translucent,on", "express");
|
||||
else
|
||||
edje_object_signal_emit(win->o_sel_bg, "translucent,off", "express");
|
||||
|
||||
edje_object_signal_emit(win->o_sel_bg, "begin", "express");
|
||||
|
||||
/* create selector */
|
||||
if (!(win->o_sel = _selector_add(win->o_win))) return;
|
||||
|
||||
EINA_LIST_FOREACH(win->channels, l, ch)
|
||||
{
|
||||
Evas_Coord w = 0, h = 0;
|
||||
|
||||
edje_object_part_unswallow(ch->o_bg, ch->o_base);
|
||||
evas_object_lower(ch->o_base);
|
||||
evas_object_move(ch->o_base, -9999, -9999);
|
||||
evas_object_show(ch->o_base);
|
||||
evas_object_clip_unset(ch->o_base);
|
||||
#if (EVAS_VERSION_MAJOR > 1) || (EVAS_VERSION_MINOR >= 8)
|
||||
evas_object_image_source_visible_set(ch->o_img, EINA_FALSE);
|
||||
#endif
|
||||
ch->unswallowed = EINA_TRUE;
|
||||
|
||||
ch->o_img = evas_object_image_filled_add(win->evas);
|
||||
evas_object_image_source_set(ch->o_img, ch->o_base);
|
||||
evas_object_geometry_get(ch->o_base, NULL, NULL, &w, &h);
|
||||
evas_object_resize(ch->o_img, w, h);
|
||||
evas_object_data_set(ch->o_img, "grid", ch->o_grid);
|
||||
|
||||
_selector_entry_add(win->o_sel, ch->o_img, (ch == chl), ch->missed);
|
||||
}
|
||||
|
||||
edje_object_part_swallow(win->o_sel_bg, "content", win->o_sel);
|
||||
evas_object_show(win->o_sel);
|
||||
edje_object_part_swallow(win->o_base, "base.content", win->o_sel_bg);
|
||||
evas_object_show(win->o_sel_bg);
|
||||
|
||||
evas_object_smart_callback_add(win->o_sel, "selected",
|
||||
_cb_selector_selected, win);
|
||||
evas_object_smart_callback_add(win->o_sel, "exit",
|
||||
_cb_selector_exit, win);
|
||||
evas_object_smart_callback_add(win->o_sel, "ending",
|
||||
_cb_selector_ending, win);
|
||||
|
||||
_selector_go(win->o_sel);
|
||||
|
||||
count = eina_list_count(win->channels);
|
||||
if (count >= 1)
|
||||
z = (1.0 / (sqrt(count)) * 0.8);
|
||||
if (z > 1.0) z = 1.0;
|
||||
|
||||
_selector_zoom_set(win->o_sel, z);
|
||||
_selector_zoom(win->o_sel, z);
|
||||
|
||||
/* if (ch != chl) */
|
||||
/* { */
|
||||
/* _selector_entry_selected_set(win->o_sel, chl->o_img, EINA_TRUE); */
|
||||
/* _selector_exit(win->o_sel); */
|
||||
/* } */
|
||||
|
||||
elm_object_focus_set(win->o_sel, EINA_TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_chlcount_prev(void *data, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Channel *chl;
|
||||
|
||||
if (!(chl = data)) return;
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_chlcount_next(void *data, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Channel *chl;
|
||||
|
||||
if (!(chl = data)) return;
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_focus_in(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
|
||||
{
|
||||
|
@ -421,6 +347,163 @@ _cb_size_hint(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event
|
|||
chl->window->size_job = ecore_job_add(_cb_size_job, chl->window);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_cb_flush(void *data EINA_UNUSED)
|
||||
{
|
||||
_flush_tmr = NULL;
|
||||
elm_cache_all_flush();
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_changed(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
|
||||
{
|
||||
if (!_flush_tmr)
|
||||
_flush_tmr = ecore_timer_add(5.0, _cb_flush, NULL);
|
||||
else
|
||||
ecore_timer_delay(_flush_tmr, 5.0);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_options(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
|
||||
{
|
||||
DBG("TODO Options");
|
||||
}
|
||||
|
||||
static void
|
||||
_main_channel_switch(Channel *chl, Channel *new_chl)
|
||||
{
|
||||
Channel *ch;
|
||||
Window *win;
|
||||
Eina_List *l;
|
||||
double z = 1.0;
|
||||
int count = 0;
|
||||
|
||||
if (!(win = chl->window)) return;
|
||||
|
||||
evas_object_hide(chl->o_bg);
|
||||
|
||||
/* create selector background */
|
||||
win->o_sel_bg = edje_object_add(win->evas);
|
||||
_theme_apply(win->o_sel_bg, "express/selector/background");
|
||||
if (_ex_cfg->gui.translucent)
|
||||
edje_object_signal_emit(win->o_sel_bg, "translucent,on", "express");
|
||||
else
|
||||
edje_object_signal_emit(win->o_sel_bg, "translucent,off", "express");
|
||||
|
||||
edje_object_signal_emit(win->o_sel_bg, "begin", "express");
|
||||
|
||||
/* create selector */
|
||||
if (!(win->o_sel = _selector_add(win->o_win))) return;
|
||||
|
||||
EINA_LIST_FOREACH(win->channels, l, ch)
|
||||
{
|
||||
Evas_Coord w = 0, h = 0;
|
||||
|
||||
edje_object_part_unswallow(ch->o_bg, ch->o_base);
|
||||
evas_object_lower(ch->o_base);
|
||||
evas_object_move(ch->o_base, -9999, -9999);
|
||||
evas_object_show(ch->o_base);
|
||||
evas_object_clip_unset(ch->o_base);
|
||||
#if (EVAS_VERSION_MAJOR > 1) || (EVAS_VERSION_MINOR >= 8)
|
||||
evas_object_image_source_visible_set(ch->o_img, EINA_FALSE);
|
||||
#endif
|
||||
ch->unswallowed = EINA_TRUE;
|
||||
|
||||
ch->o_img = evas_object_image_filled_add(win->evas);
|
||||
evas_object_image_source_set(ch->o_img, ch->o_base);
|
||||
evas_object_geometry_get(ch->o_base, NULL, NULL, &w, &h);
|
||||
evas_object_resize(ch->o_img, w, h);
|
||||
evas_object_data_set(ch->o_img, "grid", ch->o_grid);
|
||||
|
||||
_selector_entry_add(win->o_sel, ch->o_img, (ch == chl), ch->missed);
|
||||
}
|
||||
|
||||
edje_object_part_swallow(win->o_sel_bg, "content", win->o_sel);
|
||||
evas_object_show(win->o_sel);
|
||||
|
||||
edje_object_part_swallow(win->o_base, "base.content", win->o_sel_bg);
|
||||
evas_object_show(win->o_sel_bg);
|
||||
|
||||
evas_object_smart_callback_add(win->o_sel, "selected",
|
||||
_cb_selector_selected, win);
|
||||
evas_object_smart_callback_add(win->o_sel, "exit",
|
||||
_cb_selector_exit, win);
|
||||
evas_object_smart_callback_add(win->o_sel, "ending",
|
||||
_cb_selector_ending, win);
|
||||
|
||||
_selector_go(win->o_sel);
|
||||
|
||||
count = eina_list_count(win->channels);
|
||||
if (count >= 1)
|
||||
z = (1.0 / (sqrt(count)) * 0.8);
|
||||
if (z > 1.0) z = 1.0;
|
||||
|
||||
_selector_zoom_set(win->o_sel, z);
|
||||
_selector_zoom(win->o_sel, z);
|
||||
|
||||
if (chl != new_chl)
|
||||
{
|
||||
_selector_entry_selected_set(win->o_sel, new_chl->o_img, EINA_TRUE);
|
||||
_selector_exit(win->o_sel);
|
||||
}
|
||||
|
||||
elm_object_focus_set(win->o_sel, EINA_TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_channel_prev(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
|
||||
{
|
||||
Channel *chl, *pchl = NULL;
|
||||
|
||||
if (!(chl = data)) return;
|
||||
|
||||
if (chl->focused) pchl = _main_channel_previous_get(chl);
|
||||
if (pchl)
|
||||
{
|
||||
_main_channel_switch(chl, pchl);
|
||||
/* _main_channel_focus(pchl); */
|
||||
/* _main_channel_focus_show(pchl); */
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_channel_next(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
|
||||
{
|
||||
Channel *chl, *nchl = NULL;
|
||||
|
||||
if (!(chl = data)) return;
|
||||
|
||||
if (chl->focused) nchl = _main_channel_next_get(chl);
|
||||
if (nchl)
|
||||
{
|
||||
_main_channel_switch(chl, nchl);
|
||||
/* _main_channel_focus(nchl); */
|
||||
/* _main_channel_focus_show(nchl); */
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_chlcount_go(void *data, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Channel *chl;
|
||||
|
||||
if (!(chl = data)) return;
|
||||
_main_channel_switch(chl, chl);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_chlcount_prev(void *data, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
_cb_channel_prev(data, NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_chlcount_next(void *data, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
_cb_channel_next(data, NULL, NULL);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_main_window_size_walk(Window *win, int *w, int *h)
|
||||
{
|
||||
|
@ -587,6 +670,11 @@ _main_channel_new(Window *win, const char *name)
|
|||
edje_object_part_swallow(chl->o_base, "channel.content", chl->o_grid);
|
||||
edje_object_part_swallow(chl->o_bg, "background.content", chl->o_base);
|
||||
|
||||
evas_object_smart_callback_add(chl->o_grid, "changed", _cb_changed, NULL);
|
||||
evas_object_smart_callback_add(chl->o_grid, "options", _cb_options, chl);
|
||||
evas_object_smart_callback_add(chl->o_grid, "prev", _cb_channel_prev, chl);
|
||||
evas_object_smart_callback_add(chl->o_grid, "next", _cb_channel_next, chl);
|
||||
|
||||
if (!win->channels) chl->focused = EINA_TRUE;
|
||||
|
||||
/* append this channel to windows list */
|
||||
|
@ -717,6 +805,9 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
|
|||
/* shutdown config */
|
||||
_config_shutdown();
|
||||
|
||||
/* delete cache flush timer */
|
||||
if (_flush_tmr) ecore_timer_del(_flush_tmr);
|
||||
|
||||
/* unregister our logging domain */
|
||||
eina_log_domain_unregister(_log_dom);
|
||||
_log_dom = -1;
|
||||
|
|
Loading…
Reference in New Issue