forked from enlightenment/enlightenment
Better Shelf Contents Dialog.
- Allows multi-select so we don't have to constently reload the shelf. - Provides descriptions for the modules just like the module dialog. SVN revision: 33342
This commit is contained in:
parent
367038c6ee
commit
af701cf3cd
|
@ -1,33 +1,33 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
#include "e.h"
|
||||
|
||||
/* PROTOTYPES - same all the time */
|
||||
static void *_create_data(E_Config_Dialog *cfd);
|
||||
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);
|
||||
/* local function protos */
|
||||
static void _e_int_gadcon_config(E_Gadcon *gc, const char *title);
|
||||
static void *_create_data(E_Config_Dialog *cfd);
|
||||
static void _fill_data(E_Config_Dialog_Data *cfdata);
|
||||
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static int _cb_mod_update(void *data, int type, void *event);
|
||||
static void _avail_list_cb_change(void *data, Evas_Object *obj);
|
||||
static void _sel_list_cb_change(void *data, Evas_Object *obj);
|
||||
static void _load_avail_gadgets(void *data);
|
||||
static void _load_sel_gadgets(void *data);
|
||||
static void _cb_add(void *data, void *data2);
|
||||
static void _cb_del(void *data, void *data2);
|
||||
static void _set_description(void *data, const char *name);
|
||||
|
||||
/* Actual config data we will be playing with while the dialog is active */
|
||||
struct _E_Config_Dialog_Data
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
E_Gadcon *gc;
|
||||
char *name_add;
|
||||
char *id_remove;
|
||||
Evas_Hash *ids;
|
||||
Evas_Object *o_add, *o_remove, *o_instances, *o_avail;
|
||||
Evas_Object *o_avail, *o_sel;
|
||||
Evas_Object *o_add, *o_del;
|
||||
Evas_Object *o_desc;
|
||||
|
||||
E_Config_Gadcon *cf_gc;
|
||||
|
||||
E_Gadcon *gc;
|
||||
Ecore_Event_Handler *hdl;
|
||||
};
|
||||
|
||||
EAPI void
|
||||
e_int_gadcon_config_shelf(E_Gadcon *gc)
|
||||
/* externals */
|
||||
EAPI void
|
||||
e_int_gadcon_config_shelf(E_Gadcon *gc)
|
||||
{
|
||||
_e_int_gadcon_config(gc, _("Shelf Contents"));
|
||||
}
|
||||
|
@ -38,281 +38,333 @@ e_int_gadcon_config_toolbar(E_Gadcon *gc)
|
|||
_e_int_gadcon_config(gc, _("Toolbar Contents"));
|
||||
}
|
||||
|
||||
/* a nice easy setup function that does the dirty work */
|
||||
/* local functions */
|
||||
static void
|
||||
_e_int_gadcon_config(E_Gadcon *gc, const char *title)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_View *v;
|
||||
|
||||
E_Container *con;
|
||||
|
||||
v = E_NEW(E_Config_Dialog_View, 1);
|
||||
if (!v) return;
|
||||
|
||||
v->create_cfdata = _create_data;
|
||||
v->free_cfdata = _free_data;
|
||||
v->basic.create_widgets = _basic_create_widgets;
|
||||
v->override_auto_apply = 1;
|
||||
con = e_container_current_get(e_manager_current_get());
|
||||
|
||||
cfd = e_config_dialog_new(e_container_current_get(e_manager_current_get()),
|
||||
title, "E", "_gadcon_config_dialog",
|
||||
"enlightenment/shelf", 0, v, gc);
|
||||
v->create_cfdata = _create_data;
|
||||
v->free_cfdata = _free_data;
|
||||
v->basic.create_widgets = _basic_create;
|
||||
|
||||
cfd = e_config_dialog_new(con, title, "E", "_gadcon_config_dialog",
|
||||
"enlightenment/shelf", 0, v, gc);
|
||||
gc->config_dialog = cfd;
|
||||
e_dialog_resizable_set(cfd->dia, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
_fill_data(E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_List *l;
|
||||
|
||||
cfdata->name_add = NULL;
|
||||
cfdata->id_remove = NULL;
|
||||
cfdata->cf_gc = cfdata->gc->cf;
|
||||
|
||||
for (l = cfdata->cf_gc->clients; l; l = l->next)
|
||||
{
|
||||
char buf[32];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%p", l->data);
|
||||
cfdata->ids = evas_hash_add(cfdata->ids, buf, l->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void *
|
||||
_create_data(E_Config_Dialog *cfd)
|
||||
_create_data(E_Config_Dialog *cfd)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
|
||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||
cfdata->gc = cfd->data;
|
||||
_fill_data(cfdata);
|
||||
// _fill_data(cfdata);
|
||||
return cfdata;
|
||||
}
|
||||
|
||||
static void
|
||||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
static void
|
||||
_fill_data(E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
cfdata->gc->config_dialog = NULL;
|
||||
evas_hash_free(cfdata->ids);
|
||||
if (cfdata->name_add) free(cfdata->name_add);
|
||||
if (cfdata->id_remove) free(cfdata->id_remove);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
E_Gadcon *gc = NULL;
|
||||
|
||||
if (cfdata->hdl) ecore_event_handler_del(cfdata->hdl);
|
||||
E_FREE(cfdata);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_select_client(void *data)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = data;
|
||||
e_widget_disabled_set(cfdata->o_add, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_select_client_instance(void *data)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = data;
|
||||
e_widget_disabled_set(cfdata->o_remove, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_add_instance(void *data, void *data2)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = data;
|
||||
if (!cfdata) return;
|
||||
|
||||
if (!e_gadcon_client_config_new(cfdata->gc, cfdata->name_add)) return;
|
||||
|
||||
e_gadcon_unpopulate(cfdata->gc);
|
||||
e_gadcon_populate(cfdata->gc);
|
||||
e_config_save_queue();
|
||||
|
||||
_load_selected_gadgets(cfdata);
|
||||
e_widget_ilist_selected_set(cfdata->o_instances,
|
||||
e_widget_ilist_count(cfdata->o_instances) - 1);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_remove_instance(void *data, void *data2)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
int i;
|
||||
|
||||
cfdata = data;
|
||||
i = e_widget_ilist_selected_get(cfdata->o_instances);
|
||||
|
||||
e_gadcon_client_config_del(cfdata->cf_gc,
|
||||
evas_hash_find(cfdata->ids, cfdata->id_remove));
|
||||
|
||||
_load_selected_gadgets(cfdata);
|
||||
|
||||
if (i >= evas_list_count(cfdata->cf_gc->clients))
|
||||
i = evas_list_count(cfdata->cf_gc->clients) - 1;
|
||||
|
||||
if (i < 0)
|
||||
e_widget_disabled_set(cfdata->o_remove, 1);
|
||||
else
|
||||
{
|
||||
e_widget_ilist_selected_set(cfdata->o_instances, i);
|
||||
e_widget_disabled_set(cfdata->o_remove, 0);
|
||||
}
|
||||
e_gadcon_unpopulate(cfdata->gc);
|
||||
e_gadcon_populate(cfdata->gc);
|
||||
e_config_save_queue();
|
||||
if (!(gc = cfd->data)) return;
|
||||
gc->config_dialog = NULL;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *o, *of, *ob, *oi;
|
||||
Evas_Coord wmw, wmh;
|
||||
|
||||
o = e_widget_list_add(evas, 0, 1);
|
||||
Evas_Object *o = NULL, *of = NULL;
|
||||
Evas_Object *ow = NULL;
|
||||
|
||||
o = e_widget_table_add(evas, 0);
|
||||
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);
|
||||
e_widget_min_size_get(oi, &wmw, &wmh);
|
||||
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);
|
||||
ow = e_widget_ilist_add(evas, 24, 24, NULL);
|
||||
e_widget_ilist_multi_select_set(ow, 1);
|
||||
e_widget_on_change_hook_set(ow, _avail_list_cb_change, cfdata);
|
||||
cfdata->o_avail = ow;
|
||||
_load_avail_gadgets(cfdata);
|
||||
e_widget_frametable_object_append(of, ow, 0, 0, 1, 1, 1, 1, 1, 1);
|
||||
ow = e_widget_button_add(evas, _("Add Gadget"), NULL, _cb_add, cfdata, NULL);
|
||||
e_widget_disabled_set(ow, 1);
|
||||
cfdata->o_add = ow;
|
||||
e_widget_frametable_object_append(of, ow, 0, 1, 1, 1, 1, 1, 1, 0);
|
||||
e_widget_table_object_append(o, of, 0, 0, 1, 1, 1, 1, 1, 1);
|
||||
|
||||
of = e_widget_frametable_add(evas, _("Selected Gadgets"), 0);
|
||||
oi = e_widget_ilist_add(evas, 24, 24, &(cfdata->id_remove));
|
||||
cfdata->o_instances = oi;
|
||||
_load_selected_gadgets(cfdata);
|
||||
e_widget_min_size_get(oi, &wmw, &wmh);
|
||||
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);
|
||||
ow = e_widget_ilist_add(evas, 24, 24, NULL);
|
||||
e_widget_ilist_multi_select_set(ow, 1);
|
||||
e_widget_on_change_hook_set(ow, _sel_list_cb_change, cfdata);
|
||||
cfdata->o_sel = ow;
|
||||
_load_sel_gadgets(cfdata);
|
||||
e_widget_frametable_object_append(of, ow, 0, 0, 1, 1, 1, 1, 1, 1);
|
||||
ow = e_widget_button_add(evas, _("Remove Gadget"), NULL, _cb_del, cfdata, NULL);
|
||||
e_widget_disabled_set(ow, 1);
|
||||
cfdata->o_del = ow;
|
||||
e_widget_frametable_object_append(of, ow, 0, 1, 1, 1, 1, 1, 1, 0);
|
||||
e_widget_table_object_append(o, of, 1, 0, 1, 1, 1, 1, 1, 1);
|
||||
|
||||
ow = e_widget_textblock_add(evas);
|
||||
e_widget_min_size_set(ow, 200, 70);
|
||||
e_widget_textblock_markup_set(ow, _("Description: Unavailable"));
|
||||
cfdata->o_desc = ow;
|
||||
e_widget_table_object_append(o, ow, 0, 1, 2, 1, 1, 1, 1, 0);
|
||||
|
||||
if (cfdata->hdl) ecore_event_handler_del(cfdata->hdl);
|
||||
cfdata->hdl = ecore_event_handler_add(E_EVENT_MODULE_UPDATE, _cb_mod_update, cfdata);
|
||||
|
||||
cfdata->hdl = ecore_event_handler_add(E_EVENT_MODULE_UPDATE,
|
||||
_cb_mod_update, cfdata);
|
||||
return o;
|
||||
}
|
||||
|
||||
static void
|
||||
_load_available_gadgets(void *data)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
Evas_Object *oi;
|
||||
Evas_List *l;
|
||||
Evas *evas;
|
||||
|
||||
cfdata = data;
|
||||
if (!cfdata) return;
|
||||
|
||||
oi = cfdata->o_avail;
|
||||
evas = evas_object_evas_get(oi);
|
||||
|
||||
evas_event_freeze(evas);
|
||||
edje_freeze();
|
||||
e_widget_ilist_freeze(oi);
|
||||
|
||||
e_widget_ilist_clear(oi);
|
||||
for (l = e_gadcon_provider_list(); l; l = l->next)
|
||||
{
|
||||
E_Gadcon_Client_Class *cc;
|
||||
char *label;
|
||||
Evas_Object *icon;
|
||||
|
||||
cc = l->data;
|
||||
icon = NULL;
|
||||
label = NULL;
|
||||
if (cc->func.label) label = cc->func.label();
|
||||
if (!label) label = cc->name;
|
||||
if (cc->func.icon) icon = cc->func.icon(evas);
|
||||
e_widget_ilist_append(oi, icon, label, _cb_select_client, cfdata, cc->name);
|
||||
}
|
||||
e_widget_ilist_go(oi);
|
||||
e_widget_ilist_thaw(oi);
|
||||
edje_thaw();
|
||||
evas_event_thaw(evas);
|
||||
}
|
||||
|
||||
static void
|
||||
_load_selected_gadgets(void *data)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
Evas_List *l, *l2;
|
||||
Evas_Object *oi;
|
||||
Evas *evas;
|
||||
|
||||
cfdata = data;
|
||||
if (!cfdata) return;
|
||||
|
||||
oi = cfdata->o_instances;
|
||||
evas = evas_object_evas_get(oi);
|
||||
|
||||
evas_event_freeze(evas);
|
||||
edje_freeze();
|
||||
e_widget_ilist_freeze(oi);
|
||||
|
||||
e_widget_ilist_clear(oi);
|
||||
for (l = cfdata->cf_gc->clients; l; l = l->next)
|
||||
{
|
||||
E_Config_Gadcon_Client *cf_gcc;
|
||||
char *label;
|
||||
Evas_Object *icon;
|
||||
|
||||
cf_gcc = l->data;
|
||||
for (l2 = e_gadcon_provider_list(); l2; l2 = l2->next)
|
||||
{
|
||||
E_Gadcon_Client_Class *cc;
|
||||
|
||||
cc = l2->data;
|
||||
label = NULL;
|
||||
icon = NULL;
|
||||
if ((cc->name) && (cf_gcc->name) &&
|
||||
(!strcmp(cc->name, cf_gcc->name)))
|
||||
{
|
||||
char buf[32];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%p", cf_gcc);
|
||||
if (cc->func.label) label = cc->func.label();
|
||||
if (!label) label = cc->name;
|
||||
if (cc->func.icon) icon = cc->func.icon(evas);
|
||||
e_widget_ilist_append(oi, icon, label,
|
||||
_cb_select_client_instance, cfdata, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
e_widget_ilist_go(oi);
|
||||
e_widget_ilist_thaw(oi);
|
||||
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;
|
||||
|
||||
E_Config_Dialog_Data *cfdata = NULL;
|
||||
|
||||
if (type != E_EVENT_MODULE_UPDATE) return 1;
|
||||
|
||||
cfdata = data;
|
||||
ev = event;
|
||||
if (!cfdata) return 1;
|
||||
|
||||
_load_available_gadgets(cfdata);
|
||||
_load_selected_gadgets(cfdata);
|
||||
if (!(cfdata = data)) return 1;
|
||||
_load_avail_gadgets(cfdata);
|
||||
_load_sel_gadgets(cfdata);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_avail_list_cb_change(void *data, Evas_Object *obj)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata = NULL;
|
||||
const char *name;
|
||||
int sel, count;
|
||||
|
||||
if (!(cfdata = data)) return;
|
||||
e_widget_ilist_unselect(cfdata->o_sel);
|
||||
e_widget_disabled_set(cfdata->o_del, 1);
|
||||
e_widget_disabled_set(cfdata->o_add, 0);
|
||||
count = e_widget_ilist_selected_count_get(cfdata->o_avail);
|
||||
if ((count > 1) || (count == 0))
|
||||
e_widget_textblock_markup_set(cfdata->o_desc, _("Description: Unavailable"));
|
||||
else
|
||||
{
|
||||
sel = e_widget_ilist_selected_get(cfdata->o_avail);
|
||||
name = (char *)e_widget_ilist_nth_data_get(cfdata->o_avail, sel);
|
||||
_set_description(cfdata, name);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_sel_list_cb_change(void *data, Evas_Object *obj)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata = NULL;
|
||||
const char *name;
|
||||
int sel, count;
|
||||
|
||||
if (!(cfdata = data)) return;
|
||||
e_widget_ilist_unselect(cfdata->o_avail);
|
||||
e_widget_disabled_set(cfdata->o_add, 1);
|
||||
e_widget_disabled_set(cfdata->o_del, 0);
|
||||
count = e_widget_ilist_selected_count_get(cfdata->o_sel);
|
||||
if ((count > 1) || (count == 0))
|
||||
e_widget_textblock_markup_set(cfdata->o_desc, _("Description: Unavailable"));
|
||||
else
|
||||
{
|
||||
sel = e_widget_ilist_selected_get(cfdata->o_sel);
|
||||
name = (char *)e_widget_ilist_nth_data_get(cfdata->o_sel, sel);
|
||||
_set_description(cfdata, name);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_load_avail_gadgets(void *data)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata = NULL;
|
||||
Evas_List *l = NULL;
|
||||
Evas *evas;
|
||||
int w;
|
||||
|
||||
if (!(cfdata = data)) return;
|
||||
evas = evas_object_evas_get(cfdata->o_avail);
|
||||
evas_event_freeze(evas);
|
||||
edje_freeze();
|
||||
e_widget_ilist_freeze(cfdata->o_avail);
|
||||
e_widget_ilist_clear(cfdata->o_avail);
|
||||
for (l = e_gadcon_provider_list(); l; l = l->next)
|
||||
{
|
||||
E_Gadcon_Client_Class *cc;
|
||||
Evas_Object *icon = NULL;
|
||||
char *lbl = NULL;
|
||||
|
||||
if (!(cc = l->data)) continue;
|
||||
if (cc->func.label) lbl = cc->func.label();
|
||||
if (!lbl) lbl = cc->name;
|
||||
if (cc->func.icon) icon = cc->func.icon(evas);
|
||||
e_widget_ilist_append(cfdata->o_avail, icon, lbl, NULL,
|
||||
cc->name, NULL);
|
||||
}
|
||||
e_widget_ilist_go(cfdata->o_avail);
|
||||
e_widget_min_size_get(cfdata->o_avail, &w, NULL);
|
||||
e_widget_min_size_set(cfdata->o_avail, w, 250);
|
||||
e_widget_ilist_thaw(cfdata->o_avail);
|
||||
edje_thaw();
|
||||
evas_event_thaw(evas);
|
||||
}
|
||||
|
||||
static void
|
||||
_load_sel_gadgets(void *data)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata = NULL;
|
||||
Evas_List *l = NULL, *l2 = NULL;
|
||||
Evas *evas;
|
||||
int w;
|
||||
|
||||
if (!(cfdata = data)) return;
|
||||
evas = evas_object_evas_get(cfdata->o_sel);
|
||||
evas_event_freeze(evas);
|
||||
edje_freeze();
|
||||
e_widget_ilist_freeze(cfdata->o_sel);
|
||||
e_widget_ilist_clear(cfdata->o_sel);
|
||||
for (l = cfdata->gc->cf->clients; l; l = l->next)
|
||||
{
|
||||
E_Config_Gadcon_Client *cgc;
|
||||
|
||||
if (!(cgc = l->data)) continue;
|
||||
for (l2 = e_gadcon_provider_list(); l2; l2 = l2->next)
|
||||
{
|
||||
E_Gadcon_Client_Class *gcc;
|
||||
Evas_Object *icon = NULL;
|
||||
char *lbl = NULL;
|
||||
|
||||
if (!(gcc = l2->data)) continue;
|
||||
if ((cgc->name) && (gcc->name) &&
|
||||
(!strcmp(cgc->name, gcc->name)))
|
||||
{
|
||||
if (gcc->func.label) lbl = gcc->func.label();
|
||||
if (!lbl) lbl = gcc->name;
|
||||
if (gcc->func.icon) icon = gcc->func.icon(evas);
|
||||
e_widget_ilist_append(cfdata->o_sel, icon, lbl, NULL,
|
||||
gcc->name, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
e_widget_ilist_go(cfdata->o_sel);
|
||||
e_widget_min_size_get(cfdata->o_sel, &w, NULL);
|
||||
e_widget_min_size_set(cfdata->o_sel, w, 250);
|
||||
e_widget_ilist_thaw(cfdata->o_sel);
|
||||
edje_thaw();
|
||||
evas_event_thaw(evas);
|
||||
if (l) evas_list_free(l);
|
||||
if (l2) evas_list_free(l2);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_add(void *data, void *data2)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata = NULL;
|
||||
Evas_List *l = NULL;
|
||||
int i = 0, update = 0;
|
||||
|
||||
if (!(cfdata = data)) return;
|
||||
for (i = 0, l = e_widget_ilist_items_get(cfdata->o_avail); l; l = l->next, i++)
|
||||
{
|
||||
E_Ilist_Item *item = NULL;
|
||||
const char *name = NULL;
|
||||
|
||||
if (!(item = l->data)) continue;
|
||||
if (!item->selected) continue;
|
||||
name = (char *)e_widget_ilist_nth_data_get(cfdata->o_avail, i);
|
||||
if (!name) continue;
|
||||
if (!e_gadcon_client_config_new(cfdata->gc, name)) continue;
|
||||
update = 1;
|
||||
}
|
||||
if (update)
|
||||
{
|
||||
e_gadcon_unpopulate(cfdata->gc);
|
||||
e_gadcon_populate(cfdata->gc);
|
||||
e_config_save_queue();
|
||||
|
||||
_load_sel_gadgets(cfdata);
|
||||
e_widget_ilist_selected_set(cfdata->o_sel, i);
|
||||
}
|
||||
if (l) evas_list_free(l);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_del(void *data, void *data2)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata = NULL;
|
||||
Evas_List *l = NULL, *g = NULL;
|
||||
int i = 0, update = 0;
|
||||
|
||||
if (!(cfdata = data)) return;
|
||||
for (i = 0, l = e_widget_ilist_items_get(cfdata->o_sel); l; l = l->next, i++)
|
||||
{
|
||||
E_Ilist_Item *item = NULL;
|
||||
const char *name = NULL;
|
||||
|
||||
if (!(item = l->data)) continue;
|
||||
if (!item->selected) continue;
|
||||
name = (char *)e_widget_ilist_nth_data_get(cfdata->o_sel, i);
|
||||
if (!name) continue;
|
||||
for (g = cfdata->gc->cf->clients; g; g = g->next)
|
||||
{
|
||||
E_Config_Gadcon_Client *cgc;
|
||||
|
||||
if (!(cgc = g->data)) continue;
|
||||
if (strcmp(name, cgc->name)) continue;
|
||||
e_gadcon_client_config_del(cfdata->gc->cf, cgc);
|
||||
update = 1;
|
||||
}
|
||||
}
|
||||
if (update)
|
||||
{
|
||||
e_gadcon_unpopulate(cfdata->gc);
|
||||
e_gadcon_populate(cfdata->gc);
|
||||
e_config_save_queue();
|
||||
|
||||
_load_sel_gadgets(cfdata);
|
||||
|
||||
/* we just default to selecting first one here as the user may have had
|
||||
* more than one selected */
|
||||
e_widget_ilist_selected_set(cfdata->o_sel, 0);
|
||||
}
|
||||
if (g) evas_list_free(g);
|
||||
if (l) evas_list_free(l);
|
||||
}
|
||||
|
||||
static void
|
||||
_set_description(void *data, const char *name)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata = NULL;
|
||||
E_Module *mod = NULL;
|
||||
Efreet_Desktop *desk = NULL;
|
||||
char buf[4096];
|
||||
char *tmp;
|
||||
|
||||
if (!(cfdata = data)) return;
|
||||
if (!name) return;
|
||||
if (!(mod = e_module_find(name))) return;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/module.desktop", e_module_dir_get(mod));
|
||||
if (!ecore_file_exists(buf)) return;
|
||||
if (!(desk = efreet_desktop_get(buf))) return;
|
||||
if (desk->comment)
|
||||
e_widget_textblock_markup_set(cfdata->o_desc, desk->comment);
|
||||
efreet_desktop_free(desk);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue