#include "e_mod_main.h"
-#define CONFIG_VERSION 5
+#define CONFIG_VERSION 6
/* actual module specifics */
static void _e_mod_action_cb(E_Object *obj, const char *params);
E_CONFIG_VAL(D, T, hide_list, INT);
E_CONFIG_VAL(D, T, quick_nav, INT);
E_CONFIG_VAL(D, T, cmd_terminal, STR);
+ E_CONFIG_VAL(D, T, cmd_sudo, STR);
E_CONFIG_LIST(D, T, conf_subjects, conf_item_edd);
E_CONFIG_LIST(D, T, conf_actions, conf_item_edd);
E_CONFIG_LIST(D, T, conf_objects, conf_item_edd);
evry_conf->conf_objects = NULL;
evry_conf->conf_views = NULL;
evry_conf->cmd_terminal = eina_stringshare_add("/usr/bin/xterm");
+ evry_conf->cmd_sudo = eina_stringshare_add("/usr/bin/gksudo --preserve-env");
}
}
int quick_nav;
const char *cmd_terminal;
+ const char *cmd_sudo;
/* not saved data */
Eina_List *plugins;
const char *context;
const char *input;
double last_used;
+ double usage;
int count;
int transient;
};
int scroll_animate;
char *cmd_terminal;
+ char *cmd_sudo;
Evas_Object *l_subject;
Evas_Object *l_action;
if (evry_conf->cmd_terminal)
cfdata->cmd_terminal = strdup(evry_conf->cmd_terminal);
+
+ if (evry_conf->cmd_sudo)
+ cfdata->cmd_sudo = strdup(evry_conf->cmd_sudo);
}
static void *
if (cfdata->p_action) eina_list_free(cfdata->p_action);
if (cfdata->p_object) eina_list_free(cfdata->p_object);
E_FREE(cfdata->cmd_terminal);
+ E_FREE(cfdata->cmd_sudo);
E_FREE(cfdata);
}
if (evry_conf->cmd_terminal)
eina_stringshare_del(evry_conf->cmd_terminal);
evry_conf->cmd_terminal = eina_stringshare_add(cfdata->cmd_terminal);
+ if (evry_conf->cmd_sudo)
+ eina_stringshare_del(evry_conf->cmd_sudo);
+ evry_conf->cmd_sudo = eina_stringshare_add(cfdata->cmd_sudo);
e_config_save_queue();
return 1;
e_widget_framelist_object_append(of, ob);
ob = e_widget_entry_add(evas, &(cfdata->cmd_terminal), NULL, NULL, NULL);
e_widget_framelist_object_append(of, ob);
-
+
+ ob = e_widget_label_add(evas, _("Sudo GUI"));
+ e_widget_framelist_object_append(of, ob);
+ ob = e_widget_entry_add(evas, &(cfdata->cmd_sudo), NULL, NULL, NULL);
+ e_widget_framelist_object_append(of, ob);
+
e_widget_list_object_append(o, of, 1, 1, 0.5);
#include "e_mod_main.h"
-#define HISTORY_VERSION 6
+#define HISTORY_VERSION 7
-#define TIME_NOW (1.0 - (evry_hist->begin / ecore_time_get())) / 1000000000000.0
+#define SEVEN_DAYS 604800
+
+#define TIME_FACTOR(_now) (1.0 - (evry_hist->begin / _now)) / 1000000000000000.0
typedef struct _Cleanup_Data Cleanup_Data;
hist_item_edd = E_CONFIG_DD_NEW("History_Item", History_Item);
#define T History_Item
#define D hist_item_edd
- E_CONFIG_VAL(D, T, plugin, STR);
- E_CONFIG_VAL(D, T, context, STR);
- E_CONFIG_VAL(D, T, input, STR);
+ E_CONFIG_VAL(D, T, plugin, STR);
+ E_CONFIG_VAL(D, T, context, STR);
+ E_CONFIG_VAL(D, T, input, STR);
E_CONFIG_VAL(D, T, last_used, DOUBLE);
- E_CONFIG_VAL(D, T, count, INT);
+ E_CONFIG_VAL(D, T, usage, DOUBLE);
+ E_CONFIG_VAL(D, T, count, INT);
E_CONFIG_VAL(D, T, transient, INT);
#undef T
#undef D
hist_edd = E_CONFIG_DD_NEW("History", History);
#define T History
#define D hist_edd
- E_CONFIG_VAL(D, T, version, INT);
+ E_CONFIG_VAL(D, T, version, INT);
+ E_CONFIG_VAL(D, T, begin, DOUBLE);
E_CONFIG_HASH(D, T, subjects, hist_entry_edd);
E_CONFIG_HASH(D, T, actions, hist_entry_edd);
- E_CONFIG_VAL(D, T, begin, DOUBLE);
#undef T
#undef D
}
EINA_LIST_FOREACH_SAFE(he->items, l, ll, hi)
{
+ if (hi->last_used < d->time - SEVEN_DAYS)
+ {
+ hi->count--;
+ hi->last_used = d->time - SEVEN_DAYS/2;
+ }
+
/* item is transient or too old */
if (!hi->count || hi->transient)
{
if (evry_hist)
{
d = E_NEW(Cleanup_Data, 1);
- /* d->time = ecore_time_get() - SOME_YEARS; */
+ d->time = ecore_time_get();
if (evry_hist->subjects)
{
Evry_Item *it;
Eina_List *l;
const char *id;
-
+
if (!s) return;
it = s->cur_item;
if (!it) return;
- if (it->id)
- id = it->id;
- else
- id = it->label;
-
+ id = (it->id ? it->id : it->label);
+
he = eina_hash_find(hist, id);
if (!he)
{
}
else
{
- /* found history entry */
EINA_LIST_FOREACH(he->items, l, hi)
if (hi->plugin == it->plugin->name) break;
-
- if (hi)
- {
- /* found history item */
- if (hi->input)
- {
- if (!s->input || !strncmp (hi->input, s->input, strlen(s->input)))
- {
- /* s->input matches hi->input and is equal or shorter */
- hi->last_used = TIME_NOW;
- hi->count++;
- hi->transient = it->transient;
- if (it->transient)
- hi->count++;
-
- }
- else if (s->input)
- {
- if (!strncmp (hi->input, s->input, strlen(hi->input)))
- {
- /* s->input matches hi->input but is longer */
- eina_stringshare_del(hi->input);
- hi->input = eina_stringshare_add(s->input);
- }
- else
- {
- /* s->input is different from hi->input
- -> create new item */
- hi = NULL;
- }
- }
- }
- else
- {
- /* remember input for item */
- hi->count++;
-
- if (it->transient)
- hi->count++;
-
- /* hi->last_used /= 2.0; */
- hi->last_used = TIME_NOW;
-
- if (s->input)
- hi->input = eina_stringshare_add(s->input);
- }
- }
}
if (!hi)
{
hi = E_NEW(History_Item, 1);
hi->plugin = eina_stringshare_ref(it->plugin->name);
- hi->last_used = TIME_NOW;
+ he->items = eina_list_append(he->items, hi);
+ }
- hi->count = 1;
- if (it->transient)
- hi->count++;
+ if (hi)
+ {
+ hi->last_used = ecore_time_get();
+ hi->usage /= 4.0;
+ hi->usage += TIME_FACTOR(hi->last_used);
+ hi->transient = it->transient;
+ hi->count += (hi->transient ? 2:1);
if (s->input)
- hi->input = eina_stringshare_add(s->input);
+ {
+ if (hi->input)
+ eina_stringshare_del(hi->input);
- he->items = eina_list_append(he->items, hi);
- }
+ hi->input = eina_stringshare_add(s->input);
+ }
+ }
}
int
{
History_Entry *he;
History_Item *hi;
- const char *id;
Eina_List *l;
- int cnt;
-
- if (it->id)
- id = it->id;
- else
- id = it->label;
- it->usage = 0;
+ it->usage = 0.0;
- if (!(he = eina_hash_find(hist, id)))
+ if (!(he = eina_hash_find(hist, (it->id ? it->id : it->label))))
return 0;
EINA_LIST_FOREACH(he->items, l, hi)
if (hi->plugin != it->plugin->name)
continue;
- cnt = 0;
-
if (!input || !hi->input)
{
- cnt = hi->count;
+ it->usage = hi->usage * hi->count;
}
else
{
/* higher priority for exact matches */
if (!strncmp(input, hi->input, strlen(input)))
{
- cnt += hi->count*2;
+ it->usage += hi->usage * hi->count;
}
if (!strncmp(input, hi->input, strlen(hi->input)))
{
- cnt += hi->count*2;
+ it->usage += hi->usage * hi->count;
}
}
- it->usage += (cnt * hi->last_used);
}
- if (it->usage) return 1;
+ if (it->usage > 0.0)
+ return 1;
return 0;
}
-#include "Evry.h"
+#include "e_mod_main.h"
#define TERM_ACTION_CMD "/usr/bin/xterm -hold -e '%s'"
static Evry_Action *act2 = NULL;
static Evry_Action *act3 = NULL;
static Evry_Action *act4 = NULL;
+static Evry_Action *act5 = NULL;
static Eina_List *exe_path = NULL;
static Ecore_Idler *exe_scan_idler = NULL;
if (!p->added)
p->added = eina_hash_string_small_new(_hash_free);
added = p->added;
-
+
return plugin;
}
_begin(Evry_Plugin *plugin, const Evry_Item *item)
{
PLUGIN(p, plugin);
-
+
/* taken from exebuf module */
char *path, *pp, *last;
E_Exe_List *el;
efreet_desktop_free(desktop);
}
-static int
+static Evry_Item_App *
_item_add(Plugin *p, Efreet_Desktop *desktop, char *file, int match)
{
Evry_Item_App *app;
EVRY_ITEM(app)->plugin = EVRY_PLUGIN(p);
EVRY_PLUGIN_ITEM_APPEND(p, app);
}
- return 1;
+ return app;
}
len = strlen(file);
else
exe = file;
- if (!exe) return 0;
+ if (!exe) return NULL;
if ((app = eina_hash_find(p->added, exe)) &&
(!desktop || (desktop == app->desktop)))
EVRY_ITEM(app)->plugin = EVRY_PLUGIN(p);
EVRY_PLUGIN_ITEM_APPEND(p, app);
}
- return 1;
+ return app;
}
if (desktop && !already_refd)
EVRY_ITEM(app)->fuzzy_match = match;
EVRY_PLUGIN_ITEM_APPEND(p, app);
- return 1;
+ return app;
}
static void
if (input && len > 2)
{
char *space;
-
+ Evry_Item_App *app;
+ char buf[256];
if ((space = strchr(input, ' ')))
len = (space - input);
EINA_LIST_FOREACH(exe_list, l, file)
{
if (!strncmp(file, input, len))
- _item_add(p, NULL, file, 100);
+ /* && (!space || (strlen(file) == len))) */
+ {
+ app = _item_add(p, NULL, file, 100);
+
+ if (app)
+ {
+ eina_stringshare_del(EVRY_ITEM(app)->label);
+ if (!space)
+ EVRY_ITEM(app)->label = eina_stringshare_add(file);
+ else
+ {
+ snprintf(buf, sizeof(buf), "%s%s", file, space);
+ EVRY_ITEM(app)->label = eina_stringshare_add(buf);
+ eina_stringshare_del(app->file);
+ app->file = eina_stringshare_add(buf);
+ }
+ }
+ }
}
}
return evry_util_exec_app(act->item1, act->item2);
}
-/* TODO config option for terminal and shell! */
static int
_exec_term_action(Evry_Action *act)
{
int ret;
tmp = E_NEW(Evry_Item_App, 1);
- snprintf(buf, sizeof(buf), TERM_ACTION_CMD, app->file);
+ snprintf(buf, sizeof(buf), "%s%s %s",
+ evry_conf->cmd_terminal,
+ (strcmp(evry_conf->cmd_terminal, "/usr/bin/xterm") ? "" : " -hold -e"),
+ app->file);
+
tmp->file = buf;
ret = evry_util_exec_app(EVRY_ITEM(tmp), NULL);
return 0;
}
+static int
+_exec_sudo_action(Evry_Action *act)
+{
+ ITEM_APP(app, act->item1);
+ Evry_Item_App *tmp;
+ char buf[1024];
+ int ret;
+
+ tmp = E_NEW(Evry_Item_App, 1);
+ snprintf(buf, sizeof(buf), "%s %s",
+ evry_conf->cmd_sudo,
+ (app->desktop ? app->desktop->exec : app->file));
+
+ tmp->file = buf;
+ ret = evry_util_exec_app(EVRY_ITEM(tmp), NULL);
+
+ E_FREE(tmp);
+
+ return ret;
+}
+
static int
_open_with_action(Evry_Plugin *plugin, const Evry_Item *it)
{
return 0;
}
-
-
static int
_edit_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
{
"everything-launch",
_exec_app_action, _exec_app_check_item,
NULL, NULL,NULL);
-
+
act1 = evry_action_new("Open File...", "APPLICATION", "FILE", "APPLICATION",
"document-open",
_exec_app_action, _exec_app_check_item,
"everything-launch",
_edit_app_action, _edit_app_check_item,
NULL, NULL, NULL);
-
+
act4 = evry_action_new("New Application Entry", "APPLICATION", NULL, NULL,
"everything-launch",
_new_app_action, _new_app_check_item,
NULL, NULL, NULL);
- evry_action_register(act, 0);
+ act5 = evry_action_new("Run with Sudo", "APPLICATION", NULL, NULL,
+ "system-run",
+ _exec_sudo_action, NULL, NULL, NULL, NULL);
+
+ evry_action_register(act, 0);
evry_action_register(act1, 1);
evry_action_register(act2, 2);
evry_action_register(act3, 3);
evry_action_register(act4, 4);
+ evry_action_register(act5, 5);
-
-
-
-
/* taken from e_exebuf.c */
exelist_exe_edd = E_CONFIG_DD_NEW("E_Exe", E_Exe);
#undef T
evry_action_free(act2);
evry_action_free(act3);
evry_action_free(act4);
+ evry_action_free(act5);
E_CONFIG_DD_FREE(exelist_edd);
E_CONFIG_DD_FREE(exelist_exe_edd);