forked from enlightenment/enlightenment
big cleanup for conf_theme module: conf2 subsystem already tracks themes
also change check widget to radio SVN revision: 82719
This commit is contained in:
parent
cdbebff3ab
commit
ec6f8a06b0
|
@ -1,11 +1,6 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
|
||||
static Eio_File *eio_ls[2] = {NULL};
|
||||
static Eio_Monitor *eio_mon[2] = {NULL};
|
||||
static Eina_List *handlers = NULL;
|
||||
static Eina_List *sthemes = NULL;
|
||||
static Eina_List *themes = NULL;
|
||||
static const char *cur_theme = NULL;
|
||||
|
||||
static E_Module *conf_module = NULL;
|
||||
|
@ -42,33 +37,11 @@ _e_mod_run_theme_cb(void *data __UNUSED__, E_Menu *m, E_Menu_Item *mi __UNUSED__
|
|||
e_configure_registry_call("appearance/theme", m->zone->container, NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_init_main_cb(void *data __UNUSED__, Eio_File *handler, const char *file)
|
||||
{
|
||||
if (handler == eio_ls[0])
|
||||
themes = eina_list_append(themes, strdup(file));
|
||||
else if (handler == eio_ls[1])
|
||||
sthemes = eina_list_append(sthemes, strdup(file));
|
||||
}
|
||||
|
||||
static int
|
||||
_sort_cb(const char *a, const char *b)
|
||||
{
|
||||
const char *f1, *f2;
|
||||
|
||||
f1 = ecore_file_file_get(a);
|
||||
f2 = ecore_file_file_get(b);
|
||||
return e_util_strcasecmp(f1, f2);
|
||||
}
|
||||
|
||||
static void
|
||||
_theme_set(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
|
||||
{
|
||||
E_Action *a;
|
||||
|
||||
if (!e_util_strcmp(data, cur_theme)) return;
|
||||
|
||||
e_theme_config_set("theme", data);
|
||||
e_config_save_queue();
|
||||
|
||||
|
@ -77,35 +50,15 @@ _theme_set(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
|
|||
}
|
||||
|
||||
static void
|
||||
_init_error_cb(void *data __UNUSED__, Eio_File *handler, int error __UNUSED__)
|
||||
{
|
||||
if ((!eio_ls[0]) && (!eio_ls[1])) goto out;
|
||||
if (eio_ls[0] == handler)
|
||||
{
|
||||
eio_ls[0] = NULL;
|
||||
E_FREE_LIST(themes, free);
|
||||
}
|
||||
else
|
||||
{
|
||||
eio_ls[1] = NULL;
|
||||
E_FREE_LIST(sthemes, free);
|
||||
}
|
||||
return;
|
||||
out:
|
||||
E_FREE_LIST(themes, free);
|
||||
E_FREE_LIST(sthemes, free);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_new(char *file, E_Menu *m)
|
||||
_item_new(Eina_Stringshare *file, E_Menu *m)
|
||||
{
|
||||
E_Menu_Item *mi;
|
||||
char *name, *sfx;
|
||||
Eina_Bool used;
|
||||
|
||||
used = !e_util_strcmp(file, cur_theme);
|
||||
name = (char*)ecore_file_file_get(file);
|
||||
if (!name) return;
|
||||
used = (!e_util_strcmp(name, cur_theme));
|
||||
sfx = strrchr(name, '.');
|
||||
name = strndupa(name, sfx - name);
|
||||
mi = e_menu_item_new(m);
|
||||
|
@ -114,37 +67,11 @@ _item_new(char *file, E_Menu *m)
|
|||
e_menu_item_disabled_set(mi, 1);
|
||||
else
|
||||
e_menu_item_callback_set(mi, _theme_set, file);
|
||||
e_menu_item_check_set(mi, 1);
|
||||
e_menu_item_radio_group_set(mi, 1);
|
||||
e_menu_item_radio_set(mi, 1);
|
||||
e_menu_item_toggle_set(mi, used);
|
||||
}
|
||||
|
||||
static void
|
||||
_init_done_cb(void *data __UNUSED__, Eio_File *handler)
|
||||
{
|
||||
if ((!eio_ls[0]) && (!eio_ls[1])) goto out;
|
||||
if (eio_ls[0] == handler)
|
||||
{
|
||||
eio_ls[0] = NULL;
|
||||
themes = eina_list_sort(themes, 0, (Eina_Compare_Cb)_sort_cb);
|
||||
}
|
||||
else
|
||||
{
|
||||
eio_ls[1] = NULL;
|
||||
sthemes = eina_list_sort(sthemes, 0, (Eina_Compare_Cb)_sort_cb);
|
||||
}
|
||||
|
||||
return;
|
||||
out:
|
||||
E_FREE_LIST(themes, free);
|
||||
E_FREE_LIST(sthemes, free);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_eio_filter_cb(void *data __UNUSED__, Eio_File *handler __UNUSED__, const char *file)
|
||||
{
|
||||
return eina_str_has_extension(file, ".edj");
|
||||
}
|
||||
|
||||
static void
|
||||
_e_mod_menu_theme_del(void *d __UNUSED__)
|
||||
{
|
||||
|
@ -156,8 +83,8 @@ _e_mod_menu_theme_add(void *data __UNUSED__, E_Menu *m)
|
|||
{
|
||||
E_Menu_Item *mi;
|
||||
E_Config_Theme *ct;
|
||||
char *file;
|
||||
Eina_List *l;
|
||||
Eina_Stringshare *file;
|
||||
const Eina_List *themes, *sthemes, *l;
|
||||
|
||||
mi = e_menu_item_new(m);
|
||||
e_menu_item_label_set(mi, _("Theme"));
|
||||
|
@ -166,13 +93,15 @@ _e_mod_menu_theme_add(void *data __UNUSED__, E_Menu *m)
|
|||
ct = e_theme_config_get("theme");
|
||||
if (!ct) return;
|
||||
|
||||
cur_theme = ct->file;
|
||||
cur_theme = (char*)ecore_file_file_get(ct->file);
|
||||
m = e_menu_new();
|
||||
e_object_del_attach_func_set(E_OBJECT(m), _e_mod_menu_theme_del);
|
||||
e_menu_title_set(m, "Themes");
|
||||
e_menu_item_submenu_set(mi, m);
|
||||
e_object_unref(E_OBJECT(m));
|
||||
|
||||
themes = e_configure_option_util_themes_get();
|
||||
sthemes = e_configure_option_util_themes_system_get();
|
||||
EINA_LIST_FOREACH(themes, l, file)
|
||||
_item_new(file, m);
|
||||
if (themes && sthemes)
|
||||
|
@ -181,44 +110,9 @@ _e_mod_menu_theme_add(void *data __UNUSED__, E_Menu *m)
|
|||
_item_new(file, m);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_monitor_theme_rescan(void *d __UNUSED__, int type __UNUSED__, Eio_Monitor_Event *ev)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
|
||||
if (eio_mon[0] == ev->monitor)
|
||||
{
|
||||
if (eio_ls[0]) return ECORE_CALLBACK_RENEW;
|
||||
E_FREE_LIST(themes, free);
|
||||
e_user_dir_concat_static(buf, "themes");
|
||||
eio_ls[0] = eio_file_ls(buf, _eio_filter_cb, _init_main_cb, _init_done_cb, _init_error_cb, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (eio_ls[1]) return ECORE_CALLBACK_RENEW;
|
||||
E_FREE_LIST(sthemes, free);
|
||||
e_prefix_data_concat_static(buf, "data/themes");
|
||||
eio_ls[1] = eio_file_ls(buf, _eio_filter_cb, _init_main_cb, _init_done_cb, _init_error_cb, NULL);
|
||||
}
|
||||
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_monitor_error(void *d __UNUSED__, int type __UNUSED__, Eio_Monitor_Event *ev)
|
||||
{
|
||||
if (eio_mon[0] == ev->monitor)
|
||||
eio_mon[0] = NULL;
|
||||
else
|
||||
eio_mon[1] = NULL;
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
EAPI void *
|
||||
e_modapi_init(E_Module *m)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
|
||||
e_configure_registry_category_add("internal", -1, _("Internal"),
|
||||
NULL, "enlightenment/internal");
|
||||
e_configure_registry_item_add("internal/wallpaper_desk", -1, _("Wallpaper"),
|
||||
|
@ -266,18 +160,6 @@ e_modapi_init(E_Module *m)
|
|||
conf_module = m;
|
||||
e_module_delayed_set(m, 1);
|
||||
|
||||
e_user_dir_concat_static(buf, "themes");
|
||||
eio_ls[0] = eio_file_ls(buf, _eio_filter_cb, _init_main_cb, _init_done_cb, _init_error_cb, m);
|
||||
eio_mon[0] = eio_monitor_add(buf);
|
||||
e_prefix_data_concat_static(buf, "data/themes");
|
||||
eio_ls[1] = eio_file_ls(buf, _eio_filter_cb, _init_main_cb, _init_done_cb, _init_error_cb, m);
|
||||
eio_mon[1] = eio_monitor_add(buf);
|
||||
|
||||
E_LIST_HANDLER_APPEND(handlers, EIO_MONITOR_SELF_DELETED, _monitor_error, NULL);
|
||||
E_LIST_HANDLER_APPEND(handlers, EIO_MONITOR_FILE_CREATED, _monitor_theme_rescan, NULL);
|
||||
E_LIST_HANDLER_APPEND(handlers, EIO_MONITOR_FILE_DELETED, _monitor_theme_rescan, NULL);
|
||||
E_LIST_HANDLER_APPEND(handlers, EIO_MONITOR_ERROR, _monitor_error, NULL);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
|
@ -298,20 +180,6 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
|
|||
maug[1] = NULL;
|
||||
}
|
||||
|
||||
if (eio_ls[0])
|
||||
eio_file_cancel(eio_ls[0]);
|
||||
else
|
||||
E_FREE_LIST(themes, free);
|
||||
|
||||
if (eio_ls[1])
|
||||
eio_file_cancel(eio_ls[1]);
|
||||
else
|
||||
E_FREE_LIST(sthemes, free);
|
||||
if (eio_mon[0]) eio_monitor_del(eio_mon[0]);
|
||||
if (eio_mon[1]) eio_monitor_del(eio_mon[1]);
|
||||
E_FREE_LIST(handlers, ecore_event_handler_del);
|
||||
eio_ls[0] = eio_ls[1] = NULL;
|
||||
eio_mon[0] = eio_mon[1] = NULL;
|
||||
cur_theme = NULL;
|
||||
|
||||
while ((cfd = e_config_dialog_get("E", "appearance/startup")))
|
||||
|
@ -355,9 +223,3 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
|
|||
conf_module = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_save(E_Module *m __UNUSED__)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue