xsettings: Allow for custom DPI setting.
Until a wayland/X11 solution allow setting a custom DPI in Settings -> Application Theme -> X Application Settings
This commit is contained in:
parent
ec1c6b42b4
commit
9f33fbf62e
|
@ -961,6 +961,8 @@ _e_config_edd_init(Eina_Bool old)
|
|||
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_VAL(D, T, xsettings.dpi.enabled, UCHAR);
|
||||
E_CONFIG_VAL(D, T, xsettings.dpi.value, INT);
|
||||
|
||||
E_CONFIG_VAL(D, T, update.check, UCHAR);
|
||||
E_CONFIG_VAL(D, T, update.later, UCHAR);
|
||||
|
|
|
@ -392,6 +392,12 @@ struct _E_Config
|
|||
unsigned char load_kde; // GUI
|
||||
} deskenv;
|
||||
|
||||
struct dpi
|
||||
{
|
||||
unsigned char enabled;
|
||||
int value;
|
||||
} dpi;
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned char enabled; // GUI
|
||||
|
@ -405,6 +411,7 @@ struct _E_Config
|
|||
const char *net_theme_name_detected; // not saved
|
||||
const char *net_icon_theme_name;
|
||||
const char *gtk_font_name;
|
||||
struct dpi dpi;
|
||||
} xsettings;
|
||||
|
||||
struct
|
||||
|
|
|
@ -68,9 +68,7 @@ static Eina_Bool reset = EINA_FALSE;
|
|||
static const char _setting_icon_theme_name[] = "Net/IconThemeName";
|
||||
static const char _setting_theme_name[] = "Net/ThemeName";
|
||||
static const char _setting_font_name[] = "Gtk/FontName";
|
||||
#if 0
|
||||
static const char _setting_xft_dpi[] = "Xft/DPI";
|
||||
#endif
|
||||
static const char *_setting_theme = NULL;
|
||||
|
||||
static void _e_xsettings_done_cb(void *data, Eio_File *handler, const Eina_Stat *stat);
|
||||
|
@ -220,7 +218,6 @@ _e_xsettings_string_set(const char *name, const char *value)
|
|||
s->last_change = ecore_x_current_time_get();
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
_e_xsettings_int_set(const char *name, int value, Eina_Bool set)
|
||||
{
|
||||
|
@ -266,8 +263,6 @@ _e_xsettings_int_set(const char *name, int value, Eina_Bool set)
|
|||
s->length += OFFSET_ADD(strlen(name));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static unsigned char *
|
||||
_e_xsettings_copy(unsigned char *buffer, Setting *s)
|
||||
{
|
||||
|
@ -574,7 +569,7 @@ _e_xsettings_font_set(void)
|
|||
if (size < 5) size = 5; // don't allow too small
|
||||
else if (size > 100) size = 100; // don't allow silly sizes
|
||||
|
||||
_dbl_to_str(size_buf, sizeof(size_buf), (double)size * 0.75, 3);
|
||||
_dbl_to_str(size_buf, sizeof(size_buf), (double)size * 0.75, 0);
|
||||
|
||||
buf = eina_strbuf_new();
|
||||
eina_strbuf_append(buf, efp->name);
|
||||
|
@ -594,10 +589,21 @@ _e_xsettings_font_set(void)
|
|||
|
||||
e_font_properties_free(efp);
|
||||
}
|
||||
|
||||
_e_xsettings_string_set(_setting_font_name, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_xsettings_dpi_set(void)
|
||||
{
|
||||
if (e_config->xsettings.dpi.enabled)
|
||||
{
|
||||
_e_xsettings_int_set(_setting_xft_dpi, e_config->xsettings.dpi.value * 1024, EINA_TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
_e_xsettings_int_set(_setting_xft_dpi, 96 * 1024, EINA_TRUE);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
_e_xsettings_xft_set(void)
|
||||
|
@ -640,6 +646,7 @@ _e_xsettings_start(void)
|
|||
{
|
||||
if (running) return;
|
||||
|
||||
_e_xsettings_dpi_set();
|
||||
_e_xsettings_theme_set();
|
||||
_e_xsettings_icon_theme_set();
|
||||
_e_xsettings_font_set();
|
||||
|
@ -707,6 +714,17 @@ e_xsettings_shutdown(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_update_sequence(void)
|
||||
{
|
||||
_e_xsettings_dpi_set();
|
||||
_e_xsettings_theme_set();
|
||||
_e_xsettings_icon_theme_set();
|
||||
_e_xsettings_font_set();
|
||||
_e_xsettings_update();
|
||||
_e_xsettings_gtk_icon_update();
|
||||
}
|
||||
|
||||
E_API void
|
||||
e_xsettings_config_update(void)
|
||||
{
|
||||
|
@ -715,6 +733,7 @@ e_xsettings_config_update(void)
|
|||
if (eio_op) eio_file_cancel(eio_op);
|
||||
if (!e_config->xsettings.enabled)
|
||||
{
|
||||
_update_sequence();
|
||||
_e_xsettings_stop();
|
||||
return;
|
||||
}
|
||||
|
@ -725,11 +744,7 @@ e_xsettings_config_update(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
_e_xsettings_theme_set();
|
||||
_e_xsettings_icon_theme_set();
|
||||
_e_xsettings_font_set();
|
||||
_e_xsettings_update();
|
||||
_e_xsettings_gtk_icon_update();
|
||||
_update_sequence();
|
||||
reset = EINA_TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +14,11 @@ struct _E_Config_Dialog_Data
|
|||
Eina_List *widget_themes;
|
||||
const char *widget_theme;
|
||||
int enable_xsettings;
|
||||
int enable_xsettings_dpi;
|
||||
int xsettings_dpi;
|
||||
Eina_List *icon_themes;
|
||||
int match_e17_theme;
|
||||
int match_e17_icon_theme;
|
||||
Eina_List *icon_themes;
|
||||
const char *icon_theme;
|
||||
int icon_overrides;
|
||||
//int enable_icon_theme; // We just need to check whether override or match icon theme is set.
|
||||
|
@ -75,6 +77,8 @@ _create_data(E_Config_Dialog *cfd)
|
|||
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;
|
||||
cfdata->enable_xsettings_dpi = e_config->xsettings.dpi.enabled;
|
||||
cfdata->xsettings_dpi = e_config->xsettings.dpi.value;
|
||||
cfdata->icon_theme = eina_stringshare_add(e_config->icon_theme);
|
||||
cfdata->icon_overrides = e_config->icon_theme_overrides;
|
||||
//cfdata->enable_icon_theme = !!(e_config->icon_theme);
|
||||
|
@ -131,6 +135,11 @@ _basic_check_changed(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfd
|
|||
(strcmp(cfdata->icon_theme, e_config->icon_theme) != 0))
|
||||
return 1;
|
||||
|
||||
if (cfdata->enable_xsettings_dpi != e_config->xsettings.dpi.enabled)
|
||||
return 1;
|
||||
if (cfdata->xsettings_dpi != e_config->xsettings.dpi.value)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -149,6 +158,13 @@ _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
e_config->xsettings.match_e17_theme = cfdata->match_e17_theme;
|
||||
e_config->xsettings.enabled = cfdata->enable_xsettings;
|
||||
|
||||
if (cfdata->enable_xsettings_dpi)
|
||||
e_config->xsettings.dpi.enabled = 1;
|
||||
else
|
||||
e_config->xsettings.dpi.enabled = 0;
|
||||
|
||||
e_config->xsettings.dpi.value = cfdata->xsettings_dpi;
|
||||
|
||||
eina_stringshare_del(e_config->icon_theme);
|
||||
if (cfdata->icon_overrides || cfdata->match_e17_icon_theme)
|
||||
e_config->icon_theme = eina_stringshare_ref(cfdata->icon_theme);
|
||||
|
@ -453,10 +469,18 @@ _icon_theme_changed(void *data, Evas_Object *o EINA_UNUSED)
|
|||
_populate_icon_preview(cfdata);
|
||||
}
|
||||
|
||||
static void
|
||||
_xsettings_changed(void *data, Evas_Object *o EINA_UNUSED)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata = data;
|
||||
|
||||
e_config_dialog_changed_set(cfdata->cfd, 1);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_basic_create(E_Config_Dialog *cfd EINA_UNUSED, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *otb, *ol, *ilist, *of, *ow, *oc;
|
||||
Evas_Object *otb, *ol, *ilist, *of, *ow, *oc, *os;
|
||||
struct _fill_icon_themes_data *d;
|
||||
unsigned int i;
|
||||
|
||||
|
@ -487,12 +511,31 @@ _basic_create(E_Config_Dialog *cfd EINA_UNUSED, Evas *evas, E_Config_Dialog_Data
|
|||
oc = e_widget_check_add(evas, _("Enable X Application Settings"),
|
||||
&(cfdata->enable_xsettings));
|
||||
e_widget_list_object_append(ol, oc, 0, 0, 0.0);
|
||||
#endif
|
||||
|
||||
e_widget_check_widget_disable_on_unchecked_add(oc, ilist);
|
||||
e_widget_check_widget_disable_on_unchecked_add(oc, ow);
|
||||
|
||||
of = e_widget_framelist_add(evas, "X Application Settings", 0);
|
||||
|
||||
ow = e_widget_check_add(evas, _("Enable Custom DPI"), &(cfdata->enable_xsettings_dpi));
|
||||
e_widget_framelist_object_append(of, ow);
|
||||
e_widget_check_widget_disable_on_unchecked_add(oc, ow);
|
||||
e_widget_on_change_hook_set(ow, _xsettings_changed, cfdata);
|
||||
|
||||
os = e_widget_slider_add(evas, 1, 0, _("%1.0f dpi"), 50, 400, 1, 0,
|
||||
NULL, &(cfdata->xsettings_dpi), 90);
|
||||
e_widget_on_change_hook_set(os, _xsettings_changed, cfdata);
|
||||
e_widget_framelist_object_append(of, os);
|
||||
|
||||
e_widget_check_widget_disable_on_unchecked_add(ow, os);
|
||||
e_widget_check_widget_disable_on_unchecked_add(oc, os);
|
||||
|
||||
e_widget_list_object_append(ol, of, 1, 0, 0.5);
|
||||
|
||||
#endif
|
||||
|
||||
e_widget_toolbook_page_append(otb, NULL, _("GTK Applications"), ol,
|
||||
1, 1, 1, 1, 0.5, 0.0);
|
||||
|
||||
ol = e_widget_list_add(evas, 0, 0);
|
||||
ilist = e_widget_ilist_add(evas, 24, 24, &(cfdata->icon_theme));
|
||||
cfdata->gui.icon_list = ilist;
|
||||
|
|
Loading…
Reference in New Issue