extra: bring a little toolbar to the themes

I liked the popup at the top more than diretly showing the details.
This also refactors the popup showing and hiding into the utils
This commit is contained in:
Marcel Hollerbach 2017-01-22 22:35:12 +01:00
parent 06fed444de
commit f57ef54ad8
4 changed files with 131 additions and 63 deletions

View File

@ -4,7 +4,6 @@
#include "../lib/extra.h"
static Evas_Object *_selector;
static Evas_Object *_popup;
static Elm_Gengrid_Item_Class *_item_class_basic;
@ -49,37 +48,16 @@ _fullscreen_background(void *data, Evas_Object *obj EINA_UNUSED, void *event_inf
extra_ui_fullscreen_preview(path);
}
static void
_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
_popup = NULL;
evas_object_del(_popup);
}
static void
_show_tooltip(Extra_Background *b)
{
Evas_Object *tooltip, *box, *o, *icon;
Evas_Object *box, *o, *icon;
if (_popup)
{
evas_object_del(_popup);
_popup = NULL;
}
tooltip = elm_popup_add(_selector);
evas_object_smart_callback_add(tooltip, "block,clicked", _del, tooltip);
elm_popup_allow_events_set(tooltip, EINA_TRUE);
elm_popup_orient_set(tooltip, ELM_POPUP_ORIENT_TOP);
evas_object_show(tooltip);
box = elm_box_add(tooltip);
box = elm_box_add(_ui.win);
elm_box_horizontal_set(box, EINA_TRUE);
elm_object_content_set(tooltip, box);
icon = elm_icon_add(tooltip);
o = elm_button_add(box);
icon = elm_icon_add(o);
if (extra_background_installed(b))
{
@ -103,11 +81,11 @@ _show_tooltip(Extra_Background *b)
evas_object_smart_callback_add(o, "clicked", _fullscreen_background , b);
elm_box_pack_end(box, o);
evas_object_show(o);
icon = elm_icon_add(tooltip);
icon = elm_icon_add(o);
elm_icon_standard_set(icon, "view-fullscreen");
elm_object_part_content_set(o, "icon", icon);
_popup = tooltip;
extra_ui_show_popup_toolbar(box);
}
static void
@ -152,10 +130,10 @@ _item_selected(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event
static void
_selector_hide(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
if (_popup)
if (_ui.popup_toolbar)
{
evas_object_del(_popup);
_popup = NULL;
evas_object_del(_ui.popup_toolbar);
_ui.popup_toolbar = NULL;
}
}

View File

@ -7,6 +7,7 @@ typedef struct {
Evas_Object *win;
Evas_Object *background_selector;
Evas_Object *theme_selector;
Evas_Object *popup_toolbar;
} Ui;
extern Ui _ui;
@ -27,6 +28,6 @@ typedef struct {
Evas_Object* extra_ui_small_preview_new(Extra_Ui_Small_Preview_Accessor acc, Evas_Object *par, void *data);
void extra_ui_fullscreen_preview(char *path);
void extra_ui_show_popup_toolbar(Evas_Object *content);
#endif

View File

@ -77,45 +77,20 @@ _set_as_default(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_
extra_theme_use(candidate);
}
static void
_popup_theme(Evas_Object *win, Extra_Theme *theme)
static Evas_Object*
_action_button_create(Evas_Object *par, Extra_Theme *theme)
{
Evas_Object *o, *inwin, *table;
Evas_Object *install = NULL, *icon = NULL;
char title_str[1024], author_str[1024];
snprintf(title_str, sizeof(title_str), "<title>%s</title>", theme->name);
snprintf(author_str, sizeof(author_str), "<link>%s</link>", theme->author);
inwin = o = elm_win_inwin_add(win);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
table = o = elm_table_add(inwin);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_content_set(inwin, o);
evas_object_show(o);
evas_object_event_callback_add(inwin, EVAS_CALLBACK_MOUSE_UP, _detail_preview_del, o);
o = elm_label_add(inwin);
elm_object_text_set(o, title_str);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, 0.0, EVAS_HINT_FILL);
evas_object_show(o);
elm_table_pack(table, o, 0, 0, 1, 1);
if (!extra_theme_default_get(theme))
{
icon = elm_icon_add(table);
icon = elm_icon_add(par);
evas_object_show(icon);
install = o = elm_button_add(table);
install = elm_button_add(par);
elm_object_part_content_set(install, "icon", icon);
evas_object_size_hint_weight_set(install, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(install, 1.0, 0.5);
elm_table_pack(table, o, 1, 0, 1, 1);
evas_object_show(install);
}
@ -140,6 +115,39 @@ _popup_theme(Evas_Object *win, Extra_Theme *theme)
evas_object_smart_callback_add(install, "clicked", _set_as_default, theme);
elm_object_text_set(install, "Set as default");
}
return install;
}
static void
_popup_theme(Evas_Object *win, Extra_Theme *theme)
{
Evas_Object *o, *inwin, *table;
char title_str[1024], author_str[1024];
snprintf(title_str, sizeof(title_str), "<title>%s</title>", theme->name);
snprintf(author_str, sizeof(author_str), "<link>%s</link>", theme->author);
inwin = o = elm_win_inwin_add(win);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
table = o = elm_table_add(inwin);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_content_set(inwin, o);
evas_object_show(o);
evas_object_event_callback_add(inwin, EVAS_CALLBACK_MOUSE_UP, _detail_preview_del, o);
o = elm_label_add(inwin);
elm_object_text_set(o, title_str);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, 0.0, EVAS_HINT_FILL);
evas_object_show(o);
elm_table_pack(table, o, 0, 0, 1, 1);
o = _action_button_create(table, theme);
elm_table_pack(table, o, 1, 0, 1, 1);
o = extra_ui_small_preview_new(acc, inwin, theme);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _fullscreen_picture, theme);
@ -186,11 +194,55 @@ _text_basic_get(void *data, Evas_Object *obj EINA_UNUSED, const char *source EIN
}
static void
_item_selected(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
_show_details(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Elm_Gengrid_Item *it = event_info;
_popup_theme(_ui.win, data);
}
_popup_theme(data, elm_object_item_data_get(it));
static void
_show_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
char *path;
path = extra_theme_preview_get(data);
if (!path) return;
extra_ui_fullscreen_preview(path);
}
static void
_item_selected(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Evas_Object *box, *o, *icon;
Elm_Gengrid_Item *it = event_info;
Extra_Theme *t = elm_object_item_data_get(it);
box = elm_box_add(_ui.win);
elm_box_horizontal_set(box, EINA_TRUE);
o = _action_button_create(box, t);
if (o)
elm_box_pack_end(box, o);
o = elm_button_add(box);
evas_object_smart_callback_add(o, "clicked", _show_fullscreen, t);
elm_object_text_set(o, "Show Fullscreen");
evas_object_show(o);
elm_box_pack_end(box, o);
icon = elm_icon_add(o);
elm_icon_standard_set(icon, "view-fullscreen");
elm_object_part_content_set(o, "icon", icon);
o = elm_button_add(box);
evas_object_smart_callback_add(o, "clicked", _show_details, t);
elm_object_text_set(o, "Show Details");
evas_object_show(o);
elm_box_pack_end(box, o);
icon = elm_icon_add(o);
elm_icon_standard_set(icon, "document-properties");
elm_object_part_content_set(o, "icon", icon);
extra_ui_show_popup_toolbar(box);
}
static void

View File

@ -242,4 +242,41 @@ extra_ui_fullscreen_preview(char *path)
elm_object_content_set(win, image);
evas_object_show(win);
}
static void
_popup_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
elm_popup_dismiss(data);
evas_object_del(obj);
_ui.popup_toolbar = NULL;
}
void
extra_ui_show_popup_toolbar(Evas_Object *content)
{
Evas_Object *tooltip, *rect;
if (_ui.popup_toolbar)
{
evas_object_del(_ui.popup_toolbar);
_ui.popup_toolbar = NULL;
}
tooltip = elm_popup_add(_ui.win);
elm_popup_allow_events_set(tooltip, EINA_TRUE);
elm_popup_orient_set(tooltip, ELM_POPUP_ORIENT_TOP);
elm_object_content_set(tooltip, content);
evas_object_show(tooltip);
rect = evas_object_rectangle_add(evas_object_evas_get(_ui.win));
evas_object_repeat_events_set(rect, EINA_TRUE);
evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(rect, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_color_set(rect, 0, 0, 0, 0);
evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _popup_del_cb, tooltip);
elm_win_resize_object_add(_ui.win, rect);
evas_object_show(rect);
_ui.popup_toolbar = tooltip;
}