e17/evry:
authorHannes Janetzek <hannes.janetzek@gmail.com>
Tue, 16 Aug 2011 23:26:07 +0000 (23:26 +0000)
committerHannes Janetzek <hannes.janetzek@gmail.com>
Tue, 16 Aug 2011 23:26:07 +0000 (23:26 +0000)
- evry gadget now shows a window that works with illume for keyboard input
- added app menu browser
- evry_icon_get refactoring

SVN revision: 62518

src/modules/everything/e_mod_main.c
src/modules/everything/e_mod_main.h
src/modules/everything/evry.c
src/modules/everything/evry_api.h
src/modules/everything/evry_gadget.c
src/modules/everything/evry_plug_aggregator.c
src/modules/everything/evry_plug_apps.c
src/modules/everything/evry_plug_settings.c
src/modules/everything/evry_util.c
src/modules/everything/evry_view.c

index 0b898b1..4788ffc 100644 (file)
@@ -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) */
index a74eaa8..5ea9c4f 100644 (file)
@@ -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();
index 5f11348..fb9be28 100644 (file)
@@ -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);
-
-   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)
@@ -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);
+              }
          }
      }
 
index 2035b2c..22667d9 100644 (file)
@@ -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
 
index 5e7ec5d..76c0671 100644 (file)
@@ -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);
 
index 0e9da16..955015c 100644 (file)
@@ -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);
index 3b86e6c..b78c4c8 100644 (file)
@@ -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;
 
-   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);
 }
 
@@ -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);
index 789ff42..548c272 100644 (file)
@@ -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 (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;
 }
 
index 20ae4c4..ac07ba8 100644 (file)
@@ -392,145 +392,115 @@ 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;
+            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;
 }
 
index ae258ac..09f11ce 100644 (file)
@@ -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;
-     }
-
-   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;
@@ -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))