forked from enlightenment/enlightenment
e17: more work on xsettings
- app theme chooser - add option to disable 'settings daemon' SVN revision: 63615
This commit is contained in:
parent
91c299be13
commit
44fe00ffa9
|
@ -1849,6 +1849,7 @@ group "E_Config" struct {
|
|||
value "device_desktop" int: 1;
|
||||
value "device_auto_mount" int: 0;
|
||||
value "device_auto_open" int: 0;
|
||||
value "xsettings.enabled" uchar: 1;
|
||||
value "xsettings.match_e17_theme" uchar: 1;
|
||||
value "xsettings.match_e17_icon_theme" uchar: 1;
|
||||
}
|
||||
|
|
|
@ -919,10 +919,16 @@ e_config_init(void)
|
|||
E_CONFIG_VAL(D, T, deskenv.load_gnome, UCHAR);
|
||||
E_CONFIG_VAL(D, T, deskenv.load_kde, UCHAR);
|
||||
|
||||
E_CONFIG_VAL(D, T, xsettings.enabled, UCHAR);
|
||||
E_CONFIG_VAL(D, T, xsettings.match_e17_theme, UCHAR);
|
||||
E_CONFIG_VAL(D, T, xsettings.match_e17_icon_theme, UCHAR);
|
||||
E_CONFIG_VAL(D, T, xsettings.gtk_theme, STR);
|
||||
E_CONFIG_VAL(D, T, xsettings.icon_theme, STR);
|
||||
E_CONFIG_VAL(D, T, xsettings.xft_antialias, INT);
|
||||
E_CONFIG_VAL(D, T, xsettings.xft_hinting, INT);
|
||||
E_CONFIG_VAL(D, T, xsettings.xft_hint_style, STR);
|
||||
E_CONFIG_VAL(D, T, xsettings.xft_rgba, STR);
|
||||
E_CONFIG_VAL(D, T, xsettings.net_theme_name, STR);
|
||||
E_CONFIG_VAL(D, T, xsettings.net_icon_theme_name, STR);
|
||||
E_CONFIG_VAL(D, T, xsettings.gtk_font_name, STR);
|
||||
|
||||
e_config_load();
|
||||
|
||||
|
@ -1189,7 +1195,8 @@ e_config_load(void)
|
|||
COPYVAL(backlight.transition);
|
||||
IFCFGEND;
|
||||
|
||||
IFCFG(0x0144);
|
||||
IFCFG(0x0145);
|
||||
COPYVAL(xsettings.enabled);
|
||||
COPYVAL(xsettings.match_e17_theme);
|
||||
COPYVAL(xsettings.match_e17_icon_theme);
|
||||
IFCFGEND;
|
||||
|
@ -2111,9 +2118,13 @@ _e_config_free(E_Config *ecf)
|
|||
if (evr->val) eina_stringshare_del(evr->val);
|
||||
E_FREE(evr);
|
||||
}
|
||||
if (ecf->xsettings.icon_theme) eina_stringshare_del(ecf->xsettings.icon_theme);
|
||||
if (ecf->xsettings.gtk_theme) eina_stringshare_del(ecf->xsettings.gtk_theme);
|
||||
|
||||
if (ecf->xsettings.net_icon_theme_name)
|
||||
eina_stringshare_del(ecf->xsettings.net_icon_theme_name);
|
||||
if (ecf->xsettings.net_theme_name)
|
||||
eina_stringshare_del(ecf->xsettings.net_theme_name);
|
||||
if (ecf->xsettings.gtk_font_name)
|
||||
eina_stringshare_del(ecf->xsettings.gtk_font_name);
|
||||
|
||||
E_FREE(ecf);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ typedef struct _E_Event_Config_Icon_Theme E_Event_Config_Icon_Theme;
|
|||
/* increment this whenever a new set of config values are added but the users
|
||||
* config doesn't need to be wiped - simply new values need to be put in
|
||||
*/
|
||||
#define E_CONFIG_FILE_GENERATION 0x0144
|
||||
#define E_CONFIG_FILE_GENERATION 0x0145
|
||||
#define E_CONFIG_FILE_VERSION ((E_CONFIG_FILE_EPOCH << 16) | E_CONFIG_FILE_GENERATION)
|
||||
|
||||
#define E_EVAS_ENGINE_DEFAULT 0
|
||||
|
@ -362,10 +362,16 @@ struct _E_Config
|
|||
} deskenv;
|
||||
|
||||
struct {
|
||||
unsigned char match_e17_theme;
|
||||
unsigned char match_e17_icon_theme;
|
||||
const char *gtk_theme;
|
||||
const char *icon_theme;
|
||||
unsigned char enabled;
|
||||
unsigned char match_e17_theme;
|
||||
unsigned char match_e17_icon_theme;
|
||||
int xft_antialias;
|
||||
int xft_hinting;
|
||||
const char *xft_hint_style;
|
||||
const char *xft_rgba;
|
||||
const char *net_theme_name;
|
||||
const char *net_icon_theme_name;
|
||||
const char *gtk_font_name;
|
||||
} xsettings;
|
||||
};
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#define OFFSET_ADD(n) ((n + 4 - 1) & (~(4 - 1)))
|
||||
|
||||
#define DBG printf
|
||||
|
||||
typedef struct _Settings_Manger Settings_Manager;
|
||||
typedef struct _Setting Setting;
|
||||
|
||||
|
@ -36,19 +38,19 @@ struct _Setting
|
|||
unsigned long last_change;
|
||||
};
|
||||
|
||||
static void _xsettings_apply(Settings_Manager *sm);
|
||||
static void _e_xsettings_apply(Settings_Manager *sm);
|
||||
|
||||
static Ecore_X_Atom _atom_manager = 0;
|
||||
static Ecore_X_Atom _atom_xsettings = 0;
|
||||
static Eina_List *managers = NULL;
|
||||
static Eina_List *handlers = NULL;
|
||||
static Eina_List *settings = NULL;
|
||||
|
||||
static Eina_Bool running = EINA_FALSE;
|
||||
static const char _setting_icon_theme_name[] = "Net/IconThemeName";
|
||||
static const char _setting_theme_name[] = "Net/ThemeName";
|
||||
|
||||
static Ecore_X_Atom
|
||||
_xsettings_atom_screen_get(int screen_num)
|
||||
_e_xsettings_atom_screen_get(int screen_num)
|
||||
{
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), "_XSETTINGS_S%d", screen_num);
|
||||
|
@ -56,13 +58,13 @@ _xsettings_atom_screen_get(int screen_num)
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_xsettings_selection_owner_set(Settings_Manager *sm)
|
||||
_e_xsettings_selection_owner_set(Settings_Manager *sm)
|
||||
{
|
||||
Ecore_X_Atom atom;
|
||||
Ecore_X_Window cur_selection;
|
||||
Eina_Bool ret;
|
||||
|
||||
atom = _xsettings_atom_screen_get(sm->man->num);
|
||||
atom = _e_xsettings_atom_screen_get(sm->man->num);
|
||||
ecore_x_selection_owner_set(sm->selection, atom, ecore_x_current_time_get());
|
||||
ecore_x_sync();
|
||||
cur_selection = ecore_x_selection_owner_get(atom);
|
||||
|
@ -76,7 +78,7 @@ _xsettings_selection_owner_set(Settings_Manager *sm)
|
|||
}
|
||||
|
||||
static void
|
||||
_xsettings_deactivate(Settings_Manager *sm)
|
||||
_e_xsettings_deactivate(Settings_Manager *sm)
|
||||
{
|
||||
Ecore_X_Window old;
|
||||
|
||||
|
@ -84,13 +86,13 @@ _xsettings_deactivate(Settings_Manager *sm)
|
|||
|
||||
old = sm->selection;
|
||||
sm->selection = 0;
|
||||
_xsettings_selection_owner_set(sm);
|
||||
_e_xsettings_selection_owner_set(sm);
|
||||
ecore_x_sync();
|
||||
ecore_x_window_free(old);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_xsettings_activate(Settings_Manager *sm)
|
||||
_e_xsettings_activate(Settings_Manager *sm)
|
||||
{
|
||||
unsigned int visual;
|
||||
Ecore_X_Atom atom;
|
||||
|
@ -99,7 +101,7 @@ _xsettings_activate(Settings_Manager *sm)
|
|||
|
||||
if (sm->selection != 0) return 1;
|
||||
|
||||
atom = _xsettings_atom_screen_get(sm->man->num);
|
||||
atom = _e_xsettings_atom_screen_get(sm->man->num);
|
||||
old_win = ecore_x_selection_owner_get(atom);
|
||||
if (old_win != 0) return 0;
|
||||
|
||||
|
@ -107,7 +109,7 @@ _xsettings_activate(Settings_Manager *sm)
|
|||
if (sm->selection == 0)
|
||||
return 0;
|
||||
|
||||
if (!_xsettings_selection_owner_set(sm))
|
||||
if (!_e_xsettings_selection_owner_set(sm))
|
||||
{
|
||||
ecore_x_window_free(sm->selection);
|
||||
sm->selection = 0;
|
||||
|
@ -119,19 +121,19 @@ _xsettings_activate(Settings_Manager *sm)
|
|||
ecore_x_current_time_get(), atom,
|
||||
sm->selection, 0, 0);
|
||||
|
||||
_xsettings_apply(sm);
|
||||
_e_xsettings_apply(sm);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_xsettings_activate_retry(void *data)
|
||||
_e_xsettings_activate_retry(void *data)
|
||||
{
|
||||
Settings_Manager *sm = data;
|
||||
Eina_Bool ret;
|
||||
|
||||
fputs("XSETTINGS: reactivate...\n", stderr);
|
||||
ret = _xsettings_activate(sm);
|
||||
ret = _e_xsettings_activate(sm);
|
||||
if (ret)
|
||||
fputs("XSETTINGS: activate success!\n", stderr);
|
||||
else
|
||||
|
@ -146,15 +148,15 @@ _xsettings_activate_retry(void *data)
|
|||
}
|
||||
|
||||
static void
|
||||
_xsettings_retry(Settings_Manager *sm)
|
||||
_e_xsettings_retry(Settings_Manager *sm)
|
||||
{
|
||||
if (sm->timer_retry) return;
|
||||
sm->timer_retry = ecore_timer_add
|
||||
(RETRY_TIMEOUT, _xsettings_activate_retry, sm);
|
||||
(RETRY_TIMEOUT, _e_xsettings_activate_retry, sm);
|
||||
}
|
||||
|
||||
static void
|
||||
_xsettings_string_set(const char *name, const char *value)
|
||||
_e_xsettings_string_set(const char *name, const char *value)
|
||||
{
|
||||
Setting *s;
|
||||
Eina_List *l;
|
||||
|
@ -170,7 +172,7 @@ _xsettings_string_set(const char *name, const char *value)
|
|||
if (!value)
|
||||
{
|
||||
if (!s) return;
|
||||
printf("remove %s\n", name);
|
||||
DBG("remove %s\n", name);
|
||||
eina_stringshare_del(name);
|
||||
eina_stringshare_del(s->name);
|
||||
eina_stringshare_del(s->s.value);
|
||||
|
@ -180,13 +182,13 @@ _xsettings_string_set(const char *name, const char *value)
|
|||
}
|
||||
if (s)
|
||||
{
|
||||
printf("update %s %s\n", name, value);
|
||||
DBG("update %s %s\n", name, value);
|
||||
eina_stringshare_del(name);
|
||||
eina_stringshare_replace(&s->s.value, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("add %s %s\n", name, value);
|
||||
DBG("add %s %s\n", name, value);
|
||||
s = E_NEW(Setting, 1);
|
||||
s->type = SETTING_TYPE_STRING;
|
||||
s->name = name;
|
||||
|
@ -202,7 +204,7 @@ _xsettings_string_set(const char *name, const char *value)
|
|||
}
|
||||
|
||||
static void
|
||||
_xsettings_int_set(const char *name, int value)
|
||||
_e_xsettings_int_set(const char *name, int value)
|
||||
{
|
||||
Setting *s;
|
||||
Eina_List *l;
|
||||
|
@ -218,7 +220,7 @@ _xsettings_int_set(const char *name, int value)
|
|||
if (!value)
|
||||
{
|
||||
if (!s) return;
|
||||
printf("remove %s\n", name);
|
||||
DBG("remove %s\n", name);
|
||||
eina_stringshare_del(name);
|
||||
eina_stringshare_del(s->name);
|
||||
settings = eina_list_remove(settings, s);
|
||||
|
@ -227,13 +229,13 @@ _xsettings_int_set(const char *name, int value)
|
|||
}
|
||||
if (s)
|
||||
{
|
||||
printf("update %s %d\n", name, value);
|
||||
DBG("update %s %d\n", name, value);
|
||||
eina_stringshare_del(name);
|
||||
s->i.value = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("add %s %d\n", name, value);
|
||||
DBG("add %s %d\n", name, value);
|
||||
s = E_NEW(Setting, 1);
|
||||
s->type = SETTING_TYPE_INT;
|
||||
s->name = name;
|
||||
|
@ -247,7 +249,7 @@ _xsettings_int_set(const char *name, int value)
|
|||
}
|
||||
|
||||
static unsigned char *
|
||||
_xsettings_copy(unsigned char *buffer, Setting *s)
|
||||
_e_xsettings_copy(unsigned char *buffer, Setting *s)
|
||||
{
|
||||
size_t str_len;
|
||||
size_t len;
|
||||
|
@ -303,7 +305,7 @@ _xsettings_copy(unsigned char *buffer, Setting *s)
|
|||
}
|
||||
|
||||
static void
|
||||
_xsettings_apply(Settings_Manager *sm)
|
||||
_e_xsettings_apply(Settings_Manager *sm)
|
||||
{
|
||||
unsigned char *data;
|
||||
unsigned char *pos;
|
||||
|
@ -330,7 +332,7 @@ _xsettings_apply(Settings_Manager *sm)
|
|||
pos += 4;
|
||||
|
||||
EINA_LIST_FOREACH(settings, l, s)
|
||||
pos = _xsettings_copy(pos, s);
|
||||
pos = _e_xsettings_copy(pos, s);
|
||||
|
||||
ecore_x_window_prop_property_set(sm->selection,
|
||||
_atom_xsettings,
|
||||
|
@ -340,13 +342,13 @@ _xsettings_apply(Settings_Manager *sm)
|
|||
}
|
||||
|
||||
static void
|
||||
_xsettings_update(void)
|
||||
_e_xsettings_update(void)
|
||||
{
|
||||
Settings_Manager *sm;
|
||||
Eina_List *l;
|
||||
|
||||
EINA_LIST_FOREACH(managers, l, sm)
|
||||
if (sm->selection) _xsettings_apply(sm);
|
||||
if (sm->selection) _e_xsettings_apply(sm);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
|
@ -356,9 +358,9 @@ _cb_icon_theme_change(void *data, int type __UNUSED__, void *event)
|
|||
|
||||
if (e_config->xsettings.match_e17_icon_theme)
|
||||
{
|
||||
_xsettings_string_set(_setting_icon_theme_name,
|
||||
_e_xsettings_string_set(_setting_icon_theme_name,
|
||||
ev->icon_theme);
|
||||
_xsettings_update();
|
||||
_e_xsettings_update();
|
||||
}
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
|
@ -366,26 +368,26 @@ _cb_icon_theme_change(void *data, int type __UNUSED__, void *event)
|
|||
|
||||
|
||||
static void
|
||||
_xsettings_icon_theme_set(void)
|
||||
_e_xsettings_icon_theme_set(void)
|
||||
{
|
||||
if (e_config->xsettings.match_e17_icon_theme)
|
||||
{
|
||||
_xsettings_string_set(_setting_icon_theme_name,
|
||||
_e_xsettings_string_set(_setting_icon_theme_name,
|
||||
e_config->icon_theme);
|
||||
return;
|
||||
}
|
||||
else if (e_config->xsettings.icon_theme)
|
||||
else if (e_config->xsettings.net_icon_theme_name)
|
||||
{
|
||||
_xsettings_string_set(_setting_icon_theme_name,
|
||||
e_config->xsettings.icon_theme);
|
||||
_e_xsettings_string_set(_setting_icon_theme_name,
|
||||
e_config->xsettings.net_icon_theme_name);
|
||||
return;
|
||||
}
|
||||
|
||||
_xsettings_string_set(_setting_icon_theme_name, NULL);
|
||||
_e_xsettings_string_set(_setting_icon_theme_name, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_xsettings_theme_set(void)
|
||||
_e_xsettings_theme_set(void)
|
||||
{
|
||||
if (e_config->xsettings.match_e17_theme)
|
||||
{
|
||||
|
@ -395,62 +397,65 @@ _xsettings_theme_set(void)
|
|||
char *theme;
|
||||
if ((theme = edje_file_data_get(ct->file, "gtk-theme")))
|
||||
{
|
||||
_xsettings_string_set(_setting_theme_name, theme);
|
||||
_e_xsettings_string_set(_setting_theme_name, theme);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e_config->xsettings.gtk_theme)
|
||||
else if (e_config->xsettings.net_theme_name)
|
||||
{
|
||||
_xsettings_string_set(_setting_theme_name,
|
||||
e_config->xsettings.gtk_theme);
|
||||
_e_xsettings_string_set(_setting_theme_name,
|
||||
e_config->xsettings.net_theme_name);
|
||||
return;
|
||||
}
|
||||
|
||||
_xsettings_string_set(_setting_theme_name, NULL);
|
||||
_e_xsettings_string_set(_setting_theme_name, NULL);
|
||||
}
|
||||
|
||||
EINTERN int
|
||||
e_xsettings_init(void)
|
||||
static void
|
||||
_e_xsettings_start(void)
|
||||
{
|
||||
Eina_List *l;
|
||||
E_Manager *man;
|
||||
|
||||
_atom_manager = ecore_x_atom_get("MANAGER");
|
||||
_atom_xsettings = ecore_x_atom_get("_XSETTINGS_SETTINGS");
|
||||
if (running) return;
|
||||
|
||||
_xsettings_theme_set();
|
||||
_xsettings_icon_theme_set();
|
||||
DBG("start__________\n");
|
||||
_e_xsettings_theme_set();
|
||||
_e_xsettings_icon_theme_set();
|
||||
|
||||
EINA_LIST_FOREACH(e_manager_list(), l, man)
|
||||
{
|
||||
Settings_Manager *sm = E_NEW(Settings_Manager, 1);
|
||||
sm->man = man;
|
||||
|
||||
if (!_xsettings_activate(sm))
|
||||
_xsettings_retry(sm);
|
||||
if (!_e_xsettings_activate(sm))
|
||||
_e_xsettings_retry(sm);
|
||||
|
||||
managers = eina_list_append(managers, sm);
|
||||
}
|
||||
|
||||
handlers = eina_list_append(handlers, ecore_event_handler_add(E_EVENT_CONFIG_ICON_THEME,
|
||||
_cb_icon_theme_change, NULL));
|
||||
return 1;
|
||||
_cb_icon_theme_change, NULL));
|
||||
|
||||
running = EINA_TRUE;
|
||||
}
|
||||
|
||||
EINTERN int
|
||||
e_xsettings_shutdown(void)
|
||||
static void
|
||||
_e_xsettings_stop(void)
|
||||
{
|
||||
Settings_Manager *sm;
|
||||
Ecore_Event_Handler *h;
|
||||
Setting *s;
|
||||
|
||||
|
||||
if (!running) return;
|
||||
DBG("stop__________\n");
|
||||
EINA_LIST_FREE(managers, sm)
|
||||
{
|
||||
if (sm->timer_retry)
|
||||
ecore_timer_del(sm->timer_retry);
|
||||
|
||||
_xsettings_deactivate(sm);
|
||||
_e_xsettings_deactivate(sm);
|
||||
|
||||
E_FREE(sm);
|
||||
}
|
||||
|
@ -465,13 +470,48 @@ e_xsettings_shutdown(void)
|
|||
EINA_LIST_FREE(handlers, h)
|
||||
ecore_event_handler_del(h);
|
||||
|
||||
running = EINA_FALSE;
|
||||
}
|
||||
|
||||
EINTERN int
|
||||
e_xsettings_init(void)
|
||||
{
|
||||
_atom_manager = ecore_x_atom_get("MANAGER");
|
||||
_atom_xsettings = ecore_x_atom_get("_XSETTINGS_SETTINGS");
|
||||
|
||||
if (e_config->xsettings.enabled)
|
||||
_e_xsettings_start();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
EINTERN int
|
||||
e_xsettings_shutdown(void)
|
||||
{
|
||||
_e_xsettings_stop();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_xsettings_config_update(void)
|
||||
{
|
||||
_xsettings_theme_set();
|
||||
_xsettings_icon_theme_set();
|
||||
_xsettings_update();
|
||||
DBG("update\n");
|
||||
|
||||
if (!e_config->xsettings.enabled)
|
||||
{
|
||||
_e_xsettings_stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!running)
|
||||
{
|
||||
_e_xsettings_start();
|
||||
}
|
||||
else
|
||||
{
|
||||
_e_xsettings_theme_set();
|
||||
_e_xsettings_icon_theme_set();
|
||||
_e_xsettings_update();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,8 @@ module_la_SOURCES = e_mod_main.c \
|
|||
e_int_config_wallpaper_import.c \
|
||||
e_int_config_wallpaper_import.h \
|
||||
e_int_config_wallpaper_web.c \
|
||||
e_int_config_wallpaper_web.h
|
||||
e_int_config_wallpaper_web.h \
|
||||
e_int_config_xsettings.c
|
||||
|
||||
module_la_LIBADD = @e_libs@ @dlopen_libs@ @EXCHANGE_LIBS@
|
||||
module_la_LDFLAGS = -module -avoid-version
|
||||
|
|
|
@ -20,7 +20,6 @@ struct _E_Config_Dialog_Data
|
|||
struct
|
||||
{
|
||||
Evas_Object *list;
|
||||
Evas_Object *checkbox;
|
||||
Evas_Object *preview[4]; /* same size as _icon_previews */
|
||||
} gui;
|
||||
Ecore_Idler *fill_icon_themes_delayed;
|
||||
|
|
|
@ -0,0 +1,268 @@
|
|||
#include "e.h"
|
||||
|
||||
static void *_create_data(E_Config_Dialog *cfd);
|
||||
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static int _basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static int _basic_apply(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 _sort_widget_themes(const void *data1, const void *data2);
|
||||
static Evas_Object *_icon_new(Evas *evas, const char *theme, const char *icon, unsigned int size);
|
||||
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
Eina_List *widget_themes;
|
||||
const char *widget_theme;
|
||||
int enable_xsettings;
|
||||
int match_e17_theme;
|
||||
int match_e17_icon_theme;
|
||||
struct
|
||||
{
|
||||
Evas_Object *list;
|
||||
} gui;
|
||||
|
||||
/* Ecore_Idler *fill_widget_themes_delayed; */
|
||||
};
|
||||
|
||||
E_Config_Dialog *
|
||||
e_int_config_xsettings(E_Container *con, const char *params __UNUSED__)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_View *v;
|
||||
|
||||
if (e_config_dialog_find("E", "appearance/xsettings")) 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;
|
||||
v->basic.apply_cfdata = _basic_apply;
|
||||
v->basic.check_changed = _basic_check_changed;
|
||||
|
||||
cfd = e_config_dialog_new(con, _("Application Theme Settings"),
|
||||
"E", "appearance/xsettings",
|
||||
"preferences-dekstop-theme", 0, v, NULL);
|
||||
return cfd;
|
||||
}
|
||||
|
||||
static void *
|
||||
_create_data(E_Config_Dialog *cfd)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||
cfdata->cfd = cfd;
|
||||
cfdata->widget_theme = eina_stringshare_add(e_config->xsettings.net_theme_name);
|
||||
cfdata->match_e17_icon_theme = e_config->xsettings.match_e17_icon_theme;
|
||||
cfdata->match_e17_theme = e_config->xsettings.match_e17_theme;
|
||||
cfdata->enable_xsettings = e_config->xsettings.enabled;
|
||||
return cfdata;
|
||||
}
|
||||
|
||||
static void
|
||||
_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
/* if (cfdata->fill_widget_themes_delayed)
|
||||
* free(ecore_idler_del(cfdata->fill_widget_themes_delayed)); */
|
||||
|
||||
eina_stringshare_del(cfdata->widget_theme);
|
||||
E_FREE(cfdata);
|
||||
}
|
||||
|
||||
static int
|
||||
_basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
if (cfdata->match_e17_icon_theme != e_config->xsettings.match_e17_icon_theme)
|
||||
return 1;
|
||||
|
||||
if (cfdata->match_e17_theme != e_config->xsettings.match_e17_theme)
|
||||
return 1;
|
||||
|
||||
if (cfdata->enable_xsettings != !!(e_config->xsettings.enabled))
|
||||
return 1;
|
||||
|
||||
if ((!cfdata->widget_theme) && (!e_config->xsettings.net_theme_name))
|
||||
return 0;
|
||||
|
||||
if ((!cfdata->widget_theme) || (!e_config->xsettings.net_theme_name))
|
||||
return 1;
|
||||
|
||||
return strcmp(cfdata->widget_theme, e_config->xsettings.net_theme_name) != 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
E_Event_Config_Icon_Theme *ev;
|
||||
|
||||
if (!_basic_check_changed(cfd, cfdata)) return 1;
|
||||
printf("is %s \n", e_config->xsettings.net_icon_theme_name);
|
||||
printf("chose %s \n", cfdata->widget_theme);
|
||||
printf("... %s \n", e_widget_ilist_selected_label_get(cfdata->gui.list));
|
||||
|
||||
e_widget_ilist_selected_label_get(cfdata->gui.list);
|
||||
|
||||
eina_stringshare_del(e_config->xsettings.net_icon_theme_name);
|
||||
e_config->xsettings.net_theme_name =
|
||||
eina_stringshare_ref(e_widget_ilist_selected_label_get(cfdata->gui.list));
|
||||
|
||||
e_config->xsettings.match_e17_icon_theme = cfdata->match_e17_icon_theme;
|
||||
e_config->xsettings.match_e17_theme = cfdata->match_e17_theme;
|
||||
e_config->xsettings.enabled = cfdata->enable_xsettings;
|
||||
|
||||
e_config_save_queue();
|
||||
|
||||
e_xsettings_config_update();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_cb_sort(const void *data1, const void *data2)
|
||||
{
|
||||
const char *d1, *d2;
|
||||
|
||||
d1 = data1;
|
||||
d2 = data2;
|
||||
if (!d1) return 1;
|
||||
if (!d2) return -1;
|
||||
|
||||
return strcmp(d1, d2);
|
||||
}
|
||||
|
||||
static void
|
||||
_ilist_files_add(E_Config_Dialog_Data *cfdata, const char *dir)
|
||||
{
|
||||
Eina_Iterator *it;
|
||||
const char *file;
|
||||
|
||||
it = eina_file_ls(dir);
|
||||
if (!it) return;
|
||||
|
||||
EINA_ITERATOR_FOREACH(it, file)
|
||||
{
|
||||
if (ecore_file_is_dir(file))
|
||||
{
|
||||
if (!eina_list_data_find(cfdata->widget_themes, file))
|
||||
{
|
||||
|
||||
cfdata->widget_themes = eina_list_append(cfdata->widget_themes, file);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
eina_stringshare_del(file);
|
||||
}
|
||||
|
||||
eina_iterator_free(it);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_fill_files_ilist(void *data)
|
||||
{
|
||||
Evas *evas;
|
||||
Evas_Object *o;
|
||||
char theme_dir[4096];
|
||||
E_Config_Dialog_Data *cfdata = data;
|
||||
Eina_List *xdg_dirs, *l;
|
||||
const char *dir;
|
||||
|
||||
/* cfdata->fill_widget_themes_delayed = NULL; */
|
||||
|
||||
if (!(o = cfdata->gui.list))
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
|
||||
evas = evas_object_evas_get(o);
|
||||
evas_event_freeze(evas);
|
||||
edje_freeze();
|
||||
e_widget_ilist_freeze(o);
|
||||
e_widget_ilist_clear(o);
|
||||
|
||||
e_user_homedir_concat_static(theme_dir, ".themes");
|
||||
_ilist_files_add(cfdata, theme_dir);
|
||||
|
||||
xdg_dirs = efreet_data_dirs_get();
|
||||
EINA_LIST_FOREACH(xdg_dirs, l, dir)
|
||||
{
|
||||
snprintf(theme_dir, sizeof(theme_dir), "%s/themes", dir);
|
||||
_ilist_files_add(cfdata, theme_dir);
|
||||
}
|
||||
|
||||
if (cfdata->widget_themes)
|
||||
{
|
||||
const char *theme;
|
||||
int cnt = 0;
|
||||
|
||||
cfdata->widget_themes = eina_list_sort(cfdata->widget_themes, -1, _cb_sort);
|
||||
|
||||
EINA_LIST_FREE(cfdata->widget_themes, theme)
|
||||
{
|
||||
char *tmp = strdup(strrchr(theme, '/') + 1);
|
||||
|
||||
if (tmp)
|
||||
{
|
||||
e_widget_ilist_append(o, NULL, tmp, NULL, NULL, NULL);
|
||||
free(tmp);
|
||||
if (cfdata->widget_theme && !strcmp(cfdata->widget_theme, tmp))
|
||||
e_widget_ilist_selected_set(cfdata->gui.list, cnt);
|
||||
|
||||
cnt++;
|
||||
}
|
||||
|
||||
eina_stringshare_del(theme);
|
||||
}
|
||||
}
|
||||
|
||||
e_widget_ilist_go(o);
|
||||
e_widget_ilist_thaw(o);
|
||||
edje_thaw();
|
||||
evas_event_thaw(evas);
|
||||
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *o, *ilist, *ol, *ow;
|
||||
unsigned int i;
|
||||
|
||||
o = e_widget_list_add(evas, 0, 0);
|
||||
ilist = e_widget_ilist_add(evas, 24, 24, &(cfdata->widget_theme));
|
||||
cfdata->gui.list = ilist;
|
||||
e_widget_size_min_set(cfdata->gui.list, 100, 100);
|
||||
|
||||
/* e_widget_on_change_hook_set(ilist, _icon_theme_changed, cfdata); */
|
||||
e_widget_list_object_append(o, ilist, 1, 1, 0.5);
|
||||
|
||||
ow = e_widget_check_add(evas, _("Use E17 icon theme for applications"),
|
||||
&(cfdata->match_e17_icon_theme));
|
||||
e_widget_list_object_append(o, ow, 0, 0, 0.0);
|
||||
|
||||
ow = e_widget_check_add(evas, _("Match E17 theme if possible"),
|
||||
&(cfdata->match_e17_theme));
|
||||
e_widget_list_object_append(o, ow, 0, 0, 0.0);
|
||||
|
||||
/* ow = e_widget_check_add(evas, _("Set application theme"),
|
||||
* &(cfdata->enable_app_theme));
|
||||
* e_widget_list_object_append(o, ow, 0, 0, 0.0); */
|
||||
|
||||
// >> advanced
|
||||
ow = e_widget_check_add(evas, _("Enable Settings Daemon"),
|
||||
&(cfdata->enable_xsettings));
|
||||
/* e_widget_on_change_hook_set(ow, _settings_changed, cfdata); */
|
||||
e_widget_list_object_append(o, ow, 0, 0, 0.0);
|
||||
|
||||
|
||||
e_dialog_resizable_set(cfd->dia, 1);
|
||||
|
||||
/* if (cfdata->fill_widget_themes_delayed)
|
||||
* free(ecore_idler_del(cfdata->fill_widget_themes_delayed)); */
|
||||
/* cfdata->fill_widget_themes_delayed = ecore_idler_add(_fill_files_ilist, cfdata); */
|
||||
|
||||
_fill_files_ilist(cfdata);
|
||||
|
||||
return o;
|
||||
}
|
|
@ -35,6 +35,9 @@ e_modapi_init(E_Module *m)
|
|||
e_configure_registry_item_add("appearance/theme", 20, _("Theme"), NULL,
|
||||
"preferences-desktop-theme",
|
||||
e_int_config_theme);
|
||||
e_configure_registry_item_add("appearance/xsettings", 20, _("Applications"), NULL,
|
||||
"preferences-desktop-theme",
|
||||
e_int_config_xsettings);
|
||||
e_configure_registry_item_add("appearance/colors", 30, _("Colors"), NULL,
|
||||
"preferences-desktop-color",
|
||||
e_int_config_color_classes);
|
||||
|
|
|
@ -39,4 +39,6 @@ EAPI void *e_modapi_init (E_Module *m);
|
|||
EAPI int e_modapi_shutdown (E_Module *m);
|
||||
EAPI int e_modapi_save (E_Module *m);
|
||||
|
||||
E_Config_Dialog *e_int_config_xsettings(E_Container *con, const char *params __UNUSED__);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue