Revert new gadget config dialog due to issues with adding a gadget twice to a shelf.
SVN revision: 47886
This commit is contained in:
parent
536b1c6575
commit
ab0ca94a4e
|
@ -1,57 +1,68 @@
|
||||||
#include "e.h"
|
#include "e.h"
|
||||||
|
|
||||||
|
/* local function protos */
|
||||||
|
static void _e_int_gadcon_config(E_Gadcon *gc, const char *title, void *(*data_func)(E_Config_Dialog*));
|
||||||
|
static void *_create_data(E_Config_Dialog *cfd);
|
||||||
|
static void *_create_data_shelf(E_Config_Dialog *cfd);
|
||||||
|
static void *_create_data_toolbar(E_Config_Dialog *cfd);
|
||||||
|
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);
|
||||||
|
//static int _gad_list_sort(void *data1, void *data2);
|
||||||
|
|
||||||
struct _E_Config_Dialog_Data
|
struct _E_Config_Dialog_Data
|
||||||
{
|
{
|
||||||
E_Gadcon_Site site;
|
E_Gadcon_Site site;
|
||||||
|
|
||||||
|
Evas_Object *o_avail, *o_sel;
|
||||||
|
Evas_Object *o_add, *o_del;
|
||||||
|
Evas_Object *o_desc;
|
||||||
|
|
||||||
E_Gadcon *gc;
|
E_Gadcon *gc;
|
||||||
Ecore_Event_Handler *hdl;
|
Ecore_Event_Handler *hdl;
|
||||||
|
|
||||||
Evas_Object *o_list, *o_add, *o_del, *o_desc;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* local function prototypes */
|
/* externals */
|
||||||
static void _create_dialog(E_Gadcon *gc, const char *title);
|
|
||||||
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(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
|
||||||
static void _fill_gadget_list(E_Config_Dialog_Data *cfdata);
|
|
||||||
static void _cb_list_selected(void *data);
|
|
||||||
static const char *_get_comment(const char *name);
|
|
||||||
static void _cb_add(void *data, void *data2);
|
|
||||||
static void _cb_del(void *data, void *data2);
|
|
||||||
static int _cb_mod_update(void *data, int type, void *event);
|
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
e_int_gadcon_config_shelf(E_Gadcon *gc)
|
e_int_gadcon_config_shelf(E_Gadcon *gc)
|
||||||
{
|
{
|
||||||
_create_dialog(gc, _("Shelf Contents"));
|
_e_int_gadcon_config(gc, _("Shelf Contents"), _create_data_shelf);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
e_int_gadcon_config_toolbar(E_Gadcon *gc)
|
e_int_gadcon_config_toolbar(E_Gadcon *gc)
|
||||||
{
|
{
|
||||||
_create_dialog(gc, _("Toolbar Contents"));
|
_e_int_gadcon_config(gc, _("Toolbar Contents"), _create_data_toolbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* local functions */
|
/* local functions */
|
||||||
static void
|
static void
|
||||||
_create_dialog(E_Gadcon *gc, const char *title)
|
_e_int_gadcon_config(E_Gadcon *gc, const char *title, void *(*data_func)(E_Config_Dialog*))
|
||||||
{
|
{
|
||||||
E_Config_Dialog *cfd;
|
E_Config_Dialog *cfd;
|
||||||
E_Config_Dialog_View *v;
|
E_Config_Dialog_View *v;
|
||||||
E_Container *con;
|
E_Container *con;
|
||||||
|
|
||||||
if (!(v = E_NEW(E_Config_Dialog_View, 1))) return;
|
v = E_NEW(E_Config_Dialog_View, 1);
|
||||||
|
if (!v) return;
|
||||||
|
|
||||||
con = e_container_current_get(e_manager_current_get());
|
con = e_container_current_get(e_manager_current_get());
|
||||||
|
|
||||||
v->create_cfdata = _create_data;
|
v->create_cfdata = data_func ? data_func : _create_data;
|
||||||
v->free_cfdata = _free_data;
|
v->free_cfdata = _free_data;
|
||||||
v->basic.create_widgets = _basic_create;
|
v->basic.create_widgets = _basic_create;
|
||||||
|
|
||||||
cfd = e_config_dialog_new(con, title, "E", "_gadcon_config_dialog",
|
cfd = e_config_dialog_new(con, title, "E", "_gadcon_config_dialog",
|
||||||
"preferences-desktop-shelf", 0, v, gc);
|
"preferences-desktop-shelf", 0, v, gc);
|
||||||
gc->config_dialog = cfd;
|
gc->config_dialog = cfd;
|
||||||
e_dialog_resizable_set(cfd->dia, EINA_TRUE);
|
e_dialog_resizable_set(cfd->dia, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
|
@ -60,20 +71,37 @@ _create_data(E_Config_Dialog *cfd)
|
||||||
E_Config_Dialog_Data *cfdata;
|
E_Config_Dialog_Data *cfdata;
|
||||||
|
|
||||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||||
|
cfdata->site = E_GADCON_SITE_UNKNOWN;
|
||||||
|
cfdata->gc = cfd->data;
|
||||||
|
return cfdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
_create_data_shelf(E_Config_Dialog *cfd)
|
||||||
|
{
|
||||||
|
E_Config_Dialog_Data *cfdata;
|
||||||
|
|
||||||
|
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||||
|
cfdata->site = E_GADCON_SITE_SHELF;
|
||||||
|
cfdata->gc = cfd->data;
|
||||||
|
return cfdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
_create_data_toolbar(E_Config_Dialog *cfd)
|
||||||
|
{
|
||||||
|
E_Config_Dialog_Data *cfdata;
|
||||||
|
|
||||||
|
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||||
|
cfdata->site = E_GADCON_SITE_EFM_TOOLBAR;
|
||||||
cfdata->gc = cfd->data;
|
cfdata->gc = cfd->data;
|
||||||
if (cfdata->gc->shelf)
|
|
||||||
cfdata->site = E_GADCON_SITE_SHELF;
|
|
||||||
else if (cfdata->gc->toolbar)
|
|
||||||
cfdata->site = E_GADCON_SITE_EFM_TOOLBAR;
|
|
||||||
else
|
|
||||||
cfdata->site = E_GADCON_SITE_UNKNOWN;
|
|
||||||
return cfdata;
|
return cfdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||||
{
|
{
|
||||||
E_Gadcon *gc;
|
E_Gadcon *gc = NULL;
|
||||||
|
|
||||||
if (cfdata->hdl) ecore_event_handler_del(cfdata->hdl);
|
if (cfdata->hdl) ecore_event_handler_del(cfdata->hdl);
|
||||||
E_FREE(cfdata);
|
E_FREE(cfdata);
|
||||||
|
@ -85,255 +113,302 @@ _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
_basic_create(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 *ot;
|
Evas_Object *o = NULL, *of = NULL;
|
||||||
int mw;
|
Evas_Object *ow = NULL;
|
||||||
|
|
||||||
ot = e_widget_table_add(evas, 0);
|
o = e_widget_table_add(evas, 0);
|
||||||
cfdata->o_list = e_widget_ilist_add(evas, 24, 24, NULL);
|
of = e_widget_frametable_add(evas, _("Available Gadgets"), 0);
|
||||||
e_widget_ilist_multi_select_set(cfdata->o_list, EINA_TRUE);
|
ow = e_widget_ilist_add(evas, 24, 24, NULL);
|
||||||
_fill_gadget_list(cfdata);
|
e_widget_ilist_multi_select_set(ow, 1);
|
||||||
e_widget_size_min_get(cfdata->o_list, &mw, NULL);
|
e_widget_on_change_hook_set(ow, _avail_list_cb_change, cfdata);
|
||||||
if (mw < (200 * e_scale)) mw = (200 * e_scale);
|
cfdata->o_avail = ow;
|
||||||
e_widget_size_min_set(cfdata->o_list, mw, (100 * e_scale));
|
_load_avail_gadgets(cfdata);
|
||||||
e_widget_table_object_append(ot, cfdata->o_list, 0, 0, 2, 1, 1, 1, 1, 1);
|
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);
|
||||||
|
|
||||||
cfdata->o_add =
|
of = e_widget_frametable_add(evas, _("Selected Gadgets"), 0);
|
||||||
e_widget_button_add(evas, _("Add Gadget"), NULL, _cb_add, cfdata, NULL);
|
ow = e_widget_ilist_add(evas, 24, 24, NULL);
|
||||||
e_widget_disabled_set(cfdata->o_add, EINA_TRUE);
|
e_widget_ilist_multi_select_set(ow, 1);
|
||||||
e_widget_table_object_append(ot, cfdata->o_add, 0, 1, 1, 1, 1, 1, 1, 0);
|
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);
|
||||||
|
|
||||||
cfdata->o_del =
|
ow = e_widget_textblock_add(evas);
|
||||||
e_widget_button_add(evas, _("Remove Gadget"), NULL, _cb_del, cfdata, NULL);
|
e_widget_size_min_set(ow, (200 * e_scale), 70);
|
||||||
e_widget_disabled_set(cfdata->o_del, EINA_TRUE);
|
e_widget_textblock_markup_set(ow, _("Description: Unavailable"));
|
||||||
e_widget_table_object_append(ot, cfdata->o_del, 1, 1, 1, 1, 1, 1, 1, 0);
|
cfdata->o_desc = ow;
|
||||||
|
e_widget_table_object_append(o, ow, 0, 1, 2, 1, 1, 1, 1, 0);
|
||||||
cfdata->o_desc = e_widget_textblock_add(evas);
|
|
||||||
e_widget_textblock_markup_set(cfdata->o_desc,
|
|
||||||
_("Description: Unavailable"));
|
|
||||||
e_widget_size_min_set(cfdata->o_desc, mw, (70 * e_scale));
|
|
||||||
e_widget_table_object_append(ot, cfdata->o_desc, 0, 2, 2, 1, 1, 1, 1, 0);
|
|
||||||
|
|
||||||
if (cfdata->hdl) ecore_event_handler_del(cfdata->hdl);
|
if (cfdata->hdl) ecore_event_handler_del(cfdata->hdl);
|
||||||
cfdata->hdl = ecore_event_handler_add(E_EVENT_MODULE_UPDATE,
|
cfdata->hdl = ecore_event_handler_add(E_EVENT_MODULE_UPDATE,
|
||||||
_cb_mod_update, cfdata);
|
_cb_mod_update, cfdata);
|
||||||
|
return o;
|
||||||
e_win_centered_set(cfd->dia->win, EINA_TRUE);
|
|
||||||
return ot;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_fill_gadget_list(E_Config_Dialog_Data *cfdata)
|
|
||||||
{
|
|
||||||
Evas *evas;
|
|
||||||
Eina_List *l;
|
|
||||||
E_Gadcon_Site site;
|
|
||||||
E_Gadcon_Client_Class *gcc;
|
|
||||||
|
|
||||||
evas = evas_object_evas_get(cfdata->o_list);
|
|
||||||
evas_event_freeze(evas);
|
|
||||||
edje_freeze();
|
|
||||||
e_widget_ilist_freeze(cfdata->o_list);
|
|
||||||
e_widget_ilist_clear(cfdata->o_list);
|
|
||||||
|
|
||||||
EINA_LIST_FOREACH(e_gadcon_provider_list(), l, gcc)
|
|
||||||
{
|
|
||||||
Eina_List *cl;
|
|
||||||
E_Config_Gadcon_Client *cgc;
|
|
||||||
Evas_Object *end = NULL, *icon = NULL;
|
|
||||||
const char *lbl;
|
|
||||||
int found = 0;
|
|
||||||
|
|
||||||
if (!gcc) continue;
|
|
||||||
if ((gcc->func.is_site) && (!gcc->func.is_site(cfdata->site)))
|
|
||||||
continue;
|
|
||||||
if (gcc->func.label) lbl = gcc->func.label(gcc);
|
|
||||||
if (!lbl) lbl = gcc->name;
|
|
||||||
if (gcc->func.icon) icon = gcc->func.icon(gcc, evas);
|
|
||||||
|
|
||||||
end = edje_object_add(evas);
|
|
||||||
if (!e_theme_edje_object_set(end, "base/theme/widgets",
|
|
||||||
"e/widgets/ilist/toggle_end"))
|
|
||||||
{
|
|
||||||
evas_object_del(end);
|
|
||||||
end = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
EINA_LIST_FOREACH(cfdata->gc->cf->clients, cl, cgc)
|
|
||||||
{
|
|
||||||
if ((cgc->name) && (gcc->name) &&
|
|
||||||
(!strcmp(cgc->name, gcc->name)))
|
|
||||||
{
|
|
||||||
found = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (found)
|
|
||||||
{
|
|
||||||
if (end) edje_object_signal_emit(end, "e,state,checked", "e");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (end) edje_object_signal_emit(end, "e,state,unchecked", "e");
|
|
||||||
}
|
|
||||||
e_widget_ilist_append_full(cfdata->o_list, icon, end, lbl,
|
|
||||||
_cb_list_selected, cfdata, gcc->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
e_widget_ilist_go(cfdata->o_list);
|
|
||||||
e_widget_ilist_thaw(cfdata->o_list);
|
|
||||||
edje_thaw();
|
|
||||||
evas_event_thaw(evas);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_cb_list_selected(void *data)
|
|
||||||
{
|
|
||||||
E_Config_Dialog_Data *cfdata;
|
|
||||||
Eina_List *l;
|
|
||||||
const E_Ilist_Item *it;
|
|
||||||
const char *comment;
|
|
||||||
unsigned int loaded = 0, unloaded = 0;
|
|
||||||
|
|
||||||
if (!(cfdata = data)) return;
|
|
||||||
EINA_LIST_FOREACH(e_widget_ilist_items_get(cfdata->o_list), l, it)
|
|
||||||
{
|
|
||||||
E_Config_Gadcon_Client *cgc;
|
|
||||||
Eina_List *cl;
|
|
||||||
const char *name;
|
|
||||||
int found = 0;
|
|
||||||
|
|
||||||
if ((!it->selected) || (it->header)) continue;
|
|
||||||
name = e_widget_ilist_item_value_get(it);
|
|
||||||
EINA_LIST_FOREACH(cfdata->gc->cf->clients, cl, cgc)
|
|
||||||
{
|
|
||||||
if ((name) && (cgc->name) && (!strcmp(name, cgc->name)))
|
|
||||||
{
|
|
||||||
found = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (found) loaded++;
|
|
||||||
else unloaded++;
|
|
||||||
}
|
|
||||||
e_widget_disabled_set(cfdata->o_add, !unloaded);
|
|
||||||
e_widget_disabled_set(cfdata->o_del, !loaded);
|
|
||||||
|
|
||||||
if (loaded + unloaded == 1)
|
|
||||||
{
|
|
||||||
const char *name;
|
|
||||||
|
|
||||||
name = e_widget_ilist_selected_value_get(cfdata->o_list);
|
|
||||||
if (name) comment = _get_comment(name);
|
|
||||||
else comment = _("Description: Unavailable");
|
|
||||||
}
|
|
||||||
else if (loaded + unloaded > 1)
|
|
||||||
comment = _("More than one gadget selected.");
|
|
||||||
else
|
|
||||||
comment = _("No gadget selected.");
|
|
||||||
|
|
||||||
e_widget_textblock_markup_set(cfdata->o_desc, comment);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *
|
|
||||||
_get_comment(const char *name)
|
|
||||||
{
|
|
||||||
E_Module *mod;
|
|
||||||
Efreet_Desktop *desk;
|
|
||||||
const char *ret;
|
|
||||||
char buff[PATH_MAX];
|
|
||||||
|
|
||||||
if (!name) return _("Description: Unavailable");
|
|
||||||
if (!(mod = e_module_find(name))) return _("Description: Unavailable");
|
|
||||||
snprintf(buff, sizeof(buff), "%s/module.desktop", mod->dir);
|
|
||||||
if (!ecore_file_exists(buff)) return _("Description: Unavailable");
|
|
||||||
if (!(desk = efreet_desktop_new(buff)))
|
|
||||||
return _("Description: Unavailable");
|
|
||||||
if ((desk->comment) && (desk->comment[0] != '\0'))
|
|
||||||
ret = strdup(desk->comment);
|
|
||||||
efreet_desktop_free(desk);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_cb_add(void *data, void *data2)
|
|
||||||
{
|
|
||||||
E_Config_Dialog_Data *cfdata;
|
|
||||||
const E_Ilist_Item *it;
|
|
||||||
Eina_List *l;
|
|
||||||
int update = 0;
|
|
||||||
|
|
||||||
if (!(cfdata = data)) return;
|
|
||||||
EINA_LIST_FOREACH(e_widget_ilist_items_get(cfdata->o_list), l, it)
|
|
||||||
{
|
|
||||||
Evas_Object *end;
|
|
||||||
const char *name;
|
|
||||||
|
|
||||||
if ((!it->selected) || (it->header)) continue;
|
|
||||||
if (!(name = e_widget_ilist_item_value_get(it))) continue;
|
|
||||||
if (!e_gadcon_client_config_new(cfdata->gc, name)) continue;
|
|
||||||
update = 1;
|
|
||||||
if (!(end = e_widget_ilist_item_end_get(it))) continue;
|
|
||||||
edje_object_signal_emit(end, "e,state,checked", "e");
|
|
||||||
}
|
|
||||||
if (update)
|
|
||||||
{
|
|
||||||
e_gadcon_unpopulate(cfdata->gc);
|
|
||||||
e_gadcon_populate(cfdata->gc);
|
|
||||||
e_config_save_queue();
|
|
||||||
}
|
|
||||||
e_widget_ilist_unselect(cfdata->o_list);
|
|
||||||
e_widget_disabled_set(cfdata->o_add, EINA_TRUE);
|
|
||||||
e_widget_disabled_set(cfdata->o_del, EINA_TRUE);
|
|
||||||
e_widget_textblock_markup_set(cfdata->o_desc, _("No gadget selected."));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_cb_del(void *data, void *data2)
|
|
||||||
{
|
|
||||||
E_Config_Dialog_Data *cfdata;
|
|
||||||
const E_Ilist_Item *it;
|
|
||||||
Eina_List *l;
|
|
||||||
int update = 0;
|
|
||||||
|
|
||||||
if (!(cfdata = data)) return;
|
|
||||||
EINA_LIST_FOREACH(e_widget_ilist_items_get(cfdata->o_list), l, it)
|
|
||||||
{
|
|
||||||
Evas_Object *end;
|
|
||||||
const char *name;
|
|
||||||
Eina_List *cl;
|
|
||||||
E_Config_Gadcon_Client *cgc;
|
|
||||||
|
|
||||||
if ((!it->selected) || (it->header)) continue;
|
|
||||||
if (!(name = e_widget_ilist_item_value_get(it))) continue;
|
|
||||||
EINA_LIST_FOREACH(cfdata->gc->cf->clients, cl, cgc)
|
|
||||||
{
|
|
||||||
if (strcmp(name, cgc->name)) continue;
|
|
||||||
e_gadcon_client_config_del(cfdata->gc->cf, cgc);
|
|
||||||
update = 1;
|
|
||||||
if (end = e_widget_ilist_item_end_get(it))
|
|
||||||
edje_object_signal_emit(end, "e,state,unchecked", "e");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (update)
|
|
||||||
{
|
|
||||||
e_gadcon_unpopulate(cfdata->gc);
|
|
||||||
e_gadcon_populate(cfdata->gc);
|
|
||||||
e_config_save_queue();
|
|
||||||
}
|
|
||||||
e_widget_ilist_unselect(cfdata->o_list);
|
|
||||||
e_widget_disabled_set(cfdata->o_add, EINA_TRUE);
|
|
||||||
e_widget_disabled_set(cfdata->o_del, EINA_TRUE);
|
|
||||||
e_widget_textblock_markup_set(cfdata->o_desc, _("No gadget selected."));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_cb_mod_update(void *data, int type, void *event)
|
_cb_mod_update(void *data, int type, void *event)
|
||||||
{
|
{
|
||||||
E_Config_Dialog_Data *cfdata;
|
E_Config_Dialog_Data *cfdata = NULL;
|
||||||
|
|
||||||
if (type != E_EVENT_MODULE_UPDATE) return 1;
|
if (type != E_EVENT_MODULE_UPDATE) return 1;
|
||||||
if (!(cfdata = data)) return 1;
|
if (!(cfdata = data)) return 1;
|
||||||
_fill_gadget_list(cfdata);
|
_load_avail_gadgets(cfdata);
|
||||||
|
_load_sel_gadgets(cfdata);
|
||||||
return 1;
|
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;
|
||||||
|
Eina_List *l = NULL;
|
||||||
|
E_Gadcon_Client_Class *cc;
|
||||||
|
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);
|
||||||
|
// l = e_gadcon_provider_list();
|
||||||
|
// if (l) l = eina_list_sort(l, -1, _gad_list_sort);
|
||||||
|
EINA_LIST_FOREACH(e_gadcon_provider_list(), l, cc)
|
||||||
|
{
|
||||||
|
Evas_Object *icon = NULL;
|
||||||
|
const char *lbl = NULL;
|
||||||
|
|
||||||
|
if (!cc) continue;
|
||||||
|
// check the current site is allowed for this gadcon client
|
||||||
|
if ((cc->func.is_site) && (!cc->func.is_site(cfdata->site)))
|
||||||
|
continue;
|
||||||
|
if (cc->func.label) lbl = cc->func.label(cc);
|
||||||
|
if (!lbl) lbl = cc->name;
|
||||||
|
if (cc->func.icon) icon = cc->func.icon(cc, evas);
|
||||||
|
e_widget_ilist_append(cfdata->o_avail, icon, lbl, NULL,
|
||||||
|
(void *)cc->name, NULL);
|
||||||
|
}
|
||||||
|
e_widget_ilist_go(cfdata->o_avail);
|
||||||
|
e_widget_size_min_get(cfdata->o_avail, &w, NULL);
|
||||||
|
if (w < (200 * e_scale)) w = (200 * e_scale);
|
||||||
|
e_widget_size_min_set(cfdata->o_avail, w, (250 * e_scale));
|
||||||
|
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;
|
||||||
|
Eina_List *l = NULL, *l2 = NULL;
|
||||||
|
E_Config_Gadcon_Client *cgc;
|
||||||
|
E_Gadcon_Client_Class *gcc;
|
||||||
|
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);
|
||||||
|
EINA_LIST_FOREACH(cfdata->gc->cf->clients, l, cgc)
|
||||||
|
{
|
||||||
|
if (!cgc) continue;
|
||||||
|
EINA_LIST_FOREACH(e_gadcon_provider_list(), l2, gcc)
|
||||||
|
{
|
||||||
|
Evas_Object *icon = NULL;
|
||||||
|
const char *lbl = NULL;
|
||||||
|
|
||||||
|
if (!gcc) continue;
|
||||||
|
if ((cgc->name) && (gcc->name) &&
|
||||||
|
(!strcmp(cgc->name, gcc->name)))
|
||||||
|
{
|
||||||
|
if (gcc->func.label) lbl = gcc->func.label(gcc);
|
||||||
|
if (!lbl) lbl = gcc->name;
|
||||||
|
if (gcc->func.icon) icon = gcc->func.icon(gcc, evas);
|
||||||
|
e_widget_ilist_append(cfdata->o_sel, icon, lbl, NULL,
|
||||||
|
(void *)gcc->name, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
e_widget_ilist_go(cfdata->o_sel);
|
||||||
|
e_widget_size_min_get(cfdata->o_sel, &w, NULL);
|
||||||
|
if (w < (200 * e_scale)) w = (200 * e_scale);
|
||||||
|
e_widget_size_min_set(cfdata->o_sel, w, (250 * e_scale));
|
||||||
|
e_widget_ilist_thaw(cfdata->o_sel);
|
||||||
|
edje_thaw();
|
||||||
|
evas_event_thaw(evas);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_cb_add(void *data, void *data2)
|
||||||
|
{
|
||||||
|
E_Config_Dialog_Data *cfdata = NULL;
|
||||||
|
Eina_List *l = NULL;
|
||||||
|
E_Ilist_Item *item = NULL;
|
||||||
|
int i = 0, update = 0;
|
||||||
|
|
||||||
|
if (!(cfdata = data)) return;
|
||||||
|
i = -1;
|
||||||
|
EINA_LIST_FOREACH(e_widget_ilist_items_get(cfdata->o_avail), l, item)
|
||||||
|
{
|
||||||
|
const char *name = NULL;
|
||||||
|
|
||||||
|
i++;
|
||||||
|
if (!item) 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_cb_del(void *data, void *data2)
|
||||||
|
{
|
||||||
|
E_Config_Dialog_Data *cfdata = NULL;
|
||||||
|
Eina_List *l = NULL, *g = NULL;
|
||||||
|
E_Ilist_Item *item = NULL;
|
||||||
|
E_Config_Gadcon_Client *cgc;
|
||||||
|
int i = -1, update = 0;
|
||||||
|
|
||||||
|
if (!(cfdata = data)) return;
|
||||||
|
EINA_LIST_FOREACH(e_widget_ilist_items_get(cfdata->o_sel), l, item)
|
||||||
|
{
|
||||||
|
const char *name = NULL;
|
||||||
|
|
||||||
|
i++;
|
||||||
|
if (!item) continue;
|
||||||
|
if (!item->selected) continue;
|
||||||
|
name = (char *)e_widget_ilist_nth_data_get(cfdata->o_sel, i);
|
||||||
|
if (!name) continue;
|
||||||
|
EINA_LIST_FOREACH(cfdata->gc->cf->clients, g, cgc)
|
||||||
|
{
|
||||||
|
if (!cgc) continue;
|
||||||
|
if (strcmp(name, cgc->name)) continue;
|
||||||
|
e_gadcon_client_config_del(cfdata->gc->cf, cgc);
|
||||||
|
update = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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[PATH_MAX];
|
||||||
|
|
||||||
|
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_new(buf))) return;
|
||||||
|
if (desk->comment)
|
||||||
|
e_widget_textblock_markup_set(cfdata->o_desc, desk->comment);
|
||||||
|
efreet_desktop_free(desk);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME unused */
|
||||||
|
#if 0
|
||||||
|
static int
|
||||||
|
_gad_list_sort(void *data1, void *data2)
|
||||||
|
{
|
||||||
|
E_Gadcon_Client_Class *cc, *cc2;
|
||||||
|
const char *lbl1 = NULL, *lbl2 = NULL;
|
||||||
|
|
||||||
|
if (!(cc = data1)) return 1;
|
||||||
|
if (!(cc2 = data2)) return -1;
|
||||||
|
|
||||||
|
if (cc->func.label) lbl1 = cc->func.label(cc);
|
||||||
|
if (!lbl1) lbl1 = cc->name;
|
||||||
|
|
||||||
|
if (cc2->func.label) lbl2 = cc2->func.label(cc2);
|
||||||
|
if (!lbl2) lbl2 = cc2->name;
|
||||||
|
|
||||||
|
return (strcmp(lbl1, lbl2));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue