From b8c6afe5a869e4db8c9546b9de7391aa7a7c243e Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Wed, 5 Apr 2017 19:54:51 +0200 Subject: [PATCH] extra: bring the detail view to the backgrounds --- src/bin/extra_background_selector.c | 20 +++++++ src/bin/extra_private.h | 1 + src/bin/extra_theme_selector.c | 62 +-------------------- src/bin/extra_util.c | 84 +++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 61 deletions(-) diff --git a/src/bin/extra_background_selector.c b/src/bin/extra_background_selector.c index 436ea71..f6eb242 100644 --- a/src/bin/extra_background_selector.c +++ b/src/bin/extra_background_selector.c @@ -51,6 +51,16 @@ _fullscreen_background(void *data, Evas_Object *obj EINA_UNUSED, void *event_inf extra_ui_fullscreen_preview(path); } +static void +_show_details(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Extra_Background *background = data; + Evas_Object *o; + + o = extra_ui_base_object_detail(background, &background->obj, acc, _ui.win); + extra_ui_details_window_show(o); +} + static void _show_tooltip(Extra_Background *b) { @@ -78,6 +88,16 @@ _show_tooltip(Extra_Background *b) elm_box_pack_end(box, o); evas_object_show(o); + //show details + o = elm_button_add(box); + evas_object_smart_callback_add(o, "clicked", _show_details, b); + 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); + //view-fullscreen o = elm_button_add(box); elm_object_text_set(o, "Show fullscreen"); diff --git a/src/bin/extra_private.h b/src/bin/extra_private.h index 6b1cdf9..113ef4e 100644 --- a/src/bin/extra_private.h +++ b/src/bin/extra_private.h @@ -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); +Evas_Object* extra_ui_base_object_detail(void *real_obj, Extra_Base_Object *obj, Extra_Ui_Small_Preview_Accessor acc, Evas_Object *par); 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); diff --git a/src/bin/extra_theme_selector.c b/src/bin/extra_theme_selector.c index 8967863..f1b6bf8 100644 --- a/src/bin/extra_theme_selector.c +++ b/src/bin/extra_theme_selector.c @@ -17,18 +17,6 @@ static Extra_Ui_Small_Preview_Accessor acc = { ((Extra_ui_preview_download*) extra_theme_preview_download), }; - -static void -_fullscreen_picture(void *data, Evas *e EINA_UNUSED, 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 _install_done(void *data) { @@ -122,45 +110,8 @@ static void _popup_theme(Extra_Theme *theme) { Evas_Object *o, *table; - Eina_Strbuf *buf; - 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); - - evas_object_show(o); - - - buf = eina_strbuf_new(); - eina_strbuf_append_printf(buf, "%s", theme->obj.name); - - 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); - 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, 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); - evas_object_show(o); - elm_table_pack(table, o, 0, 1, 2, 1); - - buf = eina_strbuf_new(); - eina_strbuf_append_printf(buf, "%s", theme->obj.author); - - 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); - evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(o); - elm_table_pack(table, o, 0, 2, 2, 1); + table = extra_ui_base_object_detail(theme, &theme->obj, acc, _ui.win); o = elm_entry_add(table); elm_entry_editable_set(o, EINA_FALSE); @@ -170,17 +121,6 @@ _popup_theme(Extra_Theme *theme) evas_object_show(o); elm_table_pack(table, o, 0, 3, 2, 2); - buf = eina_strbuf_new(); - eina_strbuf_append_printf(buf, "%s", theme->obj.source); - - 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); - evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(o); - elm_table_pack(table, o, 0, 4, 2, 2); - extra_ui_details_window_show(table); } diff --git a/src/bin/extra_util.c b/src/bin/extra_util.c index 32b47a7..103dcc6 100644 --- a/src/bin/extra_util.c +++ b/src/bin/extra_util.c @@ -388,3 +388,87 @@ extra_ui_details_window_show(Evas_Object *content) elm_object_focus_set(content, EINA_TRUE); } + + +static void +_fullscreen(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) +{ + Extra_Ui_Small_Preview_Accessor *acc = evas_object_data_get(obj, "_acc"); + char *path; + + path = acc->preview_get(data); + + if (!path) return; + + extra_ui_fullscreen_preview(path); +} + + +static void +_link(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Extra_Base_Object *ob = data; + Eina_Strbuf *buf; + + buf = eina_strbuf_new(); + eina_strbuf_append_printf(buf, "xdg-open %s", ob->source); + + ecore_exe_run(eina_strbuf_release(buf), NULL); +} + +Evas_Object* +extra_ui_base_object_detail(void *real_obj, Extra_Base_Object *obj, Extra_Ui_Small_Preview_Accessor acc, Evas_Object *par) +{ + Evas_Object *o, *table; + Eina_Strbuf *buf; + + table = o = elm_table_add(par); + 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_show(o); + + buf = eina_strbuf_new(); + eina_strbuf_append_printf(buf, "%s", obj->name); + + 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); + evas_object_show(o); + elm_table_pack(table, o, 0, 0, 1, 1); + + o = extra_ui_small_preview_new(acc, table, obj); + evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _fullscreen, real_obj); + 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_show(o); + elm_table_pack(table, o, 0, 1, 2, 1); + + buf = eina_strbuf_new(); + eina_strbuf_append_printf(buf, "%s", obj->author); + + 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); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0); + evas_object_show(o); + elm_table_pack(table, o, 0, 2, 1, 1); + + if (obj->source) + { + buf = eina_strbuf_new(); + eina_strbuf_append_printf(buf, "Source"); + + o = elm_entry_add(table); + evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _link, obj); + 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); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0); + evas_object_show(o); + elm_table_pack(table, o, 1, 2, 1, 1); + } + + return table; +}