static int _evry_pop_state(void);
static void _evry_plugin_selector_show(Evry_Plugin *p);
static int _evry_cb_plugin_sort(const void *data1, const void *data2);
+static int _evry_cb_plugin_sort_by_trigger(const void *data1, const void *data2);
static int _evry_plug_act_select_init(void);
static int _evry_plug_act_select_begin(Evry_Plugin *p, Evry_Item *it);
{
if (!eina_list_data_find(s->cur_plugins, p))
{
- s->cur_plugins = eina_list_append(s->cur_plugins, p);
+ s->cur_plugins = eina_list_prepend(s->cur_plugins, p);
+
+ s->cur_plugins = eina_list_sort(s->cur_plugins,
+ eina_list_count(s->cur_plugins),
+ _evry_cb_plugin_sort_by_trigger);
+
_evry_plugin_selector_show(p);
}
else
edje_object_part_text_set(p->tab, "e.text.label", buf);
}
- if ((!s->cur_plugin && s->cur_plugins) || (s->cur_plugin == p) ||
- (s->plugin_auto_selected && (s->cur_plugin->config->priority > p->config->priority)))
+ if ((!s->cur_plugin && s->cur_plugins) || (s->cur_plugin == p))
+ /* || (s->plugin_auto_selected && (s->cur_plugin->config->priority > p->config->priority))) */
{
if (!s->cur_plugin)
s->plugin_auto_selected = 1;
_evry_list_clear();
_evry_show_items(s->cur_plugins->data);
}
+ else if (/*s->plugin_auto_selected &&*/ p->trigger &&
+ (!strncmp(s->input, p->trigger, strlen(p->trigger))))
+ {
+ _evry_list_clear();
+ _evry_show_items(p);
+ /* s->plugin_auto_selected = 0; */
+ }
else if (s->cur_plugin)
_evry_tab_scroll_to(s->cur_plugin);
}
{
if (cur_state->input[0] != 0)
{
- cur_state->input[0] = 0;
+ cur_state->input[0] = 0;
}
}
return p1->config->priority - p2->config->priority;
}
+static int
+_evry_cb_plugin_sort_by_trigger(const void *data1, const void *data2)
+{
+ const Evry_Plugin *p1 = data1;
+ const Evry_Plugin *p2 = data2;
+ if (p1->trigger)
+ {
+ if (!strncmp(cur_state->input, p1->trigger, strlen(p1->trigger)))
+ return 1;
+ }
+
+ return p1->config->priority - p2->config->priority;
+}
+
static int
_evry_push_state(void)
{
s->cur_plugins = NULL;
s->sel_item = NULL;
+ if (s->input)
EINA_LIST_FOREACH(s->plugins, l, p)
{
/* input matches trigger? */
if (p->trigger)
{
- const char *trigger = p->trigger;
-
- if ((strlen(s->input) < strlen(trigger)) ||
- (strncmp(s->input, trigger, strlen(trigger))))
- continue;
+ if ((strlen(s->input) >= strlen(p->trigger)) &&
+ (!strncmp(s->input, p->trigger, strlen(p->trigger))))
+ {
+ s->cur_plugins = eina_list_append(s->cur_plugins, p);
+ items = p->fetch(p, s->input);
+ break;
+ }
}
-
+ }
+
+ if (!s->cur_plugins)
+ EINA_LIST_FOREACH(s->plugins, l, p)
+ {
+ if (p->trigger) continue;
+
if (strlen(s->input) == 0)
items = !p->need_query ? p->fetch(p, NULL) : 0;
else
items = p->fetch(p, s->input);
- if (!s->initial || (items && eina_list_count(p->items) > 0))
+ if (!s->initial || (items && eina_list_count(p->items) > 0) || p->async_query)
s->cur_plugins = eina_list_append(s->cur_plugins, p);
}
if (s->cur_plugins)
{
+ /* s->cur_plugins = eina_list_sort(s->cur_plugins,
+ * eina_list_count(s->cur_plugins),
+ * _evry_cb_plugin_sort_by_trigger); */
+
if (cur_plugin && eina_list_data_find(s->cur_plugins, cur_plugin))
_evry_show_items(cur_plugin);
else
static int _cb_sort(const void *data1, const void *data2);
static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
static int _exec_app_action(Evry_Action *act);
+static int _exec_app_check_item(Evry_Action *act, Evry_Item *it);
static int _edit_app_action(Evry_Action *act);
static int _edit_app_check_item(Evry_Action *act, Evry_Item *it);
static int _new_app_action(Evry_Action *act);
+static int _new_app_check_item(Evry_Action *act, Evry_Item *it);
static Evry_Plugin *p1;
static Evry_Plugin *p2;
act->type_in2 = "FILE";
act->type_out = "NONE";
act->action = &_exec_app_action;
+ act->check_item = &_exec_app_check_item;
evry_action_register(act);
act2 = E_NEW(Evry_Action, 1);
act3->type_in2 = "NONE";
act3->type_out = "NONE";
act3->action = &_new_app_action;
+ act3->check_item = &_new_app_check_item;
evry_action_register(act3);
inst = NULL;
EINA_LIST_FREE(l, desktop)
_item_add(p, desktop, NULL, 1);
- snprintf(match1, sizeof(match1), "*%s*", input);
l = efreet_util_desktop_name_glob_list(match1);
+ EINA_LIST_FREE(l, desktop)
+ _item_add(p, desktop, NULL, 3);
+
+ snprintf(match1, sizeof(match1), "*%s*", input);
+ l = efreet_util_desktop_exec_glob_list(match1);
EINA_LIST_FREE(l, desktop)
_item_add(p, desktop, NULL, 2);
+ l = efreet_util_desktop_name_glob_list(match1);
+ EINA_LIST_FREE(l, desktop)
+ _item_add(p, desktop, NULL, 4);
+
// TODO make these optional/configurable
l = efreet_util_desktop_generic_name_glob_list(match1);
EINA_LIST_FREE(l, desktop)
- _item_add(p, desktop, NULL, 3);
+ _item_add(p, desktop, NULL, 5);
l = efreet_util_desktop_comment_glob_list(match1);
EINA_LIST_FREE(l, desktop)
- _item_add(p, desktop, NULL, 3);
- }
- else if (!p->items)
- {
- // TODO option for popular/recent
- l = e_exehist_list_get();
- EINA_LIST_FREE(l, file)
- _item_add(p, NULL, file, 1);
+ _item_add(p, desktop, NULL, 5);
}
+ /* else if (!p->items)
+ * {
+ * // TODO option for popular/recent
+ * l = e_exehist_list_get();
+ * EINA_LIST_FREE(l, file)
+ * _item_add(p, NULL, file, 1);
+ * } */
if (inst->added)
{
else return 0;
}
+static int
+_exec_app_check_item(Evry_Action *act, Evry_Item *it)
+{
+ Evry_App *app = it->data[0];
+ if (app->desktop)
+ return 1;
+
+ if (app->file && strlen(app->file) > 0)
+ return 1;
+
+ return 0;
+}
+
+
static int
_exec_app_action(Evry_Action *act)
{
snprintf(buf, 128, "%s/.local/share/applications/%s.desktop", e_user_homedir_get(), app->file);
desktop = efreet_desktop_empty_new(eina_stringshare_add(buf));
- /* XXX check if this is freed */
+ /* XXX check if this gets freed by efreet*/
desktop->exec = strdup(app->file);
}
}
+static int
+_new_app_check_item(Evry_Action *act, Evry_Item *it)
+{
+ Evry_App *app = it->data[0];
+ if (app->desktop)
+ return 1;
+
+ if (app->file && strlen(app->file) > 0)
+ return 1;
+
+ return 0;
+}
+
+
static int
_new_app_action(Evry_Action *act)
{
static Eina_List *history = NULL;
static Ecore_Event_Handler *data_handler = NULL;
static Ecore_Event_Handler *error_handler = NULL;
-
+static Ecore_X_Window clipboard_win = 0;
EAPI int
evry_plug_calc_init(void)
p->icon_get = &_item_icon_get;
evry_plugin_register(p);
+ clipboard_win = ecore_x_window_new(0, 0, 0, 1, 1);
return 1;
}
evry_plugin_unregister(p);
E_FREE(p);
+ ecore_x_window_free(clipboard_win);
+
return 1;
}
static int
_action(Evry_Plugin *p, Evry_Item *it, const char *input)
{
- if (!it)
+ if (!it) return EVRY_ACTION_CONTINUE;
+
+ if (p->items)
{
- if (p->items)
- {
- Eina_List *l;
- Evry_Item *it2;
+ Eina_List *l;
+ Evry_Item *it2;
- evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_CLEAR);
+ evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_CLEAR);
- /* remove duplicates */
- if (p->items->next)
- {
- it = p->items->data;
+ /* remove duplicates */
+ if (p->items->next)
+ {
+ it = p->items->data;
- EINA_LIST_FOREACH(p->items->next, l, it2)
- {
- if (!strcmp(it->label, it2->label))
- break;
- it2 = NULL;
- }
-
- if (it2)
- {
- p->items = eina_list_remove(p->items, it2);
- eina_stringshare_del(it2->label);
- E_FREE(it2);
- }
+ EINA_LIST_FOREACH(p->items->next, l, it2)
+ {
+ if (!strcmp(it->label, it2->label))
+ break;
+ it2 = NULL;
}
- it = p->items->data;
-
- _item_add(p, (char *) it->label, 1);
+ if (it2)
+ {
+ p->items = eina_list_remove(p->items, it2);
+ eina_stringshare_del(it2->label);
+ E_FREE(it2);
+ }
}
- evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD);
+ it = p->items->data;
- /* return EVRY_ACTION_CONTINUE; */
- }
- /* else */
- {
- /* XXX on which windows must the selection be set? */
- ecore_x_selection_primary_set(e_manager_current_get()->win,
- it->label, strlen(it->label));
- ecore_x_selection_clipboard_set(e_manager_current_get()->win,
- it->label, strlen(it->label));
-
- /* if (p->items->data == it)
- * {
- * Evry_Item *it2 = p->items->data;
- * _item_add(p, (char *) it2->label, 1);
- * } */
+ _item_add(p, (char *) it->label, 1);
}
+ /* evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD); */
+
+ ecore_x_selection_primary_set(clipboard_win, it->label, strlen(it->label));
+ ecore_x_selection_clipboard_set(clipboard_win, it->label, strlen(it->label));
+
return EVRY_ACTION_FINISHED;
}