forked from enlightenment/enlightenment
Merge configmenu from extras with Configuration Panel module(after discussion with raster). For this, I added API to disable or enable any augmentation point from any module and later enable it again. Thanks to this merge, you can have configuration panel categories directly in main menu, replacing old items like Gadgets in that submenu. You can easily switch to old style from Advanced->Configuration Panel, if the module is disabled it is the old style of course. Also I removed configmenu from emodules when it is not needed anymore.
SVN revision: 46587
This commit is contained in:
parent
e15c3cc2ed
commit
fd63280f2e
|
@ -66,11 +66,18 @@ static void _e_int_menus_item_label_set(Efreet_Menu *entry, E_Menu_Item *mi);
|
|||
|
||||
/* local subsystem globals */
|
||||
static Eina_Hash *_e_int_menus_augmentation = NULL;
|
||||
static Eina_List *_e_int_menus_augmentation_disabled = NULL;
|
||||
|
||||
static Eina_List *
|
||||
_e_int_menus_augmentation_find(const char *key)
|
||||
{
|
||||
if (!_e_int_menus_augmentation) return NULL;
|
||||
Eina_List *l;
|
||||
char *data;
|
||||
|
||||
if (!_e_int_menus_augmentation || !key) return NULL;
|
||||
|
||||
EINA_LIST_FOREACH(_e_int_menus_augmentation_disabled, l, data)
|
||||
if (!strcmp(data, key)) return NULL;
|
||||
return eina_hash_find(_e_int_menus_augmentation, key);
|
||||
}
|
||||
|
||||
|
@ -435,6 +442,16 @@ e_int_menus_menu_augmentation_del(const char *menu, E_Int_Menu_Augmentation *mau
|
|||
free(maug);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_int_menus_menu_augmentation_point_disabled_set(const char *menu, Eina_Bool disabled)
|
||||
{
|
||||
if (!menu) return;
|
||||
if (disabled)
|
||||
_e_int_menus_augmentation_disabled = eina_list_append(_e_int_menus_augmentation_disabled, menu);
|
||||
else
|
||||
_e_int_menus_augmentation_disabled = eina_list_remove(_e_int_menus_augmentation_disabled, menu);
|
||||
}
|
||||
|
||||
/* local subsystem functions */
|
||||
static void
|
||||
_e_int_menus_main_del_hook(void *obj)
|
||||
|
@ -778,8 +795,11 @@ _e_int_menus_config_pre_cb(void *data, E_Menu *m)
|
|||
if (l)
|
||||
{
|
||||
_e_int_menus_augmentation_add(m, l);
|
||||
mi = e_menu_item_new(m);
|
||||
e_menu_item_separator_set(mi, 1);
|
||||
if (_e_int_menus_augmentation_find("config/1"))
|
||||
{
|
||||
mi = e_menu_item_new(m);
|
||||
e_menu_item_separator_set(mi, 1);
|
||||
}
|
||||
}
|
||||
|
||||
l = _e_int_menus_augmentation_find("config/1");
|
||||
|
@ -1324,6 +1344,12 @@ _e_int_menus_augmentation_add(E_Menu *m, Eina_List *augmentation)
|
|||
{
|
||||
E_Int_Menu_Augmentation *aug;
|
||||
Eina_List *l;
|
||||
char *data;
|
||||
|
||||
if (!augmentation || !m) return;
|
||||
EINA_LIST_FOREACH(_e_int_menus_augmentation_disabled, l, data)
|
||||
if (eina_hash_find(_e_int_menus_augmentation, data) == augmentation)
|
||||
return;
|
||||
|
||||
EINA_LIST_FOREACH(augmentation, l, aug)
|
||||
if (aug->add.func) aug->add.func(aug->add.data, m);
|
||||
|
@ -1334,6 +1360,12 @@ _e_int_menus_augmentation_del(E_Menu *m, Eina_List *augmentation)
|
|||
{
|
||||
E_Int_Menu_Augmentation *aug;
|
||||
Eina_List *l;
|
||||
char *data;
|
||||
|
||||
if (!augmentation || !m) return;
|
||||
EINA_LIST_FOREACH(_e_int_menus_augmentation_disabled, l, data)
|
||||
if (eina_hash_find(_e_int_menus_augmentation, data) == augmentation)
|
||||
return;
|
||||
|
||||
EINA_LIST_FOREACH(augmentation, l, aug)
|
||||
if (aug->del.func) aug->del.func(aug->del.data, m);
|
||||
|
|
|
@ -60,6 +60,9 @@ EAPI E_Int_Menu_Augmentation *e_int_menus_menu_augmentation_add_sorted(const cha
|
|||
void *data_del);
|
||||
EAPI void e_int_menus_menu_augmentation_del(const char *menu,
|
||||
E_Int_Menu_Augmentation *maug);
|
||||
|
||||
EAPI void e_int_menus_menu_augmentation_point_disabled_set(const char *menu,
|
||||
Eina_Bool disabled);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -20,8 +20,9 @@ pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH
|
|||
pkg_LTLIBRARIES = module.la
|
||||
module_la_SOURCES = e_mod_main.c \
|
||||
e_mod_main.h \
|
||||
e_conf.c \
|
||||
e_conf.h
|
||||
e_conf.c \
|
||||
e_conf.h \
|
||||
e_mod_config.c
|
||||
|
||||
module_la_LIBADD = @e_libs@ @dlopen_libs@
|
||||
module_la_LDFLAGS = -module -avoid-version
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
int menu_augmentation;
|
||||
};
|
||||
|
||||
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 *
|
||||
e_int_config_conf_module(E_Container *con, const char *params)
|
||||
{
|
||||
E_Config_Dialog *cfd = NULL;
|
||||
E_Config_Dialog_View *v = NULL;
|
||||
char buf[4096];
|
||||
|
||||
/* is this config dialog already visible ? */
|
||||
if (e_config_dialog_find("Conf", "advanced/conf")) 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-conf.edj", conf->module->dir);
|
||||
cfd = e_config_dialog_new(con, _("Configuration Panel"), "Conf",
|
||||
"advanced/conf", buf, 0, v, NULL);
|
||||
|
||||
e_dialog_resizable_set(cfd->dia, 0);
|
||||
conf->cfd = cfd;
|
||||
return cfd;
|
||||
}
|
||||
|
||||
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->menu_augmentation = conf->menu_augmentation;
|
||||
}
|
||||
|
||||
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 configuration panel contents in Settings menu"),
|
||||
&(cfdata->menu_augmentation));
|
||||
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->menu_augmentation = cfdata->menu_augmentation;
|
||||
if (conf->aug)
|
||||
{
|
||||
e_int_menus_menu_augmentation_del("config/0", conf->aug);
|
||||
conf->aug = NULL;
|
||||
}
|
||||
|
||||
if (conf->menu_augmentation)
|
||||
{
|
||||
conf->aug = e_int_menus_menu_augmentation_add("config/0", e_mod_config_menu_add, NULL, NULL, NULL);
|
||||
e_int_menus_menu_augmentation_point_disabled_set("config/1", 1);
|
||||
}
|
||||
else
|
||||
e_int_menus_menu_augmentation_point_disabled_set("config/1", 0);
|
||||
|
||||
e_config_save_queue();
|
||||
return 1;
|
||||
}
|
|
@ -23,6 +23,13 @@ static Evas_Object *_gc_icon(E_Gadcon_Client_Class *client_class, Evas *evas);
|
|||
static const char *_gc_id_new(E_Gadcon_Client_Class *client_class);
|
||||
static void _cb_button_click(void *data, void *data2);
|
||||
|
||||
static void _conf_new(void);
|
||||
static void _conf_free(void);
|
||||
static int _conf_timer(void *data);
|
||||
|
||||
static E_Config_DD *conf_edd = NULL;
|
||||
Config *conf = NULL;
|
||||
|
||||
/* and actually define the gadcon class that this module provides (just 1) */
|
||||
static const E_Gadcon_Client_Class _gadcon_class =
|
||||
{
|
||||
|
@ -109,12 +116,103 @@ _cb_button_click(void *data, void *data2)
|
|||
if ((a) && (a->func.go)) a->func.go(NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_mod_run_cb(void *data, E_Menu *m, E_Menu_Item *mi)
|
||||
{
|
||||
Eina_List *l;
|
||||
char buf[1024];
|
||||
|
||||
for (l = e_configure_registry; l; l = l->next)
|
||||
{
|
||||
Eina_List *ll;
|
||||
E_Configure_Cat *ecat;
|
||||
|
||||
ecat = l->data;
|
||||
if ((ecat->pri >= 0) && (ecat->items))
|
||||
{
|
||||
for (ll = ecat->items; ll; ll = ll->next)
|
||||
{
|
||||
E_Configure_It *eci;
|
||||
char buf[1024];
|
||||
|
||||
eci = ll->data;
|
||||
if (eci->pri >= 0 && eci == data)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%s/%s", ecat->cat, eci->item);
|
||||
e_configure_registry_call(buf, m->zone->container, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_config_pre_activate_cb(void *data, E_Menu *m)
|
||||
{
|
||||
E_Configure_Cat *ecat = data;
|
||||
Eina_List *l;
|
||||
E_Menu_Item *mi;
|
||||
/*XXX is this the right way to not initiate the menu a second time ?*/
|
||||
if (e_menu_item_nth(m, 0)) return;
|
||||
|
||||
for (l = ecat->items; l; l = l->next)
|
||||
{
|
||||
E_Configure_It *eci;
|
||||
char buf[1024];
|
||||
|
||||
eci = l->data;
|
||||
if (eci->pri >= 0)
|
||||
{
|
||||
mi = e_menu_item_new(m);
|
||||
e_menu_item_label_set(mi, eci->label);
|
||||
if(eci->icon)
|
||||
e_util_menu_item_theme_icon_set(mi, eci->icon);
|
||||
|
||||
e_menu_item_callback_set(mi, _e_mod_run_cb, eci);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* menu item add hook */
|
||||
void
|
||||
e_mod_config_menu_add(void *data, E_Menu *m)
|
||||
{
|
||||
E_Menu_Item *mi;
|
||||
E_Menu *sub;
|
||||
|
||||
Eina_List *l;
|
||||
|
||||
mi = e_menu_item_new(m);
|
||||
e_menu_item_separator_set(mi, 1);
|
||||
|
||||
for (l = e_configure_registry; l; l = l->next)
|
||||
{
|
||||
Eina_List *ll;
|
||||
E_Configure_Cat *ecat;
|
||||
|
||||
ecat = l->data;
|
||||
if ((ecat->pri >= 0) && (ecat->items))
|
||||
{
|
||||
mi = e_menu_item_new(m);
|
||||
e_menu_item_label_set(mi, ecat->label);
|
||||
if(ecat->icon)
|
||||
e_util_menu_item_theme_icon_set(mi, ecat->icon);
|
||||
|
||||
sub = e_menu_new();
|
||||
e_menu_item_submenu_set(mi, sub);
|
||||
e_menu_pre_activate_callback_set(sub, _config_pre_activate_cb, ecat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* module setup */
|
||||
EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Conf" };
|
||||
|
||||
EAPI void *
|
||||
e_modapi_init(E_Module *m)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
conf_module = m;
|
||||
/* add module supplied action */
|
||||
act = e_action_add("configuration");
|
||||
|
@ -128,6 +226,71 @@ e_modapi_init(E_Module *m)
|
|||
e_int_menus_menu_augmentation_add_sorted("config/0", _("Settings Panel"),
|
||||
_e_mod_menu_add, NULL, NULL, NULL);
|
||||
e_module_delayed_set(m, 1);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/e-module-conf.edj",
|
||||
e_module_dir_get(conf_module));
|
||||
|
||||
e_configure_registry_category_add("advanced", 80, "Advanced",
|
||||
NULL, "preferences-advanced");
|
||||
e_configure_registry_item_add("advanced/conf", 110, _("Configuration Panel"),
|
||||
NULL, buf, e_int_config_conf_module);
|
||||
|
||||
conf_edd = E_CONFIG_DD_NEW("Config", Config);
|
||||
#undef T
|
||||
#undef D
|
||||
#define T Config
|
||||
#define D conf_edd
|
||||
E_CONFIG_VAL(D, T, version, INT);
|
||||
E_CONFIG_VAL(D, T, menu_augmentation, INT);
|
||||
|
||||
conf = e_config_domain_load("module.conf", conf_edd);
|
||||
if (conf)
|
||||
{
|
||||
if ((conf->version >> 16) < MOD_CONFIG_FILE_EPOCH)
|
||||
{
|
||||
_conf_free();
|
||||
ecore_timer_add(1.0, _conf_timer,
|
||||
_("Configuration Panel Module 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>"));
|
||||
}
|
||||
else if (conf->version > MOD_CONFIG_FILE_VERSION)
|
||||
{
|
||||
_conf_free();
|
||||
ecore_timer_add(1.0, _conf_timer,
|
||||
_("Your Configuration Panel 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>"));
|
||||
}
|
||||
}
|
||||
|
||||
if (!conf) _conf_new();
|
||||
conf->module = m;
|
||||
|
||||
if (conf->menu_augmentation)
|
||||
{
|
||||
conf->aug = e_int_menus_menu_augmentation_add("config/0", e_mod_config_menu_add, NULL, NULL, NULL);
|
||||
e_int_menus_menu_augmentation_point_disabled_set("config/1", 1);
|
||||
}
|
||||
else
|
||||
e_int_menus_menu_augmentation_point_disabled_set("config/1", 0);
|
||||
|
||||
e_gadcon_provider_register(&_gadcon_class);
|
||||
return m;
|
||||
}
|
||||
|
@ -136,6 +299,13 @@ EAPI int
|
|||
e_modapi_shutdown(E_Module *m)
|
||||
{
|
||||
e_configure_del();
|
||||
|
||||
e_configure_registry_item_del("advanced/conf");
|
||||
e_configure_registry_category_del("advanced");
|
||||
|
||||
if (conf->cfd) e_object_del(E_OBJECT(conf->cfd));
|
||||
conf->cfd = NULL;
|
||||
|
||||
e_gadcon_provider_unregister(&_gadcon_class);
|
||||
/* remove module-supplied menu additions */
|
||||
if (maug)
|
||||
|
@ -143,6 +313,12 @@ e_modapi_shutdown(E_Module *m)
|
|||
e_int_menus_menu_augmentation_del("config/0", maug);
|
||||
maug = NULL;
|
||||
}
|
||||
if (conf->aug)
|
||||
{
|
||||
e_int_menus_menu_augmentation_del("config/0", conf->aug);
|
||||
conf->aug = NULL;
|
||||
e_int_menus_menu_augmentation_point_disabled_set("config/1", 0);
|
||||
}
|
||||
/* remove module-supplied action */
|
||||
if (act)
|
||||
{
|
||||
|
@ -151,12 +327,17 @@ e_modapi_shutdown(E_Module *m)
|
|||
act = NULL;
|
||||
}
|
||||
conf_module = NULL;
|
||||
|
||||
E_FREE(conf);
|
||||
E_CONFIG_DD_FREE(conf_edd);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_save(E_Module *m)
|
||||
{
|
||||
e_config_domain_save("module.conf", conf_edd, conf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -257,3 +438,35 @@ _e_mod_menu_add(void *data, E_Menu *m)
|
|||
e_util_menu_item_theme_icon_set(mi, "preferences-modes");
|
||||
e_menu_item_submenu_set(mi, _e_mod_submenu_modes_get());
|
||||
}
|
||||
|
||||
static void
|
||||
_conf_new(void)
|
||||
{
|
||||
char buf[128];
|
||||
|
||||
conf = E_NEW(Config, 1);
|
||||
conf->version = (MOD_CONFIG_FILE_EPOCH << 16);
|
||||
|
||||
#define IFMODCFG(v) if ((conf->version & 0xffff) < v) {
|
||||
#define IFMODCFGEND }
|
||||
|
||||
IFMODCFG(0x008d);
|
||||
conf->menu_augmentation = 1;
|
||||
IFMODCFGEND;
|
||||
|
||||
conf->version = MOD_CONFIG_FILE_VERSION;
|
||||
e_config_save_queue();
|
||||
}
|
||||
|
||||
static void
|
||||
_conf_free(void)
|
||||
{
|
||||
E_FREE(conf);
|
||||
}
|
||||
|
||||
static int
|
||||
_conf_timer(void *data)
|
||||
{
|
||||
e_util_dialog_show(_("Configuration Panel Configuration Updated"), data);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,20 @@
|
|||
#undef E_TYPEDEFS
|
||||
#include "e_conf.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)
|
||||
|
||||
typedef struct _Config Config;
|
||||
struct _Config
|
||||
{
|
||||
E_Module *module;
|
||||
E_Config_Dialog *cfd;
|
||||
E_Int_Menu_Augmentation *aug;
|
||||
int version;
|
||||
int menu_augmentation;
|
||||
};
|
||||
|
||||
EAPI extern E_Module_Api e_modapi;
|
||||
|
||||
|
@ -17,4 +31,9 @@ EAPI void *e_modapi_init (E_Module *m);
|
|||
EAPI int e_modapi_shutdown (E_Module *m);
|
||||
EAPI int e_modapi_save (E_Module *m);
|
||||
|
||||
E_Config_Dialog *e_int_config_conf_module(E_Container *con, const char *params);
|
||||
void e_mod_config_menu_add(void *data, E_Menu *m);
|
||||
|
||||
extern Config *conf;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue