forked from enlightenment/enlightenment
'everything'
- apps config : turn off executable list. - aggregator: filter items with same id from different plugins (no duplicates for files and tracker) SVN revision: 48061
This commit is contained in:
parent
91f8efd638
commit
53b5f48a90
|
@ -23,6 +23,7 @@ struct _Plugin
|
|||
/* taken from exebuf module */
|
||||
typedef struct _E_Exe E_Exe;
|
||||
typedef struct _E_Exe_List E_Exe_List;
|
||||
typedef struct _Module_Config Module_Config;
|
||||
|
||||
struct _E_Exe
|
||||
{
|
||||
|
@ -34,6 +35,17 @@ struct _E_Exe_List
|
|||
Eina_List *list;
|
||||
};
|
||||
|
||||
|
||||
struct _Module_Config
|
||||
{
|
||||
int version;
|
||||
|
||||
unsigned char list_executables;
|
||||
|
||||
E_Config_Dialog *cfd;
|
||||
E_Module *module;
|
||||
};
|
||||
|
||||
static Plugin *p1 = NULL;
|
||||
static Plugin *p2 = NULL;
|
||||
static Evry_Action *act = NULL;
|
||||
|
@ -43,6 +55,8 @@ static Evry_Action *act3 = NULL;
|
|||
static Evry_Action *act4 = NULL;
|
||||
static Evry_Action *act5 = NULL;
|
||||
|
||||
static Module_Config *_conf;
|
||||
|
||||
static Eina_List *exe_path = NULL;
|
||||
static Ecore_Idler *exe_scan_idler = NULL;
|
||||
static E_Config_DD *exelist_exe_edd = NULL;
|
||||
|
@ -99,7 +113,7 @@ _begin_open_with(Evry_Plugin *plugin, const Evry_Item *item)
|
|||
efreet_desktop_free(d);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
d = e_exehist_mime_desktop_get(mime);
|
||||
if (d)
|
||||
{
|
||||
|
@ -122,6 +136,11 @@ _begin(Evry_Plugin *plugin, const Evry_Item *item)
|
|||
{
|
||||
PLUGIN(p, plugin);
|
||||
|
||||
p->added = eina_hash_string_small_new(_hash_free);
|
||||
|
||||
if (!_conf->list_executables)
|
||||
return plugin;
|
||||
|
||||
/* taken from exebuf module */
|
||||
char *path, *pp, *last;
|
||||
E_Exe_List *el;
|
||||
|
@ -160,8 +179,6 @@ _begin(Evry_Plugin *plugin, const Evry_Item *item)
|
|||
|
||||
exe_scan_idler = ecore_idler_add(_scan_idler, NULL);
|
||||
|
||||
p->added = eina_hash_string_small_new(_hash_free);
|
||||
|
||||
return plugin;
|
||||
}
|
||||
|
||||
|
@ -1147,29 +1164,172 @@ _scan_idler(void *data)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/**/
|
||||
/* actual module specifics */
|
||||
|
||||
static E_Module *module = NULL;
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
|
||||
static E_Config_DD *conf_edd = NULL;
|
||||
|
||||
static Eina_Bool active = EINA_FALSE;
|
||||
|
||||
/***************************************************************************/
|
||||
/**/
|
||||
/* module setup */
|
||||
EAPI E_Module_Api e_modapi =
|
||||
{
|
||||
E_MODULE_API_VERSION,
|
||||
"everything-apps"
|
||||
};
|
||||
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
int list_executables;
|
||||
};
|
||||
|
||||
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);
|
||||
static Evas_Object *_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static int _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
|
||||
E_Config_Dialog *
|
||||
_conf_dialog(E_Container *con, const char *params)
|
||||
{
|
||||
E_Config_Dialog *cfd = NULL;
|
||||
E_Config_Dialog_View *v = NULL;
|
||||
char buf[4096];
|
||||
|
||||
if (e_config_dialog_find("everything-apps", "advanced/everything-apps")) return NULL;
|
||||
|
||||
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;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/e-module.edj", _conf->module->dir);
|
||||
|
||||
cfd = e_config_dialog_new(con, _("Everything Applications"), "everything-apps",
|
||||
"advanced/everything-apps", buf, 0, v, NULL);
|
||||
|
||||
e_dialog_resizable_set(cfd->dia, 1);
|
||||
_conf->cfd = cfd;
|
||||
return cfd;
|
||||
}
|
||||
|
||||
/* Local Functions */
|
||||
static void *
|
||||
_create_data(E_Config_Dialog *cfd)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata = NULL;
|
||||
|
||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||
_fill_data(cfdata);
|
||||
return cfdata;
|
||||
}
|
||||
|
||||
static void
|
||||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
_conf->cfd = NULL;
|
||||
E_FREE(cfdata);
|
||||
}
|
||||
|
||||
static void
|
||||
_fill_data(E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
cfdata->list_executables = _conf->list_executables;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *o = NULL, *of = NULL, *ow = NULL;
|
||||
|
||||
o = e_widget_list_add(evas, 0, 0);
|
||||
|
||||
of = e_widget_framelist_add(evas, _("General"), 0);
|
||||
e_widget_framelist_content_align_set(of, 0.0, 0.0);
|
||||
ow = e_widget_check_add(evas, _("Show Executables"),
|
||||
&(cfdata->list_executables));
|
||||
e_widget_framelist_object_append(of, ow);
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
static int
|
||||
_basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
_conf->list_executables = cfdata->list_executables;
|
||||
e_config_save_queue();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
static void
|
||||
_conf_new(void)
|
||||
{
|
||||
_conf = E_NEW(Module_Config, 1);
|
||||
_conf->version = (MOD_CONFIG_FILE_EPOCH << 16);
|
||||
|
||||
#define IFMODCFG(v) if ((_conf->version & 0xffff) < v) {
|
||||
#define IFMODCFGEND }
|
||||
|
||||
/* setup defaults */
|
||||
IFMODCFG(0x008d);
|
||||
_conf->list_executables = 1;
|
||||
IFMODCFGEND;
|
||||
|
||||
_conf->version = MOD_CONFIG_FILE_VERSION;
|
||||
|
||||
e_config_save_queue();
|
||||
}
|
||||
|
||||
EAPI void *
|
||||
e_modapi_init(E_Module *m)
|
||||
{
|
||||
module = m;
|
||||
|
||||
char buf[4096];
|
||||
|
||||
if (e_datastore_get("everything_loaded"))
|
||||
active = module_init();
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/e-module.edj", m->dir);
|
||||
|
||||
e_configure_registry_category_add("extensions", 80, _("Extensions"),
|
||||
NULL, "preferences-extensions");
|
||||
|
||||
e_configure_registry_item_add("extensions/everything-apps", 110, _("Everything Applications"),
|
||||
NULL, buf, _conf_dialog);
|
||||
|
||||
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);
|
||||
E_CONFIG_VAL(D, T, list_executables, UCHAR);
|
||||
#undef T
|
||||
#undef D
|
||||
|
||||
_conf = e_config_domain_load("module.everything-apps", conf_edd);
|
||||
|
||||
if (_conf)
|
||||
{
|
||||
if (!evry_util_module_config_check
|
||||
(_("Everything Applications"), _conf->version,
|
||||
MOD_CONFIG_FILE_EPOCH, MOD_CONFIG_FILE_VERSION))
|
||||
{
|
||||
E_FREE(_conf);
|
||||
}
|
||||
}
|
||||
|
||||
if (!_conf) _conf_new();
|
||||
|
||||
_conf->module = m;
|
||||
|
||||
e_module_delayed_set(m, 1);
|
||||
|
||||
|
@ -1184,9 +1344,12 @@ e_modapi_shutdown(E_Module *m)
|
|||
|
||||
E_CONFIG_DD_FREE(exelist_edd);
|
||||
E_CONFIG_DD_FREE(exelist_exe_edd);
|
||||
|
||||
module = NULL;
|
||||
|
||||
|
||||
|
||||
E_FREE(_conf);
|
||||
|
||||
E_CONFIG_DD_FREE(conf_edd);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
#ifndef E_MOD_MAIN_H
|
||||
#define E_MOD_MAIN_H
|
||||
|
||||
#define MOD_CONFIG_FILE_EPOCH 0x0001
|
||||
#define MOD_CONFIG_FILE_GENERATION 0x008d
|
||||
#define MOD_CONFIG_FILE_VERSION \
|
||||
((MOD_CONFIG_FILE_EPOCH << 16) | MOD_CONFIG_FILE_GENERATION)
|
||||
|
||||
EAPI extern E_Module_Api e_modapi;
|
||||
|
||||
EAPI void *e_modapi_init (E_Module *m);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "Evry.h"
|
||||
#include "e_mod_main.h"
|
||||
|
||||
#define MAX_ITEMS 100
|
||||
#define MAX_ITEMS 50
|
||||
#define TERM_ACTION_DIR "%s"
|
||||
|
||||
typedef struct _Plugin Plugin;
|
||||
|
@ -148,7 +148,7 @@ _scan_func(void *data)
|
|||
|
||||
d->files = eina_list_append(d->files, file);
|
||||
|
||||
if (cnt > 100)
|
||||
if (cnt > MAX_ITEMS)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -352,12 +352,12 @@ _hist_items_add_cb(const Eina_Hash *hash, const void *key, void *data, void *fda
|
|||
|
||||
EINA_LIST_FOREACH(he->items, l, hi)
|
||||
{
|
||||
if (hi->plugin != p->base.name)
|
||||
if (hi->type != p->base.type_out)
|
||||
continue;
|
||||
|
||||
/* filter out files that we already have from history */
|
||||
EINA_LIST_FOREACH(p->files, ll, file)
|
||||
if (!strcmp(file->path,key))
|
||||
if (!strcmp(file->path, key))
|
||||
return EINA_TRUE;
|
||||
|
||||
if (!ecore_file_exists(key))
|
||||
|
|
|
@ -371,6 +371,7 @@ struct _History
|
|||
struct _History_Item
|
||||
{
|
||||
const char *plugin;
|
||||
const char *type;
|
||||
const char *context;
|
||||
const char *input;
|
||||
double last_used;
|
||||
|
@ -399,6 +400,8 @@ EAPI Eina_List *evry_fuzzy_match_sort(Eina_List *items);
|
|||
EAPI int evry_util_exec_app(const Evry_Item *it_app, const Evry_Item *it_file);
|
||||
EAPI char *evry_util_unescape(const char *string, int length);
|
||||
EAPI void evry_util_file_detail_set(Evry_Item_File *file);
|
||||
EAPI Eina_Bool evry_util_module_config_check(const char *module_name, int conf, int epoch, int version);
|
||||
|
||||
|
||||
/* e_mod_main.c */
|
||||
EAPI void evry_plugin_register(Evry_Plugin *p, int priority);
|
||||
|
|
|
@ -226,6 +226,7 @@ _config_init()
|
|||
evry_conf->width = 460;
|
||||
evry_conf->height = 310;
|
||||
evry_conf->rel_y = 0.25;
|
||||
evry_conf->scroll_animate = 1;
|
||||
evry_conf->version = CONFIG_VERSION;
|
||||
}
|
||||
|
||||
|
@ -243,15 +244,11 @@ _config_init()
|
|||
evry_conf->rel_y = 0.25;
|
||||
evry_conf->width = 460;
|
||||
evry_conf->height = 310;
|
||||
evry_conf->scroll_animate = 0;
|
||||
evry_conf->scroll_animate = 1;
|
||||
evry_conf->scroll_speed = 10.0;
|
||||
evry_conf->hide_input = 0;
|
||||
evry_conf->hide_list = 0;
|
||||
evry_conf->quick_nav = 1;
|
||||
evry_conf->conf_subjects = NULL;
|
||||
evry_conf->conf_actions = NULL;
|
||||
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");
|
||||
evry_conf->view_mode = 0;
|
||||
|
|
|
@ -37,6 +37,7 @@ evry_history_init(void)
|
|||
E_CONFIG_VAL(D, T, usage, DOUBLE);
|
||||
E_CONFIG_VAL(D, T, count, INT);
|
||||
E_CONFIG_VAL(D, T, transient, INT);
|
||||
E_CONFIG_VAL(D, T, type, STR);
|
||||
#undef T
|
||||
#undef D
|
||||
hist_entry_edd = E_CONFIG_DD_NEW("History_Entry", History_Entry);
|
||||
|
@ -70,6 +71,8 @@ _hist_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata)
|
|||
eina_stringshare_del(hi->plugin);
|
||||
if (hi->context)
|
||||
eina_stringshare_del(hi->context);
|
||||
if (hi->type)
|
||||
eina_stringshare_del(hi->type);
|
||||
E_FREE(hi);
|
||||
}
|
||||
|
||||
|
@ -109,6 +112,8 @@ _hist_cleanup_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata
|
|||
eina_stringshare_del(hi->plugin);
|
||||
if (hi->context)
|
||||
eina_stringshare_del(hi->context);
|
||||
if (hi->type)
|
||||
eina_stringshare_del(hi->type);
|
||||
E_FREE(hi);
|
||||
|
||||
he->items = eina_list_remove_list(he->items, l);
|
||||
|
@ -238,6 +243,8 @@ evry_history_add(Eina_Hash *hist, Evry_State *s, const char *ctxt)
|
|||
{
|
||||
hi = E_NEW(History_Item, 1);
|
||||
hi->plugin = eina_stringshare_ref(it->plugin->name);
|
||||
if (it->plugin->type_out)
|
||||
hi->type = eina_stringshare_ref(it->plugin->type_out);
|
||||
he->items = eina_list_append(he->items, hi);
|
||||
}
|
||||
|
||||
|
@ -248,6 +255,11 @@ evry_history_add(Eina_Hash *hist, Evry_State *s, const char *ctxt)
|
|||
hi->usage += TIME_FACTOR(hi->last_used);
|
||||
hi->transient = it->plugin->transient;
|
||||
hi->count += (hi->transient ? 2:1);
|
||||
|
||||
/* XXX can be remove just for update */
|
||||
if (it->plugin->type_out && !hi->type)
|
||||
hi->type = eina_stringshare_ref(it->plugin->type_out);
|
||||
|
||||
if (ctxt && !hi->context)
|
||||
hi->context = eina_stringshare_ref(ctxt);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "e_mod_main.h"
|
||||
|
||||
#define MAX_ITEMS 100
|
||||
#define MAX_ITEMS 50
|
||||
|
||||
typedef struct _Plugin Plugin;
|
||||
|
||||
|
@ -122,8 +122,8 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
Plugin *p = (Plugin *) plugin;
|
||||
Evry_Plugin *pp;
|
||||
Evry_State *s;
|
||||
Eina_List *l, *ll, *lp;
|
||||
Evry_Item *it;
|
||||
Eina_List *l, *ll, *lll, *lp;
|
||||
Evry_Item *it, *it2;
|
||||
int i, cnt = 0;
|
||||
Eina_List *items = NULL;
|
||||
const char *context = NULL;
|
||||
|
@ -222,7 +222,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
|
||||
if (items) eina_list_free(items);
|
||||
|
||||
/* XXX */
|
||||
/* XXX workaround */
|
||||
_auto_selected = p->selector->state->item_auto_selected;
|
||||
|
||||
if (input)
|
||||
|
@ -241,7 +241,24 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
evry_item_free(it);
|
||||
p->base.items = eina_list_remove_list(p->base.items, l);
|
||||
}
|
||||
|
||||
|
||||
/* remove duplicates provided by different plugins */
|
||||
EINA_LIST_FOREACH_SAFE(p->base.items, l, ll, it)
|
||||
{
|
||||
for (lll = l->next; lll; lll = lll->next)
|
||||
{
|
||||
it2 = lll->data;
|
||||
if ((it->plugin->name != it2->plugin->name) &&
|
||||
(it->plugin->type_out == it2->plugin->type_out) &&
|
||||
(it->id == it2->id))
|
||||
{
|
||||
p->base.items = eina_list_remove_list(p->base.items, l);
|
||||
evry_item_free(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,14 +18,18 @@ evry_util_file_detail_set(Evry_Item_File *file)
|
|||
home_dir_len = strlen(home_dir);
|
||||
}
|
||||
|
||||
if (!EVRY_ITEM(file)->browseable)
|
||||
path = ecore_file_dir_get(file->path);
|
||||
else
|
||||
path = file->path;
|
||||
/* if (!EVRY_ITEM(file)->browseable) */
|
||||
path = ecore_file_dir_get(file->path);
|
||||
/* else
|
||||
* path = file->path; */
|
||||
|
||||
if (path && !strncmp(path, home_dir, home_dir_len))
|
||||
{
|
||||
snprintf(dir_buf, sizeof(dir_buf), "~%s/", path + home_dir_len);
|
||||
if (*(path + home_dir_len) == '\0')
|
||||
snprintf(dir_buf, sizeof(dir_buf), "~%s", path + home_dir_len);
|
||||
else
|
||||
snprintf(dir_buf, sizeof(dir_buf), "~%s/", path + home_dir_len);
|
||||
|
||||
EVRY_ITEM(file)->detail = eina_stringshare_add(dir_buf);
|
||||
}
|
||||
else
|
||||
|
@ -466,3 +470,60 @@ evry_util_unescape(const char *string, int length)
|
|||
}
|
||||
|
||||
#undef ISXDIGIT
|
||||
|
||||
|
||||
|
||||
static int
|
||||
_conf_timer(void *data)
|
||||
{
|
||||
/* e_util_dialog_internal(title, */
|
||||
e_util_dialog_internal(_("Configuration Updated"), data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evry_util_module_config_check(const char *module_name, int conf, int epoch, int version)
|
||||
{
|
||||
if ((conf >> 16) < epoch)
|
||||
{
|
||||
char *too_old =
|
||||
_("%s Configuration data needed "
|
||||
"upgrading. Your old configuration<br> has been"
|
||||
" wiped and a new set of defaults initialized. "
|
||||
"This<br>will happen regularly during "
|
||||
"development, so don't report a<br>bug. "
|
||||
"This simply means the module needs "
|
||||
"new configuration<br>data by default for "
|
||||
"usable functionality that your old<br>"
|
||||
"configuration simply lacks. This new set of "
|
||||
"defaults will fix<br>that by adding it in. "
|
||||
"You can re-configure things now to your<br>"
|
||||
"liking. Sorry for the inconvenience.<br>");
|
||||
|
||||
char buf[4096];
|
||||
snprintf(buf, sizeof(buf), too_old, module_name);
|
||||
ecore_timer_add(1.0, _conf_timer, buf);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
else if (conf > version)
|
||||
{
|
||||
char *too_new =
|
||||
_("Your %s Module configuration is NEWER "
|
||||
"than the module version. This is "
|
||||
"very<br>strange. This should not happen unless"
|
||||
" you downgraded<br>the module or "
|
||||
"copied the configuration from a place where"
|
||||
"<br>a newer version of the module "
|
||||
"was running. This is bad and<br>as a "
|
||||
"precaution your configuration has been now "
|
||||
"restored to<br>defaults. Sorry for the "
|
||||
"inconvenience.<br>");
|
||||
|
||||
char buf[4096];
|
||||
snprintf(buf, sizeof(buf), too_new, module_name);
|
||||
ecore_timer_add(1.0, _conf_timer, buf);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue