2005-12-17 03:21:54 -08:00
|
|
|
#include "e.h"
|
2010-03-02 20:10:04 -08:00
|
|
|
#include <assert.h>
|
2005-12-22 14:40:21 -08:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
typedef struct _CFModule CFModule;
|
2012-06-28 03:14:25 -07:00
|
|
|
typedef struct _CFType CFType;
|
|
|
|
typedef struct _CFTypes CFTypes;
|
2007-11-02 14:41:06 -07:00
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
struct _CFModule
|
2007-08-15 06:51:00 -07:00
|
|
|
{
|
2012-06-28 03:14:25 -07:00
|
|
|
const char *short_name, *name, *comment;
|
|
|
|
const char *icon, *orig_path;
|
|
|
|
E_Module *module;
|
2015-01-31 09:13:26 -08:00
|
|
|
Elm_Object_Item *item;
|
2010-03-02 20:10:04 -08:00
|
|
|
Evas_Object *end;
|
2012-06-28 03:14:25 -07:00
|
|
|
int idx;
|
|
|
|
Eina_Bool enabled : 1;
|
2007-11-02 14:41:06 -07:00
|
|
|
};
|
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
struct _CFType
|
2007-11-02 14:41:06 -07:00
|
|
|
{
|
2008-10-18 08:19:39 -07:00
|
|
|
const char *key, *name, *icon;
|
2015-02-05 12:57:39 -08:00
|
|
|
Elm_Object_Item *gindex, *tbitem;
|
2012-06-28 03:14:25 -07:00
|
|
|
Eina_Hash *modules_hash; /* just used before constructing list */
|
|
|
|
Eina_List *modules; /* sorted and ready to be used */
|
2007-11-02 14:41:06 -07:00
|
|
|
};
|
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
struct _E_Config_Dialog_Data
|
2007-11-02 14:41:06 -07:00
|
|
|
{
|
2013-01-11 02:34:29 -08:00
|
|
|
Eina_List *types;
|
2005-12-17 03:21:54 -08:00
|
|
|
};
|
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
struct _CFTypes
|
2007-11-02 14:41:06 -07:00
|
|
|
{
|
2012-06-28 03:14:25 -07:00
|
|
|
size_t key_len;
|
2010-03-02 20:10:04 -08:00
|
|
|
const char *key, *name, *icon;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* pre defined types (used to specify icon and i18n name) */
|
|
|
|
static const CFTypes _types[] =
|
|
|
|
{
|
2012-06-28 03:14:25 -07:00
|
|
|
#define _CFT(k, n, i) \
|
2010-03-02 20:10:04 -08:00
|
|
|
{sizeof(k) - 1, k, n, i}
|
2015-01-31 09:13:26 -08:00
|
|
|
_CFT("utils", N_("Utilities"), "application-utilities"),
|
|
|
|
_CFT("system", N_("System"), "application-system"),
|
2012-06-28 03:14:25 -07:00
|
|
|
_CFT("look", N_("Look"), "modules-look"),
|
2015-01-31 09:13:26 -08:00
|
|
|
_CFT("files", N_("Files"), "folder"),
|
2012-06-28 03:14:25 -07:00
|
|
|
_CFT("launcher", N_("Launcher"), "modules-launcher"),
|
2015-01-31 09:13:26 -08:00
|
|
|
_CFT("core", N_("Core"), "e-logo"),
|
2012-06-28 03:14:25 -07:00
|
|
|
_CFT("mobile", N_("Mobile"), "modules-mobile"),
|
2015-01-31 09:13:26 -08:00
|
|
|
_CFT("settings", N_("Settings"), "application-desktop"),
|
2010-03-02 20:10:04 -08:00
|
|
|
#undef _CFT
|
2012-06-28 03:14:25 -07:00
|
|
|
{0, NULL, NULL, NULL}
|
2007-11-02 14:41:06 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/* local function protos */
|
2012-06-28 03:14:25 -07:00
|
|
|
static void _cftype_free(CFType *cft);
|
2010-03-02 20:10:04 -08:00
|
|
|
|
2012-06-28 03:14:25 -07:00
|
|
|
static void *_create_data(E_Config_Dialog *cfd);
|
|
|
|
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
2009-12-31 14:45:34 -08:00
|
|
|
static Evas_Object *_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
2012-06-28 03:14:25 -07:00
|
|
|
static void _fill_cat_list(E_Config_Dialog_Data *cfdata);
|
|
|
|
static void _module_end_state_apply(CFModule *cfm);
|
2010-10-15 08:57:20 -07:00
|
|
|
|
2012-08-30 05:21:30 -07:00
|
|
|
static CFType *_cftype_find(E_Config_Dialog_Data *cfdata, const char *key, const char *name, const char *icon);
|
2012-06-28 03:14:25 -07:00
|
|
|
static CFType *_cftype_new(const char *key, const char *name, const char *icon);
|
2013-01-15 07:34:27 -08:00
|
|
|
static void _load_module(E_Module_Desktop *md, Eina_Hash *types_hash);
|
2012-06-28 03:14:25 -07:00
|
|
|
static Eina_Bool _types_list_create_foreach_cb(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata);
|
|
|
|
static int _types_list_sort(const void *data1, const void *data2);
|
2010-03-02 20:10:04 -08:00
|
|
|
|
2015-01-31 09:13:26 -08:00
|
|
|
static Evas_Object *e_int_config_modules_create_cb(const char *path, const char *part, Evas_Object *parent, void *cbdata, void *data);
|
|
|
|
static Eina_Bool e_int_config_modules_apply_cb(const char *path, const char *part, Evas_Object *obj, void *cbdata, void *data);
|
|
|
|
static void* e_int_config_modules_data_cb(const char *path, const char *part, void *data);
|
|
|
|
static void e_int_config_modules_free_cb(const char *path, const char *part, void *cbdata, void *data);
|
2007-07-15 16:39:28 -07:00
|
|
|
|
2015-01-31 09:13:26 -08:00
|
|
|
EAPI void
|
|
|
|
e_int_config_modules_init(void)
|
2005-12-17 03:21:54 -08:00
|
|
|
{
|
2015-02-05 12:57:39 -08:00
|
|
|
e_config_panel_item_add("modules", "preferences-plugin", _("Modules"), "Extensions to extend Enlightenments functions", 0, "modules");
|
2015-01-31 09:13:26 -08:00
|
|
|
e_config_panel_part_add("modules", "modules", _("Modules"), _("Mark a module as loaded to load them on startup"), 1, "extensions",
|
|
|
|
e_int_config_modules_create_cb, e_int_config_modules_apply_cb, e_int_config_modules_data_cb, e_int_config_modules_free_cb, NULL);
|
2005-12-17 03:21:54 -08:00
|
|
|
}
|
|
|
|
|
2015-01-31 09:13:26 -08:00
|
|
|
static void*
|
|
|
|
e_int_config_modules_data_cb(const char *path, const char *part, void *data)
|
2005-12-17 03:21:54 -08:00
|
|
|
{
|
2010-10-15 08:57:20 -07:00
|
|
|
Eina_Hash *types_hash;
|
2013-01-15 07:34:27 -08:00
|
|
|
Eina_List *mods;
|
|
|
|
E_Module_Desktop *md;
|
|
|
|
E_Config_Dialog_Data *cfdata;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2013-01-15 07:34:27 -08:00
|
|
|
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
2010-10-15 08:57:20 -07:00
|
|
|
|
2013-01-15 07:34:27 -08:00
|
|
|
types_hash = eina_hash_string_superfast_new(NULL);
|
|
|
|
mods = e_module_desktop_list();
|
|
|
|
if (!mods)
|
2005-12-28 09:28:02 -08:00
|
|
|
{
|
2012-06-28 03:14:25 -07:00
|
|
|
eina_hash_free(types_hash);
|
|
|
|
return cfdata;
|
2005-12-20 20:48:20 -08:00
|
|
|
}
|
2010-03-02 20:10:04 -08:00
|
|
|
|
2013-01-15 07:34:27 -08:00
|
|
|
EINA_LIST_FREE(mods, md)
|
2010-10-15 08:57:20 -07:00
|
|
|
{
|
2013-01-15 07:34:27 -08:00
|
|
|
_load_module(md, types_hash);
|
|
|
|
e_module_desktop_free(md);
|
2010-10-15 08:57:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
eina_hash_foreach(types_hash, _types_list_create_foreach_cb, cfdata);
|
|
|
|
eina_hash_free(types_hash);
|
|
|
|
cfdata->types = eina_list_sort(cfdata->types, -1, _types_list_sort);
|
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
return cfdata;
|
2005-12-17 03:21:54 -08:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static void
|
2015-01-31 09:13:26 -08:00
|
|
|
e_int_config_modules_free_cb(const char *path, const char *part, void *cbdata, void *data)
|
2005-12-17 03:21:54 -08:00
|
|
|
{
|
2015-01-31 09:13:26 -08:00
|
|
|
E_Config_Dialog_Data *cfdata = cbdata;
|
2010-03-02 20:10:04 -08:00
|
|
|
CFType *cft;
|
|
|
|
|
2012-06-28 03:14:25 -07:00
|
|
|
EINA_LIST_FREE(cfdata->types, cft)
|
|
|
|
_cftype_free(cft);
|
2010-03-02 20:10:04 -08:00
|
|
|
|
2012-11-26 02:58:58 -08:00
|
|
|
free(cfdata);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_module_update(E_Config_Dialog_Data *cfdata, int type __UNUSED__, E_Event_Module_Update *ev)
|
|
|
|
{
|
|
|
|
CFType *cft;
|
|
|
|
Eina_List *l, *ll;
|
|
|
|
CFModule *cfm;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(cfdata->types, l, cft)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(cft->modules, ll, cfm)
|
|
|
|
if (cfm->short_name == ev->name)
|
|
|
|
{
|
|
|
|
cfm->enabled = ev->enabled;
|
|
|
|
_module_end_state_apply(cfm);
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
2005-12-17 03:21:54 -08:00
|
|
|
}
|
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
static CFModule *
|
2010-03-13 13:56:25 -08:00
|
|
|
_module_new(const char *short_name, const Efreet_Desktop *desk)
|
2007-07-15 16:39:28 -07:00
|
|
|
{
|
2010-03-02 20:10:04 -08:00
|
|
|
CFModule *cfm = E_NEW(CFModule, 1);
|
2010-03-29 18:05:56 -07:00
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
if (!cfm) return NULL;
|
|
|
|
cfm->short_name = eina_stringshare_add(short_name);
|
2005-12-28 09:28:02 -08:00
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
if (desk->name)
|
|
|
|
cfm->name = eina_stringshare_add(desk->name);
|
|
|
|
else
|
|
|
|
cfm->name = eina_stringshare_ref(cfm->short_name);
|
2007-07-15 16:39:28 -07:00
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
cfm->icon = eina_stringshare_add(desk->icon);
|
|
|
|
cfm->comment = eina_stringshare_add(desk->comment);
|
|
|
|
cfm->orig_path = eina_stringshare_add(desk->orig_path);
|
|
|
|
return cfm;
|
|
|
|
}
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
static void
|
|
|
|
_module_free(CFModule *cfm)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(cfm->short_name);
|
|
|
|
eina_stringshare_del(cfm->name);
|
|
|
|
eina_stringshare_del(cfm->icon);
|
|
|
|
eina_stringshare_del(cfm->comment);
|
|
|
|
eina_stringshare_del(cfm->orig_path);
|
|
|
|
E_FREE(cfm);
|
|
|
|
}
|
2007-11-02 14:41:06 -07:00
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
static void
|
|
|
|
_module_end_state_apply(CFModule *cfm)
|
|
|
|
{
|
|
|
|
const char *sig;
|
2010-03-29 18:05:56 -07:00
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
if (!cfm->end) return;
|
|
|
|
sig = cfm->enabled ? "e,state,checked" : "e,state,unchecked";
|
|
|
|
edje_object_signal_emit(cfm->end, sig, "e");
|
|
|
|
}
|
2007-11-02 14:41:06 -07:00
|
|
|
|
2012-08-30 05:21:30 -07:00
|
|
|
static CFType *
|
|
|
|
_cftype_find(E_Config_Dialog_Data *cfdata, const char *key, const char *name, const char *icon)
|
|
|
|
{
|
|
|
|
CFType *cft;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(cfdata->types, l, cft)
|
|
|
|
if ((!strcmp(cft->key, key)) && (!strcmp(cft->name, name)) && (!strcmp(cft->icon, icon))) return cft;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
static CFType *
|
|
|
|
_cftype_new(const char *key, const char *name, const char *icon)
|
|
|
|
{
|
2010-05-16 17:04:12 -07:00
|
|
|
CFType *cft = E_NEW(CFType, 1);
|
2010-03-29 18:05:56 -07:00
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
if (!cft) return NULL;
|
|
|
|
cft->key = eina_stringshare_add(key);
|
2012-09-03 22:21:41 -07:00
|
|
|
cft->name = eina_stringshare_add(name);
|
2010-03-02 20:10:04 -08:00
|
|
|
cft->icon = eina_stringshare_add(icon);
|
2012-09-03 22:21:41 -07:00
|
|
|
//INF("CFT NEW: key(%s) name(%s) icon(%s)", key, name, icon);
|
2010-03-02 20:10:04 -08:00
|
|
|
return cft;
|
2005-12-17 03:21:54 -08:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static void
|
2010-03-02 20:10:04 -08:00
|
|
|
_cftype_free(CFType *cft)
|
2007-07-15 16:39:28 -07:00
|
|
|
{
|
2010-03-02 20:10:04 -08:00
|
|
|
CFModule *cfm;
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2010-08-25 18:34:13 -07:00
|
|
|
assert(cft->modules_hash == NULL); // must do it before calling this function
|
2010-03-02 20:10:04 -08:00
|
|
|
EINA_LIST_FREE(cft->modules, cfm)
|
|
|
|
_module_free(cfm);
|
2007-11-02 14:41:06 -07:00
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
eina_stringshare_del(cft->key);
|
|
|
|
eina_stringshare_del(cft->name);
|
|
|
|
eina_stringshare_del(cft->icon);
|
|
|
|
E_FREE(cft);
|
2007-07-15 16:39:28 -07:00
|
|
|
}
|
2005-12-17 03:21:54 -08:00
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
static CFType *
|
|
|
|
_cftype_new_from_key(const char *key)
|
2008-10-18 08:19:39 -07:00
|
|
|
{
|
2010-03-02 20:10:04 -08:00
|
|
|
const CFTypes *itr;
|
|
|
|
char name[1024], icon[1024];
|
2010-12-22 16:41:19 -08:00
|
|
|
size_t key_len;
|
|
|
|
|
|
|
|
if (!key) return NULL;
|
2008-10-18 08:19:39 -07:00
|
|
|
|
2010-12-22 16:41:19 -08:00
|
|
|
key_len = strlen(key);
|
2010-03-02 20:10:04 -08:00
|
|
|
for (itr = _types; itr->key_len > 0; itr++)
|
|
|
|
{
|
2012-06-28 03:14:25 -07:00
|
|
|
if (key_len != itr->key_len) continue;
|
|
|
|
if (strcmp(itr->key, key) != 0) continue;
|
|
|
|
return _cftype_new(itr->key, itr->name, itr->icon);
|
2010-03-02 20:10:04 -08:00
|
|
|
}
|
2008-10-18 08:19:39 -07:00
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
if ((key_len + 1) >= sizeof(name)) return NULL;
|
|
|
|
if ((key_len + sizeof("enlightenment/")) >= sizeof(icon)) return NULL;
|
2008-10-18 08:19:39 -07:00
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
memcpy(name, key, key_len + 1);
|
|
|
|
name[0] = toupper(name[0]);
|
2008-10-18 08:19:39 -07:00
|
|
|
|
2012-12-13 04:03:41 -08:00
|
|
|
snprintf(icon, sizeof(icon), "enlightenment/%s", key);
|
2010-03-02 20:10:04 -08:00
|
|
|
return _cftype_new(key, name, icon);
|
2008-10-18 08:19:39 -07:00
|
|
|
}
|
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
static void
|
2013-01-15 07:34:27 -08:00
|
|
|
_load_module(E_Module_Desktop *md, Eina_Hash *types_hash)
|
2008-10-18 08:19:39 -07:00
|
|
|
{
|
2013-01-15 07:34:27 -08:00
|
|
|
CFType *cft;
|
|
|
|
CFModule *cfm;
|
|
|
|
const char *type, *mod;
|
|
|
|
Eina_Bool new_type = EINA_FALSE;
|
2008-10-18 08:19:39 -07:00
|
|
|
|
2013-01-15 07:34:27 -08:00
|
|
|
mod = ecore_file_file_get(md->dir);
|
|
|
|
if (md->desktop->x)
|
|
|
|
type = eina_hash_find(md->desktop->x, "X-Enlightenment-ModuleType");
|
|
|
|
else
|
|
|
|
type = NULL;
|
|
|
|
if (!type) type = "utils"; // todo: warn?
|
2008-10-18 08:19:39 -07:00
|
|
|
|
2013-01-15 07:34:27 -08:00
|
|
|
cft = eina_hash_find(types_hash, type);
|
|
|
|
if (cft)
|
2008-10-18 08:19:39 -07:00
|
|
|
{
|
2013-01-15 07:34:27 -08:00
|
|
|
new_type = EINA_FALSE;
|
|
|
|
if ((cft->modules_hash) &&
|
|
|
|
(eina_hash_find(cft->modules_hash, mod)))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cft = _cftype_new_from_key(type);
|
|
|
|
if (cft) new_type = EINA_TRUE;
|
|
|
|
else return;
|
|
|
|
}
|
2012-06-28 03:14:25 -07:00
|
|
|
|
2013-01-15 07:34:27 -08:00
|
|
|
cfm = _module_new(mod, md->desktop);
|
|
|
|
if (!cfm)
|
|
|
|
{
|
|
|
|
if (new_type) _cftype_free(cft);
|
|
|
|
return;
|
|
|
|
}
|
2012-06-28 03:14:25 -07:00
|
|
|
|
2013-01-15 07:34:27 -08:00
|
|
|
if (!cft->modules_hash)
|
|
|
|
cft->modules_hash = eina_hash_string_superfast_new(NULL);
|
|
|
|
eina_hash_direct_add(cft->modules_hash, cfm->short_name, cfm);
|
|
|
|
cft->modules = eina_list_append(cft->modules, cfm);
|
|
|
|
cfm->module = e_module_find(mod);
|
|
|
|
if (cfm->module)
|
|
|
|
cfm->enabled = e_module_enabled_get(cfm->module);
|
|
|
|
else
|
|
|
|
cfm->enabled = 0;
|
2012-06-28 03:14:25 -07:00
|
|
|
|
2013-01-15 07:34:27 -08:00
|
|
|
if (new_type)
|
|
|
|
eina_hash_direct_add(types_hash, cft->key, cft);
|
2010-03-02 20:10:04 -08:00
|
|
|
}
|
2008-10-18 08:19:39 -07:00
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
static int
|
|
|
|
_modules_list_sort(const void *data1, const void *data2)
|
|
|
|
{
|
|
|
|
const CFModule *m1 = data1, *m2 = data2;
|
|
|
|
return strcmp(m1->name, m2->name);
|
2008-10-18 08:19:39 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
2010-03-02 20:10:04 -08:00
|
|
|
_types_list_create_foreach_cb(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata)
|
2007-07-15 16:39:28 -07:00
|
|
|
{
|
2010-03-02 20:10:04 -08:00
|
|
|
E_Config_Dialog_Data *cfdata = fdata;
|
|
|
|
CFType *cft = data;
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
// otherwise it should not be here
|
|
|
|
assert(cft->modules);
|
|
|
|
assert(cft->modules_hash);
|
|
|
|
|
|
|
|
eina_hash_free(cft->modules_hash);
|
|
|
|
cft->modules_hash = NULL;
|
|
|
|
|
|
|
|
cft->modules = eina_list_sort(cft->modules, -1, _modules_list_sort);
|
|
|
|
cfdata->types = eina_list_append(cfdata->types, cft);
|
|
|
|
// TODO be paranoid about list append failure, otherwise leaks memory
|
2008-12-17 07:33:43 -08:00
|
|
|
return EINA_TRUE;
|
2007-11-02 14:41:06 -07:00
|
|
|
}
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2010-03-02 20:10:04 -08:00
|
|
|
static int
|
|
|
|
_types_list_sort(const void *data1, const void *data2)
|
2007-11-02 14:41:06 -07:00
|
|
|
{
|
2010-03-02 20:10:04 -08:00
|
|
|
const CFType *t1 = data1, *t2 = data2;
|
|
|
|
return strcmp(t1->name, t2->name);
|
2006-09-02 15:18:20 -07:00
|
|
|
}
|
|
|
|
|
2012-07-02 03:29:55 -07:00
|
|
|
static void
|
2015-01-31 09:13:26 -08:00
|
|
|
_toolbar_selected_cb(void *data, Evas_Object *obj, void *event)
|
|
|
|
{
|
|
|
|
CFType *cft = data;
|
2015-02-27 09:14:11 -08:00
|
|
|
|
|
|
|
if (evas_object_data_get(obj, "__anim")) return;
|
|
|
|
|
2015-01-31 09:13:26 -08:00
|
|
|
elm_genlist_item_bring_in(cft->gindex, ELM_GENLIST_ITEM_SCROLLTO_TOP);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
toolbar_item(Evas_Object *obj, CFType *cft)
|
2007-07-15 16:39:28 -07:00
|
|
|
{
|
2015-02-05 12:57:39 -08:00
|
|
|
cft->tbitem = elm_toolbar_item_append(obj, cft->icon, cft->name, _toolbar_selected_cb, cft);
|
2015-01-31 09:13:26 -08:00
|
|
|
}
|
2007-08-15 06:51:00 -07:00
|
|
|
|
2015-01-31 09:13:26 -08:00
|
|
|
static char *
|
|
|
|
_group_item_label_get(void *data, Evas_Object *obj, const char *part)
|
|
|
|
{
|
|
|
|
CFType *cft = data;
|
|
|
|
|
|
|
|
return strdup(cft->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
_item_label_get(void *data, Evas_Object *obj, const char *part)
|
|
|
|
{
|
|
|
|
CFModule *cfm = data;
|
|
|
|
|
|
|
|
return strdup(cfm->name);
|
|
|
|
}
|
2012-06-28 03:14:25 -07:00
|
|
|
|
2015-01-31 09:13:26 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_item_gen(CFModule *cfm, Evas_Object *icon)
|
|
|
|
{
|
|
|
|
if (!cfm->icon)
|
|
|
|
return EINA_FALSE;
|
|
|
|
if (!elm_icon_standard_set(icon, cfm->icon))
|
|
|
|
{
|
|
|
|
if (cfm->orig_path)
|
2012-06-28 03:14:25 -07:00
|
|
|
{
|
2015-01-31 09:13:26 -08:00
|
|
|
char *dir = ecore_file_dir_get(cfm->orig_path);
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s.edj", dir, cfm->icon);
|
|
|
|
if (!ecore_file_exists(buf))
|
|
|
|
{
|
|
|
|
free(dir);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
elm_image_file_set(icon, buf, "icon");
|
|
|
|
free(dir);
|
|
|
|
return EINA_TRUE;
|
2012-06-28 03:14:25 -07:00
|
|
|
}
|
2015-01-31 09:13:26 -08:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object*
|
|
|
|
_item_content_get(void *data, Evas_Object *obj, const char *part)
|
|
|
|
{
|
|
|
|
CFModule *cfm = data;
|
|
|
|
Evas_Object *icon;
|
|
|
|
|
|
|
|
if (!strcmp(part, "elm.swallow.icon"))
|
|
|
|
{
|
|
|
|
if (!cfm->icon)
|
|
|
|
icon = NULL;
|
2012-06-28 03:14:25 -07:00
|
|
|
else
|
|
|
|
{
|
2015-01-31 09:13:26 -08:00
|
|
|
icon = elm_icon_add(obj);
|
|
|
|
_item_gen(cfm, icon);
|
|
|
|
evas_object_size_hint_min_set(icon, 64, 64);
|
2012-06-28 03:14:25 -07:00
|
|
|
}
|
2007-11-02 14:41:06 -07:00
|
|
|
}
|
2010-03-02 20:10:04 -08:00
|
|
|
else
|
2015-01-31 09:13:26 -08:00
|
|
|
{
|
|
|
|
cfm->end = icon = elm_check_add(obj);
|
|
|
|
elm_object_style_set(icon, "led");
|
|
|
|
evas_object_freeze_events_set(icon, EINA_TRUE);
|
|
|
|
elm_check_state_set(icon, cfm->enabled);
|
|
|
|
//TODO delete hook!!
|
|
|
|
}
|
2007-08-15 06:51:00 -07:00
|
|
|
|
2015-01-31 09:13:26 -08:00
|
|
|
return icon;
|
2007-11-02 00:00:17 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static void
|
2015-01-31 09:13:26 -08:00
|
|
|
_list_selected(void *data, Evas_Object *obj, void *event)
|
2007-08-15 06:51:00 -07:00
|
|
|
{
|
2015-01-31 09:13:26 -08:00
|
|
|
CFModule *mod = elm_object_item_data_get(event);
|
|
|
|
Evas_Object *w = data;
|
|
|
|
Evas_Object *load = evas_object_data_get(w, "__load_btn");
|
|
|
|
Evas_Object *unload = evas_object_data_get(w, "__unload_btn");
|
2007-11-02 14:41:06 -07:00
|
|
|
|
2015-01-31 09:13:26 -08:00
|
|
|
elm_object_disabled_set(load, mod->enabled);
|
|
|
|
elm_object_disabled_set(unload, !mod->enabled);
|
|
|
|
}
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2015-01-31 09:13:26 -08:00
|
|
|
static void
|
|
|
|
_load_cb(void *data, Evas_Object *obj, void *event)
|
|
|
|
{
|
|
|
|
Evas_Object *list = data;
|
|
|
|
Evas_Object *w = elm_object_parent_widget_get(list);
|
|
|
|
Evas_Object *unload = evas_object_data_get(w, "__unload_btn");
|
|
|
|
Elm_Object_Item *sel = elm_genlist_selected_item_get(list);
|
|
|
|
CFModule *cfm = elm_object_item_data_get(sel);
|
|
|
|
|
|
|
|
if (!cfm->module)
|
|
|
|
cfm->module = e_module_find(cfm->short_name);
|
|
|
|
if (!cfm->module)
|
|
|
|
cfm->module = e_module_new(cfm->short_name);
|
|
|
|
if (cfm->module)
|
|
|
|
{
|
|
|
|
e_module_enable(cfm->module);
|
|
|
|
cfm->enabled = e_module_enabled_get(cfm->module);
|
2010-03-02 20:10:04 -08:00
|
|
|
}
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2015-01-31 09:13:26 -08:00
|
|
|
elm_check_state_set(cfm->end, EINA_TRUE);
|
|
|
|
elm_object_disabled_set(unload, EINA_FALSE);
|
|
|
|
elm_object_disabled_set(obj, EINA_TRUE);
|
2007-08-15 06:51:00 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static void
|
2015-01-31 09:13:26 -08:00
|
|
|
_unload_cb(void *data, Evas_Object *obj, void *event)
|
2008-10-18 08:19:39 -07:00
|
|
|
{
|
2015-01-31 09:13:26 -08:00
|
|
|
Evas_Object *list = data;
|
|
|
|
Evas_Object *w = elm_object_parent_widget_get(list);
|
|
|
|
Evas_Object *load = evas_object_data_get(w, "__load_btn");
|
|
|
|
Elm_Object_Item *sel = elm_genlist_selected_item_get(list);
|
|
|
|
CFModule *cfm = elm_object_item_data_get(sel);
|
|
|
|
|
|
|
|
if (!cfm->module)
|
|
|
|
cfm->module = e_module_find(cfm->short_name);
|
2008-10-18 08:19:39 -07:00
|
|
|
|
2015-01-31 09:13:26 -08:00
|
|
|
if (cfm->module)
|
2010-03-02 20:10:04 -08:00
|
|
|
{
|
2015-01-31 09:13:26 -08:00
|
|
|
e_module_disable(cfm->module);
|
|
|
|
cfm->enabled = e_module_enabled_get(cfm->module);
|
|
|
|
}
|
2007-08-15 06:51:00 -07:00
|
|
|
|
2015-01-31 09:13:26 -08:00
|
|
|
elm_check_state_set(cfm->end, EINA_FALSE);
|
|
|
|
elm_object_disabled_set(load, EINA_FALSE);
|
|
|
|
elm_object_disabled_set(obj, EINA_TRUE);
|
|
|
|
}
|
2007-10-28 00:43:46 -07:00
|
|
|
|
2015-02-05 12:57:39 -08:00
|
|
|
static void
|
|
|
|
_list_scroll_start_cb(void *data, Evas_Object *obj, void *event)
|
|
|
|
{
|
2015-02-27 09:14:11 -08:00
|
|
|
evas_object_data_set(data, "__anim", (void*) 1);
|
2015-02-05 12:57:39 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_list_scroll_stop_cb(void *data, Evas_Object *obj, void *event)
|
|
|
|
{
|
2015-02-27 09:14:11 -08:00
|
|
|
evas_object_data_del(data, "__anim");
|
2015-02-05 12:57:39 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_list_scroll_cb(void *data, Evas_Object *obj, void *event)
|
|
|
|
{
|
|
|
|
int x, y, w, h;
|
|
|
|
Elm_Object_Item *it, *gi;
|
|
|
|
CFType *cft;
|
|
|
|
|
2015-02-27 09:14:11 -08:00
|
|
|
|
2015-02-05 12:57:39 -08:00
|
|
|
|
|
|
|
evas_object_geometry_get(obj, &x, &y, &w ,&h);
|
|
|
|
it = elm_genlist_at_xy_item_get(obj, x + 3, y + 3, NULL);
|
|
|
|
|
|
|
|
if(!it) return; //something went wrong ...
|
|
|
|
|
|
|
|
if (elm_genlist_item_type_get(it) == ELM_GENLIST_ITEM_GROUP)
|
|
|
|
gi = it;
|
|
|
|
else
|
|
|
|
gi = elm_genlist_item_parent_get(it);
|
|
|
|
|
|
|
|
cft = elm_object_item_data_get(gi);
|
|
|
|
|
|
|
|
elm_toolbar_item_selected_set(cft->tbitem, EINA_TRUE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-01-31 09:13:26 -08:00
|
|
|
static Evas_Object*
|
|
|
|
e_int_config_modules_create_cb(const char *path, const char *part, Evas_Object *parent, void *cbdata, void *data)
|
|
|
|
{
|
2015-02-05 12:57:39 -08:00
|
|
|
Evas_Object *tab, *bx, *tb, *list, *lb, *load, *unload;
|
2015-01-31 09:13:26 -08:00
|
|
|
|
2015-02-05 12:57:39 -08:00
|
|
|
|
|
|
|
tab = elm_table_add(parent);
|
|
|
|
evas_object_size_hint_align_set(tab, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_size_hint_weight_set(tab, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_show(tab);
|
2015-01-31 09:13:26 -08:00
|
|
|
|
|
|
|
tb = elm_toolbar_add(parent);
|
2015-02-05 12:57:39 -08:00
|
|
|
elm_toolbar_select_mode_set(tb, ELM_OBJECT_SELECT_MODE_ALWAYS);
|
|
|
|
elm_toolbar_horizontal_set(tb, EINA_FALSE);
|
|
|
|
elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_NONE);
|
2015-01-31 09:13:26 -08:00
|
|
|
elm_toolbar_icon_order_lookup_set(tb, ELM_ICON_LOOKUP_THEME_FDO);
|
2015-02-05 12:57:39 -08:00
|
|
|
evas_object_size_hint_align_set(tb, 0.0, EVAS_HINT_FILL);
|
|
|
|
evas_object_size_hint_weight_set(tb, 0.0, EVAS_HINT_EXPAND);
|
|
|
|
elm_table_pack(tab, tb, 0, 0, 1, 1);
|
2015-01-31 09:13:26 -08:00
|
|
|
evas_object_show(tb);
|
|
|
|
|
|
|
|
list = elm_genlist_add(parent);
|
|
|
|
evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2015-02-27 09:14:11 -08:00
|
|
|
evas_object_smart_callback_add(list, "scroll", _list_scroll_cb, tb);
|
|
|
|
evas_object_smart_callback_add(list, "scroll,anim,start", _list_scroll_start_cb, tb);
|
|
|
|
evas_object_smart_callback_add(list, "scroll,anim,stop", _list_scroll_stop_cb, tb);
|
2015-02-05 12:57:39 -08:00
|
|
|
evas_object_data_set(list, "__toolbar", tb);
|
|
|
|
elm_table_pack(tab, list, 1, 0, 1, 1);
|
2015-01-31 09:13:26 -08:00
|
|
|
evas_object_show(list);
|
|
|
|
|
2015-02-05 12:57:39 -08:00
|
|
|
bx = elm_box_add(parent);
|
|
|
|
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.0);
|
|
|
|
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
|
|
|
|
elm_box_horizontal_set(bx, EINA_TRUE);
|
|
|
|
elm_table_pack(tab, bx, 0, 1, 2, 1);
|
|
|
|
evas_object_show(bx);
|
2015-01-31 09:13:26 -08:00
|
|
|
|
|
|
|
load = elm_button_add(parent);
|
|
|
|
elm_object_text_set(load, _("load"));
|
|
|
|
elm_object_disabled_set(load, EINA_TRUE);
|
2015-02-05 12:57:39 -08:00
|
|
|
evas_object_data_set(tab, "__load_btn", load);
|
2015-01-31 09:13:26 -08:00
|
|
|
evas_object_smart_callback_add(load, "clicked", _load_cb, list);
|
|
|
|
evas_object_size_hint_align_set(load, EVAS_HINT_FILL, 0.0);
|
|
|
|
evas_object_size_hint_weight_set(load, EVAS_HINT_EXPAND, 0.0);
|
2015-02-05 12:57:39 -08:00
|
|
|
elm_box_pack_end(bx, load);
|
2015-01-31 09:13:26 -08:00
|
|
|
evas_object_show(load);
|
|
|
|
|
|
|
|
unload = elm_button_add(parent);
|
|
|
|
elm_object_text_set(unload, _("unload"));
|
|
|
|
elm_object_disabled_set(unload, EINA_TRUE);
|
2015-02-05 12:57:39 -08:00
|
|
|
evas_object_data_set(tab, "__unload_btn", unload);
|
2015-01-31 09:13:26 -08:00
|
|
|
evas_object_smart_callback_add(unload, "clicked", _unload_cb, list);
|
|
|
|
evas_object_size_hint_align_set(unload, EVAS_HINT_FILL, 0.0);
|
|
|
|
evas_object_size_hint_weight_set(unload, EVAS_HINT_EXPAND, 0.0);
|
2015-02-05 12:57:39 -08:00
|
|
|
elm_box_pack_end(bx, unload);
|
2015-01-31 09:13:26 -08:00
|
|
|
evas_object_show(unload);
|
2010-03-02 20:10:04 -08:00
|
|
|
|
2015-01-31 09:13:26 -08:00
|
|
|
{
|
|
|
|
E_Config_Dialog_Data *cfdata = cbdata;
|
|
|
|
Eina_List *node;
|
|
|
|
CFType *cft;
|
|
|
|
Elm_Genlist_Item_Class *itc_group, *itc_item;
|
|
|
|
|
|
|
|
/*groupindex class*/
|
|
|
|
itc_group = elm_genlist_item_class_new();
|
|
|
|
itc_group->item_style = "group_index";
|
|
|
|
itc_group->func.text_get = _group_item_label_get;
|
|
|
|
itc_group->func.content_get = NULL;
|
|
|
|
itc_group->func.state_get = NULL;
|
|
|
|
itc_group->func.del = NULL;
|
|
|
|
|
|
|
|
itc_item = elm_genlist_item_class_new();
|
|
|
|
itc_item->item_style = "default";
|
|
|
|
itc_item->func.text_get = _item_label_get;
|
|
|
|
itc_item->func.content_get = _item_content_get;
|
|
|
|
itc_item->func.state_get = NULL;
|
|
|
|
itc_item->func.del = NULL;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(cfdata->types, node, cft)
|
|
|
|
{
|
|
|
|
CFModule *cfm;
|
|
|
|
Eina_List *l_module;
|
|
|
|
Elm_Object_Item *item, *it;
|
|
|
|
|
|
|
|
cft->gindex = item = elm_genlist_item_append(list, itc_group, cft, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
|
|
|
|
elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
|
|
|
|
|
|
|
|
toolbar_item(tb, cft);
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(cft->modules, l_module, cfm)
|
|
|
|
{
|
|
|
|
cfm->item = it = elm_genlist_item_append(list, itc_item, cfm,
|
|
|
|
item, ELM_GENLIST_ITEM_NONE,
|
|
|
|
_list_selected, bx);
|
|
|
|
elm_genlist_item_tooltip_text_set(it, cfm->comment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-05 12:57:39 -08:00
|
|
|
return tab;
|
2007-08-15 06:51:00 -07:00
|
|
|
}
|
2012-06-28 03:14:25 -07:00
|
|
|
|
2015-01-31 09:13:26 -08:00
|
|
|
static Eina_Bool
|
|
|
|
e_int_config_modules_apply_cb(const char *path, const char *part, Evas_Object *obj, void *cbdata, void *data)
|
|
|
|
{
|
|
|
|
//Nothing to do here we save things directly
|
|
|
|
}
|