Compare commits

...

8 Commits

Author SHA1 Message Date
Marcel Hollerbach 595584e781 modules: update scroll stuff to the new behaviour 2015-02-27 18:14:11 +01:00
Marcel Hollerbach f4c4149fad modules: update to the new settingspanel api 2015-02-27 18:12:55 +01:00
Marcel Hollerbach c099ccc549 module config: Improved config panel
Scrolling focuses the current category in the toolbar,
toolbar is left and vertical.
2015-02-05 21:57:39 +01:00
Marcel Hollerbach 532104e905 econfigure2: fixed some issues
And a single part is not done with a frame arround it,
2015-02-05 20:31:54 +01:00
Marcel Hollerbach 350222c77a module_config: Ported to the new e_configure 2015-01-31 18:15:18 +01:00
Marcel Hollerbach f8519aa6cd Added e_configure2 2015-01-31 18:15:18 +01:00
Marcel Hollerbach 68eb5eeb5a Tweaked buildsystem 2015-01-31 18:15:18 +01:00
Marcel Hollerbach 45964a3e6c enlightenment_remote: Added a Note that not all features are available
If module msgbus is not loaded.
2015-01-31 18:15:18 +01:00
10 changed files with 885 additions and 307 deletions

View File

@ -32,6 +32,8 @@ OPTIONS:
-default-profile-get Get the default configuration profile
-default-profile-set OPT1 Set the default configuration profile to OPT1
Options in the following section are just available if the module msgbus is loaded.
-desktops-get Get the number of virtual desktops
-desktop-show OPT1 OPT2 Show the desk at position OPT1 (x) and OPT2 (y), see -desktops-get for current count.
-desktop-show-by-name OPT1 Show the desk named OPT1

View File

@ -60,6 +60,7 @@ src/bin/e_comp_x.h \
src/bin/e_config_data.h \
src/bin/e_config_dialog.h \
src/bin/e_config.h \
src/bin/e_configure2.h \
src/bin/e_configure.h \
src/bin/e_confirm_dialog.h \
src/bin/e_datastore.h \
@ -228,6 +229,7 @@ src/bin/e_config.c \
src/bin/e_config_data.c \
src/bin/e_config_dialog.c \
src/bin/e_configure.c \
src/bin/e_configure2.c \
src/bin/e_confirm_dialog.c \
src/bin/e_datastore.c \
src/bin/e_dbusmenu.c \

View File

@ -27,7 +27,7 @@ EINTERN void
e_configure_init(void)
{
e_configure_registry_category_add("extensions", 90, _("Extensions"), NULL, "preferences-extensions");
e_configure_registry_item_add("extensions/modules", 10, _("Modules"), NULL, "preferences-plugin", e_int_config_modules);
//e_configure_registry_item_add("extensions/modules", 10, _("Modules"), NULL, "preferences-plugin", e_int_config_modules);
e_configure_registry_category_add("appearance", 10, _("Look"), NULL,
"preferences-look");
e_configure_registry_item_add("appearance/comp", 120, _("Compositor"), NULL, "preferences-composite", e_int_config_comp);
@ -273,7 +273,7 @@ e_configure_registry_exists(const char *path)
static void
_e_configure_menu_module_item_cb(void *data __UNUSED__, E_Menu *m EINA_UNUSED, E_Menu_Item *mi __UNUSED__)
{
e_int_config_modules(NULL, NULL);
/* e_int_config_modules(NULL, NULL); */ //need to find a way to port the menus etc. at the end ...
}
static void

441
src/bin/e_configure2.c Normal file
View File

@ -0,0 +1,441 @@
#include "e.h"
static Eina_List *items; // list of E_Config_Panel_Item
static Evas_Object *win; // if a window is opened this one is the opened one ;)
EAPI void
e_config_panel_init()
{
/* Init standart structure of items*/
/*Init internal "config modules" )*/
e_int_config_modules_init();
}
static int
_insert_sorted_item(const void *data1, const void *data2)
{
const E_Config_Panel_Item *part1, *part2;
part1 = data1;
part2 = data2;
if (part1->priority > part2->priority)
return -1;
else
return 1;
}
EAPI void
e_config_panel_item_add(const char *path, const char *icon, const char *label, const char *help, int priority, const char *keyword)
{
E_Config_Panel_Item *it;
it = E_NEW(E_Config_Panel_Item, 1);
it->path = eina_stringshare_add(path);
it->icon = eina_stringshare_add(icon);
it->label = eina_stringshare_add(label);
it->help = eina_stringshare_add(help);
it->keywords = eina_stringshare_add(keyword);
it->priority = priority;
items = eina_list_sorted_insert(items, _insert_sorted_item, it);
}
EAPI void
e_config_panel_item_del(const char *path)
{
Eina_List *node;
E_Config_Panel_Item *it;
EINA_LIST_FOREACH(items, node, it)
{
if (!!strcmp(it->path, path)) continue;
items = eina_list_remove_list(items, node);
eina_stringshare_del(it->path);
eina_stringshare_del(it->icon);
eina_stringshare_del(it->label);
eina_stringshare_del(it->help);
eina_stringshare_del(it->keywords);
free(it);
return;
}
}
static E_Config_Panel_Item*
_item_search(const char *path)
{
Eina_List *node;
E_Config_Panel_Item *val = NULL;
EINA_LIST_FOREACH(items, node, val)
{
if (!!strcmp(val->path, path)) continue;
return val;
}
ERR("Item not found");
return NULL;
}
static int
_insert_sorted_part(const void *data1, const void *data2)
{
const E_Config_Panel_Part *part1, *part2;
part1 = data1;
part2 = data2;
if (part1->priority > part2->priority)
return -1;
else
return 1;
}
/*
* If you pass NULL as free_cb, a simple free will be called on the result of create_cb (if it isnt NULL)
*
*/
EAPI void
e_config_panel_part_add(const char *path, const char *part_name, const char *title, const char *help,
int priority, const char *keywords,
E_Config_Panel_Create_Cb create_cb,
E_Config_Panel_Apply_Cb apply_cb,
E_Config_Panel_Data_Create_Cb data_cb,
E_Config_Panel_Data_Free_Cb free_cb,
void *data)
{
E_Config_Panel_Part *part = NULL;
E_Config_Panel_Item *item = NULL;
item = _item_search(path);
if (!item)
return;
part = E_NEW(E_Config_Panel_Part, 1);
part->name = eina_stringshare_add(part_name);
part->title = eina_stringshare_add(title);
part->help = eina_stringshare_add(help);
part->keywords = eina_stringshare_add(keywords);
part->priority = priority;
part->create_func = create_cb;
part->apply_func = apply_cb;
part->data_func = data_cb;
part->free_func = free_cb;
part->data = data;
item->parts = eina_list_sorted_insert(item->parts, _insert_sorted_part, part);
}
EAPI void
e_config_panel_part_changed_set(const char *path, const char *part, Eina_Bool val)
{
E_Config_Panel_Item *item;
Eina_List *node;
E_Config_Panel_Part *ppart;
item = _item_search(path);
if (!item) return;
elm_settingspane_item_changed_set(item->item, val);
EINA_LIST_FOREACH(item->parts, node, ppart)
{
if (!!strcmp(ppart->name, part)) continue;
ppart->changed = val;
return;
}
}
EAPI void
e_config_panel_part_del(const char *path, const char *part)
{
E_Config_Panel_Item *item = NULL;
Eina_List *node;
E_Config_Panel_Part *ppart = NULL;
item = _item_search(path);
if (!item)
return;
EINA_LIST_FOREACH(item->parts, node, ppart)
{
if (!!strcmp(ppart->name, part)) continue;
item->parts = eina_list_remove_list(item->parts, node);
eina_stringshare_del(ppart->name);
eina_stringshare_del(ppart->title);
eina_stringshare_del(ppart->help);
eina_stringshare_del(ppart->keywords);
free(ppart);
}
}
static void
string_path_item_split(const char *str, char **path, const char **item)
{
int len = strlen(str);
int i = 0;
char buf[PATH_MAX];
if (len < 2)
return;
for(i = len -2 ; i > 0; i--)
{
if (str[i] == '/')
break;
}
if (i == 0)
*path = NULL;
else
{
*path = calloc(i +1, sizeof(char));
memcpy(*path, str, i);
(*path)[i] = '\0';
}
*item = str+i+1;
}
static Evas_Object*
settingswidget_part_gen(Evas_Object *par, Evas_Object *content, const char *title, const char *help)
{
Evas_Object *frame, *pane, *table, *lb, *ic, *bx;
frame = elm_frame_add(par);
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_text_set(frame, title);
evas_object_show(frame);
table = elm_table_add(par);
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_content_set(frame, table);
bx = elm_box_add(frame);
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_box_horizontal_set(bx, EINA_TRUE);
evas_object_show(bx);
ic = elm_icon_add(bx);
evas_object_size_hint_align_set(ic, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_icon_standard_set(ic, "system-help");
elm_box_pack_end(bx, ic);
evas_object_show(ic);
lb = elm_label_add(bx);
elm_label_line_wrap_set(lb, ELM_WRAP_WORD);
evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_text_set(lb, help);
elm_box_pack_end(bx, lb);
evas_object_show(lb);
pane = elm_panel_add(frame);
evas_object_size_hint_align_set(pane, EVAS_HINT_FILL, 0.0);
evas_object_size_hint_weight_set(pane, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_panel_orient_set(pane, ELM_PANEL_ORIENT_TOP);
elm_panel_hidden_set(pane, EINA_TRUE);
elm_object_content_set(pane, bx);
evas_object_show(pane);
elm_table_pack(table, content, 0, 0, 1, 1);
elm_table_pack(table, pane, 0, 0, 1, 1);
return frame;
}
static Evas_Object*
content_cb(Evas_Object *par, Eo *item, void *data)
{
E_Config_Panel_Item *it;
E_Config_Panel_Part *part;
Eina_List *node;
Evas_Object *box, *res;
Eina_Bool single = EINA_FALSE;
it = data;
box = elm_box_add(par);
evas_object_size_hint_align_set(box, 0.5, 0.0);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
if (eina_list_count(it->parts) == 1)
single = EINA_TRUE;
EINA_LIST_FOREACH(it->parts, node, part)
{
Evas_Object *content, *result;
if (part->data_func)
part->cbdata = part->data_func(it->path, part->name, part->data);
if (part->create_func) //WTF - what does a part should do if there is nor create_func ?
part->tmp = content = part->create_func(it->path, part->name, par, part->cbdata, part->data);
part->realized = EINA_TRUE;
evas_object_show(content);
if (!single)
result = settingswidget_part_gen(par, content, it->label, it->help);
else
result = content;
elm_box_pack_end(box, result);
}
res = elm_scroller_add(par);
evas_object_size_hint_weight_set(res, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_content_set(res, box);
evas_object_show(res);
return res;
}
static void
reset_cb(void *data, Evas_Object *obj, void *event_info)
{
E_Config_Panel_Item *it = data;
elm_settingspane_item_recreate(it->item);
}
static void
apply_cb(void *data, Evas_Object *obj, void *event_info)
{
E_Config_Panel_Item *it = data;
E_Config_Panel_Part *part;
Eina_List *node;
EINA_LIST_FOREACH(it->parts, node, part)
{
part->apply_func(it->path, part->name, part->tmp, part->cbdata, part->data);
}
}
static void
settingswidget_fill(Evas_Object *obj)
{
Eina_Hash *table;
Eina_List *node;
E_Config_Panel_Item *it;
table = eina_hash_string_superfast_new(NULL);
EINA_LIST_FOREACH(items, node, it)
{
const char *file;
char *path;
char buf[PATH_MAX], tmp[PATH_MAX];
string_path_item_split(it->path, &path, &file);
Elm_Settingspane_Item *item = NULL;
if (path)
{
item = eina_hash_find(table, path);
if (!item)
{
ERR("This is bad, dangling category %s", it->path);
continue;
}
}
it->item = item = elm_settingspane_item_append(obj, it, it->label, it->help,
NULL, it->icon, item);
snprintf(buf, sizeof(buf), "%s", it->keywords);
if (it->parts)
{
elm_settingspane_item_attach_panel(item, content_cb, reset_cb, apply_cb);
/* assembling the keywords from every part and every item */
{
Eina_List *node, *node2;
E_Config_Panel_Part *p;
EINA_LIST_FOREACH(it->parts, node2, p)
{
/* attach keywords */
strcpy(tmp, buf);
snprintf(buf, sizeof(buf), "%s,%s", tmp, p->keywords);
}
}
elm_settingspane_item_keywords_set(item, eina_stringshare_add(buf));
}
else
eina_hash_add(table, it->path, item);
}
eina_hash_free(table);
}
static void
_e_config_panel_close(void *data, Evas_Object *obj, void *event)
{
Eina_List *node, *node2;
E_Config_Panel_Item *it;
E_Config_Panel_Part *p;
if (!win) return; /* check is needed because close cb is called twice when close button is doubleclicked */
EINA_LIST_FOREACH(items, node, it)
{
EINA_LIST_FOREACH(it->parts, node2, p)
{
if (!p->realized) continue;
if (p->free_func)
p->free_func(it->path, p->name, p->cbdata, p->data);
else if (p->cbdata)
free(p->cbdata);
p->realized = EINA_FALSE;
p->cbdata = NULL;
}
}
win = NULL;
}
EAPI void
e_config_panel_show(const char *itemname)
{
Evas_Object *settings;
E_Config_Panel_Item *item;
if (win)
{
elm_win_raise(win);
elm_win_urgent_set(win, EINA_TRUE);
return;
}
win = elm_win_util_standard_add("Settings", "E - Settings");
evas_object_smart_callback_add(win, "delete,request", _e_config_panel_close, NULL);
settings = elm_settingspane_add(win);
evas_object_size_hint_weight_set(settings, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(settings, EVAS_HINT_FILL, EVAS_HINT_FILL);
settingswidget_fill(settings);
evas_object_show(settings);
elm_win_resize_object_add(win, settings);
evas_object_resize(win, 200, 200);
evas_object_show(win);
if (!itemname) return;
item = _item_search(itemname);
if (!item) return;
elm_settingspane_item_focus(item->item);
}

132
src/bin/e_configure2.h Normal file
View File

@ -0,0 +1,132 @@
#ifndef E_CONFIGURE2_H
#define E_CONFIGURE2_H
/**
* How does this work ?:
* An Item is a "voice" in the panel tree menu
* A Panel is the whole page associated with a given Item
* A Part is single "piece" of a page
*
* Example:
* Item: "Look"
* Item: "Look/Theme"
* Part: "Look/Theme" "gtk_theme"
* Part: "Look/Theme" "icon_theme"
*
* TODO: need_save callback?
*
*/
typedef Evas_Object* (*E_Config_Panel_Create_Cb)(const char *path, const char *part, Evas_Object *parent, void *cbdata, void *data);
typedef Eina_Bool (*E_Config_Panel_Apply_Cb)(const char *path, const char *part, Evas_Object *obj, void *cbdata, void *data);
typedef void* (*E_Config_Panel_Data_Create_Cb)(const char *path, const char *part, void *data);
typedef void (*E_Config_Panel_Data_Free_Cb)(const char *path,const char *part, void *cbdata, void *data);
typedef struct
{
const char *path;
const char *icon;
const char *label;
const char *help;
const char *keywords;
int priority;
Eina_List *parts;
Elm_Settingspane_Item *item; //< if the ui is opened this is a item from the settingspane
} E_Config_Panel_Item;
typedef struct
{
const char *name;
const char *title;
const char *help;
const char *keywords;
int priority;
E_Config_Panel_Create_Cb create_func;
E_Config_Panel_Apply_Cb apply_func;
E_Config_Panel_Data_Create_Cb data_func;
E_Config_Panel_Data_Free_Cb free_func;
void *data;
void *cbdata;
Eina_Bool changed;
Eina_Bool realized;
Evas_Object *tmp;
} E_Config_Panel_Part;
/*
* Init the config panel
*/
EAPI void e_config_panel_init();
/*
* Will add a item to the configuration tree
*
* @param path
* Should be in the form:
* /someitem1/someitem2/someitem3/path
* The parent items should exists, otherwise they will not be displayed.
*
* @param icon
* Name of the icon which is displayed
*
* @param label
* Name of the item which will be displayed
*
* @param help
* The text which is displayed in the help section
*
* @param priority
* The higher the priority is the higher is the item in the list of items in a parent.
*
* @param search
* A list of eina_stringshare´s you want to add as search-key-words for the search from all items
*/
EAPI void e_config_panel_item_add(const char *path, const char *icon, const char *label, const char *help, int priority, const char *keywords);
/*
* Delete the given item
*
* @param path
* The path you have added the item
*/
EAPI void e_config_panel_item_del(const char *path);
EAPI void e_config_panel_part_add(const char *path, const char *part, const char *title, const char *help,
int priority, const char *keywords,
E_Config_Panel_Create_Cb create_cb,
E_Config_Panel_Apply_Cb apply_cb,
E_Config_Panel_Data_Create_Cb data_cb,
E_Config_Panel_Data_Free_Cb free_cb,
void *data);
/*
* Set if the part has unsaved changes (= is changed) or not
*
* @param path
* The path where to find the part
*
* @param part
* The part name of the part to change the auto changed value
*
* @param val
* The value, - EINA_FALSE = nothing changed, EINA_TRUE = something changed!!
*/
EAPI void e_config_panel_part_changed_set(const char *path, const char *part, Eina_Bool val);
/*
* Delete the given part
*
* @param path
* The path of the item you want to delete from the part
*
* @param part
* The name of the part you want to delete
*/
EAPI void e_config_panel_part_del(const char *path, const char *part);
EAPI void e_config_panel_show(const char *item); // NULL to start in the main menu
#endif

View File

@ -54,6 +54,7 @@
#include "e_pan.h"
#include "e_zoomap.h"
#include "e_dialog.h"
#include "e_configure2.h"
#include "e_configure.h"
#include "e_about.h"
#include "e_theme_about.h"

View File

@ -10,6 +10,7 @@ struct _CFModule
const char *short_name, *name, *comment;
const char *icon, *orig_path;
E_Module *module;
Elm_Object_Item *item;
Evas_Object *end;
int idx;
Eina_Bool enabled : 1;
@ -18,23 +19,14 @@ struct _CFModule
struct _CFType
{
const char *key, *name, *icon;
Elm_Object_Item *gindex, *tbitem;
Eina_Hash *modules_hash; /* just used before constructing list */
Eina_List *modules; /* sorted and ready to be used */
};
struct _E_Config_Dialog_Data
{
Evas *evas;
Evas_Object *l_modules;
Evas_Object *o_toolbar;
Evas_Object *b_load, *b_unload;
Evas_Object *o_desc;
Eina_List *types;
Ecore_Event_Handler *module_update;
struct
{
Eina_List *loaded, *unloaded;
} selected;
};
struct _CFTypes
@ -48,14 +40,14 @@ static const CFTypes _types[] =
{
#define _CFT(k, n, i) \
{sizeof(k) - 1, k, n, i}
_CFT("utils", N_("Utilities"), "modules-utils"),
_CFT("system", N_("System"), "modules-system"),
_CFT("utils", N_("Utilities"), "application-utilities"),
_CFT("system", N_("System"), "application-system"),
_CFT("look", N_("Look"), "modules-look"),
_CFT("files", N_("Files"), "modules-files"),
_CFT("files", N_("Files"), "folder"),
_CFT("launcher", N_("Launcher"), "modules-launcher"),
_CFT("core", N_("Core"), "modules-core"),
_CFT("core", N_("Core"), "e-logo"),
_CFT("mobile", N_("Mobile"), "modules-mobile"),
_CFT("settings", N_("Settings"), "modules-settings"),
_CFT("settings", N_("Settings"), "application-desktop"),
#undef _CFT
{0, NULL, NULL, NULL}
};
@ -63,46 +55,33 @@ static const CFTypes _types[] =
/* local function protos */
static void _cftype_free(CFType *cft);
static void _widget_list_selection_changed(void *data, Evas_Object *obj __UNUSED__);
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_cat_list(E_Config_Dialog_Data *cfdata);
static void _module_end_state_apply(CFModule *cfm);
static void _toolbar_select_cb(void *data, void *data2);
static CFType *_cftype_find(E_Config_Dialog_Data *cfdata, const char *key, const char *name, const char *icon);
static CFType *_cftype_new(const char *key, const char *name, const char *icon);
static void _load_module(E_Module_Desktop *md, Eina_Hash *types_hash);
static Eina_Bool _types_list_create_foreach_cb(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata);
static int _types_list_sort(const void *data1, const void *data2);
static void _btn_cb_unload(void *data, void *data2);
static void _btn_cb_load(void *data, void *data2);
static Evas_Object *e_int_config_modules_create_cb(const char *path, const char *part, Evas_Object *parent, void *cbdata, void *data);
static Eina_Bool e_int_config_modules_apply_cb(const char *path, const char *part, Evas_Object *obj, void *cbdata, void *data);
static void* e_int_config_modules_data_cb(const char *path, const char *part, void *data);
static void e_int_config_modules_free_cb(const char *path, const char *part, void *cbdata, void *data);
EAPI E_Config_Dialog *
e_int_config_modules(Evas_Object *parent EINA_UNUSED, const char *params __UNUSED__)
EAPI void
e_int_config_modules_init(void)
{
E_Config_Dialog *cfd = NULL;
E_Config_Dialog_View *v = NULL;
if (e_config_dialog_find("E", "extensions/modules")) return NULL;
v = E_NEW(E_Config_Dialog_View, 1);
v->create_cfdata = _create_data;
v->free_cfdata = _free_data;
v->basic.create_widgets = _basic_create;
cfd = e_config_dialog_new(NULL, _("Module Settings"),
"E", "extensions/modules",
"preferences-plugin", 0, v, NULL);
return cfd;
e_config_panel_item_add("modules", "preferences-plugin", _("Modules"), "Extensions to extend Enlightenments functions", 0, "modules");
e_config_panel_part_add("modules", "modules", _("Modules"), _("Mark a module as loaded to load them on startup"), 1, "extensions",
e_int_config_modules_create_cb, e_int_config_modules_apply_cb, e_int_config_modules_data_cb, e_int_config_modules_free_cb, NULL);
}
static void*
_create_data(E_Config_Dialog *cfd __UNUSED__)
e_int_config_modules_data_cb(const char *path, const char *part, void *data)
{
Eina_Hash *types_hash;
Eina_List *mods;
@ -133,16 +112,14 @@ _create_data(E_Config_Dialog *cfd __UNUSED__)
}
static void
_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
e_int_config_modules_free_cb(const char *path, const char *part, void *cbdata, void *data)
{
E_Config_Dialog_Data *cfdata = cbdata;
CFType *cft;
EINA_LIST_FREE(cfdata->types, cft)
_cftype_free(cft);
eina_list_free(cfdata->selected.loaded);
eina_list_free(cfdata->selected.unloaded);
if (cfdata->module_update) ecore_event_handler_del(cfdata->module_update);
free(cfdata);
}
@ -167,200 +144,6 @@ _module_update(E_Config_Dialog_Data *cfdata, int type __UNUSED__, E_Event_Module
return ECORE_CALLBACK_RENEW;
}
static Evas_Object *
_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
{
Evas_Coord mw, mh;
Evas_Object *of, *ol;
e_dialog_resizable_set(cfd->dia, 1);
cfdata->evas = evas_object_evas_get(cfd->dia->win);
of = e_widget_table_add(e_win_evas_win_get(evas), 0);
cfdata->o_toolbar = e_widget_toolbar_add(evas, 32 * e_scale, 32 * e_scale);
e_widget_toolbar_scrollable_set(cfdata->o_toolbar, 1);
_fill_cat_list(cfdata);
e_widget_table_object_append(of, cfdata->o_toolbar, 0, 0, 2, 1, 1, 1, 1, 0);
cfdata->l_modules = e_widget_ilist_add(evas, 32 * e_scale, 32 * e_scale, NULL);
e_widget_ilist_multi_select_set(cfdata->l_modules, EINA_TRUE);
e_widget_ilist_go(cfdata->l_modules);
e_widget_size_min_get(cfdata->l_modules, &mw, &mh);
if (mw < (200 * e_scale)) mw = 200 * e_scale;
if (mh < (100 * e_scale)) mh = 100 * e_scale;
e_widget_size_min_set(cfdata->l_modules, mw, mh);
e_widget_on_change_hook_set(cfdata->l_modules,
_widget_list_selection_changed, cfdata);
e_widget_table_object_append(of, cfdata->l_modules, 0, 1, 2, 1, 1, 1, 1, 1);
ol = e_widget_button_add(evas, _("Load"), NULL, _btn_cb_load, cfdata, NULL);
cfdata->b_load = ol;
e_widget_disabled_set(ol, 1);
e_widget_table_object_append(of, ol, 0, 2, 1, 1, 1, 1, 1, 0);
ol = e_widget_button_add(evas, _("Unload"), NULL, _btn_cb_unload, cfdata, NULL);
cfdata->b_unload = ol;
e_widget_disabled_set(ol, 1);
e_widget_table_object_append(of, ol, 1, 2, 1, 1, 1, 1, 1, 0);
ol = e_widget_textblock_add(evas);
e_widget_size_min_set(ol, (200 * e_scale), 40 * e_scale);
cfdata->o_desc = ol;
e_widget_table_object_append(of, ol, 0, 3, 2, 1, 1, 0, 1, 0);
e_dialog_resizable_set(cfd->dia, 1);
e_util_win_auto_resize_fill(cfd->dia->win);
elm_win_center(cfd->dia->win, 1, 1);
e_widget_focus_set(cfdata->o_toolbar, 1);
e_widget_toolbar_item_select(cfdata->o_toolbar, 0);
cfdata->module_update = ecore_event_handler_add(E_EVENT_MODULE_UPDATE, (Ecore_Event_Handler_Cb)_module_update, cfdata);
return of;
}
static void
_fill_cat_list(E_Config_Dialog_Data *cfdata)
{
Evas_Coord w, h;
Evas_Object *icon;
CFType *cft;
const CFTypes *itr;
evas_event_freeze(cfdata->evas);
edje_freeze();
for (itr = _types; itr->key_len > 0; itr++)
{
cft = _cftype_find(cfdata, itr->key, itr->name, itr->icon);
if (!cft)
{
WRN("CFT MISSING!!! key(%s) name(%s) icon(%s)", itr->key, itr->name, itr->icon);
continue;
}
icon = e_icon_add(cfdata->evas);
if (icon)
{
if (!e_util_icon_theme_set(icon, cft->icon))
{
evas_object_del(icon);
icon = NULL;
}
}
e_widget_toolbar_item_append(cfdata->o_toolbar, icon, _(cft->name),
_toolbar_select_cb, cfdata, cft);
}
e_widget_size_min_get(cfdata->o_toolbar, &w, &h);
e_widget_size_min_set(cfdata->o_toolbar, w, h);
edje_thaw();
evas_event_thaw(cfdata->evas);
}
static void
_list_item_append(E_Config_Dialog_Data *cfdata, CFModule *cfm)
{
Evas_Object *icon, *end;
if (!cfm->icon)
icon = NULL;
else
{
icon = e_icon_add(cfdata->evas);
if (icon)
{
if (!e_util_icon_theme_set(icon, cfm->icon))
{
if (cfm->orig_path)
{
char *dir = ecore_file_dir_get(cfm->orig_path);
char buf[PATH_MAX];
snprintf(buf, sizeof(buf), "%s/%s.edj", dir, cfm->icon);
free(dir);
e_icon_file_edje_set(icon, buf, "icon");
}
else
{
evas_object_del(icon);
icon = NULL;
}
}
}
}
end = edje_object_add(cfdata->evas);
if (end)
{
if (e_theme_edje_object_set(end, "base/theme/widgets",
"e/widgets/ilist/toggle_end"))
{
cfm->end = end;
_module_end_state_apply(cfm);
}
else
{
EINA_LOG_ERR("your theme is missing 'e/widgets/ilist/toggle_end'!");
evas_object_del(end);
end = NULL;
}
}
e_widget_ilist_append_full(cfdata->l_modules, icon, end,
cfm->name, NULL, cfm, NULL);
}
static void
_toolbar_select_cb(void *data, void *data2)
{
CFType *cft, *cft_cat;
E_Config_Dialog_Data *cfdata;
Eina_List *l_type;
Evas_Coord w, h;
cfdata = data;
cft_cat = data2;
if (!cfdata || !cft_cat) return;
eina_list_free(cfdata->selected.loaded);
eina_list_free(cfdata->selected.unloaded);
cfdata->selected.loaded = NULL;
cfdata->selected.unloaded = NULL;
e_widget_disabled_set(cfdata->b_load, EINA_TRUE);
e_widget_disabled_set(cfdata->b_unload, EINA_TRUE);
e_widget_textblock_markup_set(cfdata->o_desc, _("No modules selected."));
evas_event_freeze(evas_object_evas_get(cfdata->l_modules));
edje_freeze();
e_widget_ilist_freeze(cfdata->l_modules);
e_widget_ilist_clear(cfdata->l_modules);
EINA_LIST_FOREACH(cfdata->types, l_type, cft)
{
CFModule *cfm;
Eina_List *l_module;
if (strcmp(cft->key, cft_cat->key))
continue;
EINA_LIST_FOREACH(cft->modules, l_module, cfm)
_list_item_append(cfdata, cfm);
}
e_widget_ilist_go(cfdata->l_modules);
e_widget_size_min_get(cfdata->l_modules, &w, &h);
e_widget_size_min_set(cfdata->l_modules, w, h);
e_widget_ilist_thaw(cfdata->l_modules);
edje_thaw();
evas_event_thaw(evas_object_evas_get(cfdata->l_modules));
}
static CFModule *
_module_new(const char *short_name, const Efreet_Desktop *desk)
{
@ -552,55 +335,138 @@ _types_list_sort(const void *data1, const void *data2)
}
static void
_widget_list_selection_changed(void *data, Evas_Object *obj __UNUSED__)
_toolbar_selected_cb(void *data, Evas_Object *obj, void *event)
{
E_Config_Dialog_Data *cfdata = data;
const Eina_List *l;
const E_Ilist_Item *it;
CFModule *cfm = NULL;
const char *description;
CFType *cft = data;
cfdata->selected.loaded = eina_list_free(cfdata->selected.loaded);
cfdata->selected.unloaded = eina_list_free(cfdata->selected.unloaded);
if (evas_object_data_get(obj, "__anim")) return;
EINA_LIST_FOREACH(e_widget_ilist_selected_items_get(cfdata->l_modules), l, it)
{
cfm = e_widget_ilist_item_data_get(it);
if (cfm->enabled)
{
cfdata->selected.loaded =
eina_list_append(cfdata->selected.loaded, cfm);
e_widget_disabled_set(cfdata->b_unload, 0);
e_widget_disabled_set(cfdata->b_load, 1);
}
else
{
cfdata->selected.unloaded =
eina_list_append(cfdata->selected.unloaded, cfm);
e_widget_disabled_set(cfdata->b_load, 0);
e_widget_disabled_set(cfdata->b_unload, 1);
}
}
if ((cfm) && (eina_list_count(cfdata->selected.loaded) + eina_list_count(cfdata->selected.unloaded) == 1))
description = cfm->comment;
else if (eina_list_count(cfdata->selected.loaded) + eina_list_count(cfdata->selected.unloaded) > 1)
description = _("More than one module selected.");
else
description = _("No modules selected.");
e_widget_textblock_markup_set(cfdata->o_desc, description);
elm_genlist_item_bring_in(cft->gindex, ELM_GENLIST_ITEM_SCROLLTO_TOP);
}
static void
_btn_cb_unload(void *data, void *data2 __UNUSED__)
toolbar_item(Evas_Object *obj, CFType *cft)
{
E_Config_Dialog_Data *cfdata = data;
CFModule *cfm;
cft->tbitem = elm_toolbar_item_append(obj, cft->icon, cft->name, _toolbar_selected_cb, cft);
}
EINA_LIST_FREE(cfdata->selected.loaded, cfm)
static char *
_group_item_label_get(void *data, Evas_Object *obj, const char *part)
{
CFType *cft = data;
return strdup(cft->name);
}
static char *
_item_label_get(void *data, Evas_Object *obj, const char *part)
{
CFModule *cfm = data;
return strdup(cfm->name);
}
static Eina_Bool
_item_gen(CFModule *cfm, Evas_Object *icon)
{
if (!cfm->icon)
return EINA_FALSE;
if (!elm_icon_standard_set(icon, cfm->icon))
{
if (cfm->orig_path)
{
char *dir = ecore_file_dir_get(cfm->orig_path);
char buf[PATH_MAX];
snprintf(buf, sizeof(buf), "%s/%s.edj", dir, cfm->icon);
if (!ecore_file_exists(buf))
{
free(dir);
return EINA_FALSE;
}
else
elm_image_file_set(icon, buf, "icon");
free(dir);
return EINA_TRUE;
}
return EINA_FALSE;
}
return EINA_TRUE;
}
static Evas_Object*
_item_content_get(void *data, Evas_Object *obj, const char *part)
{
CFModule *cfm = data;
Evas_Object *icon;
if (!strcmp(part, "elm.swallow.icon"))
{
if (!cfm->icon)
icon = NULL;
else
{
icon = elm_icon_add(obj);
_item_gen(cfm, icon);
evas_object_size_hint_min_set(icon, 64, 64);
}
}
else
{
cfm->end = icon = elm_check_add(obj);
elm_object_style_set(icon, "led");
evas_object_freeze_events_set(icon, EINA_TRUE);
elm_check_state_set(icon, cfm->enabled);
//TODO delete hook!!
}
return icon;
}
static void
_list_selected(void *data, Evas_Object *obj, void *event)
{
CFModule *mod = elm_object_item_data_get(event);
Evas_Object *w = data;
Evas_Object *load = evas_object_data_get(w, "__load_btn");
Evas_Object *unload = evas_object_data_get(w, "__unload_btn");
elm_object_disabled_set(load, mod->enabled);
elm_object_disabled_set(unload, !mod->enabled);
}
static void
_load_cb(void *data, Evas_Object *obj, void *event)
{
Evas_Object *list = data;
Evas_Object *w = elm_object_parent_widget_get(list);
Evas_Object *unload = evas_object_data_get(w, "__unload_btn");
Elm_Object_Item *sel = elm_genlist_selected_item_get(list);
CFModule *cfm = elm_object_item_data_get(sel);
if (!cfm->module)
cfm->module = e_module_find(cfm->short_name);
if (!cfm->module)
cfm->module = e_module_new(cfm->short_name);
if (cfm->module)
{
e_module_enable(cfm->module);
cfm->enabled = e_module_enabled_get(cfm->module);
}
elm_check_state_set(cfm->end, EINA_TRUE);
elm_object_disabled_set(unload, EINA_FALSE);
elm_object_disabled_set(obj, EINA_TRUE);
}
static void
_unload_cb(void *data, Evas_Object *obj, void *event)
{
Evas_Object *list = data;
Evas_Object *w = elm_object_parent_widget_get(list);
Evas_Object *load = evas_object_data_get(w, "__load_btn");
Elm_Object_Item *sel = elm_genlist_selected_item_get(list);
CFModule *cfm = elm_object_item_data_get(sel);
if (!cfm->module)
cfm->module = e_module_find(cfm->short_name);
@ -610,38 +476,153 @@ _btn_cb_unload(void *data, void *data2 __UNUSED__)
cfm->enabled = e_module_enabled_get(cfm->module);
}
_module_end_state_apply(cfm);
cfdata->selected.unloaded = eina_list_append(cfdata->selected.unloaded, cfm);
}
e_widget_disabled_set(cfdata->b_unload, 1);
e_widget_disabled_set(cfdata->b_load, 0);
elm_check_state_set(cfm->end, EINA_FALSE);
elm_object_disabled_set(load, EINA_FALSE);
elm_object_disabled_set(obj, EINA_TRUE);
}
static void
_btn_cb_load(void *data, void *data2 __UNUSED__)
_list_scroll_start_cb(void *data, Evas_Object *obj, void *event)
{
evas_object_data_set(data, "__anim", (void*) 1);
}
static void
_list_scroll_stop_cb(void *data, Evas_Object *obj, void *event)
{
evas_object_data_del(data, "__anim");
}
static void
_list_scroll_cb(void *data, Evas_Object *obj, void *event)
{
int x, y, w, h;
Elm_Object_Item *it, *gi;
CFType *cft;
evas_object_geometry_get(obj, &x, &y, &w ,&h);
it = elm_genlist_at_xy_item_get(obj, x + 3, y + 3, NULL);
if(!it) return; //something went wrong ...
if (elm_genlist_item_type_get(it) == ELM_GENLIST_ITEM_GROUP)
gi = it;
else
gi = elm_genlist_item_parent_get(it);
cft = elm_object_item_data_get(gi);
elm_toolbar_item_selected_set(cft->tbitem, EINA_TRUE);
}
static Evas_Object*
e_int_config_modules_create_cb(const char *path, const char *part, Evas_Object *parent, void *cbdata, void *data)
{
Evas_Object *tab, *bx, *tb, *list, *lb, *load, *unload;
tab = elm_table_add(parent);
evas_object_size_hint_align_set(tab, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(tab, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(tab);
tb = elm_toolbar_add(parent);
elm_toolbar_select_mode_set(tb, ELM_OBJECT_SELECT_MODE_ALWAYS);
elm_toolbar_horizontal_set(tb, EINA_FALSE);
elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_NONE);
elm_toolbar_icon_order_lookup_set(tb, ELM_ICON_LOOKUP_THEME_FDO);
evas_object_size_hint_align_set(tb, 0.0, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(tb, 0.0, EVAS_HINT_EXPAND);
elm_table_pack(tab, tb, 0, 0, 1, 1);
evas_object_show(tb);
list = elm_genlist_add(parent);
evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_smart_callback_add(list, "scroll", _list_scroll_cb, tb);
evas_object_smart_callback_add(list, "scroll,anim,start", _list_scroll_start_cb, tb);
evas_object_smart_callback_add(list, "scroll,anim,stop", _list_scroll_stop_cb, tb);
evas_object_data_set(list, "__toolbar", tb);
elm_table_pack(tab, list, 1, 0, 1, 1);
evas_object_show(list);
bx = elm_box_add(parent);
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.0);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
elm_box_horizontal_set(bx, EINA_TRUE);
elm_table_pack(tab, bx, 0, 1, 2, 1);
evas_object_show(bx);
load = elm_button_add(parent);
elm_object_text_set(load, _("load"));
elm_object_disabled_set(load, EINA_TRUE);
evas_object_data_set(tab, "__load_btn", load);
evas_object_smart_callback_add(load, "clicked", _load_cb, list);
evas_object_size_hint_align_set(load, EVAS_HINT_FILL, 0.0);
evas_object_size_hint_weight_set(load, EVAS_HINT_EXPAND, 0.0);
elm_box_pack_end(bx, load);
evas_object_show(load);
unload = elm_button_add(parent);
elm_object_text_set(unload, _("unload"));
elm_object_disabled_set(unload, EINA_TRUE);
evas_object_data_set(tab, "__unload_btn", unload);
evas_object_smart_callback_add(unload, "clicked", _unload_cb, list);
evas_object_size_hint_align_set(unload, EVAS_HINT_FILL, 0.0);
evas_object_size_hint_weight_set(unload, EVAS_HINT_EXPAND, 0.0);
elm_box_pack_end(bx, unload);
evas_object_show(unload);
{
E_Config_Dialog_Data *cfdata = cbdata;
Eina_List *node;
CFType *cft;
Elm_Genlist_Item_Class *itc_group, *itc_item;
/*groupindex class*/
itc_group = elm_genlist_item_class_new();
itc_group->item_style = "group_index";
itc_group->func.text_get = _group_item_label_get;
itc_group->func.content_get = NULL;
itc_group->func.state_get = NULL;
itc_group->func.del = NULL;
itc_item = elm_genlist_item_class_new();
itc_item->item_style = "default";
itc_item->func.text_get = _item_label_get;
itc_item->func.content_get = _item_content_get;
itc_item->func.state_get = NULL;
itc_item->func.del = NULL;
EINA_LIST_FOREACH(cfdata->types, node, cft)
{
E_Config_Dialog_Data *cfdata = data;
CFModule *cfm;
Eina_List *l_module;
Elm_Object_Item *item, *it;
EINA_LIST_FREE(cfdata->selected.unloaded, cfm)
cft->gindex = item = elm_genlist_item_append(list, itc_group, cft, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
toolbar_item(tb, cft);
EINA_LIST_FOREACH(cft->modules, l_module, cfm)
{
if (!cfm->module)
cfm->module = e_module_find(cfm->short_name);
if (!cfm->module)
cfm->module = e_module_new(cfm->short_name);
cfm->item = it = elm_genlist_item_append(list, itc_item, cfm,
item, ELM_GENLIST_ITEM_NONE,
_list_selected, bx);
elm_genlist_item_tooltip_text_set(it, cfm->comment);
}
}
}
if (cfm->module)
return tab;
}
static Eina_Bool
e_int_config_modules_apply_cb(const char *path, const char *part, Evas_Object *obj, void *cbdata, void *data)
{
e_module_enable(cfm->module);
cfm->enabled = e_module_enabled_get(cfm->module);
//Nothing to do here we save things directly
}
_module_end_state_apply(cfm);
cfdata->selected.loaded = eina_list_append(cfdata->selected.loaded, cfm);
}
e_widget_disabled_set(cfdata->b_load, 1);
e_widget_disabled_set(cfdata->b_unload, 0);
}

View File

@ -4,6 +4,8 @@
#define E_INT_CONFIG_MODULES_H
EAPI E_Config_Dialog *e_int_config_modules(Evas_Object *parent, const char *params);
EAPI void e_int_config_modules_init(void);
#endif
#endif

View File

@ -1117,6 +1117,12 @@ _e_e_int_menus_conf_comp_cb(void *data EINA_UNUSED, E_Menu *m EINA_UNUSED, E_Men
e_int_config_comp(NULL, NULL);
}
static void
_e_e_int_menus_conf_cb(void *data EINA_UNUSED, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
{
e_config_panel_show(NULL);
}
static void
_e_int_menus_config_pre_cb(void *data __UNUSED__, E_Menu *m)
{
@ -1125,6 +1131,12 @@ _e_int_menus_config_pre_cb(void *data __UNUSED__, E_Menu *m)
e_menu_pre_activate_callback_set(m, NULL, NULL);
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, "Config 2");
e_util_menu_item_theme_icon_set(mi, "preferences");
e_menu_item_callback_set(mi, _e_e_int_menus_conf_cb, NULL);
l = _e_int_menus_augmentation_find("config/0");
if (l)
{

View File

@ -509,6 +509,11 @@ main(int argc, char **argv)
e_configure_init();
TS("E_Configure Init Done");
TS("E_Configure2 Init");
e_config_panel_init();
TS("E_Configure2 Init Done");
TS("E Directories Init");
/* setup directories we will be using for configurations storage etc. */
if (!_e_main_dirs_init())
@ -1666,7 +1671,7 @@ _e_main_efreet_paths_init(void)
static Eina_Bool
_e_main_modules_load_after(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
{
e_int_config_modules(NULL, NULL);
e_config_panel_show("modules");
E_FREE_FUNC(mod_init_end, ecore_event_handler_del);
return ECORE_CALLBACK_RENEW;
}