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);
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;
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) */
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);
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();
}
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;
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);
-
- ecore_evas_name_class_set(win->ewin->ecore_evas, "E", "everything");
- ecore_evas_show(win->ewin->ecore_evas);
+ if (popup)
+ {
+ e_win_layer_set(win->ewin, 255);
+ ecore_x_netwm_window_type_set(win->ewin->evas_win,
+ ECORE_X_WINDOW_TYPE_UTILITY);
- 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)
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);
}
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);
+ }
}
}
#include "evry_types.h"
-#define EVRY_API_VERSION 27
+#define EVRY_API_VERSION 28
#define EVRY_ACTION_OTHER 0
#define EVRY_ACTION_FINISHED 1
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);
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
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);
* 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);
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)
{
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);
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;
};
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;
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)
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)
{
}
static void
-_item_free(Evry_Item *item)
+_cb_item_free(Evry_Item *item)
{
GET_APP(app, item);
{
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);
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)
{
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;
_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);
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);
}
Evry_Item *it;
History_Types *ht;
- EVRY_PLUGIN_ITEMS_CLEAR(p);
+ Efreet_Menu *entry;
+ int i = 1;
- if (input)
- {
- if (!p->apps_all)
- p->apps_all = _desktop_list_get();
+ EVRY_PLUGIN_ITEMS_CLEAR(p);
- _desktop_list_add(p, p->apps_all, input);
- }
- else
+ if (!p->browse)
{
- _desktop_list_add(p, p->apps_mime, input);
- }
+ if (input)
+ {
+ if (!p->apps_all)
+ p->apps_all = _desktop_list_get();
- if (!input && !(plugin->items))
- {
- if (!p->apps_hist)
+ _desktop_list_add(p, p->apps_all, input);
+ }
+ else
{
- 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_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);
+ }
- EINA_LIST_FOREACH(plugin->items, l, it)
- evry->history_item_usage_set(it, input, NULL);
+ _desktop_list_add(p, p->apps_hist, NULL);
+ }
- EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort);
+ 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(p->menu_items, l, it)
+ EVRY_PLUGIN_ITEM_APPEND(p, it);
+
return !!(plugin->items);
}
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);
static Evas_Object *
_icon_get(Evry_Item *item, Evas *e)
{
- Evas_Object *o;
Settings_Item *it = (Settings_Item *) item;
-
- 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;
+ 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);
+ }
+
return NULL;
}
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;
+ o = NULL;
}
- return o;
}
-
- return NULL;
+ else if (!e_util_icon_theme_set(o, icon))
+ {
+ evas_object_del(o);
+ o = NULL;
+ }
+
+ return o;
}
+
Evas_Object *
-evry_icon_mime_get(const char *mime, Evas *e)
+evry_util_icon_get(Evry_Item *it, Evas *e)
{
Evas_Object *o = NULL;
- const char *icon;
-
- if (!e_config->icon_theme_overrides)
- o = _evry_icon_mime_theme_get(mime, e);
+ if (it->icon_get)
+ o = it->icon_get(it, 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 ((it->icon) && (it->icon[0] == '/'))
+ o = evry_icon_theme_get(it->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 (CHECK_TYPE(it, EVRY_TYPE_FILE))
{
- if (it->icon[0] == '/')
+ const char *icon;
+ char *sum;
+
+ GET_FILE(file, it);
+
+ 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)))
{
- o = e_icon_add(e);
- e_icon_preload_set(o, 1);
+ sum = evry_util_md5_sum(file->url);
- if (!e_icon_file_set(o, it->icon))
+ 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)))
{
- evas_object_del(o);
- o = NULL;
+ it->icon = eina_stringshare_add(thumb_buf);
+ return o;
}
}
- }
- 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)))
- {
- 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 ((!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 (ecore_file_exists(thumb_buf))
- it->icon = eina_stringshare_add(thumb_buf);
+ 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 (!(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)
- o = it->icon_get(it, e);
- if (o) return o;
-
- if (CHECK_TYPE(it, EVRY_TYPE_FILE))
- o = _file_icon_get(it, e);
- if (o) return o;
-
- if (!o && it->icon && it->icon[0] == '/')
+
+ if (CHECK_TYPE(it, EVRY_TYPE_APP))
{
- 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;
- }
+ 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;
}
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;
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;
- }
-
- if (aspect_w <= 0) aspect_w = 1;
- if (aspect_h <= 0) aspect_h = 1;
+ div = sd->h / div;
+ if (div < 1) div = 1;
+ hh = ww + (sd->h - div * ww) / div;
- x = 0;
- y = 0;
- ww = iw;
-
- if (sd->view->mode == VIEW_MODE_THUMB)
- hh = (aspect_h * iw) / (aspect_w);
+ if (hh > ww)
+ hh = ww + (sd->h - (div + 1) * ww) / (div + 1);
+ }
- 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;
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))
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))