2007-08-25 08:24:52 -07:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
2005-12-17 03:21:54 -08:00
|
|
|
#include "e.h"
|
2005-12-22 14:40:21 -08:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
typedef struct _CFModule CFModule;
|
|
|
|
typedef struct _CFType CFType;
|
|
|
|
typedef struct _CFTypes CFTypes;
|
|
|
|
|
|
|
|
struct _CFModule
|
2007-08-15 06:51:00 -07:00
|
|
|
{
|
2007-08-25 08:24:52 -07:00
|
|
|
const char *short_name, *name, *comment;
|
2007-11-04 12:59:04 -08:00
|
|
|
const char *icon, *orig_path;
|
2007-08-15 06:51:00 -07:00
|
|
|
int enabled, selected;
|
2007-11-02 14:41:06 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _CFType
|
|
|
|
{
|
2008-10-18 08:19:39 -07:00
|
|
|
const char *key, *name, *icon;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_Hash *modules;
|
2007-11-02 14:41:06 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _CFTypes
|
|
|
|
{
|
2008-10-18 08:19:39 -07:00
|
|
|
const char *key, *name, *icon;
|
2007-11-02 14:41:06 -07:00
|
|
|
};
|
2007-07-15 16:39:28 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
struct _E_Config_Dialog_Data
|
2005-12-17 03:21:54 -08:00
|
|
|
{
|
2007-11-02 14:41:06 -07:00
|
|
|
Evas_Object *l_avail, *l_loaded;
|
2007-07-15 16:39:28 -07:00
|
|
|
Evas_Object *b_load, *b_unload;
|
2007-08-25 08:24:52 -07:00
|
|
|
Evas_Object *o_desc;
|
2005-12-17 03:21:54 -08:00
|
|
|
};
|
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
/* Key pairs for module types
|
|
|
|
*
|
2008-04-17 23:23:21 -07:00
|
|
|
* Should be in alphabetic order
|
|
|
|
*/
|
2007-11-02 14:41:06 -07:00
|
|
|
const CFTypes _types[] =
|
|
|
|
{
|
2009-03-15 10:41:46 -07:00
|
|
|
{"appearance", N_("Appearance"), "preferences-appearance"},
|
2009-03-04 18:39:50 -08:00
|
|
|
{"config", N_("Settings"), "preferences-system"},
|
2009-03-06 11:17:12 -08:00
|
|
|
{"fileman", N_("File Manager"), "system-file-manager"},
|
2009-03-08 16:09:48 -07:00
|
|
|
{"shelf", N_("Shelf"), "preferences-desktop-shelf"}, //FIXME use gadget icon
|
2009-03-15 10:41:46 -07:00
|
|
|
{"system", N_("System"), "system"},
|
2008-10-18 08:19:39 -07:00
|
|
|
{NULL, NULL, NULL}
|
2007-11-02 14:41:06 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/* local function protos */
|
|
|
|
static void *_create_data (E_Config_Dialog *cfd);
|
|
|
|
static void _fill_data (E_Config_Dialog_Data *cfdata);
|
2008-12-17 07:33:43 -08:00
|
|
|
static void _free_data (E_Config_Dialog *cfd,
|
2007-11-02 14:41:06 -07:00
|
|
|
E_Config_Dialog_Data *cfdata);
|
2008-12-17 07:33:43 -08:00
|
|
|
static Evas_Object *_basic_create (E_Config_Dialog *cfd, Evas *evas,
|
2007-11-02 14:41:06 -07:00
|
|
|
E_Config_Dialog_Data *cfdata);
|
|
|
|
static void _fill_type_hash (void);
|
|
|
|
static void _load_modules (const char *dir);
|
|
|
|
static void _fill_list (Evas_Object *obj, int enabled);
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool _fill_list_types_avail(const Eina_Hash *hash __UNUSED__,
|
2008-10-26 13:48:44 -07:00
|
|
|
const void *key __UNUSED__,
|
2008-10-18 08:19:39 -07:00
|
|
|
void *data, void *fdata);
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool _fill_list_types_load (const Eina_Hash *hash __UNUSED__,
|
2008-10-26 13:48:44 -07:00
|
|
|
const void *key __UNUSED__,
|
2008-10-18 08:19:39 -07:00
|
|
|
void *data, void *fdata);
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool _fill_list_types (Evas_Object *obj, CFType *cft,
|
2008-10-18 08:19:39 -07:00
|
|
|
int enabled);
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool _types_hash_cb_free (const Eina_Hash *hash __UNUSED__,
|
|
|
|
const void *key __UNUSED__,
|
2007-11-02 14:41:06 -07:00
|
|
|
void *data, void *fdata __UNUSED__);
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool _mod_hash_cb_free (const Eina_Hash *hash __UNUSED__,
|
|
|
|
const void *key __UNUSED__,
|
2007-11-02 14:41:06 -07:00
|
|
|
void *data, void *fdata __UNUSED__);
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool _mod_hash_avail_list (const Eina_Hash *hash __UNUSED__,
|
|
|
|
const void *key __UNUSED__,
|
2007-11-02 14:41:06 -07:00
|
|
|
void *data, void *fdata);
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool _mod_hash_load_list (const Eina_Hash *hash __UNUSED__,
|
|
|
|
const void *key __UNUSED__,
|
2007-11-02 14:41:06 -07:00
|
|
|
void *data, void *fdata);
|
2008-10-27 00:33:21 -07:00
|
|
|
static int _mod_list_sort (const void *data1, const void *data2);
|
2008-10-22 04:49:33 -07:00
|
|
|
static void _list_widget_load (Evas_Object *obj, Eina_List *list);
|
2007-11-02 14:41:06 -07:00
|
|
|
static void _avail_list_cb_change (void *data, Evas_Object *obj);
|
|
|
|
static void _load_list_cb_change (void *data, Evas_Object *obj);
|
|
|
|
static void _unselect_all_modules (void);
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool _mod_hash_unselect (const Eina_Hash *hash __UNUSED__,
|
|
|
|
const void *key __UNUSED__,
|
2007-11-02 14:41:06 -07:00
|
|
|
void *data, void *fdata __UNUSED__);
|
|
|
|
static void _select_all_modules (Evas_Object *obj, void *data);
|
|
|
|
static void _btn_cb_unload (void *data, void *data2);
|
|
|
|
static void _btn_cb_load (void *data, void *data2);
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool _mod_hash_load (const Eina_Hash *hash __UNUSED__,
|
|
|
|
const void *key __UNUSED__,
|
2007-11-02 14:41:06 -07:00
|
|
|
void *data, void *fdata __UNUSED__);
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool _mod_hash_unload (const Eina_Hash *hash __UNUSED__,
|
|
|
|
const void *key __UNUSED__,
|
2007-11-02 14:41:06 -07:00
|
|
|
void *data, void *fdata __UNUSED__);
|
|
|
|
static void _enable_modules (int enable);
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool _enable_modules_types_enable (const Eina_Hash *hash __UNUSED__,
|
2008-10-26 13:48:44 -07:00
|
|
|
const void *key __UNUSED__,
|
2008-10-18 10:33:56 -07:00
|
|
|
void *data, void *fdata);
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool _enable_modules_types_disable (const Eina_Hash *hash __UNUSED__,
|
2008-10-26 13:48:44 -07:00
|
|
|
const void *key __UNUSED__,
|
2008-10-18 10:33:56 -07:00
|
|
|
void *data, void *fdata);
|
2007-11-02 14:41:06 -07:00
|
|
|
|
|
|
|
/* local variables */
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Hash *types_hash = NULL;
|
2007-07-15 16:39:28 -07:00
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI E_Config_Dialog *
|
2008-12-17 07:33:43 -08:00
|
|
|
e_int_config_modules(E_Container *con, const char *params __UNUSED__)
|
2005-12-17 03:21:54 -08:00
|
|
|
{
|
2007-11-02 14:41:06 -07:00
|
|
|
E_Config_Dialog *cfd = NULL;
|
|
|
|
E_Config_Dialog_View *v = NULL;
|
2007-08-15 06:51:00 -07:00
|
|
|
|
2006-10-08 01:04:18 -07:00
|
|
|
if (e_config_dialog_find("E", "_config_modules_dialog")) return NULL;
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2007-07-15 16:39:28 -07:00
|
|
|
v = E_NEW(E_Config_Dialog_View, 1);
|
|
|
|
v->create_cfdata = _create_data;
|
|
|
|
v->free_cfdata = _free_data;
|
|
|
|
v->basic.create_widgets = _basic_create;
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
cfd = e_config_dialog_new(con, _("Module Settings"),
|
|
|
|
"E", "_config_modules_dialog",
|
2009-03-04 18:39:50 -08:00
|
|
|
"preferences-plugin", 0, v, NULL);
|
2007-07-15 16:39:28 -07:00
|
|
|
e_dialog_resizable_set(cfd->dia, 1);
|
2005-12-28 09:28:02 -08:00
|
|
|
return cfd;
|
2005-12-17 03:21:54 -08:00
|
|
|
}
|
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
/* local functions */
|
2007-07-15 16:39:28 -07:00
|
|
|
static void *
|
2007-11-02 14:41:06 -07:00
|
|
|
_create_data(E_Config_Dialog *cfd)
|
2005-12-17 03:21:54 -08:00
|
|
|
{
|
2007-11-02 14:41:06 -07:00
|
|
|
E_Config_Dialog_Data *cfdata = NULL;
|
|
|
|
|
|
|
|
_fill_type_hash();
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2007-07-15 16:39:28 -07:00
|
|
|
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
2007-11-02 14:41:06 -07:00
|
|
|
if (!cfdata) return NULL;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-07-15 16:39:28 -07:00
|
|
|
_fill_data(cfdata);
|
|
|
|
return cfdata;
|
2005-12-17 03:21:54 -08:00
|
|
|
}
|
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
static void
|
|
|
|
_fill_data(E_Config_Dialog_Data *cfdata)
|
2005-12-19 18:38:47 -08:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *mdirs = NULL, *l = NULL;
|
2009-08-21 08:08:49 -07:00
|
|
|
E_Path_Dir *epd = NULL;
|
2007-08-15 06:51:00 -07:00
|
|
|
|
|
|
|
if (!cfdata) return;
|
2007-11-02 14:41:06 -07:00
|
|
|
|
|
|
|
/* loop each path_modules dir and load modules for that path */
|
2007-07-15 16:39:28 -07:00
|
|
|
mdirs = e_path_dir_list_get(path_modules);
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(mdirs, l, epd)
|
2005-12-28 09:28:02 -08:00
|
|
|
{
|
2009-08-21 08:08:49 -07:00
|
|
|
if (!epd) continue;
|
2007-07-15 16:39:28 -07:00
|
|
|
if (!ecore_file_is_dir(epd->dir)) continue;
|
2007-08-15 06:51:00 -07:00
|
|
|
_load_modules(epd->dir);
|
2005-12-20 20:48:20 -08:00
|
|
|
}
|
2007-07-15 16:39:28 -07:00
|
|
|
if (mdirs) e_path_dir_list_free(mdirs);
|
2005-12-17 03:21:54 -08:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static void
|
|
|
|
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
2005-12-17 03:21:54 -08:00
|
|
|
{
|
2008-12-17 07:33:43 -08:00
|
|
|
if (types_hash)
|
2007-08-15 06:51:00 -07:00
|
|
|
{
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_foreach(types_hash, _types_hash_cb_free, NULL);
|
|
|
|
eina_hash_free(types_hash);
|
2007-11-02 14:41:06 -07:00
|
|
|
types_hash = NULL;
|
2006-09-02 15:18:20 -07:00
|
|
|
}
|
|
|
|
E_FREE(cfdata);
|
2005-12-17 03:21:54 -08:00
|
|
|
}
|
|
|
|
|
2007-07-15 16:39:28 -07:00
|
|
|
static Evas_Object *
|
2008-12-17 07:33:43 -08:00
|
|
|
_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
2005-12-17 03:21:54 -08:00
|
|
|
{
|
2007-11-02 14:41:06 -07:00
|
|
|
Evas_Object *o, *of, *ol;
|
2007-07-15 16:39:28 -07:00
|
|
|
|
2007-12-30 11:01:33 -08:00
|
|
|
o = e_widget_table_add(evas, 0);
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2007-08-15 06:51:00 -07:00
|
|
|
of = e_widget_frametable_add(evas, _("Available Modules"), 0);
|
2007-11-02 14:41:06 -07:00
|
|
|
ol = e_widget_ilist_add(evas, 24, 24, NULL);
|
|
|
|
cfdata->l_avail = ol;
|
|
|
|
e_widget_ilist_multi_select_set(ol, 1);
|
|
|
|
e_widget_on_change_hook_set(ol, _avail_list_cb_change, cfdata);
|
|
|
|
_fill_list(ol, 0);
|
|
|
|
e_widget_frametable_object_append(of, ol, 0, 0, 1, 1, 1, 1, 1, 1);
|
2009-03-06 11:17:12 -08:00
|
|
|
ol = e_widget_button_add(evas, _("Load Module"), "list-add",
|
2007-11-02 14:41:06 -07:00
|
|
|
_btn_cb_load, cfdata, NULL);
|
|
|
|
cfdata->b_load = ol;
|
|
|
|
e_widget_disabled_set(ol, 1);
|
2007-12-30 11:01:33 -08:00
|
|
|
e_widget_frametable_object_append(of, ol, 0, 1, 1, 1, 1, 1, 1, 0);
|
|
|
|
e_widget_table_object_append(o, of, 0, 0, 1, 1, 1, 1, 1, 1);
|
|
|
|
|
2007-08-15 06:51:00 -07:00
|
|
|
of = e_widget_frametable_add(evas, _("Loaded Modules"), 0);
|
2007-11-02 14:41:06 -07:00
|
|
|
ol = e_widget_ilist_add(evas, 24, 24, NULL);
|
|
|
|
cfdata->l_loaded = ol;
|
|
|
|
e_widget_ilist_multi_select_set(ol, 1);
|
|
|
|
e_widget_on_change_hook_set(ol, _load_list_cb_change, cfdata);
|
|
|
|
_fill_list(ol, 1);
|
|
|
|
e_widget_frametable_object_append(of, ol, 0, 0, 1, 1, 1, 1, 1, 1);
|
2009-03-06 11:17:12 -08:00
|
|
|
ol = e_widget_button_add(evas, _("Unload Module"), "list-remove",
|
2007-11-02 14:41:06 -07:00
|
|
|
_btn_cb_unload, cfdata, NULL);
|
|
|
|
cfdata->b_unload = ol;
|
|
|
|
e_widget_disabled_set(ol, 1);
|
|
|
|
e_widget_frametable_object_append(of, ol, 0, 1, 1, 1, 1, 1, 1, 0);
|
2007-12-30 11:01:33 -08:00
|
|
|
e_widget_table_object_append(o, of, 1, 0, 1, 1, 1, 1, 1, 1);
|
|
|
|
|
|
|
|
ol = e_widget_textblock_add(evas);
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_set(ol, 200, 70);
|
2007-12-30 11:01:33 -08:00
|
|
|
cfdata->o_desc = ol;
|
|
|
|
e_widget_textblock_markup_set(ol, _("Description: Unavailable"));
|
|
|
|
e_widget_table_object_append(o, ol, 0, 1, 2, 1, 1, 0, 1, 0);
|
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static void
|
|
|
|
_fill_type_hash(void)
|
2007-11-02 14:41:06 -07:00
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
/* create the inital hash based on predefined list of types */
|
2008-12-17 07:33:43 -08:00
|
|
|
for (i = 0; _types[i].name; i++)
|
2007-11-02 14:41:06 -07:00
|
|
|
{
|
|
|
|
CFType *cft = NULL;
|
|
|
|
|
|
|
|
if (!_types[i].key) continue;
|
2008-12-17 07:33:43 -08:00
|
|
|
if (eina_hash_find(types_hash, _types[i].key)) continue;
|
2007-11-02 14:41:06 -07:00
|
|
|
|
|
|
|
cft = E_NEW(CFType, 1);
|
|
|
|
if (!cft) continue;
|
2008-10-15 08:12:56 -07:00
|
|
|
cft->key = eina_stringshare_add(_types[i].key);
|
2009-01-24 13:53:51 -08:00
|
|
|
cft->name = eina_stringshare_add(_(_types[i].name));
|
2008-10-18 08:19:39 -07:00
|
|
|
cft->icon = eina_stringshare_add(_types[i].icon);
|
2008-12-17 07:33:43 -08:00
|
|
|
if (!types_hash) types_hash = eina_hash_string_superfast_new(NULL);
|
|
|
|
eina_hash_direct_add(types_hash, cft->key, cft);
|
2007-11-02 14:41:06 -07:00
|
|
|
}
|
2007-07-15 16:39:28 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static void
|
|
|
|
_load_modules(const char *dir)
|
2007-07-15 16:39:28 -07:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *files = NULL;
|
|
|
|
Eina_List *l;
|
2007-11-02 14:41:06 -07:00
|
|
|
char *mod = NULL;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
char *file;
|
2005-12-28 09:28:02 -08:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
if (!dir) return;
|
2008-04-17 23:23:21 -07:00
|
|
|
if (!(files = ecore_file_ls(dir))) return;
|
2007-07-15 16:39:28 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
/* get all modules in this path_dir */
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(files, l, mod)
|
2007-07-15 16:39:28 -07:00
|
|
|
{
|
2007-11-02 14:41:06 -07:00
|
|
|
Efreet_Desktop *desk = NULL;
|
|
|
|
CFType *cft = NULL;
|
|
|
|
CFModule *cfm = NULL;
|
|
|
|
const char *type = NULL;
|
2007-08-15 06:51:00 -07:00
|
|
|
char buf[4096];
|
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
/* check that we have a desktop file for this module */
|
2007-08-15 06:51:00 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/%s/module.desktop", dir, mod);
|
|
|
|
if (!ecore_file_exists(buf)) continue;
|
2008-04-17 23:23:21 -07:00
|
|
|
if (!(desk = efreet_desktop_get(buf))) continue;
|
2007-11-02 14:41:06 -07:00
|
|
|
|
|
|
|
/* does the ModuleType exist in desktop? */
|
2008-12-17 07:33:43 -08:00
|
|
|
if (desk->x)
|
|
|
|
type = eina_hash_find(desk->x, "X-Enlightenment-ModuleType");
|
2008-10-15 08:12:56 -07:00
|
|
|
if (!type) type = eina_stringshare_add("shelf");
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
/* do we have this module already in it's type hash ? */
|
2008-12-17 07:33:43 -08:00
|
|
|
cft = eina_hash_find(types_hash, type);
|
2008-10-18 08:19:39 -07:00
|
|
|
if (cft)
|
2007-11-02 00:00:17 -07:00
|
|
|
{
|
2008-12-17 07:33:43 -08:00
|
|
|
if (cft->modules && eina_hash_find(cft->modules, mod))
|
2007-11-02 14:41:06 -07:00
|
|
|
{
|
2008-10-15 08:12:56 -07:00
|
|
|
if ((!desk->x) && (type)) eina_stringshare_del(type);
|
2007-11-02 14:41:06 -07:00
|
|
|
if (desk) efreet_desktop_free(desk);
|
|
|
|
continue;
|
|
|
|
}
|
2007-11-02 00:00:17 -07:00
|
|
|
}
|
2008-10-18 08:19:39 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
char buf[1024];
|
|
|
|
|
|
|
|
cft = E_NEW(CFType, 1);
|
|
|
|
if (!cft) continue;
|
|
|
|
cft->key = eina_stringshare_add(type);
|
|
|
|
snprintf(buf, sizeof(buf), "%s", type);
|
|
|
|
*buf = toupper(*buf);
|
|
|
|
cft->name = eina_stringshare_add(buf);
|
|
|
|
snprintf(buf, sizeof(buf), "enlightenment/%s", type);
|
|
|
|
if (e_util_edje_icon_check(buf))
|
|
|
|
cft->icon = eina_stringshare_add(buf);
|
2008-12-17 07:33:43 -08:00
|
|
|
if (!types_hash) types_hash = eina_hash_string_superfast_new(NULL);
|
|
|
|
eina_hash_direct_add(types_hash, cft->key, cft);
|
2008-10-18 08:19:39 -07:00
|
|
|
}
|
2007-11-02 14:41:06 -07:00
|
|
|
|
|
|
|
/* module not in it's type hash, add */
|
|
|
|
cfm = E_NEW(CFModule, 1);
|
|
|
|
if (!cfm) continue;
|
2008-10-15 08:12:56 -07:00
|
|
|
cfm->short_name = eina_stringshare_add(mod);
|
|
|
|
if (desk->name) cfm->name = eina_stringshare_add(desk->name);
|
|
|
|
if (desk->icon) cfm->icon = eina_stringshare_add(desk->icon);
|
|
|
|
if (desk->comment) cfm->comment = eina_stringshare_add(desk->comment);
|
2008-12-17 07:33:43 -08:00
|
|
|
if (desk->orig_path)
|
2008-10-15 08:12:56 -07:00
|
|
|
cfm->orig_path = eina_stringshare_add(desk->orig_path);
|
|
|
|
if ((!desk->x) && (type)) eina_stringshare_del(type);
|
2007-11-02 14:41:06 -07:00
|
|
|
efreet_desktop_free(desk);
|
|
|
|
|
|
|
|
if (e_module_find(mod)) cfm->enabled = 1;
|
2008-12-17 07:33:43 -08:00
|
|
|
if (!cft->modules) cft->modules = eina_hash_string_superfast_new(NULL);
|
|
|
|
eina_hash_direct_add(cft->modules, cfm->short_name, cfm);
|
2005-12-28 09:28:02 -08:00
|
|
|
}
|
2007-08-15 06:51:00 -07:00
|
|
|
free(mod);
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FREE(files, file)
|
|
|
|
free(file);
|
2005-12-17 03:21:54 -08:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static void
|
|
|
|
_fill_list(Evas_Object *obj, int enabled)
|
2007-07-15 16:39:28 -07:00
|
|
|
{
|
|
|
|
Evas *evas;
|
|
|
|
Evas_Coord w;
|
2007-08-15 06:51:00 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
/* freeze evas, edje, and list widget */
|
|
|
|
evas = evas_object_evas_get(obj);
|
2007-07-15 16:39:28 -07:00
|
|
|
evas_event_freeze(evas);
|
|
|
|
edje_freeze();
|
2007-11-02 14:41:06 -07:00
|
|
|
e_widget_ilist_freeze(obj);
|
|
|
|
e_widget_ilist_clear(obj);
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
if (types_hash)
|
2007-11-02 00:00:17 -07:00
|
|
|
{
|
2008-10-18 08:19:39 -07:00
|
|
|
if (!enabled)
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_foreach(types_hash, _fill_list_types_avail, obj);
|
2008-10-18 08:19:39 -07:00
|
|
|
else
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_foreach(types_hash, _fill_list_types_load, obj);
|
2007-11-02 00:00:17 -07:00
|
|
|
}
|
2007-11-02 14:41:06 -07:00
|
|
|
|
|
|
|
e_widget_ilist_go(obj);
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_get(obj, &w, NULL);
|
|
|
|
e_widget_size_min_set(obj, w > 180 ? w : 180, 200);
|
2007-11-02 14:41:06 -07:00
|
|
|
e_widget_ilist_thaw(obj);
|
2007-07-15 16:39:28 -07:00
|
|
|
edje_thaw();
|
|
|
|
evas_event_thaw(evas);
|
|
|
|
}
|
2005-12-17 03:21:54 -08:00
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_fill_list_types_avail(const Eina_Hash *hash __UNUSED__,
|
2008-10-26 13:48:44 -07:00
|
|
|
const void *key __UNUSED__, void *data, void *fdata)
|
2008-10-18 08:19:39 -07:00
|
|
|
{
|
|
|
|
CFType *cft;
|
|
|
|
Evas_Object *obj;
|
|
|
|
|
|
|
|
cft = data;
|
|
|
|
obj = fdata;
|
|
|
|
|
|
|
|
return _fill_list_types(obj, cft, 0);
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_fill_list_types_load(const Eina_Hash *hash __UNUSED__,
|
2008-10-26 13:48:44 -07:00
|
|
|
const void *key __UNUSED__, void *data, void *fdata)
|
2008-10-18 08:19:39 -07:00
|
|
|
{
|
|
|
|
CFType *cft;
|
|
|
|
Evas_Object *obj;
|
|
|
|
|
|
|
|
cft = data;
|
|
|
|
obj = fdata;
|
|
|
|
|
|
|
|
return _fill_list_types(obj, cft, 1);
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
2008-10-18 08:19:39 -07:00
|
|
|
_fill_list_types(Evas_Object *obj, CFType *cft, int enabled)
|
|
|
|
{
|
|
|
|
Evas *evas;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l = NULL;
|
2008-10-18 08:19:39 -07:00
|
|
|
Evas_Object *ic = NULL;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
evas = evas_object_evas_get(obj);
|
|
|
|
|
|
|
|
if (cft->modules)
|
|
|
|
{
|
|
|
|
if (!enabled)
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_foreach(cft->modules, _mod_hash_avail_list, &l);
|
2008-10-18 08:19:39 -07:00
|
|
|
else
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_foreach(cft->modules, _mod_hash_load_list, &l);
|
2008-10-18 08:19:39 -07:00
|
|
|
}
|
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
if (l) count = eina_list_count(l);
|
2008-12-17 07:33:43 -08:00
|
|
|
else return EINA_TRUE;
|
2008-10-18 08:19:39 -07:00
|
|
|
|
|
|
|
/* We have at least one, append header */
|
|
|
|
if (cft->icon)
|
|
|
|
{
|
2009-03-04 18:39:50 -08:00
|
|
|
ic = e_icon_add(evas);
|
|
|
|
e_util_icon_theme_set(ic, cft->icon);
|
2008-10-18 08:19:39 -07:00
|
|
|
}
|
|
|
|
e_widget_ilist_header_append(obj, ic, cft->name);
|
|
|
|
|
|
|
|
/* sort the list if we have more than one */
|
|
|
|
if (count > 1)
|
2008-10-22 04:49:33 -07:00
|
|
|
l = eina_list_sort(l, -1, _mod_list_sort);
|
2008-10-18 08:19:39 -07:00
|
|
|
|
|
|
|
_list_widget_load(obj, l);
|
|
|
|
|
|
|
|
if (l)
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
eina_list_free(l);
|
2008-10-18 08:19:39 -07:00
|
|
|
l = NULL;
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
return EINA_TRUE;
|
2008-10-18 08:19:39 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_types_hash_cb_free(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__,
|
|
|
|
void *data, void *fdata __UNUSED__)
|
2007-07-15 16:39:28 -07:00
|
|
|
{
|
2007-11-02 14:41:06 -07:00
|
|
|
CFType *type = NULL;
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2008-04-17 23:23:21 -07:00
|
|
|
if (!(type = data)) return 1;
|
2008-10-15 08:12:56 -07:00
|
|
|
if (type->key) eina_stringshare_del(type->key);
|
|
|
|
if (type->name) eina_stringshare_del(type->name);
|
2008-10-18 08:19:39 -07:00
|
|
|
if (type->icon) eina_stringshare_del(type->icon);
|
2008-12-17 07:33:43 -08:00
|
|
|
if (type->modules)
|
2007-11-02 00:00:17 -07:00
|
|
|
{
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_foreach(type->modules, _mod_hash_cb_free, NULL);
|
|
|
|
eina_hash_free(type->modules);
|
2007-11-02 14:41:06 -07:00
|
|
|
type->modules = NULL;
|
2007-07-15 16:39:28 -07:00
|
|
|
}
|
2007-11-02 14:41:06 -07:00
|
|
|
E_FREE(type);
|
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
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_mod_hash_cb_free(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__,
|
|
|
|
void *data, void *fdata __UNUSED__)
|
2007-11-02 14:41:06 -07:00
|
|
|
{
|
|
|
|
CFModule *mod = NULL;
|
|
|
|
|
2008-04-17 23:23:21 -07:00
|
|
|
if (!(mod = data)) return 1;
|
2008-10-15 08:12:56 -07:00
|
|
|
if (mod->short_name) eina_stringshare_del(mod->short_name);
|
|
|
|
if (mod->name) eina_stringshare_del(mod->name);
|
|
|
|
if (mod->icon) eina_stringshare_del(mod->icon);
|
|
|
|
if (mod->comment) eina_stringshare_del(mod->comment);
|
|
|
|
if (mod->orig_path) eina_stringshare_del(mod->orig_path);
|
2007-11-02 14:41:06 -07:00
|
|
|
E_FREE(mod);
|
2008-12-17 07:33:43 -08:00
|
|
|
return EINA_TRUE;
|
2006-09-02 15:18:20 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_mod_hash_avail_list(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__,
|
|
|
|
void *data, void *fdata)
|
2006-09-02 15:18:20 -07:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List **l;
|
2007-11-02 14:41:06 -07:00
|
|
|
CFModule *mod = NULL;
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
mod = data;
|
|
|
|
if ((!mod) || (mod->enabled)) return 1;
|
|
|
|
l = fdata;
|
2008-10-22 04:49:33 -07:00
|
|
|
*l = eina_list_append(*l, mod);
|
2008-12-17 07:33:43 -08:00
|
|
|
return EINA_TRUE;
|
2007-11-02 14:41:06 -07:00
|
|
|
}
|
2006-09-02 15:18:20 -07:00
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_mod_hash_load_list(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__,
|
|
|
|
void *data, void *fdata)
|
2007-11-02 14:41:06 -07:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List **l;
|
2007-11-02 14:41:06 -07:00
|
|
|
CFModule *mod = NULL;
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
mod = data;
|
|
|
|
if ((!mod) || (!mod->enabled)) return 1;
|
|
|
|
l = fdata;
|
2008-10-22 04:49:33 -07:00
|
|
|
*l = eina_list_append(*l, mod);
|
2008-12-17 07:33:43 -08:00
|
|
|
return EINA_TRUE;
|
2007-11-02 14:41:06 -07:00
|
|
|
}
|
2006-09-02 15:18:20 -07:00
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static int
|
|
|
|
_mod_list_sort(const void *data1, const void *data2)
|
2007-11-02 14:41:06 -07:00
|
|
|
{
|
2008-10-27 00:33:21 -07:00
|
|
|
const CFModule *m1, *m2;
|
2007-11-02 14:41:06 -07:00
|
|
|
|
|
|
|
if (!(m1 = data1)) return 1;
|
|
|
|
if (!(m2 = data2)) return -1;
|
|
|
|
return (strcmp(m1->name, m2->name));
|
|
|
|
}
|
2007-08-15 06:51:00 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
/* nice generic function to load an ilist with items */
|
2008-12-17 07:33:43 -08:00
|
|
|
static void
|
|
|
|
_list_widget_load(Evas_Object *obj, Eina_List *list)
|
2007-11-02 14:41:06 -07:00
|
|
|
{
|
|
|
|
Evas *evas;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *ml = NULL;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
CFModule *mod;
|
2007-11-02 14:41:06 -07:00
|
|
|
|
|
|
|
if ((!obj) || (!list)) return;
|
|
|
|
evas = evas_object_evas_get(obj);
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(list, ml, mod)
|
2007-07-15 16:39:28 -07:00
|
|
|
{
|
2007-11-02 14:41:06 -07:00
|
|
|
Evas_Object *ic = NULL;
|
|
|
|
char *path;
|
|
|
|
char buf[4096];
|
2007-10-31 07:58:29 -07:00
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
if (!mod) continue;
|
2009-04-25 01:03:53 -07:00
|
|
|
if (mod->icon)
|
2007-11-02 14:41:06 -07:00
|
|
|
{
|
2009-04-25 01:03:53 -07:00
|
|
|
ic = e_icon_add(evas);
|
|
|
|
if (!e_util_icon_theme_set(ic, mod->icon))
|
|
|
|
{
|
|
|
|
if (mod->orig_path)
|
|
|
|
{
|
|
|
|
path = ecore_file_dir_get(mod->orig_path);
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s.edj", path, mod->icon);
|
|
|
|
e_icon_file_edje_set(ic, buf, "icon");
|
|
|
|
free(path);
|
|
|
|
}
|
|
|
|
}
|
2007-11-02 14:41:06 -07:00
|
|
|
}
|
|
|
|
if (mod->name)
|
|
|
|
e_widget_ilist_append(obj, ic, mod->name, NULL, mod, NULL);
|
|
|
|
else if (mod->short_name)
|
|
|
|
e_widget_ilist_append(obj, ic, mod->short_name, NULL, mod, NULL);
|
2007-07-15 16:39:28 -07:00
|
|
|
}
|
2006-09-02 15:18:20 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static void
|
|
|
|
_avail_list_cb_change(void *data, Evas_Object *obj)
|
2006-09-02 15:18:20 -07:00
|
|
|
{
|
2007-11-02 14:41:06 -07:00
|
|
|
E_Config_Dialog_Data *cfdata = NULL;
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2008-04-17 23:23:21 -07:00
|
|
|
if (!(cfdata = data)) return;
|
2007-08-15 06:51:00 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
/* Unselect all in loaded list & disable buttons */
|
|
|
|
e_widget_ilist_unselect(cfdata->l_loaded);
|
|
|
|
e_widget_disabled_set(cfdata->b_unload, 1);
|
2007-08-15 06:51:00 -07:00
|
|
|
e_widget_disabled_set(cfdata->b_load, 1);
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
/* Unselect all modules */
|
|
|
|
_unselect_all_modules();
|
2006-09-02 15:18:20 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
/* Make sure something is selected */
|
|
|
|
if (e_widget_ilist_selected_count_get(cfdata->l_avail) < 1) return;
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
/* Select all modules in avail list that user wants */
|
|
|
|
_select_all_modules(cfdata->l_avail, cfdata);
|
|
|
|
|
|
|
|
/* Enable load button */
|
|
|
|
e_widget_disabled_set(cfdata->b_load, 0);
|
2007-07-15 16:39:28 -07:00
|
|
|
}
|
2006-09-02 15:18:20 -07:00
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static void
|
|
|
|
_load_list_cb_change(void *data, Evas_Object *obj)
|
2007-07-15 16:39:28 -07:00
|
|
|
{
|
2007-11-02 14:41:06 -07:00
|
|
|
E_Config_Dialog_Data *cfdata = NULL;
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2008-04-17 23:23:21 -07:00
|
|
|
if (!(cfdata = data)) return;
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
/* Unselect all in avail list & disable button */
|
|
|
|
e_widget_ilist_unselect(cfdata->l_avail);
|
2007-08-15 06:51:00 -07:00
|
|
|
e_widget_disabled_set(cfdata->b_unload, 1);
|
2007-11-02 14:41:06 -07:00
|
|
|
e_widget_disabled_set(cfdata->b_load, 1);
|
|
|
|
|
|
|
|
/* Unselect all modules */
|
|
|
|
_unselect_all_modules();
|
|
|
|
|
|
|
|
/* Make sure something is selected */
|
|
|
|
if (e_widget_ilist_selected_count_get(cfdata->l_loaded) < 1) return;
|
2007-08-15 06:51:00 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
/* Select all modules in loaded list that user wants */
|
|
|
|
_select_all_modules(cfdata->l_loaded, cfdata);
|
|
|
|
|
|
|
|
/* Enable unload button */
|
|
|
|
e_widget_disabled_set(cfdata->b_unload, 0);
|
2007-07-15 16:39:28 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static void
|
|
|
|
_unselect_all_modules(void)
|
2007-07-15 16:39:28 -07:00
|
|
|
{
|
2007-11-02 14:41:06 -07:00
|
|
|
int i = 0;
|
2007-08-15 06:51:00 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
if (!types_hash) return;
|
2007-08-15 06:51:00 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
/* loop types, getting all modules */
|
2008-12-17 07:33:43 -08:00
|
|
|
for (i = 0; _types[i].name; i++)
|
2007-11-02 14:41:06 -07:00
|
|
|
{
|
|
|
|
CFType *cft = NULL;
|
2007-10-31 07:58:29 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
if (!_types[i].key) continue;
|
2008-12-17 07:33:43 -08:00
|
|
|
cft = eina_hash_find(types_hash, _types[i].key);
|
2007-11-02 14:41:06 -07:00
|
|
|
if ((!cft) || (!cft->modules)) continue;
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_foreach(cft->modules, _mod_hash_unselect, NULL);
|
2007-11-02 14:41:06 -07:00
|
|
|
}
|
2007-08-15 06:51:00 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_mod_hash_unselect(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__,
|
|
|
|
void *data, void *fdata __UNUSED__)
|
2007-07-15 19:15:37 -07:00
|
|
|
{
|
2007-11-02 14:41:06 -07:00
|
|
|
CFModule *mod = NULL;
|
2007-07-15 19:15:37 -07:00
|
|
|
|
2008-04-17 23:23:21 -07:00
|
|
|
if (!(mod = data)) return 1;
|
2007-11-02 14:41:06 -07:00
|
|
|
mod->selected = 0;
|
2007-08-23 02:45:30 -07:00
|
|
|
return 1;
|
2007-08-15 06:51:00 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static void
|
|
|
|
_select_all_modules(Evas_Object *obj, void *data)
|
2007-11-02 00:00:17 -07:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l = NULL;
|
2009-08-21 08:08:49 -07:00
|
|
|
E_Ilist_Item *item = NULL;
|
2007-11-02 14:41:06 -07:00
|
|
|
E_Config_Dialog_Data *cfdata = NULL;
|
2009-08-21 08:08:49 -07:00
|
|
|
int i = -1;
|
2007-11-02 00:00:17 -07:00
|
|
|
|
2008-04-17 23:23:21 -07:00
|
|
|
if (!(cfdata = data)) return;
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(e_widget_ilist_items_get(obj), l, item)
|
2007-11-02 00:00:17 -07:00
|
|
|
{
|
2007-11-02 14:41:06 -07:00
|
|
|
CFModule *mod = NULL;
|
2009-08-21 08:08:49 -07:00
|
|
|
i++;
|
2007-11-02 00:00:17 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
if ((!item) || (!item->selected)) continue;
|
2008-04-17 23:23:21 -07:00
|
|
|
if (!(mod = e_widget_ilist_nth_data_get(obj, i))) continue;
|
2007-11-02 14:41:06 -07:00
|
|
|
mod->selected = 1;
|
|
|
|
if (mod->comment)
|
|
|
|
e_widget_textblock_markup_set(cfdata->o_desc, mod->comment);
|
2007-11-02 00:00:17 -07:00
|
|
|
else
|
2008-12-17 07:33:43 -08:00
|
|
|
e_widget_textblock_markup_set(cfdata->o_desc,
|
2007-11-02 14:41:06 -07:00
|
|
|
_("Description: Unavailable"));
|
2007-11-02 00:00:17 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static void
|
|
|
|
_btn_cb_unload(void *data, void *data2)
|
2007-11-02 00:00:17 -07:00
|
|
|
{
|
2007-11-02 14:41:06 -07:00
|
|
|
E_Config_Dialog_Data *cfdata = NULL;
|
2008-04-17 23:23:21 -07:00
|
|
|
int sel = -1;
|
2007-11-02 14:41:06 -07:00
|
|
|
|
2008-04-17 23:23:21 -07:00
|
|
|
if (!(cfdata = data)) return;
|
|
|
|
|
|
|
|
/* get what is currently selected in the list */
|
|
|
|
sel = e_widget_ilist_selected_get(cfdata->l_loaded);
|
2007-11-02 14:41:06 -07:00
|
|
|
|
|
|
|
_enable_modules(0);
|
|
|
|
e_widget_disabled_set(cfdata->b_unload, 1);
|
|
|
|
e_widget_textblock_markup_set(cfdata->o_desc, _("Description: Unavailable"));
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
/* using a total reload here as it's simpler than parsing the list(s),
|
2008-04-17 23:23:21 -07:00
|
|
|
* finding what was selected, removing it, checking for headers, etc */
|
2007-11-02 14:41:06 -07:00
|
|
|
_fill_list(cfdata->l_avail, 0);
|
|
|
|
_fill_list(cfdata->l_loaded, 1);
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
/* move the selection down one if possible. Ilist itself will check
|
2008-04-17 23:23:21 -07:00
|
|
|
* for headers, etc, etc */
|
|
|
|
e_widget_ilist_selected_set(cfdata->l_loaded, sel);
|
2007-11-02 00:00:17 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static void
|
|
|
|
_btn_cb_load(void *data, void *data2)
|
2007-08-15 06:51:00 -07:00
|
|
|
{
|
2007-11-02 14:41:06 -07:00
|
|
|
E_Config_Dialog_Data *cfdata = NULL;
|
2008-04-17 23:23:21 -07:00
|
|
|
int sel = -1;
|
2007-10-28 00:43:46 -07:00
|
|
|
|
2008-04-17 23:23:21 -07:00
|
|
|
if (!(cfdata = data)) return;
|
|
|
|
|
|
|
|
/* get what is currently selected in the list */
|
|
|
|
sel = e_widget_ilist_selected_get(cfdata->l_avail);
|
2007-11-02 14:41:06 -07:00
|
|
|
|
|
|
|
_enable_modules(1);
|
|
|
|
e_widget_disabled_set(cfdata->b_load, 1);
|
|
|
|
e_widget_textblock_markup_set(cfdata->o_desc, _("Description: Unavailable"));
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
/* using a total reload here as it's simpler than parsing the list(s),
|
2008-04-17 23:23:21 -07:00
|
|
|
* finding what was selected, removing it, checking for headers, etc */
|
2007-11-02 14:41:06 -07:00
|
|
|
_fill_list(cfdata->l_avail, 0);
|
|
|
|
_fill_list(cfdata->l_loaded, 1);
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
/* move the selection down one if possible. Ilist itself will check
|
2008-04-17 23:23:21 -07:00
|
|
|
* for headers, etc, etc */
|
|
|
|
e_widget_ilist_selected_set(cfdata->l_avail, sel);
|
2007-08-15 06:51:00 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static void
|
|
|
|
_enable_modules(int enable)
|
2007-08-15 06:51:00 -07:00
|
|
|
{
|
2007-11-02 14:41:06 -07:00
|
|
|
if (!types_hash) return;
|
|
|
|
|
2008-10-18 08:19:39 -07:00
|
|
|
if (enable)
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_foreach(types_hash, _enable_modules_types_enable, NULL);
|
2008-10-18 08:19:39 -07:00
|
|
|
else
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_foreach(types_hash, _enable_modules_types_disable, NULL);
|
2008-10-18 08:19:39 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_enable_modules_types_enable(const Eina_Hash *hash __UNUSED__,
|
2008-10-26 13:48:44 -07:00
|
|
|
const void *key __UNUSED__, void *data,
|
2008-10-18 10:33:56 -07:00
|
|
|
void *fdata)
|
2008-10-18 08:19:39 -07:00
|
|
|
{
|
|
|
|
CFType *cft;
|
|
|
|
|
|
|
|
cft = data;
|
|
|
|
if (cft && cft->modules)
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_foreach(cft->modules, _mod_hash_load, NULL);
|
2008-10-18 08:19:39 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_enable_modules_types_disable(const Eina_Hash *hash __UNUSED__,
|
2008-10-26 13:48:44 -07:00
|
|
|
const void *key __UNUSED__, void *data,
|
2008-10-18 10:33:56 -07:00
|
|
|
void *fdata)
|
2008-10-18 08:19:39 -07:00
|
|
|
{
|
|
|
|
CFType *cft;
|
|
|
|
|
|
|
|
cft = data;
|
|
|
|
if (cft && cft->modules)
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_foreach(cft->modules, _mod_hash_unload, NULL);
|
2008-10-18 08:19:39 -07:00
|
|
|
return 1;
|
2007-08-15 06:51:00 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_mod_hash_load(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__,
|
|
|
|
void *data, void *fdata __UNUSED__)
|
2007-08-15 06:51:00 -07:00
|
|
|
{
|
2007-11-02 14:41:06 -07:00
|
|
|
CFModule *mod = NULL;
|
|
|
|
E_Module *module = NULL;
|
2007-10-28 00:43:46 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
mod = data;
|
|
|
|
if ((!mod) || (!mod->selected)) return 1;
|
|
|
|
module = e_module_find(mod->short_name);
|
|
|
|
if (!module) module = e_module_new(mod->short_name);
|
|
|
|
if (!module) return 1;
|
|
|
|
mod->enabled = e_module_enable(module);
|
|
|
|
mod->selected = 0;
|
2007-08-15 06:51:00 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_mod_hash_unload(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__,
|
|
|
|
void *data, void *fdata __UNUSED__)
|
2007-08-15 06:51:00 -07:00
|
|
|
{
|
2007-11-02 14:41:06 -07:00
|
|
|
CFModule *mod = NULL;
|
|
|
|
E_Module *module = NULL;
|
2007-10-28 00:43:46 -07:00
|
|
|
|
2007-11-02 14:41:06 -07:00
|
|
|
mod = data;
|
|
|
|
if ((!mod) || (!mod->selected)) return 1;
|
|
|
|
module = e_module_find(mod->short_name);
|
|
|
|
if (module)
|
2007-08-15 06:51:00 -07:00
|
|
|
{
|
2007-11-02 14:41:06 -07:00
|
|
|
e_module_disable(module);
|
|
|
|
e_object_del(E_OBJECT(module));
|
2007-08-15 06:51:00 -07:00
|
|
|
}
|
2007-11-02 14:41:06 -07:00
|
|
|
mod->enabled = 0;
|
|
|
|
mod->selected = 0;
|
2007-08-15 06:51:00 -07:00
|
|
|
return 1;
|
|
|
|
}
|