diff --git a/src/modules/everything/e_mod_main.c b/src/modules/everything/e_mod_main.c index 0b898b119..4788ffcb5 100644 --- a/src/modules/everything/e_mod_main.c +++ b/src/modules/everything/e_mod_main.c @@ -110,7 +110,6 @@ e_modapi_init(E_Module *m) SET(action_find); SET(api_version_check); SET(type_register); - SET(icon_mime_get); SET(icon_theme_get); SET(fuzzy_match); SET(util_exec_app); @@ -526,7 +525,7 @@ _e_mod_run_defer_cb(void *data) E_Zone *zone; zone = data; - if (zone) evry_show(zone, E_ZONE_EDGE_NONE, _params); + if (zone) evry_show(zone, E_ZONE_EDGE_NONE, _params, EINA_TRUE); _idler = NULL; return ECORE_CALLBACK_CANCEL; @@ -570,7 +569,7 @@ _e_mod_action_cb_edge(E_Object *obj __UNUSED__, const char *params, E_Event_Zon if (_idler) ecore_idle_enterer_del(_idler); - evry_show(ev->zone, ev->edge, _params); + evry_show(ev->zone, ev->edge, _params, EINA_TRUE); } /* menu item callback(s) */ diff --git a/src/modules/everything/e_mod_main.h b/src/modules/everything/e_mod_main.h index a74eaa8c4..5ea9c4f7a 100644 --- a/src/modules/everything/e_mod_main.h +++ b/src/modules/everything/e_mod_main.h @@ -205,7 +205,7 @@ void evry_plugin_update(Evry_Plugin *plugin, int state); void evry_clear_input(Evry_Plugin *p); /* evry_util.c */ -Evas_Object *evry_icon_mime_get(const char *mime, Evas *e); +/* Evas_Object *evry_icon_mime_get(const char *mime, Evas *e); */ Evas_Object *evry_icon_theme_get(const char *icon, Evas *e); int evry_fuzzy_match(const char *str, const char *match); Eina_List *evry_fuzzy_match_sort(Eina_List *items); @@ -281,7 +281,7 @@ void evry_plug_collection_shutdown(void); int evry_init(void); int evry_shutdown(void); -Evry_Window *evry_show(E_Zone *zone, E_Zone_Edge edge, const char *params); +Evry_Window *evry_show(E_Zone *zone, E_Zone_Edge edge, const char *params, Eina_Bool popup); void evry_hide(Evry_Window *win, int clear); int evry_plug_actions_init(); diff --git a/src/modules/everything/evry.c b/src/modules/everything/evry.c index 5f1134892..fb9be2876 100644 --- a/src/modules/everything/evry.c +++ b/src/modules/everything/evry.c @@ -147,7 +147,7 @@ _evry_cb_item_changed(__UNUSED__ void *data, __UNUSED__ int type, void *event) } Evry_Window * -evry_show(E_Zone *zone, E_Zone_Edge edge, const char *params) +evry_show(E_Zone *zone, E_Zone_Edge edge, const char *params, Eina_Bool popup) { Evry_Window *win; Evry_Selector *sel; @@ -163,18 +163,22 @@ evry_show(E_Zone *zone, E_Zone_Edge edge, const char *params) if (!(win = _evry_window_new(zone, edge))) return NULL; - e_win_layer_set(win->ewin, 255); - ecore_x_netwm_window_type_set(win->ewin->evas_win, - ECORE_X_WINDOW_TYPE_UTILITY); + if (popup) + { + e_win_layer_set(win->ewin, 255); + ecore_x_netwm_window_type_set(win->ewin->evas_win, + ECORE_X_WINDOW_TYPE_UTILITY); - ecore_evas_name_class_set(win->ewin->ecore_evas, "E", "everything"); - ecore_evas_show(win->ewin->ecore_evas); - - if (e_grabinput_get(win->ewin->evas_win, 0, win->ewin->evas_win)) - win->grab = 1; - else - ERR("could not acquire grab"); + ecore_evas_name_class_set(win->ewin->ecore_evas, "E", "everything"); + + ecore_evas_show(win->ewin->ecore_evas); + if (e_grabinput_get(win->ewin->evas_win, 0, win->ewin->evas_win)) + win->grab = 1; + else + ERR("could not acquire grab"); + } + evry_history_load(); if (params) @@ -1236,7 +1240,8 @@ _evry_selector_thumb(Evry_Selector *sel, const Evry_Item *it) evas_object_del(sel->o_thumb); sel->o_thumb = NULL; - if (it->type != EVRY_TYPE_FILE) return 0; + if (it->type != EVRY_TYPE_FILE) + return 0; GET_FILE(file, it); @@ -1605,23 +1610,26 @@ evry_browse_item(Evry_Item *it) } else { - if ((it->plugin->browse) && - (pp = it->plugin->browse(it->plugin, it))) + if ((it->plugin->browse) && (pp = it->plugin->browse(it->plugin, it))) { plugins = eina_list_append(plugins, pp); pref = pp; } - EINA_LIST_FOREACH(sel->plugins, l, p) + /* items of type NONE can only be browsed by their own plugin */ + if (!CHECK_TYPE(it, EVRY_TYPE_NONE)) { - if (!p->browse) - continue; + EINA_LIST_FOREACH(sel->plugins, l, p) + { + if (!p->browse) + continue; - if ((pref) && (!strcmp(p->name, pref->name))) - continue; + if ((pref) && (!strcmp(p->name, pref->name))) + continue; - if ((pp = p->browse(p, it))) - plugins = eina_list_append(plugins, pp); + if ((pp = p->browse(p, it))) + plugins = eina_list_append(plugins, pp); + } } } diff --git a/src/modules/everything/evry_api.h b/src/modules/everything/evry_api.h index 2035b2c77..22667d929 100644 --- a/src/modules/everything/evry_api.h +++ b/src/modules/everything/evry_api.h @@ -3,7 +3,7 @@ #include "evry_types.h" -#define EVRY_API_VERSION 27 +#define EVRY_API_VERSION 28 #define EVRY_ACTION_OTHER 0 #define EVRY_ACTION_FINISHED 1 @@ -101,8 +101,8 @@ struct _Evry_API Evry_Type (*type_register)(const char *type); /* evry_util.c */ - Evas_Object *(*icon_mime_get)(const char *mime, Evas *e); Evas_Object *(*icon_theme_get)(const char *icon, Evas *e); + int (*fuzzy_match)(const char *str, const char *match); int (*util_exec_app)(const Evry_Item *it_app, const Evry_Item *it_file); char *(*util_url_escape)(const char *string, int inlength); @@ -197,10 +197,10 @@ struct _Evry_Event_Action_Performed EVRY_ITEM(_it)->icon = eina_stringshare_add(_icon); #define CHECK_TYPE(_item, _type) \ - (((Evry_Item *)_item)->type && ((Evry_Item *)_item)->type == _type) + (((Evry_Item *)_item)->type == _type) #define CHECK_SUBTYPE(_item, _type) \ - (((Evry_Item *)_item)->subtype && ((Evry_Item *)_item)->subtype == _type) + (((Evry_Item *)_item)->subtype == _type) #define IS_BROWSEABLE(_item) ((Evry_Item *)_item)->browseable diff --git a/src/modules/everything/evry_gadget.c b/src/modules/everything/evry_gadget.c index 5e7ec5d4c..76c0671f4 100644 --- a/src/modules/everything/evry_gadget.c +++ b/src/modules/everything/evry_gadget.c @@ -153,19 +153,28 @@ _button_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED_ ev = event_info; if (ev->button == 1) { - Evas_Coord x, y, w, h; - int cx, cy, pw, ph; + /* Evas_Coord x, y, w, h; */ + /* int cx, cy, pw, ph; */ Evry_Window *win; + if (inst->win) + { + evry_hide(inst->win, 0); + return; + } - win = evry_show(e_util_zone_current_get(e_manager_current_get()), 0, "Start"); + win = evry_show(e_util_zone_current_get(e_manager_current_get()), 0, "Start", EINA_FALSE); if (!win) return; - evas_object_geometry_get(inst->o_button, &x, &y, &w, &h); - e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, - &cx, &cy, NULL, NULL); - x += cx; - y += cy; + e_win_show(win->ewin); + + + /* evas_object_geometry_get(inst->o_button, &x, &y, &w, &h); + * e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, + * &cx, &cy, NULL, NULL); + * x += cx; + * y += cy; */ + /* evas_object_resize(win->o_main, * evry_conf->edge_width, * evry_conf->edge_height); @@ -174,46 +183,46 @@ _button_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED_ * evry_conf->edge_width, * evry_conf->edge_height); */ - pw = win->ewin->w; - ph = win->ewin->h; - - switch (inst->gcc->gadcon->orient) - { - - case E_GADCON_ORIENT_TOP: - case E_GADCON_ORIENT_CORNER_TL: - case E_GADCON_ORIENT_CORNER_TR: - e_win_move(win->ewin, x, y + h); - break; - case E_GADCON_ORIENT_BOTTOM: - case E_GADCON_ORIENT_CORNER_BR: - case E_GADCON_ORIENT_CORNER_BL: - e_win_move(win->ewin, x, y - ph); - break; - case E_GADCON_ORIENT_LEFT: - case E_GADCON_ORIENT_CORNER_LT: - case E_GADCON_ORIENT_CORNER_LB: - e_win_move(win->ewin, x + w, y); - break; - case E_GADCON_ORIENT_RIGHT: - case E_GADCON_ORIENT_CORNER_RT: - case E_GADCON_ORIENT_CORNER_RB: - e_win_move(win->ewin, x - pw, y); - break; - case E_GADCON_ORIENT_FLOAT: - case E_GADCON_ORIENT_HORIZ: - case E_GADCON_ORIENT_VERT: - default: - break; - } + /* pw = win->ewin->w; + * ph = win->ewin->h; + * + * switch (inst->gcc->gadcon->orient) + * { + * + * case E_GADCON_ORIENT_TOP: + * case E_GADCON_ORIENT_CORNER_TL: + * case E_GADCON_ORIENT_CORNER_TR: + * e_win_move(win->ewin, x, y + h); + * break; + * case E_GADCON_ORIENT_BOTTOM: + * case E_GADCON_ORIENT_CORNER_BR: + * case E_GADCON_ORIENT_CORNER_BL: + * e_win_move(win->ewin, x, y - ph); + * break; + * case E_GADCON_ORIENT_LEFT: + * case E_GADCON_ORIENT_CORNER_LT: + * case E_GADCON_ORIENT_CORNER_LB: + * e_win_move(win->ewin, x + w, y); + * break; + * case E_GADCON_ORIENT_RIGHT: + * case E_GADCON_ORIENT_CORNER_RT: + * case E_GADCON_ORIENT_CORNER_RB: + * e_win_move(win->ewin, x - pw, y); + * break; + * case E_GADCON_ORIENT_FLOAT: + * case E_GADCON_ORIENT_HORIZ: + * case E_GADCON_ORIENT_VERT: + * default: + * break; + * } */ inst->win = win; - if (win->ewin->x + pw > win->zone->w) - e_win_move(win->ewin, win->zone->w - pw, win->ewin->y); - - if (win->ewin->y + ph > win->zone->h) - e_win_move(win->ewin, win->ewin->x, win->zone->h - ph); + /* if (win->ewin->x + pw > win->zone->w) + * e_win_move(win->ewin, win->zone->w - pw, win->ewin->y); + * + * if (win->ewin->y + ph > win->zone->h) + * e_win_move(win->ewin, win->ewin->x, win->zone->h - ph); */ e_gadcon_locked_set(inst->gcc->gadcon, 1); diff --git a/src/modules/everything/evry_plug_aggregator.c b/src/modules/everything/evry_plug_aggregator.c index 0e9da1658..955015ca3 100644 --- a/src/modules/everything/evry_plug_aggregator.c +++ b/src/modules/everything/evry_plug_aggregator.c @@ -93,7 +93,7 @@ _fetch(Evry_Plugin *plugin, const char *input) if (it->usage >= 0) evry_history_item_usage_set(it, input, context); - if (it->usage && it->usage > max_usage) + if (it->usage && (it->usage > max_usage)) max_usage = it->usage; if (it->fuzzy_match == 0) @@ -222,9 +222,8 @@ _fetch(Evry_Plugin *plugin, const char *input) { EINA_LIST_FOREACH(pp->items, ll, it) { - if (((it->usage >= 0) && - (evry_history_item_usage_set(it, input, context))) || - (!subj_sel)) + if ((!subj_sel) || (it->usage < 0) || + (evry_history_item_usage_set(it, input, context))) { it->fuzzy_match = 0; items = eina_list_append(items, it); diff --git a/src/modules/everything/evry_plug_apps.c b/src/modules/everything/evry_plug_apps.c index 3b86e6cc5..b78c4c8d6 100644 --- a/src/modules/everything/evry_plug_apps.c +++ b/src/modules/everything/evry_plug_apps.c @@ -17,17 +17,21 @@ typedef struct _Plugin Plugin; typedef struct _Module_Config Module_Config; typedef struct _E_Exe E_Exe; typedef struct _E_Exe_List E_Exe_List; +typedef struct _Item_Menu Item_Menu; struct _Plugin { Evry_Plugin base; + Eina_Bool browse; const char *input; Eina_List *apps_mime; Eina_List *apps_all; Eina_List *apps_hist; + Eina_List *menu_items; Eina_Hash *added; - + Efreet_Menu *menu;; + Evry_Item_App *command; }; @@ -51,6 +55,13 @@ struct _Module_Config E_Module *module; }; +struct _Item_Menu +{ + Evry_Item base; + + Efreet_Menu *menu;; +}; + static const Evry_API *evry = NULL; static Evry_Module *evry_module = NULL; static Eina_List *handlers = NULL; @@ -70,6 +81,9 @@ static Eina_List *exe_list2 = NULL; static Eina_List *apps_cache = NULL; static void _scan_executables(); + +#define GET_MENU(_m, _it) Item_Menu *_m = (Item_Menu *)_it + /***************************************************************************/ static void _hash_free(void *data) @@ -78,39 +92,6 @@ static void _hash_free(void *data) EVRY_ITEM_FREE(app); } -static Evas_Object * -_icon_get(Evry_Item *it, Evas *e) -{ - GET_APP(app, it); - Evas_Object *o = NULL; - - if (app->desktop && app->desktop->icon) - { - if (app->desktop->icon[0] == '/') - { - o = e_icon_add(e); - e_icon_preload_set(o, 1); - - if (!e_icon_file_set(o, app->desktop->icon)) - { - evas_object_del(o); - o = NULL; - } - } - - if (!o) - o = evry->icon_theme_get(app->desktop->icon, e); - - if (!o) - o = e_util_desktop_icon_add(app->desktop, 128, e); - } - - if (!o) - o = evry->icon_theme_get("system-run", e); - - return o; -} - static int _exec_open_file_action(Evry_Action *act) { @@ -118,7 +99,7 @@ _exec_open_file_action(Evry_Action *act) } static void -_item_free(Evry_Item *item) +_cb_item_free(Evry_Item *item) { GET_APP(app, item); @@ -135,7 +116,7 @@ _item_new(Plugin *p, const char *label, const char *id) { Evry_Item_App *app; - app = EVRY_ITEM_NEW(Evry_Item_App, p, label, _icon_get, _item_free); + app = EVRY_ITEM_NEW(Evry_Item_App, p, label, NULL, _cb_item_free); EVRY_ACTN(app)->action = &_exec_open_file_action; EVRY_ACTN(app)->it1.type = EVRY_TYPE_FILE; EVRY_ITEM(app)->id = eina_stringshare_add(id); @@ -148,6 +129,24 @@ _item_new(Plugin *p, const char *label, const char *id) return app; } +static Item_Menu * +_item_menu_add(Plugin *p, Efreet_Menu *menu) +{ + Item_Menu *m; + + m = EVRY_ITEM_NEW(Item_Menu, p, NULL, NULL, NULL); + EVRY_ITEM(m)->type = EVRY_TYPE_NONE; + EVRY_ITEM(m)->browseable = EINA_TRUE; + EVRY_ITEM(m)->label = eina_stringshare_add(menu->name); + EVRY_ITEM(m)->icon = eina_stringshare_add(menu->icon); + EVRY_ITEM(m)->usage = -1; + + m->menu = menu; + p->menu_items = eina_list_append(p->menu_items, m); + + return m; +} + static int _cb_sort(const void *data1, const void *data2) { @@ -331,7 +330,7 @@ _begin_exe(Evry_Plugin *plugin, const Evry_Item *item) p->added = eina_hash_string_small_new(_hash_free); - app = EVRY_ITEM_NEW(Evry_Item_App, p, NULL, _icon_get, _item_free); + app = EVRY_ITEM_NEW(Evry_Item_App, p, NULL, NULL, _cb_item_free); EVRY_ACTN(app)->action = &_exec_open_file_action; EVRY_ACTN(app)->remember_context = EINA_TRUE; EVRY_ITEM(app)->subtype = EVRY_TYPE_ACTION; @@ -532,27 +531,55 @@ static Evry_Plugin * _begin(Evry_Plugin *plugin, const Evry_Item *item) { Plugin *p; - + if (item && (item != _act_open_with)) return NULL; - EVRY_PLUGIN_INSTANCE(p, plugin) + EVRY_PLUGIN_INSTANCE(p, plugin); p->added = eina_hash_string_small_new(_hash_free); + p->menu = efreet_menu_get(); + + return EVRY_PLUGIN(p); +} +static Evry_Plugin * +_browse(Evry_Plugin *plugin, const Evry_Item *item) +{ + Plugin *p; + + if (!item) + return NULL; + + if (!CHECK_TYPE(item, EVRY_TYPE_NONE)) + return NULL; + + EVRY_PLUGIN_INSTANCE(p, plugin); + GET_MENU(m, item); + + p->added = eina_hash_string_small_new(_hash_free); + p->menu = m->menu; + p->browse = EINA_TRUE; + return EVRY_PLUGIN(p); } static void _finish(Evry_Plugin *plugin) { - GET_PLUGIN(p, plugin); Efreet_Desktop *desktop; - + Evry_Item *it; + + GET_PLUGIN(p, plugin); + EVRY_PLUGIN_ITEMS_CLEAR(p); + /* TODO share with browse instances */ if (p->added) eina_hash_free(p->added); + if ((!p->browse) && (p->menu)) + efreet_menu_free(p->menu); + EINA_LIST_FREE(p->apps_all, desktop) efreet_desktop_free(desktop); @@ -561,6 +588,9 @@ _finish(Evry_Plugin *plugin) EINA_LIST_FREE(p->apps_mime, desktop) efreet_desktop_free(desktop); + EINA_LIST_FREE(p->menu_items, it) + EVRY_ITEM_FREE(it); + E_FREE(p); } @@ -572,36 +602,64 @@ _fetch(Evry_Plugin *plugin, const char *input) Evry_Item *it; History_Types *ht; + Efreet_Menu *entry; + int i = 1; + EVRY_PLUGIN_ITEMS_CLEAR(p); - if (input) + if (!p->browse) { - if (!p->apps_all) - p->apps_all = _desktop_list_get(); - - _desktop_list_add(p, p->apps_all, input); - } - else - { - _desktop_list_add(p, p->apps_mime, input); - } - - if (!input && !(plugin->items)) - { - if (!p->apps_hist) + if (input) { - ht = evry->history_types_get(EVRY_TYPE_APP); - if (ht) eina_hash_foreach(ht->types, _hist_items_get_cb, p); + if (!p->apps_all) + p->apps_all = _desktop_list_get(); + + _desktop_list_add(p, p->apps_all, input); + } + else + { + _desktop_list_add(p, p->apps_mime, input); } - _desktop_list_add(p, p->apps_hist, NULL); + if ((!input) && (!plugin->items)) + { + if (!p->apps_hist) + { + ht = evry->history_types_get(EVRY_TYPE_APP); + if (ht) eina_hash_foreach(ht->types, _hist_items_get_cb, p); + } + + _desktop_list_add(p, p->apps_hist, NULL); + } + + EINA_LIST_FOREACH(plugin->items, l, it) + evry->history_item_usage_set(it, input, NULL); + + EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort); + } + + if ((p->menu) && (!p->menu_items)) + { + EINA_LIST_FOREACH(p->menu->entries, l, entry) + { + if (entry->type == EFREET_MENU_ENTRY_DESKTOP) + { + _item_desktop_add(p, entry->desktop, i++); + } + else if (entry->type == EFREET_MENU_ENTRY_MENU) + { + _item_menu_add(p, entry); + } + /* else if (entry->type == EFREET_MENU_ENTRY_SEPARATOR) + * continue; + * else if (entry->type == EFREET_MENU_ENTRY_HEADER) + * continue; */ + } } - EINA_LIST_FOREACH(plugin->items, l, it) - evry->history_item_usage_set(it, input, NULL); - - EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort); - + EINA_LIST_FOREACH(p->menu_items, l, it) + EVRY_PLUGIN_ITEM_APPEND(p, it); + return !!(plugin->items); } @@ -1029,6 +1087,7 @@ _plugins_init(const Evry_API *api) p = EVRY_PLUGIN_BASE("Applications", _module_icon, EVRY_TYPE_APP, _begin, _finish, _fetch); p->complete = &_complete; + p->browse = &_browse; p->config_path = "extensions/everything-apps"; evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 1); _plugins = eina_list_append(_plugins, p); diff --git a/src/modules/everything/evry_plug_settings.c b/src/modules/everything/evry_plug_settings.c index 789ff426d..548c272c5 100644 --- a/src/modules/everything/evry_plug_settings.c +++ b/src/modules/everything/evry_plug_settings.c @@ -46,19 +46,16 @@ _finish(Evry_Plugin *plugin) static Evas_Object * _icon_get(Evry_Item *item, Evas *e) { - Evas_Object *o; Settings_Item *it = (Settings_Item *) item; + + if (!item->icon) + { + if (it->eci && it->eci->icon) + item->icon = eina_stringshare_add(it->eci->icon); + else if (it->ecat->icon) + item->icon = eina_stringshare_add(it->ecat->icon); + } - if (it->eci && it->eci->icon && - ((o = evry->icon_theme_get(it->eci->icon, e)) || - (o = e_util_icon_add(it->eci->icon, e)))) - return o; - - if (it->ecat->icon && - ((o = evry->icon_theme_get(it->ecat->icon, e)) || - (o = e_util_icon_add(it->ecat->icon, e)))) - return o; - return NULL; } diff --git a/src/modules/everything/evry_util.c b/src/modules/everything/evry_util.c index 20ae4c46c..ac07ba86a 100644 --- a/src/modules/everything/evry_util.c +++ b/src/modules/everything/evry_util.c @@ -391,146 +391,116 @@ evry_util_plugin_items_add(Evry_Plugin *p, Eina_List *items, const char *input, Evas_Object * evry_icon_theme_get(const char *icon, Evas *e) -{ - Evas_Object *obj = e_icon_add(e); - e_icon_preload_set(obj, 1); - e_icon_scale_size_set(obj, 128); - - if (!e_util_icon_theme_set(obj, icon)) - { - evas_object_del(obj); - obj = NULL; - } - - return obj; -} - -static Evas_Object * -_evry_icon_mime_theme_get(const char *mime, Evas *e) { Evas_Object *o = NULL; - char buf[1024]; - const char *file; - - if (snprintf(buf, sizeof(buf), "e/icons/fileman/mime/%s", mime) >= (int)sizeof(buf)) + if (!icon) return NULL; + + o = e_icon_add(e); + e_icon_scale_size_set(o, 128); + e_icon_preload_set(o, 1); - file = e_theme_edje_file_get("base/theme/icons", buf); - if (file && file[0]) + if (icon[0] == '/') { - o = edje_object_add(e); - if (!o) return NULL; - if (!edje_object_file_set(o, file, buf)) + if (!e_icon_file_set(o, icon)) { evas_object_del(o); - return NULL; - } - return o; - } - - return NULL; -} - -Evas_Object * -evry_icon_mime_get(const char *mime, Evas *e) -{ - Evas_Object *o = NULL; - const char *icon; - - if (!e_config->icon_theme_overrides) - o = _evry_icon_mime_theme_get(mime, e); - - if (o) return o; - - icon = efreet_mime_type_icon_get(mime, e_config->icon_theme, 128); - if (icon) - o = e_util_icon_add(icon, e); - if (o) return o; - - return _evry_icon_mime_theme_get(mime, e); -} - -static Evas_Object * -_file_icon_get(Evry_Item *it, Evas *e) -{ - Evas_Object *o = NULL; - GET_FILE(file, it); - - if (it->icon) - { - if (it->icon[0] == '/') - { - o = e_icon_add(e); - e_icon_preload_set(o, 1); - - if (!e_icon_file_set(o, it->icon)) - { - evas_object_del(o); - o = NULL; - } + o = NULL; } } - - if (!(o) && (!it->icon) && file->mime && - (/*(!strncmp(file->mime, "image/", 6)) || */ - (!strncmp(file->mime, "video/", 6)) || - (!strncmp(file->mime, "application/pdf", 15))) && - (evry_file_url_get(file))) + else if (!e_util_icon_theme_set(o, icon)) { - char *sum = evry_util_md5_sum(file->url); - - snprintf(thumb_buf, sizeof(thumb_buf), - "%s/.thumbnails/normal/%s.png", - e_user_homedir_get(), sum); - free(sum); - - if (ecore_file_exists(thumb_buf)) - it->icon = eina_stringshare_add(thumb_buf); - else - it->icon = eina_stringshare_add(""); + evas_object_del(o); + o = NULL; } - - if (!(o) &&it->browseable) - o = evry_icon_theme_get("folder", e); - - if (!(o) && file->mime) - o = evry_icon_mime_get(file->mime, e); - - if (!o) - o = evry_icon_mime_get("unknown", e); - + return o; } + Evas_Object * evry_util_icon_get(Evry_Item *it, Evas *e) { Evas_Object *o = NULL; - if (!o && it->icon_get) + if (it->icon_get) o = it->icon_get(it, e); if (o) return o; - if (CHECK_TYPE(it, EVRY_TYPE_FILE)) - o = _file_icon_get(it, e); + if ((it->icon) && (it->icon[0] == '/')) + o = evry_icon_theme_get(it->icon, e); if (o) return o; - - if (!o && it->icon && it->icon[0] == '/') + + if (CHECK_TYPE(it, EVRY_TYPE_FILE)) { - o = e_icon_add(e); - e_icon_preload_set(o, 1); + const char *icon; + char *sum; + + GET_FILE(file, it); - if (!e_icon_file_set(o, it->icon)) + if (it->browseable) + o = evry_icon_theme_get("folder", e); + if (o) return o; + + if ((!it->icon) && (file->mime) && + (/*(!strncmp(file->mime, "image/", 6)) || */ + (!strncmp(file->mime, "video/", 6)) || + (!strncmp(file->mime, "application/pdf", 15))) && + (evry_file_url_get(file))) { - evas_object_del(o); - o = NULL; + sum = evry_util_md5_sum(file->url); + + snprintf(thumb_buf, sizeof(thumb_buf), + "%s/.thumbnails/normal/%s.png", + e_user_homedir_get(), sum); + free(sum); + + if ((o = evry_icon_theme_get(thumb_buf, e))) + { + it->icon = eina_stringshare_add(thumb_buf); + return o; + } } + + if ((!it->icon) && (file->mime)) + { + icon = efreet_mime_type_icon_get(file->mime, e_config->icon_theme, 128); + /* XXX can do _ref ?*/ + if ((o = evry_icon_theme_get(icon, e))) + { + /* it->icon = eina_stringshare_add(icon); */ + return o; + } + } + + if ((icon = efreet_mime_type_icon_get("unknown", e_config->icon_theme, 128))) + it->icon = eina_stringshare_add(icon); + else + it->icon = eina_stringshare_add(""); + } + + if (CHECK_TYPE(it, EVRY_TYPE_APP)) + { + GET_APP(app, it); + + o = e_util_desktop_icon_add(app->desktop, 128, e); + if (o) return o; + + o = evry_icon_theme_get("system-run", e); + if (o) return o; } - if (!o && it->icon) + if (it->icon) o = evry_icon_theme_get(it->icon, e); + if (o) return o; + + if (it->browseable) + o = evry_icon_theme_get("folder", e); + if (o) return o; + o = evry_icon_theme_get("unknown", e); + return o; } diff --git a/src/modules/everything/evry_view.c b/src/modules/everything/evry_view.c index ae258ac05..09f11ce13 100644 --- a/src/modules/everything/evry_view.c +++ b/src/modules/everything/evry_view.c @@ -393,9 +393,8 @@ _e_smart_reconfigure_do(void *data) Smart_Data *sd = evas_object_smart_data_get(obj); Eina_List *l; Item *it; - int iw, changed = 0; - Evas_Coord x, y, xx, yy, ww, hh, mw, mh, ox = 0, oy = 0; - Evas_Coord aspect_w, aspect_h; + int changed = 0; + Evas_Coord x = 0, y = 0, xx, yy, ww, hh, mw = 0, mh = 0; if (!sd) return ECORE_CALLBACK_CANCEL; @@ -407,86 +406,41 @@ _e_smart_reconfigure_do(void *data) if (sd->cx < 0) sd->cx = 0; if (sd->cy < 0) sd->cy = 0; - aspect_w = sd->w; - aspect_h = sd->h; - if (sd->view->mode == VIEW_MODE_LIST) { - iw = sd->w; + ww = sd->w; hh = SIZE_LIST; } else if (sd->view->mode == VIEW_MODE_DETAIL) { - iw = sd->w; + ww = sd->w; hh = SIZE_DETAIL; } else { - int size; - int cnt = eina_list_count(sd->items); - double col = 1; - int width = sd->w - 8; + int div; - if (cnt < 5) - { - col = 2; - aspect_w = width * 2; - } - else if ((cnt < 9) && (sd->w < (double)sd->h * 1.2)) - { - col = 2; - aspect_w = width * 3; - } - else if (cnt < 10) - { - col = 3; - aspect_w = width * 3; - } - else if (sd->view->zoom == 0) - { - size = 96; - aspect_w = width * (1 + (sd->h / size)); - col = width / size; - } + if (sd->view->zoom == 0) + ww = 96; else if (sd->view->zoom == 1) - { - size = 128; - col = width / size; - aspect_w = width * (1 + (sd->h / size)); - } - + ww = 128; else /* if (sd->view->zoom == 2) */ - { - size = 192; - col = width / size; - aspect_w = width * (1 + (sd->h / size)); - } + ww = 192; - if (col < 1) col = 1; + div = sd->w / ww; + if (div < 1) div = 1; + ww += (sd->w - div * ww) / div; - iw = width / col; - aspect_w /= col; + div = sd->h / div; + if (div < 1) div = 1; + hh = ww + (sd->h - div * ww) / div; + + if (hh > ww) + hh = ww + (sd->h - (div + 1) * ww) / (div + 1); } - if (aspect_w <= 0) aspect_w = 1; - if (aspect_h <= 0) aspect_h = 1; - - x = 0; - y = 0; - ww = iw; - - if (sd->view->mode == VIEW_MODE_THUMB) - hh = (aspect_h * iw) / (aspect_w); - - mw = mh = 0; EINA_LIST_FOREACH(sd->items, l, it) { - if (x > (sd->w - ww)) - { - x = 0; - y += hh; - } - it->x = x; it->y = y; it->w = ww; @@ -495,10 +449,16 @@ _e_smart_reconfigure_do(void *data) if ((x + ww) > mw) mw = x + ww; if ((y + hh) > mh) mh = y + hh; x += ww; + + if (x <= (sd->w - ww)) + continue; + + x = 0; + y += hh; } - if (sd->view->mode == VIEW_MODE_LIST || - sd->view->mode == VIEW_MODE_DETAIL) + if ((sd->view->mode == VIEW_MODE_LIST) || + (sd->view->mode == VIEW_MODE_DETAIL)) mh += sd->h % hh; if ((mw != sd->cw) || (mh != sd->ch)) @@ -518,16 +478,10 @@ _e_smart_reconfigure_do(void *data) changed = 1; } - if (sd->view->mode == VIEW_MODE_THUMB) - { - if (sd->w > sd->cw) ox = (sd->w - sd->cw) / 2; - if (sd->h > sd->ch) oy = (sd->h - sd->ch) / 2; - } - EINA_LIST_FOREACH(sd->items, l, it) { - xx = sd->x - sd->cx + it->x + ox; - yy = sd->y - sd->cy + it->y + oy; + xx = sd->x - sd->cx + it->x; + yy = sd->y - sd->cy + it->y; if (E_INTERSECTS(xx, yy, it->w, it->h, 0, sd->y - it->h, sd->x + sd->w, sd->y + sd->h + it->h))