forked from enlightenment/enlightenment
'everything' added config options for files plugin
SVN revision: 48165
This commit is contained in:
parent
4b5ce1b90a
commit
320c7ded6a
|
@ -6,6 +6,9 @@
|
|||
#include "e_mod_main.h"
|
||||
|
||||
typedef struct _Plugin Plugin;
|
||||
typedef struct _Module_Config Module_Config;
|
||||
typedef struct _E_Exe E_Exe;
|
||||
typedef struct _E_Exe_List E_Exe_List;
|
||||
|
||||
struct _Plugin
|
||||
{
|
||||
|
@ -20,11 +23,6 @@ struct _Plugin
|
|||
Evry_Item_App *app_parameter;
|
||||
};
|
||||
|
||||
/* 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
|
||||
{
|
||||
const char *path;
|
||||
|
@ -46,6 +44,8 @@ struct _Module_Config
|
|||
E_Module *module;
|
||||
};
|
||||
|
||||
static Module_Config *_conf;
|
||||
|
||||
static Plugin *p1 = NULL;
|
||||
static Plugin *p2 = NULL;
|
||||
static Evry_Action *act = NULL;
|
||||
|
@ -55,8 +55,6 @@ 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;
|
||||
|
@ -1143,14 +1141,6 @@ _scan_idler(void *data)
|
|||
|
||||
static E_Config_DD *conf_edd = NULL;
|
||||
|
||||
static Eina_Bool active = EINA_FALSE;
|
||||
|
||||
EAPI E_Module_Api e_modapi =
|
||||
{
|
||||
E_MODULE_API_VERSION,
|
||||
"everything-apps"
|
||||
};
|
||||
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
int list_executables;
|
||||
|
@ -1162,14 +1152,14 @@ 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 *
|
||||
static 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;
|
||||
if (e_config_dialog_find("everything-apps", "extensions/everything-apps")) return NULL;
|
||||
|
||||
v = E_NEW(E_Config_Dialog_View, 1);
|
||||
if (!v) return NULL;
|
||||
|
@ -1182,9 +1172,9 @@ _conf_dialog(E_Container *con, const char *params)
|
|||
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);
|
||||
"extensions/everything-apps", buf, 0, v, NULL);
|
||||
|
||||
e_dialog_resizable_set(cfd->dia, 1);
|
||||
/* e_dialog_resizable_set(cfd->dia, 1); */
|
||||
_conf->cfd = cfd;
|
||||
return cfd;
|
||||
}
|
||||
|
@ -1240,8 +1230,6 @@ _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
static void
|
||||
_conf_new(void)
|
||||
{
|
||||
|
@ -1261,14 +1249,11 @@ _conf_new(void)
|
|||
e_config_save_queue();
|
||||
}
|
||||
|
||||
EAPI void *
|
||||
e_modapi_init(E_Module *m)
|
||||
static void
|
||||
_conf_init(E_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"),
|
||||
|
@ -1303,6 +1288,33 @@ e_modapi_init(E_Module *m)
|
|||
if (!_conf) _conf_new();
|
||||
|
||||
_conf->module = m;
|
||||
}
|
||||
|
||||
static void
|
||||
_conf_shutdown(void)
|
||||
{
|
||||
E_FREE(_conf);
|
||||
|
||||
E_CONFIG_DD_FREE(conf_edd);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
static Eina_Bool active = EINA_FALSE;
|
||||
|
||||
EAPI E_Module_Api e_modapi =
|
||||
{
|
||||
E_MODULE_API_VERSION,
|
||||
"everything-apps"
|
||||
};
|
||||
|
||||
EAPI void *
|
||||
e_modapi_init(E_Module *m)
|
||||
{
|
||||
if (e_datastore_get("everything_loaded"))
|
||||
active = module_init();
|
||||
|
||||
_conf_init(m);
|
||||
|
||||
e_module_delayed_set(m, 1);
|
||||
|
||||
|
@ -1315,20 +1327,18 @@ e_modapi_shutdown(E_Module *m)
|
|||
if (active && e_datastore_get("everything_loaded"))
|
||||
module_shutdown();
|
||||
|
||||
_conf_shutdown();
|
||||
|
||||
E_CONFIG_DD_FREE(exelist_edd);
|
||||
E_CONFIG_DD_FREE(exelist_exe_edd);
|
||||
|
||||
|
||||
E_FREE(_conf);
|
||||
|
||||
E_CONFIG_DD_FREE(conf_edd);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_save(E_Module *m)
|
||||
{
|
||||
e_config_domain_save("module.everything-apps", conf_edd, _conf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
typedef struct _Plugin Plugin;
|
||||
typedef struct _Data Data;
|
||||
typedef struct _Module_Config Module_Config;
|
||||
|
||||
struct _Plugin
|
||||
{
|
||||
|
@ -21,7 +22,7 @@ struct _Plugin
|
|||
const char *input;
|
||||
Eina_Bool command;
|
||||
Eina_Bool parent;
|
||||
Eina_Bool hist_added;
|
||||
Eina_List *hist_added;
|
||||
|
||||
Ecore_Thread *thread;
|
||||
Eina_Bool cleanup;
|
||||
|
@ -37,13 +38,30 @@ struct _Data
|
|||
Eina_List *list;
|
||||
};
|
||||
|
||||
struct _Module_Config
|
||||
{
|
||||
int version;
|
||||
|
||||
unsigned char show_homedir;
|
||||
unsigned char show_recent;
|
||||
unsigned char search_recent;
|
||||
|
||||
// TODO
|
||||
int sort_by;
|
||||
Eina_List *search_dirs;
|
||||
|
||||
E_Config_Dialog *cfd;
|
||||
E_Module *module;
|
||||
};
|
||||
|
||||
static Module_Config *_conf;
|
||||
|
||||
static Evry_Plugin *p1 = NULL;
|
||||
static Evry_Plugin *p2 = NULL;
|
||||
static Evry_Action *act1 = NULL;
|
||||
static Evry_Action *act2 = NULL;
|
||||
|
||||
static E_Module *module = NULL;
|
||||
static Eina_Bool active = EINA_FALSE;
|
||||
|
||||
static void _cleanup(Evry_Plugin *plugin);
|
||||
|
||||
|
@ -314,10 +332,12 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it)
|
|||
p = E_NEW(Plugin, 1);
|
||||
p->base = *plugin;
|
||||
p->base.items = NULL;
|
||||
if (_conf->show_homedir)
|
||||
p->directory = eina_stringshare_add(e_user_homedir_get());
|
||||
p->parent = EINA_FALSE;
|
||||
}
|
||||
|
||||
if (p->directory)
|
||||
_read_directory(p);
|
||||
|
||||
return EVRY_PLUGIN(p);
|
||||
|
@ -435,6 +455,7 @@ _hist_items_add_cb(const Eina_Hash *hash, const void *key, void *data, void *fda
|
|||
* EVRY_ITEM(file)->browseable = EINA_TRUE; */
|
||||
|
||||
p->files = eina_list_append(p->files, file);
|
||||
p->hist_added = eina_list_append(p->hist_added, file);
|
||||
break;
|
||||
}
|
||||
return EINA_TRUE;
|
||||
|
@ -455,10 +476,10 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
eina_stringshare_del(p->input);
|
||||
p->input = NULL;
|
||||
|
||||
if (!p->parent && input)
|
||||
if (!p->parent)
|
||||
{
|
||||
/* input is command ? */
|
||||
if (!strcmp(input, "/"))
|
||||
if (input && !strcmp(input, "/"))
|
||||
{
|
||||
/* browse root */
|
||||
EINA_LIST_FREE(p->files, file)
|
||||
|
@ -473,9 +494,18 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
}
|
||||
|
||||
/* add recent files */
|
||||
if (!p->hist_added)
|
||||
if (!p->hist_added && (_conf->show_recent || (input && _conf->search_recent)))
|
||||
{
|
||||
eina_hash_foreach(evry_hist->subjects, _hist_items_add_cb, p);
|
||||
p->hist_added = EINA_TRUE;
|
||||
}
|
||||
else if (p->hist_added && !input && _conf->search_recent)
|
||||
{
|
||||
EINA_LIST_FREE(p->hist_added, file)
|
||||
{
|
||||
p->files = eina_list_remove(p->files, file);
|
||||
evry_item_free(EVRY_ITEM(file));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* clear command items */
|
||||
|
@ -511,6 +541,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
if (!EVRY_PLUGIN(p)->items)
|
||||
return 0;
|
||||
|
||||
if (!p->parent && _conf->show_recent)
|
||||
EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort);
|
||||
|
||||
return 1;
|
||||
|
@ -639,6 +670,194 @@ module_shutdown(void)
|
|||
|
||||
/***************************************************************************/
|
||||
|
||||
static E_Config_DD *conf_edd = NULL;
|
||||
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
int show_homedir;
|
||||
int show_recent;
|
||||
int search_recent;
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
static 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-files", "extensions/everything-files")) 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 Files"), "everything-files",
|
||||
"extensions/everything-files", buf, 0, v, NULL);
|
||||
|
||||
/* e_dialog_resizable_set(cfd->dia, 1); */
|
||||
_conf->cfd = cfd;
|
||||
return cfd;
|
||||
}
|
||||
|
||||
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 Home Directory"),
|
||||
&(cfdata->show_homedir));
|
||||
e_widget_framelist_object_append(of, ow);
|
||||
|
||||
ow = e_widget_check_add(evas, _("Show Recent Files"),
|
||||
&(cfdata->show_recent));
|
||||
e_widget_framelist_object_append(of, ow);
|
||||
|
||||
ow = e_widget_check_add(evas, _("Search Recent Files"),
|
||||
&(cfdata->search_recent));
|
||||
e_widget_framelist_object_append(of, ow);
|
||||
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
return o;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
#define C(_name) cfdata->_name = _conf->_name;
|
||||
C(show_homedir);
|
||||
C(show_recent);
|
||||
C(search_recent);
|
||||
#undef C
|
||||
}
|
||||
|
||||
static int
|
||||
_basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
#define C(_name) _conf->_name = cfdata->_name;
|
||||
C(show_homedir);
|
||||
C(show_recent);
|
||||
C(search_recent);
|
||||
#undef C
|
||||
printf("apply\n");
|
||||
|
||||
e_config_domain_save("module.everything-files", conf_edd, _conf);
|
||||
e_config_save_queue();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_conf_new(void)
|
||||
{
|
||||
printf("new!!!!!\n");
|
||||
_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->show_recent = 0;
|
||||
_conf->show_homedir = 1;
|
||||
_conf->search_recent = 1;
|
||||
IFMODCFGEND;
|
||||
|
||||
_conf->version = MOD_CONFIG_FILE_VERSION;
|
||||
|
||||
e_config_domain_save("module.everything-files", conf_edd, _conf);
|
||||
e_config_save_queue();
|
||||
}
|
||||
|
||||
static void
|
||||
_conf_free(void)
|
||||
{
|
||||
E_FREE(_conf);
|
||||
}
|
||||
|
||||
static void
|
||||
_conf_init(E_Module *m)
|
||||
{
|
||||
char buf[4096];
|
||||
|
||||
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-files", 110, _("Everything Files"),
|
||||
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, show_homedir, UCHAR);
|
||||
E_CONFIG_VAL(D, T, show_recent, UCHAR);
|
||||
E_CONFIG_VAL(D, T, search_recent, UCHAR);
|
||||
#undef T
|
||||
#undef D
|
||||
|
||||
_conf = e_config_domain_load("module.everything-files", conf_edd);
|
||||
|
||||
if (_conf && !evry_util_module_config_check(_("Everything Files"), _conf->version,
|
||||
MOD_CONFIG_FILE_EPOCH, MOD_CONFIG_FILE_VERSION))
|
||||
_conf_free();
|
||||
|
||||
if (!_conf) _conf_new();
|
||||
|
||||
_conf->module = m;
|
||||
}
|
||||
|
||||
static void
|
||||
_conf_shutdown(void)
|
||||
{
|
||||
E_FREE(_conf);
|
||||
|
||||
E_CONFIG_DD_FREE(conf_edd);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
static Eina_Bool active = EINA_FALSE;
|
||||
|
||||
EAPI E_Module_Api e_modapi =
|
||||
{
|
||||
E_MODULE_API_VERSION,
|
||||
|
@ -653,6 +872,8 @@ e_modapi_init(E_Module *m)
|
|||
if (e_datastore_get("everything_loaded"))
|
||||
active = module_init();
|
||||
|
||||
_conf_init(m);
|
||||
|
||||
e_module_delayed_set(m, 1);
|
||||
|
||||
return m;
|
||||
|
@ -664,7 +885,7 @@ e_modapi_shutdown(E_Module *m)
|
|||
if (active && e_datastore_get("everything_loaded"))
|
||||
module_shutdown();
|
||||
|
||||
module = NULL;
|
||||
_conf_shutdown();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -672,5 +893,6 @@ e_modapi_shutdown(E_Module *m)
|
|||
EAPI int
|
||||
e_modapi_save(E_Module *m)
|
||||
{
|
||||
e_config_domain_save("module.everything-files", conf_edd, _conf);
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue