'everything' big cleanup.
authorHannes Janetzek <hannes.janetzek@gmail.com>
Sat, 24 Apr 2010 00:21:45 +0000 (00:21 +0000)
committerHannes Janetzek <hannes.janetzek@gmail.com>
Sat, 24 Apr 2010 00:21:45 +0000 (00:21 +0000)
- fixed bug with going back to thumb view
- aggregator can now have his one view

SVN revision: 48263

src/modules/everything/Evry.h
src/modules/everything/e_mod_main.c
src/modules/everything/e_mod_main.h
src/modules/everything/evry.c
src/modules/everything/evry_config.c
src/modules/everything/evry_plug_aggregator.c
src/modules/everything/evry_plug_view_thumb.c

index d9c3b64..0390f69 100644 (file)
@@ -84,7 +84,7 @@ typedef struct _Plugin_Setting  Plugin_Setting;
    not to have any data lying around after cleanup you
    can use this */
 #define EVRY_PLUGIN_FREE(_p)                   \
-  evry_plugin_free(EVRY_PLUGIN(_p), 0);                \
+  if (_p) evry_plugin_free(EVRY_PLUGIN(_p), 0);        \
   E_FREE(_p);
 
 struct _Evry_Item
@@ -341,14 +341,13 @@ struct _Config
   /* use up/down keys for prev/next in thumb view */
   int cycle_mode;
 
+  unsigned char first_run;
+  
   /* not saved data */
-  Eina_List *plugins;
   Eina_List *actions;
   Eina_List *views;
-
+  
   int min_w, min_h;
-
-  unsigned char first_run;
 };
 
 struct _Plugin_Config
index ea35fdb..50a5743 100644 (file)
@@ -12,7 +12,7 @@
 /* #undef DBG
  * #define DBG(...) ERR(__VA_ARGS__) */
 
-#define CONFIG_VERSION 12
+#define CONFIG_VERSION 13
 
 /* actual module specifics */
 static void _e_mod_action_cb(E_Object *obj, const char *params);
@@ -134,8 +134,8 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
    evry_plug_clipboard_shutdown();
    evry_plug_text_shutdown();
    
-   EINA_LIST_FREE(evry_conf->plugins, p)
-     evry_plugin_free(p, 1); 
+   /* EINA_LIST_FREE(evry_conf->plugins, p)
+    *   evry_plugin_free(p, 1);  */
 
    EINA_LIST_FREE(evry_conf->actions, a)
      evry_action_free(a); 
@@ -162,7 +162,6 @@ EAPI int
 e_modapi_save(E_Module *m __UNUSED__)
 {
    e_config_domain_save("module.everything", conf_edd, evry_conf);
-
    return 1;
 }
 
@@ -231,28 +230,29 @@ _config_init()
        evry_conf->version = 11;
      }
 
-   if (evry_conf && evry_conf->version == 11)
+   if (evry_conf && evry_conf->version <= 12)
      {
        Plugin_Config *pc;
+       Eina_List *conf[3];
+       int i;
        
-       EINA_LIST_FREE(evry_conf->conf_subjects, pc)
-        {
-          if (pc->name) eina_stringshare_del(pc->name);
-          if (pc->trigger) eina_stringshare_del(pc->trigger);
-          E_FREE(pc);
-        }
-       EINA_LIST_FREE(evry_conf->conf_actions, pc)
-        {
-          if (pc->name) eina_stringshare_del(pc->name);
-          if (pc->trigger) eina_stringshare_del(pc->trigger);
-          E_FREE(pc);
-        }
-       EINA_LIST_FREE(evry_conf->conf_objects, pc)
+       conf[0] = evry_conf->conf_subjects;
+       conf[1] = evry_conf->conf_actions;
+       conf[2] = evry_conf->conf_objects;
+
+       for (i = 0; i < 3; i++)
         {
-          if (pc->name) eina_stringshare_del(pc->name);
-          if (pc->trigger) eina_stringshare_del(pc->trigger);
-          E_FREE(pc);
+           EINA_LIST_FREE(conf[i], pc)
+             {
+                if (pc->name) eina_stringshare_del(pc->name);
+                if (pc->trigger) eina_stringshare_del(pc->trigger);
+                E_FREE(pc);
+             }
         }
+       evry_conf->conf_subjects = NULL;
+       evry_conf->conf_actions = NULL;
+       evry_conf->conf_objects = NULL;
+       
        evry_conf->version = CONFIG_VERSION;
      }
 
@@ -290,28 +290,29 @@ static void
 _config_free(void)
 {
    Plugin_Config *pc;
+   int i;
+   Eina_List *conf[3];
 
-   /* free config */
-   if (evry_conf->cmd_terminal)
-     eina_stringshare_del(evry_conf->cmd_terminal);
-   EINA_LIST_FREE(evry_conf->conf_subjects, pc)
-     {
-       if (pc->name) eina_stringshare_del(pc->name);
-       if (pc->trigger) eina_stringshare_del(pc->trigger);
-       E_FREE(pc);
-     }
-   EINA_LIST_FREE(evry_conf->conf_actions, pc)
-     {
-       if (pc->name) eina_stringshare_del(pc->name);
-       if (pc->trigger) eina_stringshare_del(pc->trigger);
-       E_FREE(pc);
-     }
-   EINA_LIST_FREE(evry_conf->conf_objects, pc)
+   conf[0] = evry_conf->conf_subjects;
+   conf[1] = evry_conf->conf_actions;
+   conf[2] = evry_conf->conf_objects;
+
+   for (i = 0; i < 3; i++)
      {
-       if (pc->name) eina_stringshare_del(pc->name);
-       if (pc->trigger) eina_stringshare_del(pc->trigger);
-       E_FREE(pc);
+       EINA_LIST_FREE(conf[i], pc)
+         {
+            if (pc->name) eina_stringshare_del(pc->name);
+            if (pc->trigger) eina_stringshare_del(pc->trigger);
+            if (pc->plugin) evry_plugin_free(pc->plugin, 1);
+            E_FREE(pc);
+         }
      }
+
+   if (evry_conf->cmd_terminal)
+     eina_stringshare_del(evry_conf->cmd_terminal);
+   if (evry_conf->cmd_sudo)
+     eina_stringshare_del(evry_conf->cmd_sudo);
+
    E_FREE(evry_conf);
 }
 
@@ -393,12 +394,10 @@ EAPI int evry_api_version_check(int version)
 static int
 _evry_cb_plugin_sort(const void *data1, const void *data2)
 {
-   const Evry_Plugin *p1 = data1;
-   const Evry_Plugin *p2 = data2;
-   if (!p1->config) return -1;
-   if (!p2->config) return 1;
+   const Plugin_Config *pc1 = data1;
+   const Plugin_Config *pc2 = data2;
    
-   return p1->config->priority - p2->config->priority;
+   return pc1->priority - pc2->priority;
 }
 
 Evry_Plugin *
@@ -433,8 +432,6 @@ evry_plugin_new(Evry_Plugin *base, const char *name, const char *label, int type
    p->history = EINA_TRUE;
    p->view_mode = VIEW_MODE_NONE;
    
-   DBG("%s", p->name);
-   
    return p;
 }
 
@@ -444,7 +441,7 @@ evry_plugin_free(Evry_Plugin *p, int free_pointer)
    evry_plugin_unregister(p);
 
    DBG("%s", p->name);
-   
+   if (p->config) p->config->plugin = NULL;
    if (p->name)     eina_stringshare_del(p->name);
    if (p->label)    eina_stringshare_del(p->label);
    if (p->type_in)  eina_stringshare_del(p->type_in);
@@ -472,8 +469,6 @@ evry_action_new(const char *name, const char *label, const char *type_in1, const
    act->action = action;
    act->check_item = check_item;
    act->icon = (icon ? eina_stringshare_add(icon) : NULL);
-
-   DBG("%s", name);
    
    return act;
 }
@@ -500,21 +495,16 @@ evry_action_free(Evry_Action *act)
 void
 evry_plugin_register(Evry_Plugin *p, int priority)
 {
-   Eina_List *l, *confs = NULL;
+   Eina_List *l, *confs;
    Plugin_Config *pc;
-
-   DBG("%s", p->name);
+   Eina_List *conf[3];
+   int i = 0;
    
-   evry_conf->plugins = eina_list_append(evry_conf->plugins, p);
-
-   if (p->type == type_subject)
-     confs = evry_conf->conf_subjects;
-   else if (p->type == type_action)
-     confs = evry_conf->conf_actions;
-   else if (p->type == type_object)
-     confs = evry_conf->conf_objects;
+   conf[0] = evry_conf->conf_subjects;
+   conf[1] = evry_conf->conf_actions;
+   conf[2] = evry_conf->conf_objects;
 
-   EINA_LIST_FOREACH(confs, l, pc)
+   EINA_LIST_FOREACH(conf[p->type], l, pc)
      if (pc->name && p->name && !strcmp(pc->name, p->name))
        break;
 
@@ -530,24 +520,22 @@ evry_plugin_register(Evry_Plugin *p, int priority)
            pc->trigger = eina_stringshare_add(p->trigger); 
            pc->trigger_only = 1;
          }
-       
-       pc->plugin = p;
-       confs = eina_list_append(confs, pc);
+       conf[p->type] = eina_list_append(conf[p->type], pc);
      }
    
    p->config = pc;
-   evry_conf->plugins = eina_list_sort(evry_conf->plugins,
-                                      eina_list_count(evry_conf->plugins),
-                                      _evry_cb_plugin_sort);
+   pc->plugin = p;
+   
+   conf[p->type] = eina_list_sort(conf[p->type], -1, _evry_cb_plugin_sort);
 
-   if (p->type == type_subject)
-     evry_conf->conf_subjects = confs;
-   else if (p->type == type_action)
-     evry_conf->conf_actions = confs;
-   else if (p->type == type_object)
-     evry_conf->conf_objects = confs;
+   EINA_LIST_FOREACH(conf[p->type], l, pc)
+     pc->priority = i++;
+   
+   evry_conf->conf_subjects = conf[0];
+   evry_conf->conf_actions = conf[1];
+   evry_conf->conf_objects = conf[2];
 
-   if (p->type == type_subject)
+   if (p->type == type_subject && !p->type_in)
      {
        char buf[256];
        snprintf(buf, sizeof(buf), _("Show %s Plugin"), p->name);
@@ -562,7 +550,7 @@ evry_plugin_unregister(Evry_Plugin *p)
 {
    DBG("%s", p->name);
    
-   evry_conf->plugins = eina_list_remove(evry_conf->plugins, p);
+   /* evry_conf->plugins = eina_list_remove(evry_conf->plugins, p); */
 
    if (p->type == type_subject)
      {
index 22f3ab9..0acb3ef 100644 (file)
@@ -90,7 +90,7 @@ int  evry_shutdown(void);
 int  evry_show(E_Zone *zone, const char *params);
 void evry_hide(void);
 
-EAPI Evry_Plugin *evry_plug_aggregator_new(Evry_Selector *selector);
+EAPI Evry_Plugin *evry_plug_aggregator_new(Evry_Selector *selector, int type);
 EAPI void evry_plug_aggregator_free(Evry_Plugin *plugin);
 
 EAPI Evry_Plugin *evry_plug_actions_new(int type);
index 68a9fcc..1f4e617 100644 (file)
@@ -258,7 +258,6 @@ evry_hide(void)
      ecore_timer_del(_show_timer);
    _show_timer = NULL;
 
-
    list->visible = EINA_FALSE;
    _evry_selector_free(selectors[0]);
    _evry_selector_free(selectors[1]);
@@ -702,8 +701,8 @@ _evry_window_free(Evry_Window *win)
 static Evry_Selector *
 _evry_selector_new(int type)
 {
-   Evry_Plugin *p;
-   Eina_List *l;
+   Plugin_Config *pc;
+   Eina_List *l, *pcs;
    Evry_Selector *sel = E_NEW(Evry_Selector, 1);
    Evas_Object *o = edje_object_add(win->popup->evas);
    sel->o_main = o;
@@ -711,34 +710,35 @@ _evry_selector_new(int type)
                           "e/modules/everything/selector_item");
    evas_object_show(o);
 
+   sel->aggregator = evry_plug_aggregator_new(sel, type);
+   
    if (type == type_subject)
      {
        sel->history = evry_hist->subjects;
-       sel->actions = evry_plug_actions_new(type_subject);
+       sel->actions = evry_plug_actions_new(type);
        edje_object_part_swallow(win->o_main, "e.swallow.subject_selector", o);
+       pcs = evry_conf->conf_subjects;
      }
    else if (type == type_action)
      {
        sel->history = evry_hist->actions;
-       sel->actions = evry_plug_actions_new(type_action);
+       sel->actions = evry_plug_actions_new(type);
        edje_object_part_swallow(win->o_main, "e.swallow.action_selector", o);
+       pcs = evry_conf->conf_actions;
      }
    else if (type == type_object)
      {
        sel->history = evry_hist->subjects;
        edje_object_part_swallow(win->o_main, "e.swallow.object_selector", o);
+       pcs = evry_conf->conf_objects;
      }
 
-   p = evry_plug_aggregator_new(sel);
-
-   sel->plugins = eina_list_append(sel->plugins, p);
-   sel->aggregator = p;
-
-   EINA_LIST_FOREACH(evry_conf->plugins, l, p)
+   EINA_LIST_FOREACH(pcs, l, pc)
      {
-       if (!p->config->enabled) continue;
-       if (p->type != type) continue;
-       sel->plugins = eina_list_append(sel->plugins, p);
+       if (!pc->enabled) continue;
+       if (!pc->plugin) continue;
+       if (pc->plugin == sel->aggregator) continue;
+       sel->plugins = eina_list_append(sel->plugins, pc->plugin);
      }
 
    return sel;
@@ -762,12 +762,9 @@ _evry_selector_free(Evry_Selector *sel)
    while (sel->states)
      _evry_state_pop(sel);
 
-   if (sel->aggregator)
-     evry_plugin_free(sel->aggregator, 1);
-
-   if (sel->actions)
-     evry_plug_actions_free(sel->actions);
-
+   EVRY_PLUGIN_FREE(sel->aggregator);
+   EVRY_PLUGIN_FREE(sel->actions);
+   
    if (sel->plugins) eina_list_free(sel->plugins);
 
    if (sel->update_timer)
@@ -1063,7 +1060,7 @@ _evry_selector_actions_get(Evry_Item *it)
 
    EINA_LIST_FOREACH(sel->plugins, l, plugin)
      {
-       if ((plugin == sel->actions) || (plugin == sel->aggregator) ||
+       if ((plugin == sel->actions) ||
            (plugin->type_in && type_out && plugin->type_in == type_out))
          {
             if (plugin->begin)
@@ -1162,8 +1159,7 @@ _evry_state_pop(Evry_Selector *sel)
    EINA_LIST_FREE(s->plugins, p)
      p->cleanup(p);
 
-   if (sel->aggregator)
-     sel->aggregator->cleanup(sel->aggregator);
+   sel->aggregator->cleanup(sel->aggregator);
 
    E_FREE(s);
 
@@ -1302,8 +1298,7 @@ _evry_selectors_switch(int dir)
          {
             _evry_selector_objects_get(act);
             _evry_selector_update(selectors[2]);
-            edje_object_signal_emit(win->o_main,
-                                    "e,state,object_selector_show", "e");
+            edje_object_signal_emit(win->o_main, "e,state,object_selector_show", "e");
             next_selector = 2;
          }
        _evry_selector_activate(selectors[next_selector]);
@@ -1311,18 +1306,14 @@ _evry_selectors_switch(int dir)
    else if (selector == selectors[1] && dir < 0)
      {
          _evry_selector_activate(selectors[0]);
-
-         edje_object_signal_emit(win->o_main,
-                                 "e,state,object_selector_hide", "e");
+         edje_object_signal_emit(win->o_main, "e,state,object_selector_hide", "e");
      }
    else if (selector == selectors[2] && dir > 0)
      {
        while (selector->states)
          _evry_state_pop(selector);
 
-       edje_object_signal_emit(win->o_main,
-                               "e,state,object_selector_hide", "e");
-
+       edje_object_signal_emit(win->o_main, "e,state,object_selector_hide", "e");
        _evry_selector_activate(selectors[0]);
      }
    else if (selector == selectors[2] && dir < 0)
@@ -1935,7 +1926,7 @@ _evry_matches_update(Evry_Selector *sel, int async)
             if ((len_inp >= len) &&
                 (!strncmp(s->inp, p->config->trigger, len)))
               {
-                len_trigger = len;
+                 len_trigger = len;
                  s->cur_plugins = eina_list_append(s->cur_plugins, p);
                  if(len_inp == len)
                    p->fetch(p, NULL);
@@ -1959,9 +1950,9 @@ _evry_matches_update(Evry_Selector *sel, int async)
    
    if (!s->cur_plugins)
      {
-       s->input = s->inp;
+       s->input = s->inp;
        
-       EINA_LIST_FOREACH(s->plugins, l, p)
+       EINA_LIST_FOREACH(s->plugins, l, p)
          {
             if ((!win->plugin_dedicated) &&
                 (p->config->trigger_only) &&
@@ -1987,17 +1978,8 @@ _evry_matches_update(Evry_Selector *sel, int async)
               }
          }
 
-       if ((eina_list_count(s->cur_plugins) > 0) &&
-           /* dont add aggregator when there is only one plugin
-              which wont show items in agrregator */
-           !(eina_list_count(s->cur_plugins) == 1 &&
-             !((Evry_Plugin *)s->cur_plugins->data)->aggregate))
-         {
-            s->cur_plugins = eina_list_prepend(s->cur_plugins, sel->aggregator);
-            sel->aggregator->fetch(sel->aggregator, input);
-         }
-       else
-         sel->aggregator->cleanup(sel->aggregator);
+       if (sel->aggregator->fetch(sel->aggregator, input))
+         _evry_plugin_list_insert(s, sel->aggregator);         
      }
 
    if (s->plugin_auto_selected ||
@@ -2049,15 +2031,12 @@ _evry_plugin_select(Evry_State *s, Evry_Plugin *p)
        p = s->cur_plugins->data;
        s->plugin_auto_selected = EINA_TRUE;
      }
-   else if (p)
-     {
-       s->plugin_auto_selected = EINA_FALSE;
-     }
+
+   if (p)
+     s->plugin_auto_selected = EINA_FALSE;
 
    if (s->plugin != p)
-     {
-       _evry_item_desel(s, NULL);
-     }
+     _evry_item_desel(s, NULL);
 
    s->plugin = p;
 }
index 40ac078..88232d3 100644 (file)
@@ -147,9 +147,6 @@ _basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
    C(scroll_speed);
 #undef C
 
-   /* evry_conf->plugins = eina_list_sort(evry_conf->plugins, -1,
-    *                                 _evry_cb_plugin_sort); */
-
    if (evry_conf->conf_subjects) eina_list_free(evry_conf->conf_subjects);
    if (evry_conf->conf_actions) eina_list_free(evry_conf->conf_actions);
    if (evry_conf->conf_objects) eina_list_free(evry_conf->conf_objects);
index 0bb61a9..cfa4516 100644 (file)
@@ -127,20 +127,6 @@ _fetch(Evry_Plugin *plugin, const char *input)
 
    /* first is aggregator itself */
    lp = s->cur_plugins->next;
-
-   /* EINA_LIST_FOREACH(lp, l, pp)   
-    *   {
-    *  if (pp->changed)
-    *    {
-    *       plugin->changed = 1;
-    *       break;
-    *    }
-    *   }
-    * 
-    * if (!plugin->changed)
-    *   return 1; */
-   /* printf("aggreator changed\n"); */
-
    
    EVRY_PLUGIN_ITEMS_FREE(p);
 
@@ -299,34 +285,20 @@ _icon_get(Evry_Plugin *plugin, const Evry_Item *it, Evas *e)
    return o;
 }
 
-static void
-_plugin_free(Evry_Plugin *plugin)
-{
-   PLUGIN(p, plugin);
-
-   E_FREE(plugin->config);
-   E_FREE(p);
-}
-
 Evry_Plugin *
-evry_plug_aggregator_new(Evry_Selector *selector)
+evry_plug_aggregator_new(Evry_Selector *sel, int type)
 {
    Plugin *p;
-   Plugin_Config *pc;
-
+      
    p = E_NEW(Plugin, 1);
-   EVRY_PLUGIN_NEW(EVRY_PLUGIN(p), N_("All"), 0, "", "",
-                  NULL, _cleanup, _fetch, _icon_get, _plugin_free);
+   EVRY_PLUGIN_NEW(EVRY_PLUGIN(p), N_("All"), type, "", "",
+                  NULL, _cleanup, _fetch, _icon_get, NULL);
 
    EVRY_PLUGIN(p)->action = &_action;
-     
-   pc = E_NEW(Plugin_Config, 1);
-   pc->enabled = 1;
-   pc->priority = -1;
-   pc->view_mode = -1;
-   EVRY_PLUGIN(p)->config = pc;
-
-   p->selector = selector;
+   EVRY_PLUGIN(p)->history = EINA_FALSE;
+
+   evry_plugin_register(EVRY_PLUGIN(p), -1);
+   p->selector = sel;
 
    return EVRY_PLUGIN(p);
 }
index 723ee72..7a34c69 100644 (file)
@@ -1071,7 +1071,8 @@ _view_update(Evry_View *view, int slide)
      }
 
    sd->items = eina_list_sort(sd->items, eina_list_count(sd->items), _sort_cb);
-
+   if (!sd->cur_item && sd->items) sd->cur_item = sd->items->data;
+   
    if (update || !last_vis || v->plugin != p)
      {
        v->plugin = p;
@@ -1185,7 +1186,9 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev)
 
    if (sd->items)
      l = eina_list_data_find_list(sd->items, sd->cur_item);
-
+   if (!l)
+     l = sd->items;
+     
    if (v->mode == VIEW_MODE_THUMB && !evry_conf->cycle_mode)
      {
        if (!strcmp(ev->key, "Right"))