Adding support for selection of theme

SVN revision: 77333
devs/lucas/wip
Flavio Vinicius Alvares Ceolin 10 years ago
parent 6e2b6480a5
commit 22fba090a0
  1. 1
      TODO
  2. 2
      src/bin/main.c
  3. 1
      src/bin/options.c
  4. 144
      src/bin/options_theme.c
  5. 1
      src/bin/options_theme.h
  6. 20
      src/bin/termio.c
  7. 2
      src/bin/termio.h

@ -6,7 +6,6 @@ make it a first-class terminal:
[ ] dnd file uri's too as text etc.
[ ] general input mode handling improvements (keypad, other key
input, etc.)
[ ] selection of themes
[ ] selection of background "wallpapers" (and support them at all -
doesn't right now - should support regular images, animated gifs,
and edje files)

@ -674,6 +674,7 @@ elm_main(int argc, char **argv)
retval = EXIT_FAILURE;
goto end;
}
theme_auto_reload_enable(o);
elm_object_content_set(conform, o);
evas_object_show(o);
@ -709,6 +710,7 @@ elm_main(int argc, char **argv)
term = o = termio_add(win, config, cmd, login_shell, cd, size_w, size_h);
termio_win_set(o, win);
termio_theme_set(o, bg);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_event_callback_add(o, EVAS_CALLBACK_CHANGED_SIZE_HINTS,

@ -90,6 +90,7 @@ _cb_op_del_delay(void *data __UNUSED__)
evas_object_del(op_opbox);
evas_object_del(op_frame);
options_font_clear();
options_theme_clear();
op_opbox = NULL;
op_frame = NULL;
op_del_timer = NULL;

@ -6,15 +6,149 @@
#include "options.h"
#include "options_theme.h"
static Evas_Object *op_themelist;
static Eina_List *themes = NULL;
typedef struct _Theme Theme;
struct _Theme
{
Elm_Object_Item *item;
const char *name;
Evas_Object *term;
};
static char *
_cb_op_theme_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
{
Theme *t = data;
char buf[4096], *p;
eina_strlcpy(buf, t->name, sizeof(buf));
p = strrchr(buf, '.');
if (p) *p = 0;
return strdup(buf);
}
static Evas_Object *
_cb_op_theme_content_get(void *data, Evas_Object *obj, const char *part)
{
Theme *t = data;
char buf[4096];
if (!strcmp(part, "elm.swallow.icon"))
{
Evas_Object *o;
Config *config = termio_config_get(t->term);
snprintf(buf, sizeof(buf), "%s/themes/%s", elm_app_data_dir_get(), t->name);
o = edje_object_add(evas_object_evas_get(obj));
if (!edje_object_file_set(o, buf, "terminology/background"))
return NULL;
evas_object_size_hint_min_set(o,
96 * elm_config_scale_get(),
40 * elm_config_scale_get());
return o;
}
return NULL;
}
static void
_cb_op_theme_sel(void *data, Evas_Object *obj, void *event __UNUSED__)
{
Theme *t = data;
Config *config = termio_config_get(t->term);
Evas_Object *edje = termio_theme_get(t->term);
if ((config->theme) && (!strcmp(t->name, config->theme)))
return;
eina_stringshare_replace(&(config->theme), t->name);
config_save(config, NULL);
if (!theme_apply(edje, config, "terminology/background"))
ERR("Couldn't find terminology theme!");
}
static int
_cb_op_theme_sort(const void *d1, const void *d2)
{
return strcasecmp(d1, d2);
}
void
options_theme(Evas_Object *opbox, Evas_Object *term __UNUSED__)
options_theme(Evas_Object *opbox, Evas_Object *term)
{
Evas_Object *o;
Evas_Object *o, *box, *fr;
Elm_Genlist_Item_Class *it_class;
Eina_List *files;
char buf[4096], *file;
Theme *t;
o = elm_label_add(opbox);
options_theme_clear();
fr = o = elm_frame_add(opbox);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_text_set(o, "Not Implemented Yet.");
evas_object_show(o);
elm_object_text_set(o, "Theme");
elm_box_pack_end(opbox, o);
evas_object_show(o);
box = o = elm_box_add(opbox);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_horizontal_set(o, EINA_TRUE);
elm_object_content_set(fr, o);
evas_object_show(o);
it_class = elm_genlist_item_class_new();
it_class->item_style = "end_icon";
it_class->func.text_get = _cb_op_theme_text_get;
it_class->func.content_get = _cb_op_theme_content_get;
op_themelist = o = elm_genlist_add(opbox);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_genlist_mode_set(o, ELM_LIST_COMPRESS);
elm_genlist_homogeneous_set(o, EINA_TRUE);
snprintf(buf, sizeof(buf), "%s/themes", elm_app_data_dir_get());
files = ecore_file_ls(buf);
if (files)
files = eina_list_sort(files, eina_list_count(files),
_cb_op_theme_sort);
EINA_LIST_FREE(files, file)
{
t = calloc(1, sizeof(Theme));
t->name = eina_stringshare_add(file);
t->term = term;
t->item = elm_genlist_item_append(o, it_class, t, NULL,
ELM_GENLIST_ITEM_NONE,
_cb_op_theme_sel, t);
themes = eina_list_append(themes, t);
free(file);
}
elm_genlist_item_class_free(it_class);
elm_box_pack_end(box, o);
evas_object_size_hint_weight_set(opbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(opbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(o);
}
void
options_theme_clear(void)
{
Theme *t;
op_themelist = NULL;
EINA_LIST_FREE(themes, t)
{
eina_stringshare_del(t->name);
free(t);
}
}

@ -1 +1,2 @@
void options_theme_clear(void);
void options_theme(Evas_Object *opbox, Evas_Object *term);

@ -62,7 +62,7 @@ struct _Termio
Ecore_Timer *delayed_size_timer;
Ecore_Timer *link_do_timer;
Ecore_Job *mouse_move_job;
Evas_Object *win;
Evas_Object *win, *theme;
Config *config;
Ecore_IMF_Context *imf;
Eina_Bool jump_on_change : 1;
@ -2325,6 +2325,24 @@ termio_win_set(Evas_Object *obj, Evas_Object *win)
}
}
void
termio_theme_set(Evas_Object *obj, Evas_Object *theme)
{
Termio *sd = evas_object_smart_data_get(obj);
if (!sd) return;
if (theme)
sd->theme = theme;
}
Evas_Object *
termio_theme_get(Evas_Object *obj)
{
Termio *sd = evas_object_smart_data_get(obj);
if (!sd) return;
return sd->theme;
}
char *
termio_selection_get(Evas_Object *obj, int c1x, int c1y, int c2x, int c2y)
{

@ -5,6 +5,8 @@
Evas_Object *termio_add(Evas_Object *parent, Config *config, const char *cmd, Eina_Bool login_shell, const char *cd, int w, int h);
void termio_win_set(Evas_Object *obj, Evas_Object *win);
void termio_theme_set(Evas_Object *obj, Evas_Object *theme);
Evas_Object *termio_theme_get(Evas_Object *obj);
char *termio_selection_get(Evas_Object *obj, int c1x, int c1y, int c2x, int c2y);
void termio_config_update(Evas_Object *obj);
Config *termio_config_get(const Evas_Object *obj);

Loading…
Cancel
Save