themes: introduce theme support with themes

This commit is contained in:
Al Poole 2017-12-03 14:49:32 +00:00
commit 556df6ee74
8 changed files with 158 additions and 30 deletions

14
NEWS
View File

@ -1,3 +1,17 @@
=======
Edi 0.7
=======
Features:
* Added theme support and new themes.
* Added notification support.
* Added split-view option for editors.
* Project wizard and new project templates.
* Improved debugging support.
* Added edi_scm helper command.
* Replace all in project.
=======
Edi 0.6
=======

View File

@ -5,7 +5,7 @@ cmd = [ edje_cc,
'@INPUT@', '@OUTPUT@'
]
theme_names = ['black', 'white']
theme_names = ['white', 'solarized', 'solarized_dark']
foreach theme_name : theme_names
custom_target('theme ' + theme_name,

64
data/themes/solarized.edc Normal file
View File

@ -0,0 +1,64 @@
data {
item: "title" "Solarized";
}
collections {
/* simple layout to pack our scrolling content into an elm_layout */
group { name: "elm/code/layout/default";
data {
item: "font.name" "Mono";
item: "font.size" "10";
}
parts {
part { name: "elm.swallow.content"; type: SWALLOW;
description { state: "default" 0.0;
align: 0.5 0.0;
fixed: 0 1;
rel2 {
relative: 1.0 1.0;
offset: 0 0;
}
}
}
}
}
color_classes {
color_class { name: "elm/code/status/default"; color: 253 246 227 255; }
color_class { name: "elm/code/status/current"; color: 238 232 213 255; }
color_class { name: "elm/code/status/ignored"; color: 36 36 36 255; }
color_class { name: "elm/code/status/note"; color: 221 119 17 255; }
color_class { name: "elm/code/status/warning"; color: 221 119 17 255; }
color_class { name: "elm/code/status/error"; color: 204 17 17 255; }
color_class { name: "elm/code/status/fatal"; color: 204 17 17 255; }
color_class { name: "elm/code/status/added"; color: 36 96 36 255; }
color_class { name: "elm/code/status/removed"; color: 96 36 36 255; }
color_class { name: "elm/code/status/changed"; color: 36 36 96 255; }
color_class { name: "elm/code/status/passed"; color: 54 96 54 255; }
color_class { name: "elm/code/status/failed"; color: 96 54 54 255; }
color_class { name: "elm/code/status/todo"; color: 211 54 130 255; }
color_class { name: "elm/code/token/default"; color: 88 110 117 255; }
color_class { name: "elm/code/token/comment"; color: 147 161 161 255; }
color_class { name: "elm/code/token/string"; color: 42 161 152 255; }
color_class { name: "elm/code/token/number"; color: 42 161 152 255; }
color_class { name: "elm/code/token/brace"; color: 101 123 131 255; }
color_class { name: "elm/code/token/type"; color: 181 137 0 255; }
color_class { name: "elm/code/token/class"; color: 255 255 255 255; }
color_class { name: "elm/code/token/function"; color: 255 255 255 255; }
color_class { name: "elm/code/token/param"; color: 133 153 0 255; }
color_class { name: "elm/code/token/keyword"; color: 133 153 0 255; }
color_class { name: "elm/code/token/preprocessor"; color: 203 75 22 255; }
color_class { name: "elm/code/token/added"; color: 54 255 54 255; }
color_class { name: "elm/code/token/removed"; color: 255 54 54 255; }
color_class { name: "elm/code/token/changed"; color: 54 54 255 255; }
color_class { name: "elm/code/token/match"; color: 187 187 51 255; }
color_class { name: "elm/code/widget/color/selection"; color: 133 153 0 255; }
color_class { name: "elm/code/widget/color/gutter/bg"; color: 238 232 213 255; }
color_class { name: "elm/code/widget/color/gutter/fg"; color: 147 161 161 255; }
color_class { name: "elm/code/widget/color/gutter/scope/bg"; color: 54 54 54 255; }
color_class { name: "elm/code/widget/color/whitespace"; color: 50 50 50 127; }
}
}

View File

@ -1,3 +1,7 @@
data {
item: "title" "Solarized Dark";
}
collections {
/* simple layout to pack our scrolling content into an elm_layout */
@ -22,8 +26,8 @@ group { name: "elm/code/layout/default";
}
color_classes {
color_class { name: "elm/code/status/default"; color: 0 0 0 255; }
color_class { name: "elm/code/status/current"; color: 12 12 12 255; }
color_class { name: "elm/code/status/default"; color: 0 43 54 255; }
color_class { name: "elm/code/status/current"; color: 7 54 66 255; }
color_class { name: "elm/code/status/ignored"; color: 36 36 36 255; }
color_class { name: "elm/code/status/note"; color: 221 119 17 255; }
color_class { name: "elm/code/status/warning"; color: 221 119 17 255; }
@ -34,27 +38,27 @@ color_classes {
color_class { name: "elm/code/status/changed"; color: 36 36 96 255; }
color_class { name: "elm/code/status/passed"; color: 54 96 54 255; }
color_class { name: "elm/code/status/failed"; color: 96 54 54 255; }
color_class { name: "elm/code/status/todo"; color: 51 85 187 255; }
color_class { name: "elm/code/status/todo"; color: 211 54 130 255; }
color_class { name: "elm/code/token/default"; color: 187 187 187 255; }
color_class { name: "elm/code/token/comment"; color: 85 85 85 255; }
color_class { name: "elm/code/token/string"; color: 255 136 119 255; }
color_class { name: "elm/code/token/number"; color: 170 153 34 255; }
color_class { name: "elm/code/token/brace"; color: 170 102 170 255; }
color_class { name: "elm/code/token/type"; color: 255 255 255 255; }
color_class { name: "elm/code/token/default"; color: 147 161 161 255; }
color_class { name: "elm/code/token/comment"; color: 88 110 117 255; }
color_class { name: "elm/code/token/string"; color: 42 161 152 255; }
color_class { name: "elm/code/token/number"; color: 42 161 152 255; }
color_class { name: "elm/code/token/brace"; color: 131 148 150 255; }
color_class { name: "elm/code/token/type"; color: 181 137 0 255; }
color_class { name: "elm/code/token/class"; color: 255 255 255 255; }
color_class { name: "elm/code/token/function"; color: 255 255 255 255; }
color_class { name: "elm/code/token/param"; color: 187 187 187 255; }
color_class { name: "elm/code/token/keyword"; color: 68 136 204 255; }
color_class { name: "elm/code/token/preprocessor"; color: 102 255 85 255; }
color_class { name: "elm/code/token/param"; color: 181 137 0 255; }
color_class { name: "elm/code/token/keyword"; color: 181 137 0 255; }
color_class { name: "elm/code/token/preprocessor"; color: 203 75 22 255; }
color_class { name: "elm/code/token/added"; color: 54 255 54 255; }
color_class { name: "elm/code/token/removed"; color: 255 54 54 255; }
color_class { name: "elm/code/token/changed"; color: 54 54 255 255; }
color_class { name: "elm/code/token/match"; color: 187 187 51 255; }
color_class { name: "elm/code/widget/color/selection"; color: 51 153 255 255; }
color_class { name: "elm/code/widget/color/gutter/bg"; color: 75 75 75 255; }
color_class { name: "elm/code/widget/color/gutter/fg"; color: 139 139 139 255; }
color_class { name: "elm/code/widget/color/selection"; color: 38 139 210 255; }
color_class { name: "elm/code/widget/color/gutter/bg"; color: 7 54 66 255; }
color_class { name: "elm/code/widget/color/gutter/fg"; color: 88 110 117 255; }
color_class { name: "elm/code/widget/color/gutter/scope/bg"; color: 54 54 54 255; }
color_class { name: "elm/code/widget/color/whitespace"; color: 50 50 50 127; }
}

View File

@ -1,5 +1,8 @@
collections {
data {
item: "title" "Black on White";
}
collections {
/* simple layout to pack our scrolling content into an elm_layout */
group { name: "elm/code/layout/default";
data {

View File

@ -35,6 +35,37 @@ edi_theme_elm_code_set(Evas_Object *obj, const char *name)
}
}
Edi_Theme *
edi_theme_theme_by_name(const char *name)
{
Eina_List *l;
Edi_Theme *theme;
if (!name) return NULL;
edi_theme_themes_get();
EINA_LIST_FOREACH(_edi_themes, l, theme)
{
if (!strcmp(theme->name, name))
return theme;
}
return NULL;
}
static int
_theme_sort_cb(const void *t1, const void *t2)
{
const Edi_Theme *theme1 = t1;
const Edi_Theme *theme2 = t2;
if (!theme1) return 1;
if (!theme2) return -1;
return strcmp(theme1->title, theme2->title);
}
Eina_List *
edi_theme_themes_get(void)
{
@ -49,6 +80,8 @@ edi_theme_themes_get(void)
theme = malloc(sizeof(Edi_Theme));
theme->name = strdup("default");
theme->path = edi_path_append(elm_theme_system_dir_get(), "default.edj");
theme->title = strdup("Default EFL");
_edi_themes = eina_list_append(_edi_themes, theme);
files = ecore_file_ls(directory);
@ -60,8 +93,8 @@ edi_theme_themes_get(void)
name = strdup(file);
name[strlen(name) - 4] = '\0';
theme->name = name;
theme->path = edi_path_append(directory, file);
theme->title = edje_file_data_get(theme->path, "title");
_edi_themes = eina_list_append(_edi_themes, theme);
}
free(file);
@ -70,6 +103,8 @@ edi_theme_themes_get(void)
if (files)
eina_list_free(files);
_edi_themes = eina_list_sort(_edi_themes, eina_list_count(_edi_themes), _theme_sort_cb);
return _edi_themes;
}

View File

@ -7,6 +7,7 @@
typedef struct _Edi_Theme {
char *name;
char *path;
char *title;
} Edi_Theme;
#ifdef __cplusplus
@ -47,6 +48,16 @@ void edi_theme_elm_code_set(Evas_Object *obj, const char *name);
*/
Eina_List *edi_theme_themes_get(void);
/**
* Get theme obj by its name.
*
* @return the theme obj matching the name.
*
* @ingroup Theme
*/
Edi_Theme *edi_theme_theme_by_name(const char *name);
/**
* @}
*/

View File

@ -146,12 +146,15 @@ _edi_settings_font_preview_add(Evas_Object *parent, const char *font_name, int f
static void
_edi_settings_display_theme_pressed_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info)
{
Edi_Theme *theme;
const char *text = elm_object_item_text_get(event_info);
theme = elm_object_item_data_get(event_info);
if (_edi_project_config->gui.theme)
eina_stringshare_del(_edi_project_config->gui.theme);
_edi_project_config->gui.theme = eina_stringshare_add(text);
_edi_project_config->gui.theme = eina_stringshare_add(theme->name);
_edi_project_config_save();
elm_object_text_set(obj, text);
@ -162,14 +165,10 @@ static char *
_edi_settings_display_theme_text_get_cb(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
{
Edi_Theme *current;
int i;
i = (int)(uintptr_t) data;
current = eina_list_nth(edi_theme_themes_get(), i);
current = data;
if (!current) return NULL;
return strdup(current->name);
return strdup(current->title);
}
static Evas_Object *
@ -180,7 +179,6 @@ _edi_settings_display_create(Evas_Object *parent)
Elm_Genlist_Item_Class *itc;
Edi_Theme *theme;
Eina_List *themes, *l;
int i = 0;
frame = _edi_settings_panel_create(parent, _("Display"));
box = elm_object_part_content_get(frame, "default");
@ -225,9 +223,9 @@ _edi_settings_display_create(Evas_Object *parent)
_edi_settings_display_theme_pressed_cb, NULL);
if (!_edi_project_config->gui.theme)
elm_object_text_set(combobox, _("default"));
elm_object_text_set(combobox, edi_theme_theme_by_name("default")->title);
else
elm_object_text_set(combobox, _edi_project_config->gui.theme);
elm_object_text_set(combobox, edi_theme_theme_by_name(_edi_project_config->gui.theme)->title);
elm_table_pack(table, combobox, 1, 1, 1, 1);
elm_box_pack_end(box, table);
@ -239,8 +237,7 @@ _edi_settings_display_create(Evas_Object *parent)
EINA_LIST_FOREACH(themes, l, theme)
{
elm_genlist_item_append(combobox, itc, (void *)(uintptr_t) i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)(uintptr_t) i);
i++;
elm_genlist_item_append(combobox, itc, theme, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
}
elm_genlist_realized_items_update(combobox);