Overhaul for font configuration (hope people like it)


			
			
				devs/princeamd/enlightenment-0.17-elive
			
			
		
Stafford Mitchell Horne 16 years ago
parent a44e3a19e4
commit 922208c066
  1. 3
      data/themes/Makefile.am
  2. 1
      data/themes/default.edc
  3. 31
      data/themes/default_fontpreview.edc
  4. 4
      src/bin/Makefile.am
  5. 2
      src/bin/e_fm.c
  6. 4
      src/bin/e_font.c
  7. 10
      src/bin/e_font.h
  8. 1
      src/bin/e_includes.h
  9. 675
      src/bin/e_int_config_fonts.c
  10. 102
      src/bin/e_widget_font_preview.c
  11. 13
      src/bin/e_widget_font_preview.h
  12. 15
      src/bin/e_widget_ilist.c
  13. 1
      src/bin/e_widget_ilist.h

@ -58,7 +58,8 @@ default_cslider.edc \
default_spectrum.edc \
default_color_well.edc \
default_sys.edc \
default_deskpreview.edc
default_deskpreview.edc \
default_fontpreview.edc
default.edj: Makefile $(EXTRA_DIST)
$(EDJE_CC) $(EDJE_FLAGS) \

@ -76,5 +76,6 @@ collections {
#include "default_color_well.edc"
#include "default_sys.edc"
#include "default_deskpreview.edc"
#include "default_fontpreview.edc"
}

@ -0,0 +1,31 @@
group {
name: "e/widgets/fontpreview";
parts {
part {
name: "e.fontpreview.text";
type: TEXT;
mouse_events: 0;
description {
state: "default" 0.0;
color: 0 0 0 255;
color_class: "entry_text";
rel1 {
relative: 0.0 0.0;
offset: 4 4;
}
rel2 {
relative: 1.0 1.0;
offset: -5 -5;
}
text {
text_class: "_e_font_preview";
text: "The quick brown fox jumped over YO MAMMA!";
font: "Edje-Vera";
size: 10;
min: 1 1;
align: 0.5 0.5;
}
}
}
}
}

@ -189,7 +189,8 @@ e_fm_prop.h \
e_int_config_mouse.h \
e_mouse.h \
e_order.h \
e_exec.h
e_exec.h \
e_widget_font_preview.h
enlightenment_src = \
e_user.c \
@ -354,6 +355,7 @@ e_int_config_mouse.c \
e_mouse.c \
e_order.c \
e_exec.c \
e_widget_font_preview.c \
$(ENLIGHTENMENTHEADERS)
enlightenment_SOURCES = \

@ -914,7 +914,7 @@ e_fm2_icon_get(Evas *evas, const char *realpath,
{
Evas_Object *oic;
char buf[4096], *p;
if (ici->icon)
{
/* custom icon */

@ -369,7 +369,7 @@ e_font_fallback_list(void)
}
EAPI void
e_font_default_set(const char *text_class, const char *font, int size)
e_font_default_set(const char *text_class, const char *font, Evas_Font_Size size)
{
E_Font_Default *efd;
Evas_List *next;
@ -465,7 +465,7 @@ e_font_default_list(void)
* we need a font name and size.
*/
EAPI const char *
e_font_default_string_get(const char *text_class, int *size_ret)
e_font_default_string_get(const char *text_class, Evas_Font_Size *size_ret)
{
E_Font_Default *efd;
Evas_List *next;

@ -14,9 +14,9 @@ typedef struct _E_Font_Properties E_Font_Properties;
struct _E_Font_Default
{
const char *text_class;
const char *font;
int size;
const char *text_class;
const char *font;
Evas_Font_Size size;
};
struct _E_Font_Fallback
@ -54,11 +54,11 @@ EAPI void e_font_fallback_remove(const char *font);
EAPI Evas_List *e_font_fallback_list(void);
/* setup edje text classes */
EAPI void e_font_default_set(const char *text_class, const char *font, int size);
EAPI void e_font_default_set(const char *text_class, const char *font, Evas_Font_Size size);
EAPI E_Font_Default *e_font_default_get(const char *text_class);
EAPI void e_font_default_remove(const char *text_class);
EAPI Evas_List *e_font_default_list(void);
EAPI const char *e_font_default_string_get(const char *text_class, int *size_ret);
EAPI const char *e_font_default_string_get(const char *text_class, Evas_Font_Size *size_ret);
#endif
#endif

@ -165,3 +165,4 @@
#include "e_int_config_mouse.h"
#include "e_order.h"
#include "e_exec.h"
#include "e_widget_font_preview.h"

@ -3,6 +3,7 @@
*/
#include "e.h"
typedef struct _E_Font_Size_Data E_Font_Size_Data;
typedef struct _E_Text_Class_Pair E_Text_Class_Pair;
typedef struct _CFText_Class CFText_Class;
@ -12,15 +13,31 @@ static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
static int _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
static void _fill_ilist(E_Config_Dialog_Data *cfdata);
static void _ilist_font_cb_change(void *data, Evas_Object *obj);
static void _enabled_font_cb_change(void *data, Evas_Object *obj);
static void _enabled_fallback_cb_change(void *data, Evas_Object *obj);
static void _basic_font_cb_change(void *data, Evas_Object *obj);
static void _basic_enable_cb_change(void *data, Evas_Object *obj);
static void _basic_style_cb_change(void *data, Evas_Object *obj);
static void _basic_init_data_fill(E_Config_Dialog_Data *cfdata);
static void _adv_class_cb_change(void *data, Evas_Object *obj);
static void _adv_enabled_font_cb_change(void *data, Evas_Object *obj);
static void _adv_enabled_fallback_cb_change(void *data, Evas_Object *obj);
static void _adv_font_cb_change(void *data, Evas_Object *obj);
static void _adv_style_cb_change(void *data, Evas_Object *obj);
static void _size_cb_change(void *data);
static int _sort_fonts(void *data1, void *data2);
static void _size_cb_change(void *data, Evas_Object *obj);
static void _font_cb_change(void *data, Evas_Object *obj);
static void _style_cb_change(void *data, Evas_Object *obj);
static void _font_list_load(E_Config_Dialog_Data *cfdata, const char *cur_font);
static void _size_list_load(E_Config_Dialog_Data *cfdata, Evas_List *size_list, Evas_Font_Size cur_size, int clear);
static void _class_list_load(E_Config_Dialog_Data *cfdata);
static void _font_preview_update(E_Config_Dialog_Data *cfdata);
struct _E_Font_Size_Data
{
E_Config_Dialog_Data *cfdata;
const char *size_str;
Evas_Font_Size size;
};
struct _E_Text_Class_Pair
{
@ -30,11 +47,11 @@ struct _E_Text_Class_Pair
struct _CFText_Class
{
const char *class_name;
const char *class_description;
const char *font;
const char *style;
double size;
const char *class_name;
const char *class_description;
const char *font;
const char *style;
Evas_Font_Size size;
unsigned char enabled : 1;
};
@ -99,6 +116,8 @@ struct _E_Config_Dialog_Data
/* Font Data */
Evas_Hash *font_hash;
Evas_List *font_list;
Evas_List *font_px_list;
Evas_List *font_scale_list;
/* Current data */
char *cur_font;
@ -119,11 +138,12 @@ struct _E_Config_Dialog_Data
Evas_Object *class_list;
Evas_Object *font_list;
Evas_Object *style_list;
Evas_Object *font;
Evas_Object *size;
Evas_Object *size_list;
Evas_Object *enabled;
Evas_Object *preview;
/* Font Fallbacks */
Evas_Object *fallback_list; /* Selecting a list entry starts edit*/
}
@ -159,6 +179,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
Evas_List *font_list;
Evas_List *next;
E_Font_Default *efd;
E_Font_Size_Data *size_data;
CFText_Class *tc;
int i;
@ -224,6 +245,57 @@ _fill_data(E_Config_Dialog_Data *cfdata)
/* Fill Hinting */
cfdata->hinting = e_config->font_hinting;
size_data = E_NEW(E_Font_Size_Data, 1);
size_data->cfdata = cfdata;
size_data->size_str = evas_stringshare_add(_("Tiny"));
size_data->size = -50;
cfdata->font_scale_list = evas_list_append(cfdata->font_scale_list, size_data);
size_data = E_NEW(E_Font_Size_Data, 1);
size_data->cfdata = cfdata;
size_data->size_str = evas_stringshare_add(_("Small"));
size_data->size = -80;
cfdata->font_scale_list = evas_list_append(cfdata->font_scale_list, size_data);
size_data = E_NEW(E_Font_Size_Data, 1);
size_data->cfdata = cfdata;
size_data->size_str = evas_stringshare_add(_("Normal"));
size_data->size = -100;
cfdata->font_scale_list = evas_list_append(cfdata->font_scale_list, size_data);
size_data = E_NEW(E_Font_Size_Data, 1);
size_data->cfdata = cfdata;
size_data->size_str = evas_stringshare_add(_("Big"));
size_data->size = -150;
cfdata->font_scale_list = evas_list_append(cfdata->font_scale_list, size_data);
size_data = E_NEW(E_Font_Size_Data, 1);
size_data->cfdata = cfdata;
size_data->size_str = evas_stringshare_add(_("Really Big"));
size_data->size = -190;
cfdata->font_scale_list = evas_list_append(cfdata->font_scale_list, size_data);
size_data = E_NEW(E_Font_Size_Data, 1);
size_data->cfdata = cfdata;
size_data->size_str = evas_stringshare_add(_("Huge"));
size_data->size = -250;
cfdata->font_scale_list = evas_list_append(cfdata->font_scale_list, size_data);
for (i = 5; i < 21; i++)
{
char str[16];
str[0] = 0;
snprintf(str, sizeof(str), _("%d pixels"), i);
size_data = E_NEW(E_Font_Size_Data, 1);
size_data->cfdata = cfdata;
size_data->size_str = evas_stringshare_add(str);
size_data->size = i;
cfdata->font_px_list = evas_list_append(cfdata->font_px_list, size_data);
}
return;
}
@ -248,7 +320,6 @@ _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
cfdata->font_list = evas_list_remove_list(cfdata->font_list, cfdata->font_list);
}
while ((l = cfdata->text_classes))
{
@ -260,6 +331,26 @@ _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
if (tc->style) evas_stringshare_del(tc->style);
E_FREE(tc);
}
while ((l = cfdata->font_scale_list))
{
E_Font_Size_Data *size_data;
size_data = l->data;
cfdata->font_scale_list = evas_list_remove_list(cfdata->font_scale_list, l);
if (size_data->size_str) evas_stringshare_del(size_data->size_str);
E_FREE(size_data);
}
while ((l = cfdata->font_px_list))
{
E_Font_Size_Data *size_data;
size_data = l->data;
cfdata->font_px_list = evas_list_remove_list(cfdata->font_scale_list, l);
if (size_data->size_str) evas_stringshare_del(size_data->size_str);
E_FREE(size_data);
}
E_FREE(cfdata->cur_font);
E_FREE(cfdata->cur_style);
@ -270,39 +361,60 @@ static int
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
Evas_List *next;
CFText_Class *tc;
/* Save current data */
if (cfdata->cur_index >= 0)
{
tc = evas_list_nth(cfdata->text_classes, cfdata->cur_index);
tc->enabled = cfdata->cur_enabled;
tc->size = cfdata->cur_size;
if (cfdata->cur_font)
tc->font = evas_stringshare_add(cfdata->cur_font);
if (cfdata->cur_style)
tc->style = evas_stringshare_add(cfdata->cur_style);
}
int i;
for (next = cfdata->text_classes; next; next = next->next)
if (cfdata->cur_enabled && cfdata->cur_font == NULL)
return 0;
for (i = 0; text_class_predefined_names[i].class_description; i++ )
{
tc = next->data;
if (!text_class_predefined_names[i].class_name) continue;
if (!tc->class_name) continue;
if (tc->enabled && tc->font)
if (cfdata->cur_enabled)
{
const char *name;
name = e_font_fontconfig_name_get(tc->font, tc->style);
e_font_default_set(tc->class_name, name, tc->size);
evas_stringshare_del(name);
const char *class_name;
const char *font_name;
class_name = text_class_predefined_names[i].class_name;
font_name = e_font_fontconfig_name_get(cfdata->cur_font, cfdata->cur_style);
e_font_default_set(class_name, font_name, cfdata->cur_size);
if (i == 1)
e_font_default_set("e_basic_font", font_name, cfdata->cur_size);
evas_stringshare_del(font_name);
}
else
e_font_default_remove(tc->class_name);
{
e_font_default_remove(text_class_predefined_names[i].class_name);
if (i == 1)
e_font_default_remove("e_basic_font");
}
}
e_font_apply();
e_config_save_queue();
/* Apply to advanced */
for (next = cfdata->text_classes; next; next = next->next)
{
CFText_Class *tc;
tc = next->data;
tc->size = cfdata->cur_size;
if (tc->font) evas_stringshare_del(tc->font);
if (cfdata->cur_font)
tc->font = evas_stringshare_add(cfdata->cur_font);
if (tc->style) evas_stringshare_del(tc->style);
if (cfdata->cur_style)
tc->style = evas_stringshare_add(cfdata->cur_style);
tc->enabled = cfdata->cur_enabled;
}
return 1;
}
@ -322,99 +434,128 @@ _font_hash_cb(Evas_Hash *hash, const char *key, void *data, void *fdata)
static Evas_Object *
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
{
Evas_Object *ot, *ob, *of, *ott;
Evas_Coord w;
Evas_Object *ot, *ob, *of;
cfdata->cur_index = -1;
cfdata->evas = evas;
cfdata->gui.font = NULL;
ot = e_widget_table_add(evas, 0);
of = e_widget_framelist_add(evas, _("Font Classes"), 0);
ob = e_widget_ilist_add(evas, 16, 16, NULL);
cfdata->gui.class_list = ob;
_fill_ilist(cfdata);
e_widget_ilist_multi_select_set(ob, 1);
e_widget_min_size_get(ob, &w, NULL);
e_widget_min_size_set(ob, w, 250);
e_widget_on_change_hook_set(ob, _ilist_font_cb_change, cfdata);
e_widget_framelist_object_append(of, ob);
e_widget_table_object_append(ot, of, 0, 0, 1, 1, 1, 1, 1, 1);
cfdata->gui.class_list = NULL;
ob = e_widget_check_add(evas, _("Enable Custom Font Classes"), &(cfdata->cur_enabled));
cfdata->gui.enabled = ob;
e_widget_on_change_hook_set(ob, _basic_enable_cb_change, cfdata);
e_widget_disabled_set(ob, 0);
e_widget_table_object_append(ot, ob, 0, 0, 1, 1, 1, 0, 1, 0);
of = e_widget_framelist_add(evas, _("Fonts"), 1);
ob = e_widget_ilist_add(evas, 16, 16, &(cfdata->cur_font));
cfdata->gui.font_list = ob;
e_widget_on_change_hook_set(ob, _font_cb_change, cfdata);
evas_event_freeze(evas_object_evas_get(ob));
edje_freeze();
e_widget_ilist_freeze(ob);
e_widget_on_change_hook_set(ob, _basic_font_cb_change, cfdata);
e_widget_ilist_go(ob);
e_widget_framelist_object_append(of, ob);
e_widget_table_object_append(ot, of, 0, 1, 1, 1, 1, 1, 1, 1);
if (cfdata->font_hash == NULL)
of = e_widget_framelist_add(evas, _("Size"), 1);
ob = e_widget_ilist_add(evas, 16, 16, NULL);
cfdata->gui.size_list = ob;
e_widget_ilist_go(ob);
e_widget_min_size_set(ob, 100, 200);
e_widget_framelist_object_append(of, ob);
e_widget_table_object_append(ot, of, 1, 1, 1, 1, 1, 1, 1, 1);
ob = e_widget_font_preview_add(evas, _("Basic preview text: 123: 我的天空!"));
cfdata->gui.preview = ob;
e_widget_table_object_append(ot, ob, 0, 2, 2, 1, 1, 0, 1, 0);
_basic_init_data_fill(cfdata);
e_dialog_resizable_set(cfd->dia, 1);
return ot;
}
static void
_basic_style_cb_change(void *data, Evas_Object *obj)
{
E_Config_Dialog_Data *cfdata;
cfdata = data;
if (!cfdata) return;
_font_preview_update(cfdata);
}
static void
_basic_font_cb_change(void *data, Evas_Object *obj)
{
E_Config_Dialog_Data *cfdata;
cfdata = data;
if (!cfdata) return;
_font_preview_update(cfdata);
}
static void
_basic_enable_cb_change(void *data, Evas_Object *obj)
{
E_Config_Dialog_Data *cfdata;
cfdata = data;
if (!cfdata) return;
e_widget_disabled_set(cfdata->gui.font_list, !cfdata->cur_enabled);
e_widget_disabled_set(cfdata->gui.size_list, !cfdata->cur_enabled);
if (!cfdata->cur_enabled)
{
Evas_List *fonts;
fonts = evas_font_available_list(evas);
cfdata->font_hash = e_font_available_list_parse(fonts);
evas_hash_foreach(cfdata->font_hash, _font_hash_cb, cfdata);
if (cfdata->font_list)
{
cfdata->font_list = evas_list_sort(cfdata->font_list,
evas_list_count(cfdata->font_list),
_sort_fonts);
}
evas_font_available_list_free(evas, fonts);
e_widget_ilist_unselect(cfdata->gui.font_list);
e_widget_ilist_unselect(cfdata->gui.size_list);
}
}
if (cfdata->font_list)
{
Evas_List *next;
/* fill the basic dialog with inital data and select it */
static void
_basic_init_data_fill(E_Config_Dialog_Data *cfdata)
{
Evas_Object *ob;
E_Font_Default *efd;
const char *init_font;
Evas_Font_Size init_size;
for (next = cfdata->font_list; next; next = next->next)
init_font = NULL;
init_size = -100;
/* Get inital basic basic */
efd = e_font_default_get("e_basic_font");
if (efd)
{
if (efd->font)
{
char *f;
f = next->data;
e_widget_ilist_append(ob, NULL, f, NULL, NULL, f);
E_Font_Properties *efp;
efp = e_font_fontconfig_name_parse(efd->font);
init_font = evas_stringshare_add(efp->name);
e_font_properties_free(efp);
}
init_size = efd->size;
}
e_widget_ilist_go(ob);
e_widget_min_size_get(ob, &w, NULL);
e_widget_min_size_set(ob, w, 250);
e_widget_ilist_thaw(ob);
edje_thaw();
evas_event_thaw(evas_object_evas_get(ob));
e_widget_framelist_object_append(of, ob);
e_widget_table_object_append(ot, of, 1, 0, 1, 1, 1, 1, 1, 1);
of = e_widget_framelist_add(evas, _("Styles"), 1);
ob = e_widget_ilist_add(evas, 16, 16, &(cfdata->cur_style));
cfdata->gui.style_list = ob;
e_widget_on_change_hook_set(ob, _style_cb_change, cfdata);
e_widget_ilist_go(ob);
e_widget_min_size_set(ob, 125, 250);
e_widget_framelist_object_append(of, ob);
e_widget_table_object_append(ot, of, 2, 0, 1, 1, 1, 1, 1, 1);
/* Check based on efd */
ob = cfdata->gui.enabled;
if (efd == NULL)
e_widget_check_checked_set(ob, 0);
else if (!strcmp(efd->text_class, "default"))
e_widget_check_checked_set(ob, 0);
else
e_widget_check_checked_set(ob, 1);
/* Populate font list (Select current font) */
_font_list_load(cfdata, init_font);
ob = e_widget_check_add(evas, _("Enable Font Class"), &(cfdata->cur_enabled));
cfdata->gui.enabled = ob;
e_widget_on_change_hook_set(ob, _enabled_font_cb_change, cfdata);
e_widget_disabled_set(ob, 1);
e_widget_table_object_append(ot, ob, 0, 1, 1, 1, 1, 0, 1, 0);
ott = e_widget_table_add(evas, 1);
ob = e_widget_label_add(evas, _("Font Size:"));
e_widget_table_object_append(ott, ob, 0, 0, 1, 1, 1, 0, 1, 0);
ob = e_widget_slider_add(evas, 1, 0, _("%2.1f pixels"), 5.0, 25.0, 0.5, 0,
&(cfdata->cur_size), NULL, 25);
cfdata->gui.size = ob;
e_widget_disabled_set(ob, 1);
e_widget_on_change_hook_set(ob, _size_cb_change, cfdata);
e_widget_table_object_append(ott, ob, 1, 0, 2, 1, 1, 0, 1, 0);
e_widget_table_object_append(ot, ott, 1, 1, 2, 1, 1, 0, 1, 0);
e_dialog_resizable_set(cfd->dia, 1);
return ot;
/* Populate size list (Select current font) */
_size_list_load(cfdata, cfdata->font_scale_list, init_size, 1);
}
static int
@ -478,7 +619,7 @@ _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
static Evas_Object *
_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
{
Evas_Object *ot, *ob, *of, *ott;
Evas_Object *ot, *ob, *of, *ol;
Evas_Coord w;
E_Radio_Group *rg;
Evas_List *next;
@ -486,92 +627,62 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
cfdata->cur_index = -1;
cfdata->evas = evas;
cfdata->gui.font = NULL;
ot = e_widget_table_add(evas, 0);
/* Serup Section List */
ol = e_widget_list_add(evas, 0, 0);
/* Table for Font Class Setup */
ot = e_widget_table_add(evas, 0);
of = e_widget_framelist_add(evas, _("Font Classes"), 0);
ob = e_widget_ilist_add(evas, 16, 16, NULL);
cfdata->gui.class_list = ob;
_fill_ilist(cfdata);
_class_list_load(cfdata);
e_widget_ilist_multi_select_set(ob, 1);
e_widget_min_size_get(ob, &w, NULL);
e_widget_min_size_set(ob, w, 250);
e_widget_on_change_hook_set(ob, _ilist_font_cb_change, cfdata);
e_widget_on_change_hook_set(ob, _adv_class_cb_change, cfdata);
e_widget_framelist_object_append(of, ob);
e_widget_table_object_append(ot, of, 0, 0, 1, 1, 1, 1, 1, 1);
e_widget_table_object_append(ot, of, 0, 0, 1, 2, 1, 1, 1, 1);
of = e_widget_framelist_add(evas, _("Fonts"), 1);
ob = e_widget_ilist_add(evas, 16, 16, &(cfdata->cur_font));
cfdata->gui.font_list = ob;
e_widget_on_change_hook_set(ob, _font_cb_change, cfdata);
evas_event_freeze(evas_object_evas_get(ob));
edje_freeze();
e_widget_ilist_freeze(ob);
if (cfdata->font_hash == NULL)
{
Evas_List *fonts;
fonts = evas_font_available_list(evas);
cfdata->font_hash = e_font_available_list_parse(fonts);
evas_hash_foreach(cfdata->font_hash, _font_hash_cb, cfdata);
if (cfdata->font_list)
{
cfdata->font_list = evas_list_sort(cfdata->font_list,
evas_list_count(cfdata->font_list),
_sort_fonts);
}
evas_font_available_list_free(evas, fonts);
}
if (cfdata->font_list)
{
Evas_List *next;
for (next = cfdata->font_list; next; next = next->next)
{
char *f;
f = next->data;
e_widget_ilist_append(ob, NULL, f, NULL, NULL, f);
}
}
e_widget_ilist_go(ob);
e_widget_min_size_get(ob, &w, NULL);
e_widget_min_size_set(ob, w, 250);
e_widget_ilist_thaw(ob);
edje_thaw();
evas_event_thaw(evas_object_evas_get(ob));
e_widget_on_change_hook_set(ob, _adv_font_cb_change, cfdata);
_font_list_load(cfdata, NULL);
e_widget_framelist_object_append(of, ob);
e_widget_table_object_append(ot, of, 1, 0, 1, 1, 1, 1, 1, 1);
e_widget_table_object_append(ot, of, 1, 0, 1, 2, 1, 1, 1, 1);
of = e_widget_framelist_add(evas, _("Styles"), 1);
ob = e_widget_ilist_add(evas, 16, 16, &(cfdata->cur_style));
cfdata->gui.style_list = ob;
e_widget_on_change_hook_set(ob, _style_cb_change, cfdata);
e_widget_on_change_hook_set(ob, _adv_style_cb_change, cfdata);
e_widget_ilist_go(ob);
e_widget_min_size_set(ob, 125, 250);
e_widget_min_size_set(ob, 125, 125);
e_widget_framelist_object_append(of, ob);
e_widget_table_object_append(ot, of, 2, 0, 1, 1, 1, 1, 1, 1);
of = e_widget_framelist_add(evas, _("Size"), 1);
ob = e_widget_ilist_add(evas, 16, 16, NULL);
cfdata->gui.size_list = ob;
e_widget_ilist_go(ob);
e_widget_min_size_set(ob, 125, 125);
e_widget_framelist_object_append(of, ob);
e_widget_table_object_append(ot, of, 2, 1, 1, 1, 1, 1, 1, 1);
ob = e_widget_check_add(evas, _("Enable Font Class"), &(cfdata->cur_enabled));
cfdata->gui.enabled = ob;
e_widget_on_change_hook_set(ob, _enabled_font_cb_change, cfdata);
e_widget_disabled_set(ob, 1);
e_widget_table_object_append(ot, ob, 0, 1, 1, 1, 1, 0, 1, 0);
ott = e_widget_table_add(evas, 1);
ob = e_widget_label_add(evas, _("Font Size:"));
e_widget_table_object_append(ott, ob, 0, 0, 1, 1, 1, 0, 1, 0);
ob = e_widget_slider_add(evas, 1, 0, _("%2.1f pixels"), 5.0, 25.0, 0.5, 0,
&(cfdata->cur_size), NULL, 25);
cfdata->gui.size = ob;
e_widget_on_change_hook_set(ob, _adv_enabled_font_cb_change, cfdata);
e_widget_disabled_set(ob, 1);
e_widget_on_change_hook_set(ob, _size_cb_change, cfdata);
e_widget_table_object_append(ott, ob, 1, 0, 2, 1, 1, 0, 1, 0);
e_widget_table_object_append(ot, ott, 1, 1, 2, 1, 1, 0, 1, 0);
e_widget_table_object_append(ot, ob, 0, 2, 1, 1, 1, 0, 1, 0);
ob = e_widget_font_preview_add(evas, _("Advanced Preview Text.. 我真的会写中文"));
cfdata->gui.preview = ob;
e_widget_table_object_append(ot, ob, 1, 2, 2, 1, 1, 0, 1, 0);
e_widget_list_object_append(ol, ot, 1, 1, 0.5);
/* Frame for Hinting Setup */
of = e_widget_framelist_add(evas, _("Hinting"), 1);
rg = e_widget_radio_group_new(&(cfdata->hinting));
option_enable = evas_font_hinting_can_hint(evas, EVAS_FONT_HINTING_BYTECODE);
@ -586,13 +697,13 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
ob = e_widget_radio_add(evas, _("None"), 2, rg);
e_widget_disabled_set(ob, !option_enable);
e_widget_framelist_object_append(of, ob);
e_widget_table_object_append(ot, of, 0, 2, 3, 1, 1, 0, 1, 0);
e_widget_list_object_append(ol, of, 1, 1, 0.5);
/* Frame for Fallbacks Setup */
of = e_widget_framelist_add(evas, _("Font Fallbacks"), 0);
ob = e_widget_config_list_add(evas, e_widget_entry_add, _("Fallback Name"), 2);
cfdata->gui.fallback_list = ob;
e_widget_framelist_object_append(of, ob);
e_widget_table_object_append(ot, of, 0, 3, 3, 1, 1, 0, 1, 0);
option_enable = 0;
for (next = e_font_fallback_list(); next; next = next->next)
{
@ -606,17 +717,18 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
ob = e_widget_check_add(evas, _("Enable Fallbacks"), &(cfdata->cur_fallbacks_enabled));
e_widget_config_list_object_append(cfdata->gui.fallback_list, ob,
0, 3, 2, 1, 1, 1, 1, 1);
e_widget_on_change_hook_set(ob, _enabled_fallback_cb_change, cfdata);
e_widget_on_change_hook_set(ob, _adv_enabled_fallback_cb_change, cfdata);
e_widget_check_checked_set(ob, option_enable);
e_widget_change(ob);
e_widget_list_object_append(ol, of, 1, 1, 0.5);
e_dialog_resizable_set(cfd->dia, 1);
return ot;
return ol;
}
/* Private Font Class Functions */
static void
_fill_ilist(E_Config_Dialog_Data *cfdata)
_class_list_load(E_Config_Dialog_Data *cfdata)
{
Evas *evas;
Evas_List *next;
@ -628,7 +740,7 @@ _fill_ilist(E_Config_Dialog_Data *cfdata)
e_widget_ilist_freeze(cfdata->gui.class_list);
e_widget_ilist_clear(cfdata->gui.class_list);
/* Fill In Ilist */
/* Fill in Class Ilist */
for (next = cfdata->text_classes; next; next = next->next)
{
CFText_Class *tc;
@ -658,8 +770,9 @@ _fill_ilist(E_Config_Dialog_Data *cfdata)
evas_event_thaw(evas);
}
/* Called whenever class list selection changes */
static void
_ilist_font_cb_change(void *data, Evas_Object *obj)
_adv_class_cb_change(void *data, Evas_Object *obj)
{
int indx;
E_Config_Dialog_Data *cfdata;
@ -682,14 +795,17 @@ _ilist_font_cb_change(void *data, Evas_Object *obj)
tc->style = evas_stringshare_add(cfdata->cur_style);
if (cfdata->gui.style_list)
e_widget_ilist_unselect(cfdata->gui.style_list);
if (cfdata->gui.size_list)
e_widget_ilist_unselect(cfdata->gui.size_list);
}
/* If no class is selected unselect all and return */
indx = e_widget_ilist_selected_get(cfdata->gui.class_list);
if (indx < 0)
{
e_widget_disabled_set(cfdata->gui.enabled, 1);
e_widget_disabled_set(cfdata->gui.font, 1);
e_widget_disabled_set(cfdata->gui.size, 1);
e_widget_disabled_set(cfdata->gui.font_list, 1);
e_widget_disabled_set(cfdata->gui.size_list, 1);
e_widget_check_checked_set(cfdata->gui.enabled, 0);
if (cfdata->gui.font_list)
e_widget_ilist_unselect(cfdata->gui.font_list);
@ -700,13 +816,13 @@ _ilist_font_cb_change(void *data, Evas_Object *obj)
cfdata->cur_index = indx;
e_widget_disabled_set(cfdata->gui.enabled, 0);
e_widget_disabled_set(cfdata->gui.font, !tc->enabled);
e_widget_disabled_set(cfdata->gui.size, !tc->enabled);
e_widget_disabled_set(cfdata->gui.font_list, !tc->enabled);
e_widget_disabled_set(cfdata->gui.size_list, !tc->enabled);
e_widget_check_checked_set(cfdata->gui.enabled, tc->enabled);
/* Basic GUI Parts */
if (cfdata->gui.font_list)
{
/* Select the configured font */
for (indx = 0; indx < e_widget_ilist_count(cfdata->gui.font_list); indx++)
{
const char *f;
@ -719,14 +835,10 @@ _ilist_font_cb_change(void *data, Evas_Object *obj)
}
}
}
/* Advanced GUI */
if (cfdata->gui.font)
e_widget_entry_text_set(cfdata->gui.font, tc->font);
e_widget_slider_value_double_set(cfdata->gui.size, tc->size);
}
static void
_enabled_font_cb_change(void *data, Evas_Object *obj)
_adv_enabled_font_cb_change(void *data, Evas_Object *obj)
{
E_Config_Dialog_Data *cfdata;
Evas_List *l;
@ -734,8 +846,9 @@ _enabled_font_cb_change(void *data, Evas_Object *obj)
cfdata = data;
if (!cfdata) return;
e_widget_disabled_set(cfdata->gui.font, !cfdata->cur_enabled);
e_widget_disabled_set(cfdata->gui.size, !cfdata->cur_enabled);
e_widget_disabled_set(cfdata->gui.font_list, !cfdata->cur_enabled);
e_widget_disabled_set(cfdata->gui.style_list, !cfdata->cur_enabled);
e_widget_disabled_set(cfdata->gui.size_list, !cfdata->cur_enabled);
/* Search class list fot selected and enable Icon */
for (n = 0, l = e_widget_ilist_items_get(cfdata->gui.class_list); l; l = l->next, n++)
@ -764,15 +877,23 @@ _enabled_font_cb_change(void *data, Evas_Object *obj)
}
static void
_size_cb_change(void *data, Evas_Object *obj)
_size_cb_change(void *data)
{
E_Config_Dialog_Data *cfdata;
E_Font_Size_Data *size_data;
Evas_List *l;
int n;
cfdata = data;
size_data = data;
cfdata = size_data->cfdata;
if (!cfdata) return;
cfdata->cur_size = size_data->size;
_font_preview_update(cfdata);
if (!cfdata->gui.class_list) return;
for (n = 0, l = e_widget_ilist_items_get(cfdata->gui.class_list); l; l = l->next, n++)
{
E_Ilist_Item *i;
@ -784,11 +905,11 @@ _size_cb_change(void *data, Evas_Object *obj)
tc = evas_list_nth(cfdata->text_classes, n);
tc->size = cfdata->cur_size;
}
}
}
static void
_font_cb_change(void *data, Evas_Object *obj)
_adv_font_cb_change(void *data, Evas_Object *obj)
{
E_Config_Dialog_Data *cfdata;
CFText_Class *tc;
@ -799,7 +920,7 @@ _font_cb_change(void *data, Evas_Object *obj)
cfdata = data;
if (!cfdata) return;
/* Set up the new font name */
/* Set up the new font name for each selected class */
for (n = 0, l = e_widget_ilist_items_get(cfdata->gui.class_list); l; l = l->next, n++)
{
E_Ilist_Item *i;
@ -840,7 +961,7 @@ _font_cb_change(void *data, Evas_Object *obj)
evas_event_thaw(evas_object_evas_get(cfdata->gui.style_list));
}
/* select configured style from list */
if (tc && tc->style)
{
for (n = 0; n < e_widget_ilist_count(cfdata->gui.style_list); n++)
@ -855,10 +976,135 @@ _font_cb_change(void *data, Evas_Object *obj)
}
}
}
/* load and select size list */
if (tc)
{
cfdata->cur_size = tc->size;
_size_list_load(cfdata, cfdata->font_scale_list, tc->size, 1);
_size_list_load(cfdata, cfdata->font_px_list, tc->size, 0);
}
_font_preview_update(cfdata);
}
static void
_size_list_load(E_Config_Dialog_Data *cfdata, Evas_List *size_list, Evas_Font_Size cur_size, int clear)
{
Evas_List *next;
Evas_Object *ob;
Evas *evas;
int n;
ob = cfdata->gui.size_list;
evas = evas_object_evas_get(ob);
evas_event_freeze(evas);
edje_freeze();
e_widget_ilist_freeze(ob);
if (clear) e_widget_ilist_clear(ob);
for (next = size_list; next; next = next->next)
{
E_Font_Size_Data *size_data;
size_data = next->data;
e_widget_ilist_append(ob, NULL, size_data->size_str, _size_cb_change,
size_data, NULL);
}
e_widget_ilist_go(ob);
e_widget_ilist_thaw(ob);
edje_thaw();
evas_event_thaw(evas);
for (n = 0; n < e_widget_ilist_count(ob); n++)
{
E_Font_Size_Data *size_data;
size_data = e_widget_ilist_nth_data_get(ob, n);
if (cur_size == size_data->size)
{
e_widget_ilist_selected_set(ob, n);
break;
}
}
}
static void
_font_list_load(E_Config_Dialog_Data *cfdata, const char *cur_font)
{
int n;
Evas_List *next;
Evas_Object *ob;
Evas *evas;
Evas_Coord w;
ob = cfdata->gui.font_list;
evas = evas_object_evas_get(ob);
evas_event_freeze(evas);
edje_freeze();
e_widget_ilist_freeze(ob);
/* Load Hash a single time */
if (cfdata->font_hash == NULL)
{
Evas_List *fonts;
fonts = evas_font_available_list(evas);
cfdata->font_hash = e_font_available_list_parse(fonts);
evas_hash_foreach(cfdata->font_hash, _font_hash_cb, cfdata);
if (cfdata->font_list)
{
cfdata->font_list = evas_list_sort(cfdata->font_list,
evas_list_count(cfdata->font_list),
_sort_fonts);
}
evas_font_available_list_free(evas, fonts);
}
/* Load the list */
if (cfdata->font_list)
{
Evas_List *next;
for (next = cfdata->font_list; next; next = next->next)
{
const char *f;
f = next->data;
e_widget_ilist_append(ob, NULL, f, NULL, NULL, f);
}
}
e_widget_ilist_go(ob);
e_widget_min_size_get(ob, &w, NULL);
e_widget_min_size_set(ob, w, 250);
e_widget_ilist_thaw(ob);
edje_thaw();
evas_event_thaw(evas);
if (!cur_font) return;
/* Select Current Font */
n = 0;
for (next = cfdata->font_list; next; next = next->next)
{
const char *f;
f = next->data;
if (cur_font && !strcasecmp(f, cur_font))
{
e_widget_ilist_selected_set(ob, n);
break;
}
n++;
}
}
static void
_style_cb_change(void *data, Evas_Object *obj)
_adv_style_cb_change(void *data, Evas_Object *obj)
{
E_Config_Dialog_Data *cfdata;
Evas_List *l;
@ -882,11 +1128,13 @@ _style_cb_change(void *data, Evas_Object *obj)
if (cfdata->cur_style)
tc->style = evas_stringshare_add(cfdata->cur_style);
}
_font_preview_update(cfdata);
}
/* Private Font Fallback Functions */
static void
_enabled_fallback_cb_change(void *data, Evas_Object *obj)
_adv_enabled_fallback_cb_change(void *data, Evas_Object *obj)
{
E_Config_Dialog_Data *cfdata;
@ -904,3 +1152,16 @@ _sort_fonts(void *data1, void *data2)
return e_util_strcmp(data1, data2);
}
static void
_font_preview_update(E_Config_Dialog_Data *cfdata)
{
/* update preview */
if (cfdata->cur_font)
{
const char *name;
name = e_font_fontconfig_name_get(cfdata->cur_font, cfdata->cur_style);
e_widget_font_preview_font_set(cfdata->gui.preview, name, cfdata->cur_size);
evas_stringshare_del(name);
}
}

@ -0,0 +1,102 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include "e.h"
typedef struct _E_Widget_Data E_Widget_Data;
struct _E_Widget_Data
{
Evas_Object *o_scrollframe;
Evas_Object *o_text;
};
static void _e_wid_cb_scrollframe_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _e_wid_del_hook(Evas_Object *obj);
/* local subsystem functions */
/* externally accessible functions */
EAPI Evas_Object *
e_widget_font_preview_add(Evas *evas, const char *text)
{
Evas_Object *obj, *o;
E_Widget_Data *wd;
obj = e_widget_add(evas);
e_widget_del_hook_set(obj, _e_wid_del_hook);
wd = calloc(1, sizeof(E_Widget_Data));
e_widget_data_set(obj, wd);
/* Add Scrollpane */
o = e_scrollframe_add(evas);
wd->o_scrollframe = o;
e_scrollframe_policy_set(o, E_SCROLLFRAME_POLICY_OFF, E_SCROLLFRAME_POLICY_OFF);
evas_object_show(o);
e_widget_sub_object_add(obj, o);
e_widget_resize_object_set(obj, o);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _e_wid_focus_steal, obj);
/* Add Text */
o = edje_object_add(evas);
wd->o_text = o;
e_theme_edje_object_set(o, "base/theme/widgets",
"e/widgets/fontpreview");
evas_object_event_callback_add(wd->o_scrollframe, EVAS_CALLBACK_RESIZE, _e_wid_cb_scrollframe_resize, wd);
e_scrollframe_child_set(wd->o_scrollframe, o);
e_widget_sub_object_add(obj, o);
evas_object_show(o);
edje_object_part_text_set(wd->o_text, "e.fontpreview.text", text);
evas_object_resize(obj, 40, 40);
e_widget_min_size_set(obj, 40, 40);
return obj;
}
EAPI void
e_widget_font_preview_font_set(Evas_Object *obj, const char *font, Evas_Font_Size size)
{
E_Widget_Data *wd;
wd = e_widget_data_get(obj);
if (size < 0)
size = (-size * 10) / 100;
if (size == 0)
size = 10;
edje_object_text_class_set(wd->o_text, "_e_font_preview", font, size);
}
static void
_e_wid_del_hook(Evas_Object *obj)
{
E_Widget_Data *wd;
wd = e_widget_data_get(obj);
free(wd);
}
static void
_e_wid_cb_scrollframe_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
E_Widget_Data *wd;
Evas_Coord mw, mh, vw, vh;
wd = data;
e_scrollframe_child_viewport_size_get(obj, &vw, &vh);
edje_object_size_min_calc(wd->o_text, &mw, &mh);
e_scrollframe_child_viewport_size_get(wd->o_scrollframe, &vw, &vh);
if (vw > mw) mw = vw;
if (vh > mh) mh = vh;
evas_object_resize(wd->o_text, mw, mh);
}
static void
_e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
e_widget_focus_steal(data);
}

@ -0,0 +1,13 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifdef E_TYPEDEFS
#else
#ifndef E_WIDGET_FONT_PREVIEW_H
#define E_WIDGET_FONT_PREVIEW_H
EAPI Evas_Object *e_widget_font_preview_add(Evas *evas, const char *text);
EAPI void e_widget_font_preview_font_set(Evas_Object *obj, const char *font, Evas_Font_Size size);
#endif
#endif

@ -218,6 +218,21 @@ e_widget_ilist_nth_icon_get(Evas_Object *obj, int n)
return e_ilist_nth_icon_get(wd->o_ilist, n);
}
EAPI void *
e_widget_ilist_nth_data_get(Evas_Object *obj, int n)
{
E_Widget_Data *wd;
E_Widget_Callback *wcb;
wd = e_widget_data_get(obj);
wcb = evas_list_nth(wd->callbacks, n);
if (!wcb)
return NULL;
else
return wcb->data;
}
EAPI Evas_Object *
e_widget_ilist_selected_icon_get(Evas_Object *obj)
{

@ -25,6 +25,7 @@ EAPI Evas_Object *e_widget_ilist_selected_icon_get(Evas_Object *obj);
EAPI int e_widget_ilist_count(Evas_Object *obj);
EAPI void e_widget_ilist_clear(Evas_Object *obj);
EAPI int e_widget_ilist_nth_is_header(Evas_Object *obj, int n);
EAPI void *e_widget_ilist_nth_data_get(Evas_Object *obj, int n);
EAPI void e_widget_ilist_freeze(Evas_Object *obj);
EAPI void e_widget_ilist_thaw(Evas_Object *obj);
EAPI void e_widget_ilist_multi_select_set(Evas_Object *obj, int multi);

Loading…
Cancel
Save