forked from enlightenment/enlightenment
Add an event for when a module gets loaded/unloaded. Event structure consits
of module name, and a bool for enabled/disabled. This allows the 'Shelf Contents' dialog to be dynamically updated when a module loads/unloads. Change Modules config dialog to use an event. SVN revision: 30839
This commit is contained in:
parent
bd51b88a80
commit
8c20c3a819
|
@ -24,6 +24,7 @@ static void _cb_load(void *data, void *data2);
|
|||
static void _cb_unload(void *data, void *data2);
|
||||
static void _cb_about(void *data, void *data2);
|
||||
static void _cb_config(void *data, void *data2);
|
||||
static int _cb_mod_update(void *data, int type, void *event);
|
||||
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
|
@ -31,6 +32,8 @@ struct _E_Config_Dialog_Data
|
|||
Evas_Object *o_all, *o_loaded;
|
||||
Evas_Object *b_load, *b_unload;
|
||||
Evas_Object *b_about, *b_configure;
|
||||
|
||||
Ecore_Event_Handler *hdl;
|
||||
};
|
||||
|
||||
static Evas_List *monitors = NULL;
|
||||
|
@ -94,6 +97,9 @@ _fill_data(E_Config_Dialog_Data *cfdata)
|
|||
static void
|
||||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
/* Remove module update event handler */
|
||||
if (cfdata->hdl) ecore_event_handler_del(cfdata->hdl);
|
||||
|
||||
/* Remove file monitors for module directories */
|
||||
if (mod_mon) ecore_file_monitor_del(mod_mon);
|
||||
if (dir_mon) ecore_file_monitor_del(dir_mon);
|
||||
|
@ -156,6 +162,12 @@ _basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
|||
e_widget_frametable_object_append(of, ob, 1, 1, 1, 1, 1, 0, 0, 0);
|
||||
|
||||
e_widget_table_object_append(o, of, 1, 0, 1, 1, 1, 1, 1, 1);
|
||||
|
||||
/* Setup Module update handler */
|
||||
if (cfdata->hdl) ecore_event_handler_del(cfdata->hdl);
|
||||
cfdata->hdl = ecore_event_handler_add(E_EVENT_MODULE_UPDATE,
|
||||
_cb_mod_update, cfdata);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
@ -512,10 +524,6 @@ _cb_load(void *data, void *data2)
|
|||
e_module_enable(mod);
|
||||
}
|
||||
if (l) evas_list_free(l);
|
||||
|
||||
/* Refill the lists */
|
||||
_fill_all(cfdata);
|
||||
_fill_loaded(cfdata);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -552,10 +560,6 @@ _cb_unload(void *data, void *data2)
|
|||
if ((mod) && (mod->enabled)) e_module_disable(mod);
|
||||
}
|
||||
if (l) evas_list_free(l);
|
||||
|
||||
/* Refill the lists */
|
||||
_fill_all(cfdata);
|
||||
_fill_loaded(cfdata);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -591,3 +595,20 @@ _cb_config(void *data, void *data2)
|
|||
if (!mod) return;
|
||||
if ((mod) && (mod->func.config)) mod->func.config(mod);
|
||||
}
|
||||
|
||||
static int
|
||||
_cb_mod_update(void *data, int type, void *event)
|
||||
{
|
||||
E_Event_Module_Update *ev;
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
if (type != E_EVENT_MODULE_UPDATE) return 1;
|
||||
|
||||
cfdata = data;
|
||||
ev = event;
|
||||
if (!cfdata) return 1;
|
||||
|
||||
_load_modules(cfdata);
|
||||
_fill_all(cfdata);
|
||||
_fill_loaded(cfdata);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
|||
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static void _load_available_gadgets(void *data);
|
||||
static void _load_selected_gadgets(void *data);
|
||||
static int _cb_mod_update(void *data, int type, void *event);
|
||||
|
||||
/* Actual config data we will be playing with whil the dialog is active */
|
||||
struct _E_Config_Dialog_Data
|
||||
|
@ -19,6 +20,8 @@ struct _E_Config_Dialog_Data
|
|||
Evas_Object *o_add, *o_remove, *o_instances, *o_avail;
|
||||
|
||||
E_Config_Gadcon *cf_gc;
|
||||
|
||||
Ecore_Event_Handler *hdl;
|
||||
};
|
||||
|
||||
/* a nice easy setup function that does the dirty work */
|
||||
|
@ -70,6 +73,7 @@ _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
cfdata->gc->config_dialog = NULL;
|
||||
if (cfdata->name_add) free(cfdata->name_add);
|
||||
if (cfdata->id_remove) free(cfdata->id_remove);
|
||||
if (cfdata->hdl) ecore_event_handler_del(cfdata->hdl);
|
||||
E_FREE(cfdata);
|
||||
}
|
||||
|
||||
|
@ -77,8 +81,8 @@ static void
|
|||
_cb_select_client(void *data)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
cfdata = data;
|
||||
|
||||
cfdata = data;
|
||||
e_widget_disabled_set(cfdata->o_add, 0);
|
||||
}
|
||||
|
||||
|
@ -86,8 +90,8 @@ static void
|
|||
_cb_select_client_instance(void *data)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
cfdata = data;
|
||||
|
||||
cfdata = data;
|
||||
e_widget_disabled_set(cfdata->o_remove, 0);
|
||||
}
|
||||
|
||||
|
@ -147,7 +151,6 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
|||
o = e_widget_list_add(evas, 0, 1);
|
||||
|
||||
of = e_widget_frametable_add(evas, _("Available Gadgets"), 0);
|
||||
|
||||
oi = e_widget_ilist_add(evas, 24, 24, &(cfdata->name_add));
|
||||
cfdata->o_avail = oi;
|
||||
_load_available_gadgets(cfdata);
|
||||
|
@ -155,12 +158,10 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
|||
if (wmw < 200) wmw = 200;
|
||||
e_widget_min_size_set(oi, wmw, 250);
|
||||
e_widget_frametable_object_append(of, oi, 0, 0, 1, 1, 1, 1, 1, 1);
|
||||
|
||||
ob = e_widget_button_add(evas, _("Add Gadget"), NULL, _cb_add_instance, cfdata, NULL);
|
||||
e_widget_disabled_set(ob, 1);
|
||||
cfdata->o_add = ob;
|
||||
e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 1, 1, 1, 0);
|
||||
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
|
||||
of = e_widget_frametable_add(evas, _("Selected Gadgets"), 0);
|
||||
|
@ -171,14 +172,15 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
|||
if (wmw < 200) wmw = 200;
|
||||
e_widget_min_size_set(oi, wmw, 250);
|
||||
e_widget_frametable_object_append(of, oi, 0, 0, 1, 1, 1, 1, 1, 1);
|
||||
|
||||
ob = e_widget_button_add(evas, _("Remove Gadget"), NULL, _cb_remove_instance, cfdata, NULL);
|
||||
e_widget_disabled_set(ob, 1);
|
||||
cfdata->o_remove = ob;
|
||||
e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 1, 1, 1, 0);
|
||||
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
|
||||
if (cfdata->hdl) ecore_event_handler_del(cfdata->hdl);
|
||||
cfdata->hdl = ecore_event_handler_add(E_EVENT_MODULE_UPDATE, _cb_mod_update, cfdata);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
@ -270,3 +272,19 @@ _load_selected_gadgets(void *data)
|
|||
edje_thaw();
|
||||
evas_event_thaw(evas);
|
||||
}
|
||||
|
||||
static int
|
||||
_cb_mod_update(void *data, int type, void *event)
|
||||
{
|
||||
E_Event_Module_Update *ev;
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
if (type != E_EVENT_MODULE_UPDATE) return 1;
|
||||
|
||||
cfdata = data;
|
||||
ev = event;
|
||||
if (!cfdata) return 1;
|
||||
|
||||
_load_available_gadgets(cfdata);
|
||||
_load_selected_gadgets(cfdata);
|
||||
}
|
||||
|
|
|
@ -14,14 +14,18 @@
|
|||
static void _e_module_free(E_Module *m);
|
||||
static void _e_module_dialog_disable_show(const char *title, const char *body, E_Module *m);
|
||||
static void _e_module_cb_dialog_disable(void *data, E_Dialog *dia);
|
||||
static void _e_module_event_update_free(void *data, void *event);
|
||||
|
||||
/* local subsystem globals */
|
||||
static Evas_List *_e_modules = NULL;
|
||||
|
||||
EAPI int E_EVENT_MODULE_UPDATE = 0;
|
||||
|
||||
/* externally accessible functions */
|
||||
EAPI int
|
||||
e_module_init(void)
|
||||
{
|
||||
E_EVENT_MODULE_UPDATE = ecore_event_type_new();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -246,6 +250,7 @@ EAPI int
|
|||
e_module_enable(E_Module *m)
|
||||
{
|
||||
Evas_List *l;
|
||||
E_Event_Module_Update *ev;
|
||||
|
||||
E_OBJECT_CHECK_RETURN(m, 0);
|
||||
E_OBJECT_TYPE_CHECK_RETURN(m, E_MODULE_TYPE, 0);
|
||||
|
@ -263,6 +268,12 @@ e_module_enable(E_Module *m)
|
|||
{
|
||||
em->enabled = 1;
|
||||
e_config_save_queue();
|
||||
|
||||
ev = E_NEW(E_Event_Module_Update, 1);
|
||||
ev->name = strdup(em->name);
|
||||
ev->enabled = 1;
|
||||
ecore_event_add(E_EVENT_MODULE_UPDATE, ev,
|
||||
_e_module_event_update_free, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -274,6 +285,7 @@ e_module_enable(E_Module *m)
|
|||
EAPI int
|
||||
e_module_disable(E_Module *m)
|
||||
{
|
||||
E_Event_Module_Update *ev;
|
||||
Evas_List *l;
|
||||
int ret;
|
||||
|
||||
|
@ -292,6 +304,12 @@ e_module_disable(E_Module *m)
|
|||
{
|
||||
em->enabled = 0;
|
||||
e_config_save_queue();
|
||||
|
||||
ev = E_NEW(E_Event_Module_Update, 1);
|
||||
ev->name = strdup(em->name);
|
||||
ev->enabled = 0;
|
||||
ecore_event_add(E_EVENT_MODULE_UPDATE, ev,
|
||||
_e_module_event_update_free, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -374,7 +392,7 @@ e_module_dialog_show(E_Module *m, const char *title, const char *body)
|
|||
if (!icon)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%s/%s.edj",
|
||||
e_module_dir_get(m), desktop->icon);
|
||||
e_module_dir_get(m), desktop->icon);
|
||||
icon = buf;
|
||||
}
|
||||
dia->icon_object = e_util_icon_add(icon, e_win_evas_get(dia->win));
|
||||
|
@ -462,3 +480,14 @@ _e_module_cb_dialog_disable(void *data, E_Dialog *dia)
|
|||
e_object_del(E_OBJECT(dia));
|
||||
e_config_save_queue();
|
||||
}
|
||||
|
||||
static void
|
||||
_e_module_event_update_free(void *data, void *event)
|
||||
{
|
||||
E_Event_Module_Update *ev;
|
||||
|
||||
ev = event;
|
||||
if (!ev) return;
|
||||
E_FREE(ev->name);
|
||||
E_FREE(ev);
|
||||
}
|
||||
|
|
|
@ -8,12 +8,22 @@
|
|||
typedef struct _E_Module E_Module;
|
||||
typedef struct _E_Module_Api E_Module_Api;
|
||||
|
||||
typedef struct _E_Event_Module_Update E_Event_Module_Update;
|
||||
|
||||
#else
|
||||
#ifndef E_MODULE_H
|
||||
#define E_MODULE_H
|
||||
|
||||
#define E_MODULE_TYPE 0xE0b0100b
|
||||
|
||||
extern EAPI int E_EVENT_MODULE_UPDATE;
|
||||
|
||||
struct _E_Event_Module_Update
|
||||
{
|
||||
char *name;
|
||||
unsigned char enabled : 1;
|
||||
};
|
||||
|
||||
struct _E_Module
|
||||
{
|
||||
E_Object e_obj_inherit;
|
||||
|
|
Loading…
Reference in New Issue