ajwillia-ms pushed a commit to branch master. http://git.enlightenment.org/tools/edi.git/commit/?id=9751009a7e0c315f3949f85735d7ae2c4f0ecfe4
commit 9751009a7e0c315f3949f85735d7ae2c4f0ecfe4 Author: Andy Williams <[email protected]> Date: Sun Feb 22 14:17:51 2015 +0000 files: Use correct icon for mime/editor type Use mime type or user selected default type for file icons. Use the same icon lookups for our popup menus to be consistent too. --- src/bin/edi_content_provider.c | 10 +++--- src/bin/edi_content_provider.h | 1 + src/bin/edi_filepanel.c | 75 +++++++++++++++++++++++++---------------- src/bin/mainview/edi_mainview.c | 30 +++++++++++------ 4 files changed, 71 insertions(+), 45 deletions(-) diff --git a/src/bin/edi_content_provider.c b/src/bin/edi_content_provider.c index e508e10..44c8cf6 100644 --- a/src/bin/edi_content_provider.c +++ b/src/bin/edi_content_provider.c @@ -49,12 +49,12 @@ _edi_content_provider_diff_add(Evas_Object *parent, Edi_Mainview_Item *item) static Edi_Content_Provider _edi_content_provider_registry[] = { - {"text", EINA_TRUE, EINA_TRUE, edi_editor_add}, - {"code", EINA_TRUE, EINA_TRUE, edi_editor_add}, - {"image", EINA_FALSE, EINA_FALSE, _edi_content_provider_image_add}, - {"diff", EINA_TRUE, EINA_FALSE, _edi_content_provider_diff_add}, + {"text", "txt", EINA_TRUE, EINA_TRUE, edi_editor_add}, + {"code", "text-x-csrc", EINA_TRUE, EINA_TRUE, edi_editor_add}, + {"image", "image", EINA_FALSE, EINA_FALSE, _edi_content_provider_image_add}, + {"diff", "text-x-source", EINA_TRUE, EINA_FALSE, _edi_content_provider_diff_add}, - {NULL, EINA_FALSE, EINA_FALSE, NULL} + {NULL, NULL, EINA_FALSE, EINA_FALSE, NULL} }; Edi_Content_Provider *edi_content_provider_for_mime_get(const char *mime) diff --git a/src/bin/edi_content_provider.h b/src/bin/edi_content_provider.h index d870290..5cd2da3 100644 --- a/src/bin/edi_content_provider.h +++ b/src/bin/edi_content_provider.h @@ -17,6 +17,7 @@ extern "C" { typedef struct _Edi_Content_Provider { const char *id; + const char *icon; Eina_Bool is_text; Eina_Bool is_editable; diff --git a/src/bin/edi_filepanel.c b/src/bin/edi_filepanel.c index 54c3d81..289926f 100644 --- a/src/bin/edi_filepanel.c +++ b/src/bin/edi_filepanel.c @@ -11,6 +11,7 @@ #include "Edi.h" #include "edi_filepanel.h" +#include "edi_content_provider.h" #include "edi_private.h" @@ -90,6 +91,19 @@ _item_menu_dismissed_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, } static void +_item_menu_filetype_create(Evas_Object *menu, Elm_Object_Item *parent, const char *type, + Evas_Smart_Cb func) +{ + Edi_Content_Provider *provider; + + provider = edi_content_provider_for_id_get(type); + if (!provider) + return; + + elm_menu_item_add(menu, parent, provider->icon, provider->id, func, NULL); +} + +static void _item_menu_create(Evas_Object *win) { Elm_Object_Item *menu_it; @@ -103,9 +117,9 @@ _item_menu_create(Evas_Object *win) menu_it = elm_menu_item_add(menu, NULL, "gtk-execute", "open external", _item_menu_xdgopen_cb, NULL); menu_it = elm_menu_item_add(menu, NULL, NULL, "open as", NULL, NULL); - elm_menu_item_add(menu, menu_it, "txt", "text", _item_menu_open_as_text_cb, NULL); - elm_menu_item_add(menu, menu_it, "text-x-csrc", "code", _item_menu_open_as_code_cb, NULL); - elm_menu_item_add(menu, menu_it, "image", "image", _item_menu_open_as_image_cb, NULL); + _item_menu_filetype_create(menu, menu_it, "text", _item_menu_open_as_text_cb); + _item_menu_filetype_create(menu, menu_it, "code", _item_menu_open_as_code_cb); + _item_menu_filetype_create(menu, menu_it, "image", _item_menu_open_as_image_cb); } static void @@ -139,25 +153,27 @@ _text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *source EINA_UNUS static Evas_Object * _content_get(void *data, Evas_Object *obj, const char *source) { - if (!strcmp(source, "elm.swallow.icon")) - { - Evas_Object *ic; - const char *iconpath; + Evas_Object *ic; + Edi_Content_Provider *provider; + const char *mime; - ic = elm_icon_add(obj); - // TODO hook into the selected theme somehow (currently owned by E...) - iconpath = efreet_mime_type_icon_get(data, "hicolor", 128); + if (strcmp(source, "elm.swallow.icon")) + return NULL; - if (iconpath) - elm_image_file_set(ic, iconpath, NULL); - else - elm_icon_standard_set(ic, "file"); + mime = efreet_mime_type_get((const char *)data); + provider = edi_content_provider_for_mime_get(mime); - evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); - evas_object_show(ic); - return ic; - } - return NULL; + ic = elm_icon_add(obj); + elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME); + if (provider) + elm_icon_standard_set(ic, provider->icon); + else + elm_icon_standard_set(ic, "empty"); + + evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + evas_object_show(ic); + + return ic; } static void @@ -178,17 +194,17 @@ _item_sel(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED static Evas_Object * _content_dir_get(void *data EINA_UNUSED, Evas_Object *obj, const char *source) { - if (!strcmp(source, "elm.swallow.icon")) - { - Evas_Object *ic; + Evas_Object *ic; - ic = elm_icon_add(obj); - elm_icon_standard_set(ic, "folder"); - evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); - evas_object_show(ic); - return ic; - } - return NULL; + if (strcmp(source, "elm.swallow.icon")) + return NULL; + + ic = elm_icon_add(obj); + elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME); + elm_icon_standard_set(ic, "folder"); + evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + evas_object_show(ic); + return ic; } static Eina_Bool @@ -387,6 +403,7 @@ edi_filepanel_add(Evas_Object *parent, Evas_Object *win, const char *sharedpath; list = elm_genlist_add(parent); + elm_genlist_homogeneous_set(list, EINA_TRUE); evas_object_size_hint_min_set(list, 100, -1); evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL); diff --git a/src/bin/mainview/edi_mainview.c b/src/bin/mainview/edi_mainview.c index eecc04d..c9baafa 100644 --- a/src/bin/mainview/edi_mainview.c +++ b/src/bin/mainview/edi_mainview.c @@ -283,9 +283,24 @@ _edi_mainview_choose_type_close_cb(void *data EINA_UNUSED, } static void +_edi_mainview_filetype_create(Evas_Object *popup, const char *type, void *cb) +{ + Edi_Content_Provider *provider; + Evas_Object *icon; + + provider = edi_content_provider_for_id_get(type); + if (!provider) + return; + + icon = elm_icon_add(popup); + elm_icon_standard_set(icon, provider->icon); + elm_popup_item_append(popup, type, icon, cb, type); +} + +static void _edi_mainview_choose_type(Evas_Object *parent EINA_UNUSED, Edi_Path_Options *options, void *cb) { - Evas_Object *popup, *cancel, *icon; + Evas_Object *popup, *cancel; popup = elm_popup_add(_main_win); _edi_mainview_choose_popup = popup; @@ -295,16 +310,9 @@ _edi_mainview_choose_type(Evas_Object *parent EINA_UNUSED, Edi_Path_Options *opt elm_object_part_text_set(popup, "title,text", "Unrecognied file type"); - icon = elm_icon_add(popup); - elm_icon_standard_set(icon, "txt"); - elm_popup_item_append(popup, "text", icon, cb, "text"); - icon = elm_icon_add(popup); - elm_icon_standard_set(icon, "text-x-csrc"); - elm_popup_item_append(popup, "code", icon, cb, "code"); - icon = elm_icon_add(popup); - elm_icon_standard_set(icon, "image"); - elm_popup_item_append(popup, "image", icon, cb, "image"); - + _edi_mainview_filetype_create(popup, "text", cb); + _edi_mainview_filetype_create(popup, "code", cb); + _edi_mainview_filetype_create(popup, "image", cb); cancel = elm_button_add(popup); elm_object_text_set(cancel, "cancel"); --
