2010-05-11 10:24:38 -07:00
|
|
|
#include "e.h"
|
|
|
|
#include "evry_api.h"
|
2009-08-27 13:52:14 -07:00
|
|
|
|
2012-12-21 15:57:05 -08:00
|
|
|
/* Increment for Major Changes */
|
|
|
|
#define MOD_CONFIG_FILE_EPOCH 1
|
|
|
|
/* Increment for Minor Changes (ie: user doesn't need a new config) */
|
|
|
|
#define MOD_CONFIG_FILE_GENERATION 0
|
|
|
|
#define MOD_CONFIG_FILE_VERSION ((MOD_CONFIG_FILE_EPOCH * 1000000) + MOD_CONFIG_FILE_GENERATION)
|
2011-04-08 15:16:59 -07:00
|
|
|
|
2011-01-23 14:34:28 -08:00
|
|
|
// FIXME clear cache on .desktop chage event
|
|
|
|
|
2011-01-20 16:14:48 -08:00
|
|
|
/* #undef DBG
|
|
|
|
* #define DBG(...) ERR(__VA_ARGS__) */
|
|
|
|
|
|
|
|
#define MAX_ITEMS 200
|
2012-11-01 08:02:03 -07:00
|
|
|
#define MAX_EXE 50
|
|
|
|
#define DEFAULT_MATCH_PRIORITY 15
|
|
|
|
#define PREFIX_MATCH_PRIORITY 11
|
2011-01-20 16:14:48 -08:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
typedef struct _Plugin Plugin;
|
2010-04-20 10:48:21 -07:00
|
|
|
typedef struct _Module_Config Module_Config;
|
2011-11-29 19:32:54 -08:00
|
|
|
typedef struct _E_Exe E_Exe;
|
|
|
|
typedef struct _E_Exe_List E_Exe_List;
|
|
|
|
typedef struct _Item_Menu Item_Menu;
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
struct _Plugin
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
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;
|
2009-06-21 03:31:38 -07:00
|
|
|
};
|
|
|
|
|
2009-08-25 02:30:14 -07:00
|
|
|
struct _E_Exe
|
|
|
|
{
|
2012-11-04 16:17:26 -08:00
|
|
|
unsigned int len;
|
|
|
|
const char *path;
|
2009-08-25 02:30:14 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _E_Exe_List
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
Eina_List *list;
|
2009-08-25 02:30:14 -07:00
|
|
|
};
|
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
struct _Module_Config
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
int version;
|
|
|
|
const char *cmd_terminal;
|
|
|
|
const char *cmd_sudo;
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
E_Config_Dialog *cfd;
|
|
|
|
E_Module *module;
|
2010-04-16 18:10:20 -07:00
|
|
|
};
|
|
|
|
|
2011-08-16 16:26:07 -07:00
|
|
|
struct _Item_Menu
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
Evry_Item base;
|
|
|
|
Efreet_Menu *menu;
|
2011-08-16 16:26:07 -07:00
|
|
|
};
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
static const Evry_API *evry = NULL;
|
|
|
|
static Evry_Module *evry_module = NULL;
|
|
|
|
static Eina_List *handlers = NULL;
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
static Module_Config *_conf;
|
2011-04-08 16:03:12 -07:00
|
|
|
static char _module_icon[] = "system-run";
|
2011-11-29 19:32:54 -08:00
|
|
|
static Eina_List *_plugins = NULL;
|
|
|
|
static Eina_List *_actions = NULL;
|
|
|
|
static Evry_Item *_act_open_with = NULL;
|
2012-11-04 16:17:26 -08:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
static Eina_List *exe_list = NULL;
|
|
|
|
static Eina_List *apps_cache = NULL;
|
2012-11-04 14:11:02 -08:00
|
|
|
|
2012-11-04 16:17:26 -08:00
|
|
|
static char _exebuf_cache_file[] = "evry_exebuf_cache";
|
2012-11-04 14:11:02 -08:00
|
|
|
static Eina_Bool update_path;
|
|
|
|
static char *current_path = NULL;
|
|
|
|
static Eina_List *dir_monitors = NULL;
|
2012-11-04 16:17:26 -08:00
|
|
|
static Eina_List *exe_path = NULL;
|
|
|
|
static Ecore_Idler *exe_scan_idler = NULL;
|
|
|
|
static E_Config_DD *exelist_exe_edd = NULL;
|
|
|
|
static E_Config_DD *exelist_edd = NULL;
|
|
|
|
static Eina_Iterator *exe_dir = NULL;
|
|
|
|
static Eina_List *exe_files = NULL;
|
2012-11-04 14:11:02 -08:00
|
|
|
|
2010-04-29 08:20:12 -07:00
|
|
|
static void _scan_executables();
|
2010-04-27 20:22:40 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
#define GET_MENU(_m, _it) Item_Menu * _m = (Item_Menu *)_it
|
2011-08-16 16:26:07 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
/***************************************************************************/
|
2009-08-25 02:30:14 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
static void
|
|
|
|
_hash_free(void *data)
|
2009-08-24 21:23:11 -07:00
|
|
|
{
|
2010-04-27 20:22:40 -07:00
|
|
|
GET_APP(app, data);
|
2010-05-11 10:24:38 -07:00
|
|
|
EVRY_ITEM_FREE(app);
|
2009-08-24 21:23:11 -07:00
|
|
|
}
|
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
static int
|
|
|
|
_exec_open_file_action(Evry_Action *act)
|
|
|
|
{
|
|
|
|
return evry->util_exec_app(EVRY_ITEM(act), act->it1.item);
|
|
|
|
}
|
2010-05-15 19:37:07 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
static Evry_Item_App *
|
|
|
|
_item_new(Plugin *p, const char *label, const char *id)
|
|
|
|
{
|
|
|
|
Evry_Item_App *app;
|
2010-04-16 18:10:20 -07:00
|
|
|
|
2011-11-29 20:00:51 -08:00
|
|
|
app = EVRY_ITEM_NEW(Evry_Item_App, p, label, NULL, evry_item_app_free);
|
2010-05-19 07:46:37 -07:00
|
|
|
EVRY_ACTN(app)->action = &_exec_open_file_action;
|
2011-01-23 08:02:33 -08:00
|
|
|
EVRY_ACTN(app)->it1.type = EVRY_TYPE_FILE;
|
2010-05-19 07:46:37 -07:00
|
|
|
EVRY_ITEM(app)->id = eina_stringshare_add(id);
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
eina_hash_add(p->added, id, app);
|
2010-05-15 19:37:07 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
EVRY_ACTN(app)->remember_context = EINA_TRUE;
|
|
|
|
EVRY_ITEM(app)->subtype = EVRY_TYPE_ACTION;
|
2009-09-02 12:43:16 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
return app;
|
2009-08-25 02:30:14 -07:00
|
|
|
}
|
|
|
|
|
2011-08-16 16:26:07 -07:00
|
|
|
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;
|
2011-11-29 19:32:54 -08:00
|
|
|
p->menu_items = eina_list_append(p->menu_items, m);
|
2011-08-16 16:26:07 -07:00
|
|
|
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
static int
|
|
|
|
_cb_sort(const void *data1, const void *data2)
|
2009-08-25 02:30:14 -07:00
|
|
|
{
|
2010-05-19 07:46:37 -07:00
|
|
|
const Evry_Item *it1 = data1;
|
|
|
|
const Evry_Item *it2 = data2;
|
2010-05-15 19:37:07 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
if (it1->usage && it2->usage)
|
2011-11-29 19:32:54 -08:00
|
|
|
return it1->usage > it2->usage ? -1 : 1;
|
2010-05-19 07:46:37 -07:00
|
|
|
if (it1->usage && !it2->usage)
|
|
|
|
return -1;
|
|
|
|
if (it2->usage && !it1->usage)
|
|
|
|
return 1;
|
2009-09-02 12:43:16 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
if (it1->fuzzy_match || it2->fuzzy_match)
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (it1->fuzzy_match && !it2->fuzzy_match)
|
|
|
|
return -1;
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
if (!it1->fuzzy_match && it2->fuzzy_match)
|
|
|
|
return 1;
|
2010-04-16 18:10:20 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
if (it1->fuzzy_match - it2->fuzzy_match)
|
|
|
|
return it1->fuzzy_match - it2->fuzzy_match;
|
2010-05-19 07:46:37 -07:00
|
|
|
}
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2010-05-27 07:38:51 -07:00
|
|
|
return strcasecmp(it1->label, it2->label);
|
2009-06-21 14:16:02 -07:00
|
|
|
}
|
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
/***************************************************************************/
|
2010-04-29 08:20:12 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
static Evry_Item_App *
|
|
|
|
_item_exe_add(Plugin *p, const char *exe, int match)
|
2009-08-13 15:42:40 -07:00
|
|
|
{
|
2010-05-19 07:46:37 -07:00
|
|
|
Evry_Item_App *app = NULL;
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
if ((app = eina_hash_find(p->added, exe)))
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (eina_list_data_find_list(p->base.items, app))
|
|
|
|
return app;
|
2010-05-19 07:46:37 -07:00
|
|
|
}
|
2009-08-27 13:52:14 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
if (!app)
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
app = _item_new(p, ecore_file_file_get(exe), exe);
|
|
|
|
app->file = eina_stringshare_ref(EVRY_ITEM(app)->id);
|
2010-05-19 07:46:37 -07:00
|
|
|
}
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
EVRY_ITEM(app)->fuzzy_match = match;
|
|
|
|
EVRY_PLUGIN_ITEM_APPEND(p, app);
|
2009-08-25 02:30:14 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
return app;
|
|
|
|
}
|
2010-04-29 08:20:12 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
static Eina_Bool
|
2011-01-23 14:34:28 -08:00
|
|
|
_hist_exe_get_cb(const Eina_Hash *hash __UNUSED__, const void *key, void *data, void *fdata)
|
2010-04-29 08:20:12 -07:00
|
|
|
{
|
2010-05-19 07:46:37 -07:00
|
|
|
History_Entry *he = data;
|
|
|
|
History_Item *hi;
|
|
|
|
Plugin *p = fdata;
|
|
|
|
Eina_List *l;
|
|
|
|
Evry_Item_App *app;
|
|
|
|
int match;
|
2010-05-20 08:41:27 -07:00
|
|
|
const char *exe = key;
|
2010-04-29 08:20:12 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FOREACH (he->items, l, hi)
|
2010-05-19 07:46:37 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
app = NULL;
|
|
|
|
|
|
|
|
if (strcmp(hi->plugin, EVRY_PLUGIN(p)->name))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!p->input)
|
|
|
|
{
|
|
|
|
app = _item_exe_add(p, exe, 0);
|
|
|
|
}
|
|
|
|
else if ((match = evry->fuzzy_match(exe, p->input)))
|
|
|
|
{
|
|
|
|
app = _item_exe_add(p, exe, match);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (app)
|
|
|
|
{
|
|
|
|
EVRY_ITEM(app)->hi = hi;
|
|
|
|
evry->history_item_usage_set(EVRY_ITEM(app), p->input, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2010-05-19 07:46:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
2010-04-29 08:20:12 -07:00
|
|
|
}
|
|
|
|
|
2010-04-27 20:22:40 -07:00
|
|
|
static int
|
2010-05-19 07:46:37 -07:00
|
|
|
_fetch_exe(Evry_Plugin *plugin, const char *input)
|
2010-04-27 20:22:40 -07:00
|
|
|
{
|
2010-05-19 07:46:37 -07:00
|
|
|
GET_PLUGIN(p, plugin);
|
|
|
|
Eina_List *l;
|
2012-04-30 00:07:33 -07:00
|
|
|
Evry_Item *eit;
|
2010-05-19 07:46:37 -07:00
|
|
|
History_Types *ht;
|
2012-11-01 08:02:03 -07:00
|
|
|
unsigned int input_len = (input ? strlen(input) : 0);
|
2010-05-19 07:46:37 -07:00
|
|
|
double max = 0.0;
|
2012-11-04 16:17:26 -08:00
|
|
|
unsigned int cnt = 0, end = input_len;
|
2012-11-01 08:02:03 -07:00
|
|
|
Eina_Bool query = (input_len >= (unsigned int)plugin->config->min_query);
|
2010-05-19 07:46:37 -07:00
|
|
|
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
2010-04-27 20:22:40 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
p->input = input;
|
2010-04-27 20:22:40 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
ht = evry->history_types_get(EVRY_TYPE_APP);
|
|
|
|
if (ht) eina_hash_foreach(ht->types, _hist_exe_get_cb, p);
|
2010-04-27 20:22:40 -07:00
|
|
|
|
2010-06-04 17:11:12 -07:00
|
|
|
if (input)
|
|
|
|
{
|
2012-11-04 16:17:26 -08:00
|
|
|
const char *tmp;
|
|
|
|
const E_Exe *ee, *match = NULL;
|
2012-11-01 08:02:03 -07:00
|
|
|
// begin of arguments (end of executable part)
|
2011-11-29 19:32:54 -08:00
|
|
|
if ((tmp = strchr(input, ' ')))
|
|
|
|
end = tmp - input;
|
|
|
|
|
|
|
|
if ((!exe_list) && (!exe_scan_idler))
|
|
|
|
_scan_executables();
|
2012-11-04 16:17:26 -08:00
|
|
|
EINA_LIST_FOREACH (exe_list, l, ee)
|
2011-11-29 19:32:54 -08:00
|
|
|
{
|
2012-11-04 16:17:26 -08:00
|
|
|
if ((end < input_len) && (ee->len > end))
|
2011-11-29 19:32:54 -08:00
|
|
|
continue;
|
2012-11-04 16:17:26 -08:00
|
|
|
if (!strncmp(input, ee->path, end))
|
2011-11-29 19:32:54 -08:00
|
|
|
{
|
2012-11-04 16:17:26 -08:00
|
|
|
if (query && (cnt++ < MAX_EXE) && (input_len != ee->len))
|
|
|
|
_item_exe_add(p, ee->path, DEFAULT_MATCH_PRIORITY);
|
|
|
|
|
|
|
|
if ((!match) || (ee->len < match->len))
|
|
|
|
match = ee;
|
|
|
|
|
|
|
|
if ((!query) && (ee->len == input_len))
|
2011-11-29 19:32:54 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-04 16:17:26 -08:00
|
|
|
if (match)
|
2011-11-29 19:32:54 -08:00
|
|
|
{
|
|
|
|
GET_ITEM(it, p->command);
|
2012-11-04 16:17:26 -08:00
|
|
|
const char *cmd;
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2012-11-04 16:17:26 -08:00
|
|
|
if (match->len < input_len)
|
|
|
|
cmd = input;
|
|
|
|
else
|
|
|
|
cmd = match->path;
|
|
|
|
|
|
|
|
EVRY_ITEM_LABEL_SET(it, cmd);
|
2011-11-29 19:32:54 -08:00
|
|
|
|
|
|
|
IF_RELEASE(p->command->file);
|
|
|
|
p->command->file = eina_stringshare_ref(it->label);
|
2012-11-04 16:17:26 -08:00
|
|
|
it->fuzzy_match = PREFIX_MATCH_PRIORITY;
|
2011-11-29 19:32:54 -08:00
|
|
|
EVRY_PLUGIN_ITEM_APPEND(p, it);
|
|
|
|
evry->item_changed(it, 0, 0);
|
|
|
|
}
|
2010-06-04 17:11:12 -07:00
|
|
|
}
|
|
|
|
|
2012-04-30 00:07:33 -07:00
|
|
|
EINA_LIST_FOREACH (plugin->items, l, eit)
|
2010-05-19 07:46:37 -07:00
|
|
|
{
|
2012-04-30 00:07:33 -07:00
|
|
|
evry->history_item_usage_set(eit, input, NULL);
|
2012-11-01 08:02:03 -07:00
|
|
|
if (input && (eit->usage > max) && !strncmp(input, eit->label, input_len))
|
2012-04-30 00:07:33 -07:00
|
|
|
max = eit->usage;
|
2010-05-19 07:46:37 -07:00
|
|
|
}
|
|
|
|
EVRY_ITEM(p->command)->usage = (max * 2.0);
|
2010-04-27 20:22:40 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort);
|
2010-04-27 20:22:40 -07:00
|
|
|
|
2011-08-21 08:41:37 -07:00
|
|
|
return EVRY_PLUGIN_HAS_ITEMS(p);
|
2010-04-27 20:22:40 -07:00
|
|
|
}
|
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
static Evry_Plugin *
|
|
|
|
_begin_exe(Evry_Plugin *plugin, const Evry_Item *item)
|
2009-08-10 08:00:41 -07:00
|
|
|
{
|
2010-05-19 07:46:37 -07:00
|
|
|
Plugin *p;
|
2009-08-22 20:12:05 -07:00
|
|
|
Evry_Item_App *app;
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
if (item && (item != _act_open_with))
|
|
|
|
return NULL;
|
2009-08-27 13:52:14 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
EVRY_PLUGIN_INSTANCE(p, plugin)
|
2009-08-27 13:52:14 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
p->added = eina_hash_string_small_new(_hash_free);
|
2009-08-10 08:00:41 -07:00
|
|
|
|
2011-11-29 20:00:51 -08:00
|
|
|
app = EVRY_ITEM_NEW(Evry_Item_App, p, NULL, NULL, evry_item_app_free);
|
2010-05-19 07:46:37 -07:00
|
|
|
EVRY_ACTN(app)->action = &_exec_open_file_action;
|
|
|
|
EVRY_ACTN(app)->remember_context = EINA_TRUE;
|
|
|
|
EVRY_ITEM(app)->subtype = EVRY_TYPE_ACTION;
|
|
|
|
p->command = app;
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
return EVRY_PLUGIN(p);
|
|
|
|
}
|
2009-08-25 02:30:14 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
static void
|
|
|
|
_finish_exe(Evry_Plugin *plugin)
|
|
|
|
{
|
|
|
|
GET_PLUGIN(p, plugin);
|
|
|
|
char *str;
|
2012-11-04 16:17:26 -08:00
|
|
|
E_Exe *ee;
|
2009-08-27 13:52:14 -07:00
|
|
|
|
2010-05-30 06:30:13 -07:00
|
|
|
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
|
|
|
EVRY_ITEM_FREE(p->command);
|
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
if (p->added)
|
|
|
|
eina_hash_free(p->added);
|
2010-04-27 20:22:40 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
if (exe_dir)
|
|
|
|
{
|
2012-04-30 00:07:33 -07:00
|
|
|
eina_iterator_free(exe_dir);
|
2011-11-29 19:32:54 -08:00
|
|
|
exe_dir = NULL;
|
2009-09-24 16:08:59 -07:00
|
|
|
}
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (exe_path, str)
|
2010-05-19 07:46:37 -07:00
|
|
|
free(str);
|
|
|
|
|
|
|
|
if (exe_scan_idler)
|
2009-09-24 16:08:59 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
ecore_idler_del(exe_scan_idler);
|
|
|
|
exe_scan_idler = NULL;
|
2009-09-24 16:08:59 -07:00
|
|
|
}
|
2012-11-04 16:17:26 -08:00
|
|
|
|
|
|
|
EINA_LIST_FREE (exe_list, ee)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(ee->path);
|
|
|
|
free(ee);
|
|
|
|
}
|
|
|
|
|
|
|
|
EINA_LIST_FREE (exe_files, str)
|
|
|
|
eina_stringshare_del(str);
|
2010-05-19 07:46:37 -07:00
|
|
|
|
|
|
|
E_FREE(p);
|
|
|
|
}
|
2009-08-24 21:23:11 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
/***************************************************************************/
|
2009-08-10 08:00:41 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
static void
|
|
|
|
_item_desktop_add(Plugin *p, Efreet_Desktop *desktop, int match)
|
|
|
|
{
|
|
|
|
Evry_Item_App *app = NULL;
|
2009-08-11 09:07:30 -07:00
|
|
|
|
2013-12-04 09:02:05 -08:00
|
|
|
if (desktop->no_display) return;
|
2010-05-19 07:46:37 -07:00
|
|
|
if ((app = eina_hash_find(p->added, desktop->exec)))
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (eina_list_data_find_list(p->base.items, app))
|
|
|
|
return;
|
2009-08-25 02:30:14 -07:00
|
|
|
}
|
2010-04-08 15:37:50 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
if (!app)
|
2009-08-25 02:30:14 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
app = _item_new(p, desktop->name, desktop->exec);
|
|
|
|
efreet_desktop_ref(desktop);
|
|
|
|
app->desktop = desktop;
|
|
|
|
|
|
|
|
if (desktop->comment)
|
|
|
|
{
|
|
|
|
EVRY_ITEM_DETAIL_SET(app, desktop->comment);
|
|
|
|
}
|
|
|
|
else if (desktop->generic_name)
|
|
|
|
{
|
|
|
|
EVRY_ITEM_DETAIL_SET(app, desktop->generic_name);
|
|
|
|
}
|
2010-04-08 15:37:50 -07:00
|
|
|
}
|
2010-05-15 19:37:07 -07:00
|
|
|
|
2009-08-25 02:30:14 -07:00
|
|
|
EVRY_ITEM(app)->fuzzy_match = match;
|
|
|
|
EVRY_PLUGIN_ITEM_APPEND(p, app);
|
2009-08-10 08:00:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-05-19 07:46:37 -07:00
|
|
|
_desktop_list_add(Plugin *p, Eina_List *apps, const char *input)
|
2009-08-10 08:00:41 -07:00
|
|
|
{
|
|
|
|
Efreet_Desktop *desktop;
|
|
|
|
Eina_List *l;
|
2009-08-15 17:13:56 -07:00
|
|
|
int m1, m2;
|
2010-05-15 14:22:06 -07:00
|
|
|
const char *exec, *end;
|
|
|
|
char buf[PATH_MAX];
|
2010-05-15 19:37:07 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FOREACH (apps, l, desktop)
|
2009-08-10 08:00:41 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (eina_list_count(p->base.items) >= MAX_ITEMS) break;
|
|
|
|
|
|
|
|
m1 = m2 = 0;
|
|
|
|
|
|
|
|
if (input)
|
|
|
|
{
|
|
|
|
/* strip path and parameter */
|
|
|
|
exec = ecore_file_file_get(desktop->exec);
|
|
|
|
if ((exec) && (end = strchr(exec, '%')) &&
|
|
|
|
((end - exec) - 1 > 0))
|
|
|
|
{
|
|
|
|
strncpy(buf, exec, (end - exec) - 1);
|
|
|
|
buf[(end - exec) - 1] = '\0';
|
|
|
|
m1 = evry->fuzzy_match(buf, input);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m1 = evry->fuzzy_match(exec, input);
|
|
|
|
}
|
|
|
|
|
|
|
|
m2 = evry->fuzzy_match(desktop->name, input);
|
|
|
|
|
|
|
|
if (!m1 || (m2 && m2 < m1)) m1 = m2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!input || m1) _item_desktop_add(p, desktop, m1);
|
2009-08-10 08:00:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
static Eina_List *
|
|
|
|
_desktop_list_get(void)
|
2009-08-10 08:00:41 -07:00
|
|
|
{
|
2010-05-19 07:46:37 -07:00
|
|
|
Eina_List *apps = NULL;
|
|
|
|
Eina_List *cat_ss;
|
|
|
|
Eina_List *l, *ll;
|
|
|
|
Efreet_Desktop *d;
|
2009-08-10 08:00:41 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
apps = efreet_util_desktop_name_glob_list("*");
|
2009-08-14 11:55:35 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
/* remove screensaver */
|
|
|
|
cat_ss = efreet_util_desktop_category_list("Screensaver");
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FOREACH (cat_ss, l, d)
|
2010-04-09 07:41:37 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if ((ll = eina_list_data_find_list(apps, d)))
|
|
|
|
{
|
|
|
|
efreet_desktop_free(d);
|
|
|
|
apps = eina_list_remove_list(apps, ll);
|
|
|
|
}
|
2012-11-04 11:11:25 -08:00
|
|
|
//printf("%d %s\n", d->ref, d->name);
|
2011-11-29 19:32:54 -08:00
|
|
|
|
|
|
|
efreet_desktop_free(d);
|
2010-04-09 07:41:37 -07:00
|
|
|
}
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
return apps;
|
2009-08-10 08:00:41 -07:00
|
|
|
}
|
|
|
|
|
2009-09-24 16:08:59 -07:00
|
|
|
static Eina_Bool
|
2011-01-23 14:34:28 -08:00
|
|
|
_hist_items_get_cb(const Eina_Hash *hash __UNUSED__, const void *key, void *data, void *fdata)
|
2009-09-24 16:08:59 -07:00
|
|
|
{
|
2010-04-10 13:05:57 -07:00
|
|
|
History_Entry *he = data;
|
|
|
|
History_Item *hi;
|
|
|
|
Plugin *p = fdata;
|
|
|
|
Efreet_Desktop *d;
|
2010-05-19 07:46:37 -07:00
|
|
|
Eina_List *l, *ll;
|
|
|
|
const char *exec = key;
|
2010-04-10 13:05:57 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FOREACH (he->items, l, hi)
|
2010-04-10 13:05:57 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
d = NULL;
|
|
|
|
|
|
|
|
if (hi->transient)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (strcmp(hi->plugin, EVRY_PLUGIN(p)->name))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH (apps_cache, ll, d)
|
|
|
|
if (d->exec && !strcmp(d->exec, exec)) break;
|
|
|
|
|
|
|
|
if (!d)
|
|
|
|
{
|
|
|
|
if (!p->apps_all)
|
|
|
|
p->apps_all = _desktop_list_get();
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH (p->apps_all, ll, d)
|
|
|
|
if (d->exec && !strcmp(d->exec, exec)) break;
|
|
|
|
|
|
|
|
if (d)
|
|
|
|
{
|
|
|
|
efreet_desktop_ref(d);
|
|
|
|
apps_cache = eina_list_append(apps_cache, d);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* remove from history */
|
|
|
|
/* DBG("no desktop: %s", exec);
|
|
|
|
* hi->transient = 1; */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!d)
|
|
|
|
{
|
|
|
|
DBG("app not found %s", exec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
p->apps_hist = eina_list_append(p->apps_hist, d);
|
|
|
|
break;
|
2010-04-10 13:05:57 -07:00
|
|
|
}
|
2010-05-19 07:46:37 -07:00
|
|
|
|
2010-04-10 13:05:57 -07:00
|
|
|
return EINA_TRUE;
|
2009-09-24 16:08:59 -07:00
|
|
|
}
|
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
static Evry_Plugin *
|
|
|
|
_begin(Evry_Plugin *plugin, const Evry_Item *item)
|
2010-04-14 13:09:38 -07:00
|
|
|
{
|
2010-05-19 07:46:37 -07:00
|
|
|
Plugin *p;
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
if (item && (item != _act_open_with))
|
|
|
|
return NULL;
|
2010-04-14 13:09:38 -07:00
|
|
|
|
2011-08-16 16:26:07 -07:00
|
|
|
EVRY_PLUGIN_INSTANCE(p, plugin);
|
2010-05-19 07:46:37 -07:00
|
|
|
p->added = eina_hash_string_small_new(_hash_free);
|
2011-08-16 16:26:07 -07:00
|
|
|
p->menu = efreet_menu_get();
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2011-08-16 16:26:07 -07:00
|
|
|
return EVRY_PLUGIN(p);
|
|
|
|
}
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2011-08-16 16:26:07 -07:00
|
|
|
static Evry_Plugin *
|
|
|
|
_browse(Evry_Plugin *plugin, const Evry_Item *item)
|
|
|
|
{
|
|
|
|
Plugin *p;
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2011-08-16 16:26:07 -07:00
|
|
|
if (!item)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!CHECK_TYPE(item, EVRY_TYPE_NONE))
|
|
|
|
return NULL;
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2011-08-16 16:26:07 -07:00
|
|
|
EVRY_PLUGIN_INSTANCE(p, plugin);
|
|
|
|
GET_MENU(m, item);
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2011-08-16 16:26:07 -07:00
|
|
|
p->added = eina_hash_string_small_new(_hash_free);
|
|
|
|
p->menu = m->menu;
|
|
|
|
p->browse = EINA_TRUE;
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
return EVRY_PLUGIN(p);
|
|
|
|
}
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
static void
|
|
|
|
_finish(Evry_Plugin *plugin)
|
|
|
|
{
|
|
|
|
Efreet_Desktop *desktop;
|
2011-08-16 16:26:07 -07:00
|
|
|
Evry_Item *it;
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2011-08-16 16:26:07 -07:00
|
|
|
GET_PLUGIN(p, plugin);
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2010-05-30 06:30:13 -07:00
|
|
|
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
|
|
|
|
2011-08-16 16:26:07 -07:00
|
|
|
/* TODO share with browse instances */
|
2010-05-19 07:46:37 -07:00
|
|
|
if (p->added)
|
|
|
|
eina_hash_free(p->added);
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2011-08-16 16:26:07 -07:00
|
|
|
if ((!p->browse) && (p->menu))
|
|
|
|
efreet_menu_free(p->menu);
|
2011-11-29 19:32:54 -08:00
|
|
|
|
|
|
|
EINA_LIST_FREE (p->apps_all, desktop)
|
2010-05-19 07:46:37 -07:00
|
|
|
efreet_desktop_free(desktop);
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (p->apps_hist, desktop) ;
|
2010-04-14 13:09:38 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (p->apps_mime, desktop)
|
2010-05-19 07:46:37 -07:00
|
|
|
efreet_desktop_free(desktop);
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (p->menu_items, it)
|
2011-08-16 16:26:07 -07:00
|
|
|
EVRY_ITEM_FREE(it);
|
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
E_FREE(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_fetch(Evry_Plugin *plugin, const char *input)
|
|
|
|
{
|
|
|
|
GET_PLUGIN(p, plugin);
|
|
|
|
Eina_List *l;
|
|
|
|
Evry_Item *it;
|
|
|
|
History_Types *ht;
|
2010-04-14 13:09:38 -07:00
|
|
|
|
2011-08-16 16:26:07 -07:00
|
|
|
Efreet_Menu *entry;
|
|
|
|
int i = 1;
|
2010-04-14 13:09:38 -07:00
|
|
|
|
2011-08-16 16:26:07 -07:00
|
|
|
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
2011-01-23 14:34:28 -08:00
|
|
|
|
2011-08-16 16:26:07 -07:00
|
|
|
if (!p->browse)
|
2010-05-19 07:46:37 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (input)
|
|
|
|
{
|
|
|
|
if (!p->apps_all)
|
|
|
|
p->apps_all = _desktop_list_get();
|
|
|
|
|
|
|
|
_desktop_list_add(p, p->apps_all, input);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_desktop_list_add(p, p->apps_mime, input);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
_desktop_list_add(p, p->apps_hist, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH (plugin->items, l, it)
|
|
|
|
evry->history_item_usage_set(it, input, NULL);
|
|
|
|
|
|
|
|
EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort);
|
2011-08-16 16:26:07 -07:00
|
|
|
}
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2011-08-16 16:26:07 -07:00
|
|
|
if ((p->menu) && (!p->menu_items))
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
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; */
|
|
|
|
}
|
2011-08-16 16:26:07 -07:00
|
|
|
}
|
2010-05-27 07:38:51 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FOREACH (p->menu_items, l, it)
|
2011-08-21 08:41:37 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (!input)
|
|
|
|
{
|
|
|
|
EVRY_PLUGIN_ITEM_APPEND(p, it);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((it->fuzzy_match = evry->fuzzy_match(it->label, input)))
|
|
|
|
EVRY_PLUGIN_ITEM_APPEND(p, it);
|
2011-08-21 08:41:37 -07:00
|
|
|
}
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2011-08-21 08:41:37 -07:00
|
|
|
return EVRY_PLUGIN_HAS_ITEMS(p);
|
2010-05-19 07:46:37 -07:00
|
|
|
}
|
2010-04-14 13:09:38 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
/***************************************************************************/
|
2010-04-14 13:09:38 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
static Evry_Plugin *
|
|
|
|
_begin_mime(Evry_Plugin *plugin, const Evry_Item *item)
|
|
|
|
{
|
|
|
|
Plugin *p = NULL;
|
2010-10-28 16:07:59 -07:00
|
|
|
Efreet_Desktop *d;
|
2010-05-19 07:46:37 -07:00
|
|
|
const char *mime;
|
|
|
|
const char *path = NULL;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
if (CHECK_TYPE(item, EVRY_TYPE_ACTION))
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
GET_ACTION(act, item);
|
|
|
|
GET_FILE(file, act->it1.item);
|
2010-05-19 07:46:37 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
if (!evry->file_path_get(file))
|
|
|
|
return NULL;
|
2010-05-19 07:46:37 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
path = file->path;
|
|
|
|
mime = file->mime;
|
2010-05-19 07:46:37 -07:00
|
|
|
}
|
|
|
|
else if (CHECK_TYPE(item, EVRY_TYPE_FILE))
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
GET_FILE(file, item);
|
2010-04-14 13:09:38 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
if (!evry->file_path_get(file))
|
|
|
|
return NULL;
|
2010-04-14 13:09:38 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
path = file->path;
|
|
|
|
mime = file->mime;
|
2010-05-19 07:46:37 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
return NULL;
|
2010-05-19 07:46:37 -07:00
|
|
|
}
|
2010-04-14 13:09:38 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
if (!path || !mime || !(mime = efreet_mime_type_get(path)))
|
|
|
|
return NULL;
|
2010-04-14 13:09:38 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
EVRY_PLUGIN_INSTANCE(p, plugin);
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
p->apps_mime = efreet_util_desktop_mime_list(mime);
|
2010-04-14 13:09:38 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
if (strcmp(mime, "text/plain") && (!strncmp(mime, "text/", 5)))
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
l = efreet_util_desktop_mime_list("text/plain");
|
|
|
|
|
|
|
|
EINA_LIST_FREE (l, d)
|
|
|
|
{
|
|
|
|
if (!eina_list_data_find_list(p->apps_mime, d))
|
|
|
|
p->apps_mime = eina_list_append(p->apps_mime, d);
|
|
|
|
else
|
|
|
|
efreet_desktop_free(d);
|
|
|
|
}
|
2010-04-14 13:09:38 -07:00
|
|
|
}
|
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
if (item->browseable && strcmp(mime, "x-directory/normal"))
|
2010-04-14 13:09:38 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
l = efreet_util_desktop_mime_list("x-directory/normal");
|
|
|
|
|
|
|
|
EINA_LIST_FREE (l, d)
|
|
|
|
{
|
|
|
|
if (!eina_list_data_find_list(p->apps_mime, d))
|
|
|
|
p->apps_mime = eina_list_append(p->apps_mime, d);
|
|
|
|
else
|
|
|
|
efreet_desktop_free(d);
|
|
|
|
}
|
2010-04-14 13:09:38 -07:00
|
|
|
}
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
if ((d = e_exehist_mime_desktop_get(mime)))
|
2010-04-14 13:09:38 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if ((l = eina_list_data_find_list(p->apps_mime, d)))
|
|
|
|
{
|
|
|
|
p->apps_mime = eina_list_promote_list(p->apps_mime, l);
|
|
|
|
efreet_desktop_free(d);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p->apps_mime = eina_list_prepend(p->apps_mime, d);
|
|
|
|
}
|
2010-04-14 13:09:38 -07:00
|
|
|
}
|
2010-05-19 07:46:37 -07:00
|
|
|
|
|
|
|
p->added = eina_hash_string_small_new(_hash_free);
|
|
|
|
|
|
|
|
return EVRY_PLUGIN(p);
|
2010-04-14 13:09:38 -07:00
|
|
|
}
|
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
static void
|
|
|
|
_finish_mime(Evry_Plugin *plugin)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2010-04-27 20:22:40 -07:00
|
|
|
GET_PLUGIN(p, plugin);
|
2010-05-19 07:46:37 -07:00
|
|
|
Efreet_Desktop *desktop;
|
2010-04-29 08:20:12 -07:00
|
|
|
|
2010-05-30 06:30:13 -07:00
|
|
|
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
if (p->added)
|
|
|
|
eina_hash_free(p->added);
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (p->apps_mime, desktop)
|
2010-05-19 07:46:37 -07:00
|
|
|
efreet_desktop_free(desktop);
|
2010-05-30 06:30:13 -07:00
|
|
|
|
|
|
|
E_FREE(p);
|
2010-04-29 08:20:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-05-19 07:46:37 -07:00
|
|
|
_fetch_mime(Evry_Plugin *plugin, const char *input)
|
2010-04-29 08:20:12 -07:00
|
|
|
{
|
|
|
|
GET_PLUGIN(p, plugin);
|
|
|
|
Eina_List *l;
|
|
|
|
Evry_Item *it;
|
|
|
|
|
|
|
|
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
/* add apps for a given mimetype */
|
|
|
|
_desktop_list_add(p, p->apps_mime, input);
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FOREACH (plugin->items, l, it)
|
2010-05-11 10:24:38 -07:00
|
|
|
evry->history_item_usage_set(it, input, NULL);
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
if (input)
|
|
|
|
EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort);
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
return 1;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
2010-04-15 08:46:12 -07:00
|
|
|
static int
|
2011-01-23 14:34:28 -08:00
|
|
|
_complete(Evry_Plugin *plugin __UNUSED__, const Evry_Item *it, char **input)
|
2010-04-15 08:46:12 -07:00
|
|
|
{
|
2010-04-27 20:22:40 -07:00
|
|
|
GET_APP(app, it);
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2010-04-15 08:46:12 -07:00
|
|
|
char buf[128];
|
|
|
|
|
|
|
|
if (app->desktop)
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
char *space = strchr(app->desktop->exec, ' ');
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
snprintf(buf, sizeof(buf), "%s", app->desktop->exec);
|
|
|
|
if (space)
|
|
|
|
buf[1 + space - app->desktop->exec] = '\0';
|
2010-04-15 08:46:12 -07:00
|
|
|
}
|
|
|
|
else
|
2010-06-04 17:53:47 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s", app->file);
|
2010-04-15 08:46:12 -07:00
|
|
|
|
|
|
|
*input = strdup(buf);
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2010-04-15 08:46:12 -07:00
|
|
|
return EVRY_COMPLETE_INPUT;
|
|
|
|
}
|
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
/***************************************************************************/
|
|
|
|
|
2009-07-15 07:37:01 -07:00
|
|
|
static int
|
2011-01-23 14:34:28 -08:00
|
|
|
_exec_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it __UNUSED__)
|
2009-07-15 07:37:01 -07:00
|
|
|
{
|
2009-09-15 10:19:53 -07:00
|
|
|
return 1;
|
2009-08-14 11:55:35 -07:00
|
|
|
}
|
|
|
|
|
2009-08-10 08:00:41 -07:00
|
|
|
static int
|
2009-08-21 18:15:21 -07:00
|
|
|
_exec_app_action(Evry_Action *act)
|
2009-08-14 11:55:35 -07:00
|
|
|
{
|
2010-05-11 10:24:38 -07:00
|
|
|
return evry->util_exec_app(act->it1.item, act->it2.item);
|
2009-08-14 11:55:35 -07:00
|
|
|
}
|
|
|
|
|
2010-04-29 08:20:12 -07:00
|
|
|
static int
|
|
|
|
_exec_file_action(Evry_Action *act)
|
|
|
|
{
|
2010-05-11 10:24:38 -07:00
|
|
|
return evry->util_exec_app(act->it2.item, act->it1.item);
|
2010-04-29 08:20:12 -07:00
|
|
|
}
|
|
|
|
|
2009-08-25 02:30:14 -07:00
|
|
|
static int
|
|
|
|
_exec_term_action(Evry_Action *act)
|
|
|
|
{
|
2010-04-28 05:58:24 -07:00
|
|
|
GET_APP(app, act->it1.item);
|
2009-08-27 03:35:32 -07:00
|
|
|
Evry_Item_App *tmp;
|
2009-08-25 02:30:14 -07:00
|
|
|
char buf[1024];
|
2009-08-27 03:35:32 -07:00
|
|
|
int ret;
|
2009-09-17 23:33:33 -07:00
|
|
|
char *escaped = ecore_file_escape_name(app->file);
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2009-08-27 03:35:32 -07:00
|
|
|
tmp = E_NEW(Evry_Item_App, 1);
|
2012-07-04 12:09:36 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s %s",
|
2011-11-29 19:32:54 -08:00
|
|
|
_conf->cmd_terminal,
|
|
|
|
(escaped ? escaped : app->file));
|
2009-09-02 12:43:16 -07:00
|
|
|
|
2009-08-27 03:35:32 -07:00
|
|
|
tmp->file = buf;
|
2010-05-11 10:24:38 -07:00
|
|
|
ret = evry->util_exec_app(EVRY_ITEM(tmp), NULL);
|
2009-08-25 02:30:14 -07:00
|
|
|
|
2009-08-27 03:35:32 -07:00
|
|
|
E_FREE(tmp);
|
2009-09-17 23:33:33 -07:00
|
|
|
E_FREE(escaped);
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2009-08-27 03:35:32 -07:00
|
|
|
return ret;
|
2009-08-25 02:30:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_exec_term_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
|
|
|
{
|
2010-04-27 20:22:40 -07:00
|
|
|
GET_APP(app, it);
|
2009-08-25 02:30:14 -07:00
|
|
|
|
|
|
|
if (app->file)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-09-02 12:43:16 -07:00
|
|
|
static int
|
|
|
|
_exec_sudo_action(Evry_Action *act)
|
|
|
|
{
|
2010-04-28 05:58:24 -07:00
|
|
|
GET_APP(app, act->it1.item);
|
2009-09-02 12:43:16 -07:00
|
|
|
Evry_Item_App *tmp;
|
|
|
|
char buf[1024];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
tmp = E_NEW(Evry_Item_App, 1);
|
|
|
|
snprintf(buf, sizeof(buf), "%s %s",
|
2011-11-29 19:32:54 -08:00
|
|
|
_conf->cmd_sudo,
|
|
|
|
(app->desktop ? app->desktop->exec : app->file));
|
2009-09-02 12:43:16 -07:00
|
|
|
|
|
|
|
tmp->file = buf;
|
2010-05-11 10:24:38 -07:00
|
|
|
ret = evry->util_exec_app(EVRY_ITEM(tmp), NULL);
|
2009-09-02 12:43:16 -07:00
|
|
|
|
|
|
|
E_FREE(tmp);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-07-15 05:22:42 -07:00
|
|
|
static int
|
2009-08-12 05:17:43 -07:00
|
|
|
_edit_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
2009-07-15 05:22:42 -07:00
|
|
|
{
|
2010-04-27 20:22:40 -07:00
|
|
|
GET_APP(app, it);
|
2009-08-24 21:23:11 -07:00
|
|
|
|
2009-07-15 05:22:42 -07:00
|
|
|
if (app->desktop)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-07-15 05:22:42 -07:00
|
|
|
static int
|
2009-08-21 18:15:21 -07:00
|
|
|
_edit_app_action(Evry_Action *act)
|
2009-07-15 05:22:42 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
Efreet_Desktop *desktop;
|
2010-04-28 05:58:24 -07:00
|
|
|
GET_APP(app, act->it1.item);
|
2009-08-10 04:36:37 -07:00
|
|
|
|
|
|
|
if (app->desktop)
|
|
|
|
desktop = app->desktop;
|
|
|
|
else
|
2009-07-15 05:22:42 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
char buf[128];
|
|
|
|
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 by efreet*/
|
|
|
|
desktop->exec = strdup(app->file);
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
2009-07-15 05:22:42 -07:00
|
|
|
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
e_desktop_edit(NULL, desktop);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
return 1;
|
2009-07-15 05:22:42 -07:00
|
|
|
}
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-07-15 07:37:01 -07:00
|
|
|
static int
|
2009-08-12 05:17:43 -07:00
|
|
|
_new_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
2009-07-15 07:37:01 -07:00
|
|
|
{
|
2010-04-27 20:22:40 -07:00
|
|
|
GET_APP(app, it);
|
2009-08-24 21:23:11 -07:00
|
|
|
|
2009-07-15 07:37:01 -07:00
|
|
|
if (app->desktop)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (app->file && strlen(app->file) > 0)
|
|
|
|
return 1;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-07-15 07:37:01 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-15 05:22:42 -07:00
|
|
|
static int
|
2009-08-21 18:15:21 -07:00
|
|
|
_new_app_action(Evry_Action *act)
|
2009-07-15 05:22:42 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
char *name;
|
|
|
|
char buf[4096];
|
|
|
|
char *end;
|
|
|
|
Efreet_Desktop *desktop;
|
|
|
|
int i;
|
|
|
|
|
2010-04-28 05:58:24 -07:00
|
|
|
GET_APP(app, act->it1.item);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (app->desktop)
|
|
|
|
name = strdup(app->desktop->name);
|
|
|
|
else
|
|
|
|
/* TODO replace '/' and remove other special characters */
|
|
|
|
name = strdup(app->file);
|
2009-07-15 05:22:42 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if ((end = strchr(name, ' ')))
|
|
|
|
name[end - name] = '\0';
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
snprintf(buf, 4096, "%s/.local/share/applications/%s-%d.desktop",
|
|
|
|
e_user_homedir_get(), name, i);
|
|
|
|
if (ecore_file_exists(buf))
|
|
|
|
{
|
|
|
|
buf[0] = '\0';
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else break;
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
|
|
|
free(name);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2010-04-26 11:21:09 -07:00
|
|
|
if (strlen(buf) == 0)
|
2009-08-10 04:36:37 -07:00
|
|
|
return 0;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (!app->desktop)
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
desktop = efreet_desktop_empty_new(buf);
|
|
|
|
desktop->exec = (char *)eina_stringshare_add(app->file);
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
2009-08-12 12:00:25 -07:00
|
|
|
else
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
desktop = efreet_desktop_empty_new(buf);
|
|
|
|
if (app->desktop->name)
|
|
|
|
desktop->name = strdup(app->desktop->name);
|
|
|
|
if (app->desktop->comment)
|
|
|
|
desktop->comment = strdup(app->desktop->comment);
|
|
|
|
if (app->desktop->generic_name)
|
|
|
|
desktop->generic_name = strdup(app->desktop->generic_name);
|
|
|
|
if (app->desktop->exec)
|
|
|
|
desktop->exec = strdup(app->desktop->exec);
|
|
|
|
if (app->desktop->icon)
|
|
|
|
desktop->icon = strdup(app->desktop->icon);
|
|
|
|
if (app->desktop->mime_types)
|
|
|
|
desktop->mime_types = eina_list_clone(app->desktop->mime_types);
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
2010-04-21 03:59:08 -07:00
|
|
|
if (desktop)
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
e_desktop_edit(NULL, desktop);
|
2009-07-15 05:22:42 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
return 1;
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
2009-07-15 05:22:42 -07:00
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
static int
|
|
|
|
_open_term_action(Evry_Action *act)
|
|
|
|
{
|
|
|
|
GET_FILE(file, act->it1.item);
|
|
|
|
Evry_Item_App *tmp;
|
|
|
|
char cwd[4096];
|
|
|
|
char *dir;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (!(evry->file_path_get(file)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (IS_BROWSEABLE(file))
|
|
|
|
dir = strdup(file->path);
|
|
|
|
else
|
|
|
|
dir = ecore_file_dir_get(file->path);
|
|
|
|
|
|
|
|
if (dir)
|
|
|
|
{
|
2012-12-13 06:09:55 -08:00
|
|
|
if ((!getcwd(cwd, sizeof(cwd))) || (chdir(dir)))
|
|
|
|
{
|
|
|
|
free(dir);
|
|
|
|
return 0;
|
|
|
|
}
|
2011-11-29 19:32:54 -08:00
|
|
|
|
|
|
|
tmp = E_NEW(Evry_Item_App, 1);
|
|
|
|
tmp->file = _conf->cmd_terminal;
|
|
|
|
|
|
|
|
ret = evry->util_exec_app(EVRY_ITEM(tmp), NULL);
|
2012-12-13 06:09:55 -08:00
|
|
|
free(tmp);
|
|
|
|
free(dir);
|
2011-11-29 19:32:54 -08:00
|
|
|
if (chdir(cwd))
|
|
|
|
return 0;
|
2010-05-11 10:24:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-01-23 15:37:50 -08:00
|
|
|
static int
|
|
|
|
_check_executable(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
|
|
|
{
|
|
|
|
GET_FILE(file, it);
|
|
|
|
|
|
|
|
return ecore_file_can_exec(evry->file_path_get(file));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_run_executable(Evry_Action *act)
|
|
|
|
{
|
|
|
|
GET_FILE(file, act->it1.item);
|
|
|
|
|
|
|
|
e_exec(e_util_zone_current_get(e_manager_current_get()), NULL, file->path, NULL, NULL);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-05-19 07:46:37 -07:00
|
|
|
/***************************************************************************/
|
2011-01-23 14:34:28 -08:00
|
|
|
static Eina_Bool
|
2011-08-18 00:34:02 -07:00
|
|
|
_desktop_cache_update(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
|
2011-01-23 14:34:28 -08:00
|
|
|
{
|
|
|
|
Efreet_Desktop *d;
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (apps_cache, d)
|
2011-01-23 14:34:28 -08:00
|
|
|
efreet_desktop_unref(d);
|
|
|
|
|
2011-08-18 00:34:02 -07:00
|
|
|
return EINA_TRUE;
|
2011-01-23 14:34:28 -08:00
|
|
|
}
|
2012-11-04 14:11:02 -08:00
|
|
|
static void
|
|
|
|
_dir_watcher(void *data __UNUSED__, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path __UNUSED__)
|
|
|
|
{
|
|
|
|
//printf("exebuf path changed\n");
|
|
|
|
switch (event)
|
|
|
|
{
|
|
|
|
case ECORE_FILE_EVENT_DELETED_SELF:
|
|
|
|
ecore_file_monitor_del(em);
|
2012-11-04 16:17:26 -08:00
|
|
|
dir_monitors = eina_list_remove(dir_monitors, em);
|
2012-11-04 14:11:02 -08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
update_path = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_dir_monitor_add()
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
const char *dir;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(exe_path, l, dir)
|
|
|
|
{
|
|
|
|
Ecore_File_Monitor *dir_mon;
|
|
|
|
dir_mon = ecore_file_monitor_add(dir, _dir_watcher, NULL);
|
|
|
|
if (dir_mon)
|
2012-11-04 16:17:26 -08:00
|
|
|
dir_monitors = eina_list_append(dir_monitors, dir_mon);
|
2012-11-04 14:11:02 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_dir_monitor_free()
|
|
|
|
{
|
|
|
|
Ecore_File_Monitor *dir_mon;
|
2012-11-04 16:17:26 -08:00
|
|
|
|
2012-11-04 14:11:02 -08:00
|
|
|
EINA_LIST_FREE (dir_monitors, dir_mon)
|
|
|
|
ecore_file_monitor_del(dir_mon);
|
|
|
|
}
|
2010-05-19 07:46:37 -07:00
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
static int
|
2011-08-12 04:41:15 -07:00
|
|
|
_plugins_init(const Evry_API *api)
|
2009-08-10 08:00:41 -07:00
|
|
|
{
|
2010-04-24 17:31:11 -07:00
|
|
|
Evry_Plugin *p;
|
2010-04-27 20:22:40 -07:00
|
|
|
int prio = 0;
|
|
|
|
Eina_List *l;
|
|
|
|
Evry_Action *act;
|
2011-11-29 20:54:52 -08:00
|
|
|
const char *config_path;
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2011-08-12 04:41:15 -07:00
|
|
|
evry = api;
|
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
if (!evry->api_version_check(EVRY_API_VERSION))
|
2010-04-08 04:55:15 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
|
2011-11-29 20:54:52 -08:00
|
|
|
config_path = eina_stringshare_add("launcher/everything-apps");
|
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
p = EVRY_PLUGIN_BASE(N_("Applications"), _module_icon, EVRY_TYPE_APP,
|
2011-11-29 19:32:54 -08:00
|
|
|
_begin, _finish, _fetch);
|
2010-04-24 17:31:11 -07:00
|
|
|
p->complete = &_complete;
|
2011-08-16 16:26:07 -07:00
|
|
|
p->browse = &_browse;
|
2011-11-29 20:54:52 -08:00
|
|
|
p->config_path = eina_stringshare_ref(config_path);
|
2010-05-11 10:24:38 -07:00
|
|
|
evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 1);
|
2010-05-19 07:46:37 -07:00
|
|
|
_plugins = eina_list_append(_plugins, p);
|
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
p = EVRY_PLUGIN_BASE(N_("Exebuf"), _module_icon, EVRY_TYPE_APP,
|
2011-11-29 19:32:54 -08:00
|
|
|
_begin_exe, _finish_exe, _fetch_exe);
|
2010-05-19 07:46:37 -07:00
|
|
|
p->complete = &_complete;
|
2011-11-29 20:54:52 -08:00
|
|
|
p->config_path = eina_stringshare_ref(config_path);
|
2010-05-19 07:46:37 -07:00
|
|
|
_plugins = eina_list_append(_plugins, p);
|
2010-05-21 23:35:46 -07:00
|
|
|
if (evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 3))
|
2011-09-11 05:09:53 -07:00
|
|
|
p->config->min_query = 3;
|
2010-04-29 08:20:12 -07:00
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
p = EVRY_PLUGIN_BASE(N_("Applications"), _module_icon, EVRY_TYPE_APP,
|
2011-11-29 19:32:54 -08:00
|
|
|
_begin_mime, _finish, _fetch);
|
2010-04-29 08:20:12 -07:00
|
|
|
p->complete = &_complete;
|
2011-11-29 20:54:52 -08:00
|
|
|
p->config_path = eina_stringshare_ref(config_path);
|
2010-05-11 10:24:38 -07:00
|
|
|
evry->plugin_register(p, EVRY_PLUGIN_OBJECT, 1);
|
2010-05-19 07:46:37 -07:00
|
|
|
_plugins = eina_list_append(_plugins, p);
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
p = EVRY_PLUGIN_BASE(N_("Open with..."), _module_icon, EVRY_TYPE_APP,
|
2011-11-29 19:32:54 -08:00
|
|
|
_begin_mime, _finish_mime, _fetch_mime);
|
2011-11-29 20:54:52 -08:00
|
|
|
p->config_path = eina_stringshare_ref(config_path);
|
2010-05-11 10:24:38 -07:00
|
|
|
evry->plugin_register(p, EVRY_PLUGIN_ACTION, 1);
|
2010-05-30 06:30:13 -07:00
|
|
|
_plugins = eina_list_append(_plugins, p);
|
2009-08-10 08:00:41 -07:00
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
act = EVRY_ACTION_NEW(N_("Launch"),
|
2011-11-29 19:32:54 -08:00
|
|
|
EVRY_TYPE_APP, 0,
|
|
|
|
"system-run",
|
|
|
|
_exec_app_action,
|
|
|
|
_exec_app_check_item);
|
2010-05-11 10:24:38 -07:00
|
|
|
_actions = eina_list_append(_actions, act);
|
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
act = EVRY_ACTION_NEW(N_("Open File..."),
|
2011-11-29 19:32:54 -08:00
|
|
|
EVRY_TYPE_APP, EVRY_TYPE_FILE,
|
|
|
|
"document-open",
|
|
|
|
_exec_app_action,
|
|
|
|
_exec_app_check_item);
|
2010-05-11 10:24:38 -07:00
|
|
|
_actions = eina_list_append(_actions, act);
|
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
act = EVRY_ACTION_NEW(N_("Run in Terminal"),
|
2011-11-29 19:32:54 -08:00
|
|
|
EVRY_TYPE_APP, 0,
|
|
|
|
"system-run",
|
|
|
|
_exec_term_action,
|
|
|
|
_exec_term_check_item);
|
2010-05-11 10:24:38 -07:00
|
|
|
_actions = eina_list_append(_actions, act);
|
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
act = EVRY_ACTION_NEW(N_("Edit Application Entry"),
|
2011-11-29 19:32:54 -08:00
|
|
|
EVRY_TYPE_APP, 0,
|
|
|
|
"everything-launch",
|
|
|
|
_edit_app_action,
|
|
|
|
_edit_app_check_item);
|
2010-04-27 20:22:40 -07:00
|
|
|
_actions = eina_list_append(_actions, act);
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
act = EVRY_ACTION_NEW(N_("New Application Entry"),
|
2011-11-29 19:32:54 -08:00
|
|
|
EVRY_TYPE_APP, 0,
|
|
|
|
"everything-launch",
|
|
|
|
_new_app_action,
|
|
|
|
_new_app_check_item);
|
2010-04-27 20:22:40 -07:00
|
|
|
_actions = eina_list_append(_actions, act);
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
act = EVRY_ACTION_NEW(N_("Run with Sudo"),
|
2011-11-29 19:32:54 -08:00
|
|
|
EVRY_TYPE_APP, 0,
|
|
|
|
"system-run",
|
|
|
|
_exec_sudo_action, NULL);
|
2010-04-27 20:22:40 -07:00
|
|
|
_actions = eina_list_append(_actions, act);
|
2010-04-29 08:20:12 -07:00
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
act = EVRY_ACTION_NEW(N_("Open with..."),
|
2011-11-29 19:32:54 -08:00
|
|
|
EVRY_TYPE_FILE, EVRY_TYPE_APP,
|
|
|
|
"everything-launch",
|
|
|
|
_exec_file_action, NULL);
|
2010-04-29 08:20:12 -07:00
|
|
|
_act_open_with = EVRY_ITEM(act);
|
|
|
|
_actions = eina_list_append(_actions, act);
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
act = EVRY_ACTION_NEW(N_("Open Terminal here"),
|
2011-11-29 19:32:54 -08:00
|
|
|
EVRY_TYPE_FILE, 0,
|
|
|
|
"system-run",
|
|
|
|
_open_term_action, NULL);
|
2010-05-11 10:24:38 -07:00
|
|
|
_actions = eina_list_append(_actions, act);
|
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
act = EVRY_ACTION_NEW(N_("Run Executable"),
|
2011-11-29 19:32:54 -08:00
|
|
|
EVRY_TYPE_FILE, 0,
|
|
|
|
"system-run",
|
|
|
|
_run_executable,
|
|
|
|
_check_executable);
|
2011-01-23 15:37:50 -08:00
|
|
|
_actions = eina_list_append(_actions, act);
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FOREACH (_actions, l, act)
|
|
|
|
evry->action_register(act, prio++);
|
2009-08-27 13:52:14 -07:00
|
|
|
|
2011-01-23 14:34:28 -08:00
|
|
|
handlers = eina_list_append
|
2011-11-29 19:32:54 -08:00
|
|
|
(handlers, ecore_event_handler_add
|
|
|
|
(EFREET_EVENT_DESKTOP_CACHE_UPDATE, _desktop_cache_update, NULL));
|
2011-01-23 14:34:28 -08:00
|
|
|
|
2011-11-29 20:54:52 -08:00
|
|
|
eina_stringshare_del(config_path);
|
2012-11-04 14:11:02 -08:00
|
|
|
|
|
|
|
update_path = EINA_TRUE;
|
2012-11-04 16:17:26 -08:00
|
|
|
|
2009-08-10 08:00:41 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-04-24 16:07:13 -07:00
|
|
|
_plugins_shutdown(void)
|
2009-08-10 08:00:41 -07:00
|
|
|
{
|
2010-04-27 20:22:40 -07:00
|
|
|
Evry_Action *act;
|
2010-05-19 07:46:37 -07:00
|
|
|
Evry_Plugin *p;
|
2011-01-23 14:34:28 -08:00
|
|
|
Efreet_Desktop *d;
|
|
|
|
Ecore_Event_Handler *h;
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (apps_cache, d)
|
2011-01-23 14:34:28 -08:00
|
|
|
efreet_desktop_unref(d);
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (_plugins, p)
|
2010-05-19 07:46:37 -07:00
|
|
|
EVRY_PLUGIN_FREE(p);
|
2009-08-27 13:52:14 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (_actions, act)
|
2010-05-30 06:30:13 -07:00
|
|
|
EVRY_ACTION_FREE(act);
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (handlers, h)
|
2011-01-23 14:34:28 -08:00
|
|
|
ecore_event_handler_del(h);
|
2012-11-04 14:11:02 -08:00
|
|
|
|
|
|
|
_dir_monitor_free();
|
|
|
|
|
2012-12-21 13:31:13 -08:00
|
|
|
E_FREE(current_path);
|
2009-08-25 02:30:14 -07:00
|
|
|
}
|
2010-04-10 13:05:57 -07:00
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2010-04-16 18:10:20 -07:00
|
|
|
static E_Config_DD *conf_edd = NULL;
|
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
struct _E_Config_Dialog_Data
|
2010-04-16 18:10:20 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
char *cmd_terminal;
|
|
|
|
char *cmd_sudo;
|
2010-04-16 18:10:20 -07:00
|
|
|
};
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
static void *_create_data(E_Config_Dialog *cfd);
|
|
|
|
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
|
|
|
static void _fill_data(E_Config_Dialog_Data *cfdata);
|
2010-04-16 18:10:20 -07:00
|
|
|
static Evas_Object *_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
2011-11-29 19:32:54 -08:00
|
|
|
static int _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
2010-04-16 18:10:20 -07:00
|
|
|
|
2010-04-20 10:48:21 -07:00
|
|
|
static E_Config_Dialog *
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
_conf_dialog(E_Comp *comp, const char *params __UNUSED__)
|
2010-04-16 18:10:20 -07:00
|
|
|
{
|
|
|
|
E_Config_Dialog *cfd = NULL;
|
|
|
|
E_Config_Dialog_View *v = NULL;
|
|
|
|
|
2011-04-08 16:03:12 -07:00
|
|
|
if (e_config_dialog_find("everything-apps", "launcher/everything-apps")) return NULL;
|
2010-04-16 18:10:20 -07:00
|
|
|
|
|
|
|
v = E_NEW(E_Config_Dialog_View, 1);
|
|
|
|
if (!v) return NULL;
|
|
|
|
|
|
|
|
v->create_cfdata = _create_data;
|
|
|
|
v->free_cfdata = _free_data;
|
|
|
|
v->basic.create_widgets = _basic_create;
|
|
|
|
v->basic.apply_cfdata = _basic_apply;
|
|
|
|
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
cfd = e_config_dialog_new(comp, _("Everything Applications"), "everything-apps",
|
2011-11-29 19:32:54 -08:00
|
|
|
"launcher/everything-apps", _module_icon, 0, v, NULL);
|
2010-04-16 18:10:20 -07:00
|
|
|
|
|
|
|
_conf->cfd = cfd;
|
|
|
|
return cfd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
2011-01-23 14:34:28 -08:00
|
|
|
_create_data(E_Config_Dialog *cfd __UNUSED__)
|
2010-04-16 18:10:20 -07:00
|
|
|
{
|
|
|
|
E_Config_Dialog_Data *cfdata = NULL;
|
|
|
|
|
|
|
|
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
|
|
|
_fill_data(cfdata);
|
|
|
|
return cfdata;
|
|
|
|
}
|
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
static void
|
2011-01-23 14:34:28 -08:00
|
|
|
_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
2010-04-16 18:10:20 -07:00
|
|
|
{
|
|
|
|
_conf->cfd = NULL;
|
|
|
|
E_FREE(cfdata);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2011-01-23 14:34:28 -08:00
|
|
|
_basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *e, E_Config_Dialog_Data *cfdata)
|
2010-04-16 18:10:20 -07:00
|
|
|
{
|
|
|
|
Evas_Object *o = NULL, *of = NULL, *ow = NULL;
|
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
o = e_widget_list_add(e, 0, 0);
|
2010-04-16 18:10:20 -07:00
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
of = e_widget_framelist_add(e, _("Commands"), 0);
|
|
|
|
ow = e_widget_label_add(e, _("Terminal Command"));
|
|
|
|
e_widget_framelist_object_append(of, ow);
|
|
|
|
ow = e_widget_entry_add(e, &(cfdata->cmd_terminal), NULL, NULL, NULL);
|
|
|
|
e_widget_framelist_object_append(of, ow);
|
|
|
|
|
|
|
|
ow = e_widget_label_add(e, _("Sudo GUI"));
|
|
|
|
e_widget_framelist_object_append(of, ow);
|
|
|
|
ow = e_widget_entry_add(e, &(cfdata->cmd_sudo), NULL, NULL, NULL);
|
|
|
|
e_widget_framelist_object_append(of, ow);
|
|
|
|
|
2010-04-16 18:10:20 -07:00
|
|
|
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
|
|
|
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
static void
|
|
|
|
_fill_data(E_Config_Dialog_Data *cfdata)
|
|
|
|
{
|
|
|
|
#define CP(_name) cfdata->_name = strdup(_conf->_name);
|
2011-11-29 19:32:54 -08:00
|
|
|
#define C(_name) cfdata->_name = _conf->_name;
|
2010-05-11 10:24:38 -07:00
|
|
|
CP(cmd_terminal);
|
|
|
|
CP(cmd_sudo);
|
|
|
|
#undef CP
|
|
|
|
#undef C
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2011-01-23 14:34:28 -08:00
|
|
|
_basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
2010-04-16 18:10:20 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
#define CP(_name) \
|
2012-07-04 12:09:36 -07:00
|
|
|
eina_stringshare_replace(&(_conf->_name), cfdata->_name)
|
2010-05-11 10:24:38 -07:00
|
|
|
#define C(_name) _conf->_name = cfdata->_name;
|
|
|
|
CP(cmd_terminal);
|
|
|
|
CP(cmd_sudo);
|
|
|
|
#undef CP
|
|
|
|
#undef C
|
|
|
|
|
2010-04-17 05:40:28 -07:00
|
|
|
e_config_domain_save("module.everything-apps", conf_edd, _conf);
|
|
|
|
|
2012-07-04 12:09:36 -07:00
|
|
|
/* backwards compatible with exebuf */
|
|
|
|
eina_stringshare_replace(&(e_config->exebuf_term_cmd), _conf->cmd_terminal);
|
|
|
|
e_config_save_queue();
|
2010-04-16 18:10:20 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
static void
|
2010-04-17 05:40:28 -07:00
|
|
|
_conf_new(void)
|
2010-04-16 18:10:20 -07:00
|
|
|
{
|
2010-05-11 10:24:38 -07:00
|
|
|
if (!_conf)
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
_conf = E_NEW(Module_Config, 1);
|
2012-12-21 15:57:05 -08:00
|
|
|
/* setup defaults */
|
|
|
|
_conf->cmd_terminal = eina_stringshare_add("/usr/bin/xterm -hold -e");
|
|
|
|
_conf->cmd_sudo = eina_stringshare_add("/usr/bin/gksudo --preserve-env");
|
2010-05-11 10:24:38 -07:00
|
|
|
}
|
2010-04-16 18:10:20 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
_conf->version = MOD_CONFIG_FILE_VERSION;
|
2010-04-16 18:10:20 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
/* e_config_save_queue(); */
|
2010-05-11 10:24:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_conf_free(void)
|
|
|
|
{
|
|
|
|
if (!_conf) return;
|
|
|
|
|
|
|
|
IF_RELEASE(_conf->cmd_sudo);
|
|
|
|
IF_RELEASE(_conf->cmd_terminal);
|
|
|
|
E_FREE(_conf);
|
2010-04-16 18:10:20 -07:00
|
|
|
}
|
|
|
|
|
2010-04-20 10:48:21 -07:00
|
|
|
static void
|
|
|
|
_conf_init(E_Module *m)
|
2010-04-10 13:05:57 -07:00
|
|
|
{
|
2011-04-08 15:16:59 -07:00
|
|
|
char title[4096];
|
|
|
|
|
|
|
|
snprintf(title, sizeof(title), "%s: %s", _("Everything Plugin"), _("Applications"));
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2011-04-08 16:03:12 -07:00
|
|
|
e_configure_registry_item_add("launcher/everything-apps", 110, title,
|
2011-11-29 19:32:54 -08:00
|
|
|
NULL, _module_icon, _conf_dialog);
|
2010-04-16 18:10:20 -07:00
|
|
|
|
|
|
|
conf_edd = E_CONFIG_DD_NEW("Module_Config", Module_Config);
|
|
|
|
|
|
|
|
#undef T
|
|
|
|
#undef D
|
|
|
|
#define T Module_Config
|
|
|
|
#define D conf_edd
|
|
|
|
E_CONFIG_VAL(D, T, version, INT);
|
2010-05-11 10:24:38 -07:00
|
|
|
E_CONFIG_VAL(D, T, cmd_terminal, STR);
|
|
|
|
E_CONFIG_VAL(D, T, cmd_sudo, STR);
|
2010-04-16 18:10:20 -07:00
|
|
|
#undef T
|
|
|
|
#undef D
|
|
|
|
|
|
|
|
_conf = e_config_domain_load("module.everything-apps", conf_edd);
|
|
|
|
|
2011-08-31 05:57:07 -07:00
|
|
|
if (_conf && !e_util_module_config_check(_("Everything Applications"),
|
2011-11-29 19:32:54 -08:00
|
|
|
_conf->version,
|
|
|
|
MOD_CONFIG_FILE_VERSION))
|
2010-05-11 10:24:38 -07:00
|
|
|
_conf_free();
|
2010-04-16 18:10:20 -07:00
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
_conf_new();
|
2010-04-16 18:10:20 -07:00
|
|
|
_conf->module = m;
|
2010-04-20 10:48:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_conf_shutdown(void)
|
|
|
|
{
|
2011-04-08 16:03:12 -07:00
|
|
|
e_configure_registry_item_del("launcher/everything-apps");
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
_conf_free();
|
2010-04-20 10:48:21 -07:00
|
|
|
|
|
|
|
E_CONFIG_DD_FREE(conf_edd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2011-04-08 15:16:59 -07:00
|
|
|
Eina_Bool
|
|
|
|
evry_plug_apps_init(E_Module *m)
|
2010-05-11 10:24:38 -07:00
|
|
|
{
|
2010-04-20 10:48:21 -07:00
|
|
|
_conf_init(m);
|
2010-04-27 20:22:40 -07:00
|
|
|
|
2011-08-12 04:41:15 -07:00
|
|
|
EVRY_MODULE_NEW(evry_module, evry, _plugins_init, _plugins_shutdown);
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2010-04-27 20:22:40 -07:00
|
|
|
exelist_exe_edd = E_CONFIG_DD_NEW("E_Exe", E_Exe);
|
|
|
|
#undef T
|
|
|
|
#undef D
|
|
|
|
#define T E_Exe
|
|
|
|
#define D exelist_exe_edd
|
|
|
|
E_CONFIG_VAL(D, T, path, STR);
|
2012-11-04 16:17:26 -08:00
|
|
|
E_CONFIG_VAL(D, T, len, UINT);
|
2010-04-27 20:22:40 -07:00
|
|
|
exelist_edd = E_CONFIG_DD_NEW("E_Exe_List", E_Exe_List);
|
|
|
|
#undef T
|
|
|
|
#undef D
|
|
|
|
#define T E_Exe_List
|
|
|
|
#define D exelist_edd
|
|
|
|
E_CONFIG_LIST(D, T, list, exelist_exe_edd);
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2011-04-08 15:16:59 -07:00
|
|
|
return EINA_TRUE;
|
2010-04-10 13:05:57 -07:00
|
|
|
}
|
|
|
|
|
2011-04-08 15:16:59 -07:00
|
|
|
void
|
|
|
|
evry_plug_apps_shutdown(void)
|
2010-04-10 13:05:57 -07:00
|
|
|
{
|
2011-04-01 05:46:05 -07:00
|
|
|
EVRY_MODULE_FREE(evry_module);
|
2010-04-10 13:05:57 -07:00
|
|
|
|
2010-04-20 10:48:21 -07:00
|
|
|
_conf_shutdown();
|
|
|
|
|
2010-04-10 14:38:36 -07:00
|
|
|
E_CONFIG_DD_FREE(exelist_edd);
|
|
|
|
E_CONFIG_DD_FREE(exelist_exe_edd);
|
2011-04-08 15:16:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evry_plug_apps_save(void)
|
|
|
|
{
|
|
|
|
e_config_domain_save("module.everything-apps", conf_edd, _conf);
|
|
|
|
}
|
2010-04-16 18:10:20 -07:00
|
|
|
|
2010-04-10 13:05:57 -07:00
|
|
|
/***************************************************************************/
|
|
|
|
|
2010-04-27 20:22:40 -07:00
|
|
|
/* taken from e_exebuf.c */
|
2010-06-24 09:19:12 -07:00
|
|
|
static Eina_Bool
|
2011-01-23 14:34:28 -08:00
|
|
|
_scan_idler(void *data __UNUSED__)
|
2010-04-27 20:22:40 -07:00
|
|
|
{
|
|
|
|
char *dir;
|
|
|
|
|
|
|
|
/* no more path items left - stop scanning */
|
|
|
|
if (!exe_path)
|
|
|
|
{
|
2012-12-14 09:10:35 -08:00
|
|
|
Eina_Bool different = EINA_FALSE;
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2012-12-14 09:10:35 -08:00
|
|
|
if (eina_list_count(exe_list) == eina_list_count(exe_files))
|
2011-11-29 19:32:54 -08:00
|
|
|
{
|
2012-12-14 09:10:35 -08:00
|
|
|
E_Exe *ee;
|
|
|
|
Eina_List *l, *l2 = exe_files;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(exe_list, l ,ee)
|
2011-11-29 19:32:54 -08:00
|
|
|
{
|
2012-12-14 09:10:35 -08:00
|
|
|
if (ee->path != l2->data)
|
|
|
|
{
|
|
|
|
different = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
l2 = l2->next;
|
2011-11-29 19:32:54 -08:00
|
|
|
}
|
|
|
|
}
|
2012-12-14 09:10:35 -08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
different = EINA_TRUE;
|
|
|
|
}
|
2012-04-30 00:07:33 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
if (different)
|
|
|
|
{
|
2012-11-04 16:17:26 -08:00
|
|
|
E_Exe *ee;
|
|
|
|
|
|
|
|
EINA_LIST_FREE (exe_list, ee)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(ee->path);
|
|
|
|
free(ee);
|
|
|
|
}
|
|
|
|
|
2012-04-30 00:07:33 -07:00
|
|
|
const char *s;
|
|
|
|
E_Exe_List *el;
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
el = calloc(1, sizeof(E_Exe_List));
|
2012-04-30 00:07:33 -07:00
|
|
|
if (!el) return ECORE_CALLBACK_CANCEL;
|
|
|
|
|
|
|
|
el->list = NULL;
|
|
|
|
|
2012-11-04 16:17:26 -08:00
|
|
|
EINA_LIST_FREE(exe_files, s)
|
2011-11-29 19:32:54 -08:00
|
|
|
{
|
2012-04-30 00:07:33 -07:00
|
|
|
ee = malloc(sizeof(E_Exe));
|
|
|
|
if (!ee) continue ;
|
|
|
|
|
2012-11-04 16:17:26 -08:00
|
|
|
ee->path = s;
|
|
|
|
ee->len = strlen(s);
|
2012-04-30 00:07:33 -07:00
|
|
|
el->list = eina_list_append(el->list, ee);
|
|
|
|
}
|
|
|
|
|
2012-11-04 16:17:26 -08:00
|
|
|
e_config_domain_save(_exebuf_cache_file, exelist_edd, el);
|
2012-12-14 09:10:35 -08:00
|
|
|
INF("plugin exebuf save: %s, %d", _exebuf_cache_file, eina_list_count(el->list));
|
|
|
|
|
2012-11-04 16:17:26 -08:00
|
|
|
exe_list = el->list;
|
2012-04-30 00:07:33 -07:00
|
|
|
free(el);
|
2011-11-29 19:32:54 -08:00
|
|
|
}
|
2012-11-04 16:17:26 -08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
const char *str;
|
|
|
|
EINA_LIST_FREE(exe_files, str)
|
|
|
|
eina_stringshare_del(str);
|
|
|
|
}
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
exe_scan_idler = NULL;
|
|
|
|
return ECORE_CALLBACK_CANCEL;
|
2010-04-27 20:22:40 -07:00
|
|
|
}
|
|
|
|
/* no dir is open - open the first path item */
|
|
|
|
if (!exe_dir)
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
dir = exe_path->data;
|
2012-04-30 00:07:33 -07:00
|
|
|
exe_dir = eina_file_direct_ls(dir);
|
2012-12-14 09:10:35 -08:00
|
|
|
INF("scan dir: %s", dir);
|
|
|
|
|
2010-04-27 20:22:40 -07:00
|
|
|
}
|
|
|
|
/* if we have an opened dir - scan the next item */
|
|
|
|
if (exe_dir)
|
|
|
|
{
|
2012-04-30 00:07:33 -07:00
|
|
|
Eina_File_Direct_Info *info;
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2012-04-30 00:07:33 -07:00
|
|
|
if (eina_iterator_next(exe_dir, (void**) &info))
|
2011-11-29 19:32:54 -08:00
|
|
|
{
|
2012-04-30 00:07:33 -07:00
|
|
|
Eina_Stat st;
|
|
|
|
|
2012-11-04 11:11:25 -08:00
|
|
|
if (!eina_file_statat(eina_iterator_container_get(exe_dir), info, &st) &&
|
2012-04-30 00:07:33 -07:00
|
|
|
(!S_ISDIR(st.mode)) &&
|
|
|
|
(!access(info->path, X_OK)))
|
2012-12-14 09:10:35 -08:00
|
|
|
exe_files = eina_list_append(exe_files,
|
|
|
|
eina_stringshare_add(info->path + info->name_start));
|
2011-11-29 19:32:54 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* we reached the end of a dir - remove the dir at the head
|
|
|
|
* of the path list so we advance and next loop we will pick up
|
|
|
|
* the next item, or if null- abort
|
|
|
|
*/
|
2012-04-30 00:07:33 -07:00
|
|
|
dir = exe_path->data;
|
|
|
|
free(dir);
|
|
|
|
|
|
|
|
eina_iterator_free(exe_dir);
|
2011-11-29 19:32:54 -08:00
|
|
|
exe_dir = NULL;
|
2012-04-30 00:07:33 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
exe_path = eina_list_remove_list(exe_path, exe_path);
|
|
|
|
}
|
2010-04-27 20:22:40 -07:00
|
|
|
}
|
|
|
|
/* obviously the dir open failed - so remove the first path item */
|
|
|
|
else
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
free(eina_list_data_get(exe_path));
|
|
|
|
exe_path = eina_list_remove_list(exe_path, exe_path);
|
2010-04-27 20:22:40 -07:00
|
|
|
}
|
2010-09-08 16:59:07 -07:00
|
|
|
/* we have more scannign to do */
|
2010-06-24 09:19:12 -07:00
|
|
|
return ECORE_CALLBACK_RENEW;
|
2010-04-27 20:22:40 -07:00
|
|
|
}
|
2010-04-29 08:20:12 -07:00
|
|
|
|
2012-11-04 14:11:02 -08:00
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_exe_path_list()
|
2010-04-29 08:20:12 -07:00
|
|
|
{
|
|
|
|
char *path, *pp, *last;
|
2012-11-04 14:11:02 -08:00
|
|
|
Eina_Bool changed;
|
2010-04-29 08:20:12 -07:00
|
|
|
|
2012-11-04 14:11:02 -08:00
|
|
|
path = getenv("PATH");
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2012-11-04 14:11:02 -08:00
|
|
|
// nothing changed
|
|
|
|
if (!update_path && (current_path && path) && !strcmp(current_path, path))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
changed = (path && (!current_path || !strcmp(current_path, path)));
|
|
|
|
|
|
|
|
if (current_path)
|
|
|
|
{
|
|
|
|
free(current_path);
|
|
|
|
current_path = NULL;
|
2010-04-29 08:20:12 -07:00
|
|
|
}
|
2012-11-04 16:17:26 -08:00
|
|
|
|
2010-04-29 08:20:12 -07:00
|
|
|
if (path)
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
path = strdup(path);
|
2012-11-04 14:11:02 -08:00
|
|
|
current_path = strdup(path);
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
last = path;
|
|
|
|
for (pp = path; pp[0]; pp++)
|
|
|
|
{
|
|
|
|
if (pp[0] == ':') pp[0] = '\0';
|
|
|
|
if (pp[0] == 0)
|
|
|
|
{
|
|
|
|
exe_path = eina_list_append(exe_path, strdup(last));
|
|
|
|
last = pp + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pp > last)
|
|
|
|
exe_path = eina_list_append(exe_path, strdup(last));
|
2012-12-14 09:10:35 -08:00
|
|
|
|
2012-12-13 06:13:08 -08:00
|
|
|
free(path);
|
2010-04-29 08:20:12 -07:00
|
|
|
}
|
|
|
|
|
2012-11-04 14:11:02 -08:00
|
|
|
if (changed)
|
|
|
|
{
|
|
|
|
_dir_monitor_free();
|
|
|
|
_dir_monitor_add();
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
2010-04-29 08:20:12 -07:00
|
|
|
}
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2012-11-04 14:11:02 -08:00
|
|
|
static void
|
|
|
|
_scan_executables()
|
|
|
|
{
|
|
|
|
E_Exe_List *el;
|
|
|
|
|
2012-11-04 16:17:26 -08:00
|
|
|
el = e_config_domain_load(_exebuf_cache_file, exelist_edd);
|
2012-11-04 14:11:02 -08:00
|
|
|
if (el)
|
|
|
|
{
|
2012-11-04 16:17:26 -08:00
|
|
|
exe_list = el->list;
|
2012-12-14 09:10:35 -08:00
|
|
|
INF("plugin exebuf load: %s, %d", _exebuf_cache_file, eina_list_count(el->list));
|
|
|
|
|
2012-11-04 14:11:02 -08:00
|
|
|
free(el);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_exe_path_list())
|
|
|
|
{
|
|
|
|
exe_scan_idler = ecore_idler_add(_scan_idler, NULL);
|
|
|
|
update_path = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|