2013-07-20 01:51:56 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "common.h"
|
|
|
|
|
2014-02-06 01:19:59 -08:00
|
|
|
const char *IMGPATH = "imgpath";
|
|
|
|
const char *SNDPATH = "sndpath";
|
|
|
|
const char *FNTPATH = "fntpath";
|
|
|
|
const char *DATPATH = "datpath";
|
|
|
|
const char *FNTSIZE = "fntsize";
|
|
|
|
const char *VIEWSCALE = "viewscale";
|
|
|
|
const char *STATSBAR = "statsbar";
|
|
|
|
const char *LINENUM = "linenum";
|
|
|
|
const char *HIGHLIGHT = "highlight";
|
|
|
|
const char *SWALLOW = "swallow";
|
|
|
|
const char *INDENT = "indent";
|
|
|
|
|
2014-02-04 04:48:06 -08:00
|
|
|
typedef struct config_s
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
const char *edc_path;
|
|
|
|
const char *edj_path;
|
|
|
|
|
|
|
|
Eina_List *edc_img_path_list;
|
|
|
|
Eina_List *edc_snd_path_list;
|
2013-08-27 10:26:13 -07:00
|
|
|
Eina_List *edc_fnt_path_list;
|
2013-08-27 21:16:34 -07:00
|
|
|
Eina_List *edc_data_path_list;
|
2013-07-20 01:51:56 -07:00
|
|
|
Eina_Strbuf *edc_img_path_buf; //pre-stored image paths for edc compile.
|
|
|
|
Eina_Strbuf *edc_snd_path_buf; //pre-stored sound paths for edc compile.
|
2013-08-27 21:16:34 -07:00
|
|
|
Eina_Strbuf *edc_fnt_path_buf; //pre-stored font paths for edc compile.
|
|
|
|
Eina_Strbuf *edc_data_path_buf; //pre-stored data paths for edc compile.
|
2013-08-27 10:26:13 -07:00
|
|
|
|
2013-08-22 05:47:23 -07:00
|
|
|
float font_size;
|
2014-01-26 08:21:02 -08:00
|
|
|
double view_scale;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2014-01-29 09:45:10 -08:00
|
|
|
void (*update_cb)(void *data);
|
2013-07-20 01:51:56 -07:00
|
|
|
void *update_cb_data;
|
|
|
|
Evas_Coord_Size view_size;
|
|
|
|
|
2014-02-06 01:19:59 -08:00
|
|
|
Eina_Bool stats_bar;
|
|
|
|
Eina_Bool linenumber;
|
|
|
|
Eina_Bool part_highlight;
|
|
|
|
Eina_Bool dummy_swallow;
|
|
|
|
Eina_Bool auto_indent;
|
|
|
|
Eina_Bool hotkeys;
|
2014-02-04 04:48:06 -08:00
|
|
|
} config_data;
|
2014-01-29 19:28:07 -08:00
|
|
|
|
2014-01-29 09:45:10 -08:00
|
|
|
static config_data *g_cd = NULL;
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
static void
|
2013-08-24 10:41:53 -07:00
|
|
|
config_edj_path_update(config_data *cd)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
//apply edj path also
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
char edj_path[PATH_MAX];
|
|
|
|
|
2013-08-24 10:41:53 -07:00
|
|
|
char *ext = strstr(cd->edc_path, ".edc");
|
|
|
|
const char *file = ecore_file_file_get(cd->edc_path);
|
2013-07-20 01:51:56 -07:00
|
|
|
if (ext && file)
|
|
|
|
snprintf(buf, (ext - file) + 1, "%s", file);
|
|
|
|
else
|
|
|
|
strncpy(buf, file, sizeof(buf));
|
2013-08-24 10:41:53 -07:00
|
|
|
sprintf(edj_path, "%s/%s.edj", ecore_file_dir_get(cd->edc_path), buf);
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-08-24 10:41:53 -07:00
|
|
|
eina_stringshare_replace(&cd->edj_path, edj_path);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2014-02-06 01:19:59 -08:00
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
config_load(config_data *cd)
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
snprintf(buf, sizeof(buf), "%s/.enventor/config.eet", getenv("HOME"));
|
|
|
|
Eet_File *ef = eet_open(buf, EET_FILE_MODE_READ);
|
|
|
|
if (!ef)
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("Cannot load a config file \"%s\"", buf);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int size;
|
|
|
|
char *ret;
|
|
|
|
|
|
|
|
ret = eet_read(ef, IMGPATH, &size);
|
|
|
|
if (size > 0) { config_edc_img_path_set(ret); free(ret); }
|
|
|
|
ret = eet_read(ef, SNDPATH, &size);
|
|
|
|
if (size > 0) { config_edc_snd_path_set(ret); free(ret); }
|
|
|
|
ret = eet_read(ef, FNTPATH, &size);
|
|
|
|
if (size > 0) { config_edc_fnt_path_set(ret); free(ret); }
|
|
|
|
ret = eet_read(ef, DATPATH, &size);
|
|
|
|
if (size > 0) { config_edc_data_path_set(ret); free(ret); }
|
|
|
|
ret = eet_read(ef, FNTSIZE, &size);
|
|
|
|
if (size > 0) { cd->font_size = atof(ret); free(ret); }
|
|
|
|
ret = eet_read(ef, VIEWSCALE, &size);
|
|
|
|
if (size > 0) { cd->view_scale = atof(ret); free(ret); }
|
|
|
|
ret = eet_read(ef, STATSBAR, &size);
|
|
|
|
if (size > 0) { cd->stats_bar = (Eina_Bool) atoi(ret); free(ret); }
|
|
|
|
ret = eet_read(ef, LINENUM, &size);
|
|
|
|
if (size > 0) { cd->linenumber = (Eina_Bool) atoi(ret); free(ret); }
|
|
|
|
ret = eet_read(ef, HIGHLIGHT, &size);
|
|
|
|
if (size > 0) { cd->part_highlight = (Eina_Bool) atoi(ret); free(ret); }
|
|
|
|
ret = eet_read(ef, SWALLOW, &size);
|
|
|
|
if (size > 0) { cd->dummy_swallow = (Eina_Bool) atoi(ret); free(ret); }
|
|
|
|
ret = eet_read(ef, INDENT, &size);
|
|
|
|
if (size > 0) { cd->auto_indent = (Eina_Bool) atoi(ret); free(ret); }
|
|
|
|
|
|
|
|
eet_close(ef);
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
edc_paths_write(Eet_File *ef, const char *key, Eina_List *paths,
|
|
|
|
Eina_Strbuf *strbuf)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
char *path;
|
|
|
|
|
|
|
|
eina_strbuf_reset(strbuf);
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(paths, l, path)
|
|
|
|
{
|
|
|
|
eina_strbuf_append(strbuf, path);
|
|
|
|
eina_strbuf_append(strbuf, ";");
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *str = eina_strbuf_string_get(strbuf);
|
|
|
|
eet_write(ef, key, str, strlen(str) + 1, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
config_save(config_data *cd)
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
snprintf(buf, sizeof(buf), "%s/.enventor", getenv("HOME"));
|
|
|
|
|
|
|
|
//Create config folder if it doesn't exist.
|
|
|
|
if (!ecore_file_exists(buf))
|
|
|
|
{
|
|
|
|
Eina_Bool success = ecore_file_mkdir(buf);
|
|
|
|
if (!success)
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("Cannot create a config folder \"%s\"", buf);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Save config file.
|
|
|
|
snprintf(buf, sizeof(buf), "%s/.enventor/config.eet", getenv("HOME"));
|
|
|
|
Eet_File *ef = eet_open(buf, EET_FILE_MODE_WRITE);
|
|
|
|
if (!ef)
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("Cannot save a config file \"%s\"", buf);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO: Use Eet Descriptor if the attributes are getting bigger and bigger
|
|
|
|
Eina_Strbuf *strbuf = eina_strbuf_new();
|
|
|
|
edc_paths_write(ef, IMGPATH, cd->edc_img_path_list, strbuf);
|
|
|
|
edc_paths_write(ef, SNDPATH, cd->edc_snd_path_list, strbuf);
|
|
|
|
edc_paths_write(ef, FNTPATH, cd->edc_fnt_path_list, strbuf);
|
|
|
|
edc_paths_write(ef, DATPATH, cd->edc_data_path_list, strbuf);
|
|
|
|
eina_strbuf_free(strbuf);
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%f", cd->font_size);
|
|
|
|
eet_write(ef, FNTSIZE, buf, strlen(buf) + 1, 0);
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%f", cd->view_scale);
|
|
|
|
eet_write(ef, VIEWSCALE, buf, strlen(buf) + 1, 0);
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%d", cd->stats_bar);
|
|
|
|
eet_write(ef, STATSBAR, buf, strlen(buf) + 1, 0);
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%d", cd->linenumber);
|
|
|
|
eet_write(ef, LINENUM, buf, strlen(buf) + 1, 0);
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%d", cd->part_highlight);
|
|
|
|
eet_write(ef, HIGHLIGHT, buf, strlen(buf) + 1, 0);
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%d", cd->dummy_swallow);
|
|
|
|
eet_write(ef, SWALLOW, buf, strlen(buf) + 1, 0);
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%d", cd->auto_indent);
|
|
|
|
eet_write(ef, INDENT, buf, strlen(buf) + 1, 0);
|
|
|
|
|
|
|
|
eet_close(ef);
|
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
void
|
2014-01-29 09:45:10 -08:00
|
|
|
config_edc_path_set(const char *edc_path)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
eina_stringshare_replace(&cd->edc_path, edc_path);
|
|
|
|
config_edj_path_update(cd);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2014-01-29 09:45:10 -08:00
|
|
|
void
|
2013-08-24 10:41:53 -07:00
|
|
|
config_init(const char *edc_path, const char *edc_img_path,
|
2013-08-27 21:16:34 -07:00
|
|
|
const char *edc_snd_path, const char *edc_fnt_path,
|
|
|
|
const char *edc_data_path)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2013-08-24 10:41:53 -07:00
|
|
|
config_data *cd = calloc(1, sizeof(config_data));
|
2014-01-29 09:45:10 -08:00
|
|
|
g_cd = cd;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-08-24 10:41:53 -07:00
|
|
|
cd->edc_path = eina_stringshare_add(edc_path);
|
|
|
|
config_edj_path_update(cd);
|
2014-02-06 01:19:59 -08:00
|
|
|
|
|
|
|
if (!config_load(cd))
|
|
|
|
{
|
|
|
|
//failed to load config file. set default values.
|
|
|
|
config_edc_img_path_set(edc_img_path);
|
|
|
|
config_edc_snd_path_set(edc_snd_path);
|
|
|
|
config_edc_fnt_path_set(edc_fnt_path);
|
|
|
|
config_edc_data_path_set(edc_data_path);
|
|
|
|
|
|
|
|
cd->font_size = 1.0f;
|
|
|
|
cd->view_scale = 1;
|
|
|
|
cd->linenumber = EINA_TRUE;
|
|
|
|
cd->part_highlight = EINA_TRUE;
|
|
|
|
cd->dummy_swallow = EINA_TRUE;
|
|
|
|
cd->auto_indent = EINA_TRUE;
|
|
|
|
}
|
|
|
|
//hotkey is not decided yet to keep the function or not.
|
2014-01-29 19:18:31 -08:00
|
|
|
cd->hotkeys = EINA_TRUE;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-01-29 09:45:10 -08:00
|
|
|
config_term()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
|
|
|
|
2014-02-06 01:19:59 -08:00
|
|
|
config_save(cd);
|
|
|
|
|
2013-08-24 10:41:53 -07:00
|
|
|
eina_stringshare_del(cd->edc_path);
|
|
|
|
eina_stringshare_del(cd->edj_path);
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
Eina_List *l;
|
|
|
|
Eina_Stringshare *str;
|
|
|
|
|
|
|
|
//free the image paths
|
2013-08-24 10:41:53 -07:00
|
|
|
EINA_LIST_FOREACH(cd->edc_img_path_list, l, str)
|
2013-07-20 01:51:56 -07:00
|
|
|
eina_stringshare_del(str);
|
2013-08-24 10:41:53 -07:00
|
|
|
eina_list_free(cd->edc_img_path_list);
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
//free the sound paths
|
2013-08-24 10:41:53 -07:00
|
|
|
EINA_LIST_FOREACH(cd->edc_snd_path_list, l, str)
|
2013-07-20 01:51:56 -07:00
|
|
|
eina_stringshare_del(str);
|
2013-08-24 10:41:53 -07:00
|
|
|
eina_list_free(cd->edc_snd_path_list);
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-08-27 10:26:13 -07:00
|
|
|
//free the font paths
|
|
|
|
EINA_LIST_FOREACH(cd->edc_fnt_path_list, l, str)
|
|
|
|
eina_stringshare_del(str);
|
|
|
|
eina_list_free(cd->edc_fnt_path_list);
|
|
|
|
|
2013-08-27 21:16:34 -07:00
|
|
|
//free the data paths
|
|
|
|
EINA_LIST_FOREACH(cd->edc_data_path_list, l, str)
|
|
|
|
eina_stringshare_del(str);
|
|
|
|
eina_list_free(cd->edc_data_path_list);
|
|
|
|
|
2013-08-27 10:28:29 -07:00
|
|
|
if (cd->edc_img_path_buf) eina_strbuf_free(cd->edc_img_path_buf);
|
|
|
|
if (cd->edc_snd_path_buf) eina_strbuf_free(cd->edc_snd_path_buf);
|
|
|
|
if (cd->edc_fnt_path_buf) eina_strbuf_free(cd->edc_fnt_path_buf);
|
2013-08-27 21:16:34 -07:00
|
|
|
if (cd->edc_data_path_buf) eina_strbuf_free(cd->edc_data_path_buf);
|
2013-08-27 10:28:29 -07:00
|
|
|
|
2013-08-24 10:41:53 -07:00
|
|
|
free(cd);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-01-29 09:45:10 -08:00
|
|
|
config_edc_snd_path_set(const char *edc_snd_path)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
//Free the existing paths
|
|
|
|
Eina_List *l;
|
|
|
|
const char *s;
|
2013-08-24 10:41:53 -07:00
|
|
|
EINA_LIST_FOREACH(cd->edc_snd_path_list, l, s)
|
2013-07-20 01:51:56 -07:00
|
|
|
eina_stringshare_del(s);
|
2013-08-24 10:41:53 -07:00
|
|
|
cd->edc_snd_path_list = eina_list_free(cd->edc_snd_path_list);
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-08-24 10:41:53 -07:00
|
|
|
if (cd->edc_snd_path_buf) eina_strbuf_free(cd->edc_snd_path_buf);
|
|
|
|
cd->edc_snd_path_buf = eina_strbuf_new();
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
//parse paths by ';'
|
|
|
|
const char *lex;
|
|
|
|
Eina_Stringshare *append;
|
|
|
|
|
|
|
|
while(edc_snd_path && (strlen(edc_snd_path) > 0))
|
|
|
|
{
|
|
|
|
lex = strstr(edc_snd_path, ";");
|
|
|
|
if (lex)
|
|
|
|
{
|
|
|
|
append = eina_stringshare_add_length(edc_snd_path,
|
|
|
|
(lex - edc_snd_path));
|
2013-08-24 10:41:53 -07:00
|
|
|
cd->edc_snd_path_list = eina_list_append(cd->edc_snd_path_list,
|
2013-07-20 01:51:56 -07:00
|
|
|
append);
|
2013-08-24 10:41:53 -07:00
|
|
|
eina_strbuf_append(cd->edc_snd_path_buf, " -sd ");
|
|
|
|
eina_strbuf_append(cd->edc_snd_path_buf, append);
|
2013-07-20 01:51:56 -07:00
|
|
|
lex++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
append = eina_stringshare_add(edc_snd_path);
|
2013-08-24 10:41:53 -07:00
|
|
|
cd->edc_snd_path_list = eina_list_append(cd->edc_snd_path_list,
|
2013-07-20 01:51:56 -07:00
|
|
|
append);
|
2013-08-24 10:41:53 -07:00
|
|
|
eina_strbuf_append(cd->edc_snd_path_buf, " -sd ");
|
|
|
|
eina_strbuf_append(cd->edc_snd_path_buf, append);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
edc_snd_path = lex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-27 21:16:34 -07:00
|
|
|
void
|
2014-01-29 09:45:10 -08:00
|
|
|
config_edc_data_path_set(const char *edc_data_path)
|
2013-08-27 21:16:34 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
|
|
|
|
2013-08-27 21:16:34 -07:00
|
|
|
//Free the existing paths
|
|
|
|
Eina_List *l;
|
|
|
|
const char *s;
|
|
|
|
EINA_LIST_FOREACH(cd->edc_data_path_list, l, s)
|
|
|
|
eina_stringshare_del(s);
|
|
|
|
cd->edc_data_path_list = eina_list_free(cd->edc_data_path_list);
|
|
|
|
|
|
|
|
if (cd->edc_data_path_buf) eina_strbuf_free(cd->edc_data_path_buf);
|
|
|
|
cd->edc_data_path_buf = eina_strbuf_new();
|
|
|
|
|
|
|
|
//parse paths by ';'
|
|
|
|
const char *lex;
|
|
|
|
Eina_Stringshare *append;
|
|
|
|
|
|
|
|
while(edc_data_path && (strlen(edc_data_path) > 0))
|
|
|
|
{
|
|
|
|
lex = strstr(edc_data_path, ";");
|
|
|
|
if (lex)
|
|
|
|
{
|
|
|
|
append = eina_stringshare_add_length(edc_data_path,
|
|
|
|
(lex - edc_data_path));
|
|
|
|
cd->edc_data_path_list = eina_list_append(cd->edc_data_path_list,
|
|
|
|
append);
|
|
|
|
eina_strbuf_append(cd->edc_data_path_buf, " -fd ");
|
|
|
|
eina_strbuf_append(cd->edc_data_path_buf, append);
|
|
|
|
lex++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
append = eina_stringshare_add(edc_data_path);
|
|
|
|
cd->edc_data_path_list = eina_list_append(cd->edc_data_path_list,
|
|
|
|
append);
|
|
|
|
eina_strbuf_append(cd->edc_data_path_buf, " -fd ");
|
|
|
|
eina_strbuf_append(cd->edc_data_path_buf, append);
|
|
|
|
}
|
|
|
|
|
|
|
|
edc_data_path = lex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-27 10:26:13 -07:00
|
|
|
void
|
2014-01-29 09:45:10 -08:00
|
|
|
config_edc_fnt_path_set(const char *edc_fnt_path)
|
2013-08-27 10:26:13 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
|
|
|
|
2013-08-27 10:26:13 -07:00
|
|
|
//Free the existing paths
|
|
|
|
Eina_List *l;
|
|
|
|
const char *s;
|
|
|
|
EINA_LIST_FOREACH(cd->edc_fnt_path_list, l, s)
|
|
|
|
eina_stringshare_del(s);
|
|
|
|
cd->edc_fnt_path_list = eina_list_free(cd->edc_fnt_path_list);
|
|
|
|
|
|
|
|
if (cd->edc_fnt_path_buf) eina_strbuf_free(cd->edc_fnt_path_buf);
|
|
|
|
cd->edc_fnt_path_buf = eina_strbuf_new();
|
|
|
|
|
|
|
|
//parse paths by ';'
|
|
|
|
const char *lex;
|
|
|
|
Eina_Stringshare *append;
|
|
|
|
|
|
|
|
while(edc_fnt_path && (strlen(edc_fnt_path) > 0))
|
|
|
|
{
|
|
|
|
lex = strstr(edc_fnt_path, ";");
|
|
|
|
if (lex)
|
|
|
|
{
|
|
|
|
append = eina_stringshare_add_length(edc_fnt_path,
|
|
|
|
(lex - edc_fnt_path));
|
|
|
|
cd->edc_fnt_path_list = eina_list_append(cd->edc_fnt_path_list,
|
|
|
|
append);
|
|
|
|
eina_strbuf_append(cd->edc_fnt_path_buf, " -fd ");
|
|
|
|
eina_strbuf_append(cd->edc_fnt_path_buf, append);
|
|
|
|
lex++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
append = eina_stringshare_add(edc_fnt_path);
|
|
|
|
cd->edc_fnt_path_list = eina_list_append(cd->edc_fnt_path_list,
|
|
|
|
append);
|
|
|
|
eina_strbuf_append(cd->edc_fnt_path_buf, " -fd ");
|
|
|
|
eina_strbuf_append(cd->edc_fnt_path_buf, append);
|
|
|
|
}
|
|
|
|
|
|
|
|
edc_fnt_path = lex;
|
|
|
|
}
|
|
|
|
}
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
void
|
2014-01-29 09:45:10 -08:00
|
|
|
config_edc_img_path_set(const char *edc_img_path)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
//Free the existing paths
|
|
|
|
Eina_List *l;
|
|
|
|
const char *s;
|
2013-08-24 10:41:53 -07:00
|
|
|
EINA_LIST_FOREACH(cd->edc_img_path_list, l, s)
|
2013-07-20 01:51:56 -07:00
|
|
|
eina_stringshare_del(s);
|
2013-08-24 10:41:53 -07:00
|
|
|
cd->edc_img_path_list = eina_list_free(cd->edc_img_path_list);
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-08-24 10:41:53 -07:00
|
|
|
if (cd->edc_img_path_buf) eina_strbuf_free(cd->edc_img_path_buf);
|
|
|
|
cd->edc_img_path_buf = eina_strbuf_new();
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
//parse paths by ';'
|
|
|
|
const char *lex;
|
|
|
|
Eina_Stringshare *append;
|
|
|
|
|
|
|
|
while(edc_img_path && (strlen(edc_img_path) > 0))
|
|
|
|
{
|
|
|
|
lex = strstr(edc_img_path, ";");
|
|
|
|
if (lex)
|
|
|
|
{
|
|
|
|
append = eina_stringshare_add_length(edc_img_path,
|
|
|
|
(lex - edc_img_path));
|
2013-08-24 10:41:53 -07:00
|
|
|
cd->edc_img_path_list = eina_list_append(cd->edc_img_path_list,
|
2013-07-20 01:51:56 -07:00
|
|
|
append);
|
2013-08-24 10:41:53 -07:00
|
|
|
eina_strbuf_append(cd->edc_img_path_buf, " -id ");
|
|
|
|
eina_strbuf_append(cd->edc_img_path_buf, append);
|
2013-07-20 01:51:56 -07:00
|
|
|
lex++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
append = eina_stringshare_add(edc_img_path);
|
2013-08-24 10:41:53 -07:00
|
|
|
cd->edc_img_path_list = eina_list_append(cd->edc_img_path_list,
|
2013-07-20 01:51:56 -07:00
|
|
|
append);
|
2013-08-24 10:41:53 -07:00
|
|
|
eina_strbuf_append(cd->edc_img_path_buf, " -id ");
|
|
|
|
eina_strbuf_append(cd->edc_img_path_buf, append);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
edc_img_path = lex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-01-29 09:45:10 -08:00
|
|
|
config_apply()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
|
|
|
if (cd->update_cb) cd->update_cb(cd->update_cb_data);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2013-09-08 01:04:56 -07:00
|
|
|
Eina_List *
|
2014-01-29 09:45:10 -08:00
|
|
|
config_edc_img_path_list_get()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
return cd->edc_img_path_list;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2013-09-08 01:04:56 -07:00
|
|
|
Eina_List *
|
2014-01-29 09:45:10 -08:00
|
|
|
config_edc_snd_path_list_get()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
return cd->edc_snd_path_list;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2013-09-08 01:04:56 -07:00
|
|
|
Eina_List *
|
2014-01-29 09:45:10 -08:00
|
|
|
config_edc_data_path_list_get()
|
2013-08-27 21:16:34 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-27 21:16:34 -07:00
|
|
|
return cd->edc_data_path_list;
|
|
|
|
}
|
|
|
|
|
2013-09-08 01:04:56 -07:00
|
|
|
Eina_List *
|
2014-01-29 09:45:10 -08:00
|
|
|
config_edc_fnt_path_list_get()
|
2013-08-27 10:26:13 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-27 10:26:13 -07:00
|
|
|
return cd->edc_fnt_path_list;
|
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
const char *
|
2014-01-29 09:45:10 -08:00
|
|
|
config_edc_img_path_get()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
if (!cd->edc_img_path_buf) return NULL;
|
|
|
|
return eina_strbuf_string_get(cd->edc_img_path_buf);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
2014-01-29 09:45:10 -08:00
|
|
|
config_edc_snd_path_get()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
if (!cd->edc_snd_path_buf) return NULL;
|
|
|
|
return eina_strbuf_string_get(cd->edc_snd_path_buf);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2013-08-27 21:16:34 -07:00
|
|
|
const char *
|
2014-01-29 09:45:10 -08:00
|
|
|
config_edc_data_path_get()
|
2013-08-27 21:16:34 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-27 21:16:34 -07:00
|
|
|
if (!cd->edc_data_path_buf) return NULL;
|
|
|
|
return eina_strbuf_string_get(cd->edc_data_path_buf);
|
|
|
|
}
|
|
|
|
|
2013-08-27 10:26:13 -07:00
|
|
|
const char *
|
2014-01-29 09:45:10 -08:00
|
|
|
config_edc_fnt_path_get()
|
2013-08-27 10:26:13 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-27 10:26:13 -07:00
|
|
|
if (!cd->edc_fnt_path_buf) return NULL;
|
|
|
|
return eina_strbuf_string_get(cd->edc_fnt_path_buf);
|
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
const char *
|
2014-01-29 09:45:10 -08:00
|
|
|
config_edc_path_get()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
return cd->edc_path;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
2014-01-29 09:45:10 -08:00
|
|
|
config_edj_path_get()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
return cd->edj_path;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
2014-01-29 09:45:10 -08:00
|
|
|
config_linenumber_get()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
return cd->linenumber;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
2014-01-29 09:45:10 -08:00
|
|
|
config_stats_bar_get()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
return cd->stats_bar;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-01-29 09:45:10 -08:00
|
|
|
config_linenumber_set(Eina_Bool enabled)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
cd->linenumber = enabled;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-01-29 09:45:10 -08:00
|
|
|
config_stats_bar_set(Eina_Bool enabled)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
cd->stats_bar = enabled;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-01-29 09:45:10 -08:00
|
|
|
config_update_cb_set(void (*cb)(void *data), void *data)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
cd->update_cb = cb;
|
|
|
|
cd->update_cb_data = data;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
2014-01-29 09:45:10 -08:00
|
|
|
config_part_highlight_get()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
return cd->part_highlight;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-01-29 09:45:10 -08:00
|
|
|
config_part_highlight_set(Eina_Bool highlight)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
cd->part_highlight = highlight;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
2013-07-20 03:56:33 -07:00
|
|
|
|
|
|
|
Eina_Bool
|
2014-01-29 09:45:10 -08:00
|
|
|
config_dummy_swallow_get()
|
2013-07-20 03:56:33 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
return cd->dummy_swallow;
|
2013-07-20 03:56:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-01-29 09:45:10 -08:00
|
|
|
config_dummy_swallow_set(Eina_Bool dummy_swallow)
|
2013-07-20 03:56:33 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
cd->dummy_swallow = dummy_swallow;
|
2013-07-20 03:56:33 -07:00
|
|
|
}
|
2013-08-20 09:19:09 -07:00
|
|
|
|
|
|
|
Eina_Bool
|
2014-01-29 09:45:10 -08:00
|
|
|
config_auto_indent_get()
|
2013-08-20 09:19:09 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
return cd->auto_indent;
|
2013-08-20 09:19:09 -07:00
|
|
|
}
|
|
|
|
|
2013-08-22 05:47:23 -07:00
|
|
|
void
|
2014-01-29 09:45:10 -08:00
|
|
|
config_font_size_set(float font_size)
|
2013-08-22 05:47:23 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
|
|
|
|
2013-08-24 09:46:56 -07:00
|
|
|
if (font_size > MAX_FONT_SIZE)
|
|
|
|
font_size = MAX_FONT_SIZE;
|
|
|
|
else if (font_size < MIN_FONT_SIZE)
|
|
|
|
font_size = MIN_FONT_SIZE;
|
|
|
|
|
2013-08-24 10:41:53 -07:00
|
|
|
cd->font_size = font_size;
|
2013-08-22 05:47:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
float
|
2014-01-29 09:45:10 -08:00
|
|
|
config_font_size_get()
|
2013-08-22 05:47:23 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
return cd->font_size;
|
2013-08-22 05:47:23 -07:00
|
|
|
}
|
|
|
|
|
2013-08-20 09:19:09 -07:00
|
|
|
void
|
2014-01-29 09:45:10 -08:00
|
|
|
config_auto_indent_set(Eina_Bool auto_indent)
|
2013-08-20 09:19:09 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2013-08-24 10:41:53 -07:00
|
|
|
cd->auto_indent = auto_indent;
|
2013-08-20 09:19:09 -07:00
|
|
|
}
|
2014-01-26 08:21:02 -08:00
|
|
|
|
|
|
|
void
|
2014-01-29 09:45:10 -08:00
|
|
|
config_view_scale_set(double view_scale)
|
2014-01-26 08:21:02 -08:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
|
|
|
|
2014-01-26 08:21:02 -08:00
|
|
|
if (view_scale > MAX_VIEW_SCALE)
|
|
|
|
view_scale = MAX_VIEW_SCALE;
|
|
|
|
else if (view_scale < MIN_VIEW_SCALE)
|
|
|
|
view_scale = MIN_VIEW_SCALE;
|
|
|
|
cd->view_scale = view_scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
2014-01-29 09:45:10 -08:00
|
|
|
config_view_scale_get()
|
2014-01-26 08:21:02 -08:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
2014-01-26 08:21:02 -08:00
|
|
|
return cd->view_scale;
|
|
|
|
}
|
2014-01-29 09:11:21 -08:00
|
|
|
|
|
|
|
void
|
2014-01-29 09:45:10 -08:00
|
|
|
config_view_size_set(Evas_Coord w, Evas_Coord h)
|
2014-01-29 09:11:21 -08:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
|
|
|
|
2014-01-29 09:11:21 -08:00
|
|
|
cd->view_size.w = w;
|
|
|
|
cd->view_size.h = h;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-01-29 09:45:10 -08:00
|
|
|
config_view_size_get(Evas_Coord *w, Evas_Coord *h)
|
2014-01-29 09:11:21 -08:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_data *cd = g_cd;
|
|
|
|
|
2014-01-29 09:11:21 -08:00
|
|
|
if (w) *w = cd->view_size.w;
|
|
|
|
if (h) *h = cd->view_size.h;
|
|
|
|
}
|
2014-01-29 19:18:31 -08:00
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
config_hotkeys_get()
|
|
|
|
{
|
|
|
|
config_data *cd = g_cd;
|
|
|
|
return cd->hotkeys;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
config_hotkeys_set(Eina_Bool enabled)
|
|
|
|
{
|
|
|
|
config_data *cd = g_cd;
|
|
|
|
cd->hotkeys = enabled;
|
|
|
|
}
|