extra: move the inwin creation code to utils

This commit is contained in:
Marcel Hollerbach 2017-04-05 16:37:02 +02:00
parent 0bf20cea61
commit 36661e17c4
3 changed files with 46 additions and 29 deletions

View File

@ -27,6 +27,7 @@ typedef struct {
} Extra_Ui_Small_Preview_Accessor;
Evas_Object* extra_ui_small_preview_new(Extra_Ui_Small_Preview_Accessor acc, Evas_Object *par, void *data);
void extra_ui_details_window_show(Evas_Object *content);
void extra_ui_fullscreen_preview(char *path);
void extra_ui_show_popup_toolbar(Evas_Object *content);
void gengrid_reapply_state(Evas_Object *grid);

View File

@ -29,19 +29,6 @@ _fullscreen_picture(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSE
extra_ui_fullscreen_preview(path);
}
static void
_detail_preview_del(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info)
{
Evas_Event_Mouse_Up *up = event_info;
Eina_Rectangle box;
evas_object_geometry_get(data, &box.x, &box.y, &box.w, &box.h);
if (eina_rectangle_coords_inside(&box, up->output.x , up->output.y)) return;
evas_object_del(obj);
}
static void
_install_done(void *data)
{
@ -132,27 +119,22 @@ _action_button_create(Evas_Object *par, Extra_Theme *theme)
}
static void
_popup_theme(Evas_Object *win, Extra_Theme *theme)
_popup_theme(Extra_Theme *theme)
{
Evas_Object *o, *inwin, *table;
Evas_Object *o, *table;
Eina_Strbuf *buf;
inwin = o = elm_win_inwin_add(win);
table = o = elm_table_add(_ui.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);
buf = eina_strbuf_new();
eina_strbuf_append_printf(buf, "<title>%s</title>", theme->obj.name);
o = elm_label_add(inwin);
o = elm_label_add(table);
elm_object_text_set(o, eina_strbuf_release(buf));
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, 0.0, EVAS_HINT_FILL);
@ -162,7 +144,7 @@ _popup_theme(Evas_Object *win, Extra_Theme *theme)
o = _action_button_create(table, theme);
elm_table_pack(table, o, 1, 0, 1, 1);
o = extra_ui_small_preview_new(acc, inwin, theme);
o = extra_ui_small_preview_new(acc, table, theme);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _fullscreen_picture, theme);
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);
@ -172,7 +154,7 @@ _popup_theme(Evas_Object *win, Extra_Theme *theme)
buf = eina_strbuf_new();
eina_strbuf_append_printf(buf, "<link>%s</link>", theme->obj.author);
o = elm_entry_add(inwin);
o = elm_entry_add(table);
elm_object_text_set(o, eina_strbuf_release(buf));
elm_entry_editable_set(o, EINA_FALSE);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
@ -180,7 +162,7 @@ _popup_theme(Evas_Object *win, Extra_Theme *theme)
evas_object_show(o);
elm_table_pack(table, o, 0, 2, 2, 1);
o = elm_entry_add(inwin);
o = elm_entry_add(table);
elm_entry_editable_set(o, EINA_FALSE);
elm_object_text_set(o, theme->description);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
@ -189,9 +171,9 @@ _popup_theme(Evas_Object *win, Extra_Theme *theme)
elm_table_pack(table, o, 0, 3, 2, 2);
buf = eina_strbuf_new();
eina_strbuf_append_printf(buf, "<link>%s</link>", theme->obj.source, theme->obj.source);
eina_strbuf_append_printf(buf, "<link>%s</link>", theme->obj.source);
o = elm_entry_add(inwin);
o = elm_entry_add(table);
elm_entry_editable_set(o, EINA_FALSE);
elm_object_text_set(o, eina_strbuf_release(buf));
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
@ -199,7 +181,8 @@ _popup_theme(Evas_Object *win, Extra_Theme *theme)
evas_object_show(o);
elm_table_pack(table, o, 0, 4, 2, 2);
elm_win_inwin_activate(inwin);
extra_ui_details_window_show(table);
}
static Evas_Object*
@ -223,7 +206,7 @@ _text_basic_get(void *data, Evas_Object *obj EINA_UNUSED, const char *source EIN
static void
_show_details(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
_popup_theme(_ui.win, data);
_popup_theme(data);
evas_object_del(_ui.popup_toolbar);
}

View File

@ -355,3 +355,36 @@ extra_ui_show_popup_toolbar(Evas_Object *content)
_ui.popup_toolbar = tooltip;
}
static void
_detail_preview_del(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info)
{
Evas_Object *content;
Evas_Event_Mouse_Up *up = event_info;
Eina_Rectangle box;
content = elm_object_content_get(obj);
evas_object_geometry_get(content, &box.x, &box.y, &box.w, &box.h);
if (eina_rectangle_coords_inside(&box, up->output.x , up->output.y)) return;
evas_object_del(obj);
}
void
extra_ui_details_window_show(Evas_Object *content)
{
Evas_Object *o;
o = elm_win_inwin_add(_ui.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);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _detail_preview_del, o);
evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, _key_down_cb, o);
elm_win_inwin_activate(o);
elm_object_content_set(o, content);
elm_object_focus_set(content, EINA_TRUE);
}