extra: move the common fields to a struct
This commit is contained in:
parent
b62d34180c
commit
34e1160449
|
@ -119,7 +119,7 @@ _text_basic_get(void *data, Evas_Object *obj EINA_UNUSED, const char *source EIN
|
|||
{
|
||||
Extra_Background *t = data;
|
||||
|
||||
return strdup(t->name);
|
||||
return strdup(t->obj.name);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -164,4 +164,4 @@ extra_background_selector_create(void)
|
|||
evas_object_event_callback_add(grid, EVAS_CALLBACK_HIDE, _selector_hide, NULL);
|
||||
|
||||
return grid;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ _install_theme(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_U
|
|||
Eina_Strbuf *title;
|
||||
|
||||
title = eina_strbuf_new();
|
||||
eina_strbuf_append_printf(title, "Installing theme %s!", candidate->name);
|
||||
eina_strbuf_append_printf(title, "Installing theme %s!", candidate->obj.name);
|
||||
|
||||
progress = extra_ui_progress_popup_show(eina_strbuf_string_get(title), _install_done, candidate);
|
||||
extra_theme_download(progress, candidate);
|
||||
|
@ -137,8 +137,8 @@ _popup_theme(Evas_Object *win, Extra_Theme *theme)
|
|||
Evas_Object *o, *inwin, *table;
|
||||
char title_str[1024], author_str[1024];
|
||||
|
||||
snprintf(title_str, sizeof(title_str), "<title>%s</title>", theme->name);
|
||||
snprintf(author_str, sizeof(author_str), "<link>%s</link>", theme->author);
|
||||
snprintf(title_str, sizeof(title_str), "<title>%s</title>", theme->obj.name);
|
||||
snprintf(author_str, sizeof(author_str), "<link>%s</link>", theme->obj.author);
|
||||
|
||||
inwin = o = elm_win_inwin_add(win);
|
||||
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
|
@ -203,7 +203,7 @@ _text_basic_get(void *data, Evas_Object *obj EINA_UNUSED, const char *source EIN
|
|||
{
|
||||
Extra_Theme *t = data;
|
||||
|
||||
return strdup(t->name);
|
||||
return strdup(t->obj.name);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -21,7 +21,7 @@ Eina_List *_background_list = NULL;
|
|||
void _extra_theme_cache_load();
|
||||
static Eina_Bool extra_request_may_override(Extra_Request *req, Extra_Progress *progress);
|
||||
|
||||
#define GEN_FILE_NAME(buf, t) eina_strbuf_append_printf(buf, "%s-%d.edj", t->id, t->version);
|
||||
#define GEN_FILE_NAME(buf, t) eina_strbuf_append_printf(buf, "%s-%d.edj", t->obj.id, t->obj.version);
|
||||
|
||||
//===========
|
||||
//theme stuff
|
||||
|
@ -67,11 +67,11 @@ _fill_themes(Eina_Strbuf *buf)
|
|||
versionNumb = atoi(eina_strbuf_string_get(obj->version));
|
||||
|
||||
theme = calloc(1, sizeof(*theme));
|
||||
theme->theme.id = sec_strdup(obj->id);
|
||||
theme->theme.name = sec_strdup(obj->name);
|
||||
theme->theme.author = sec_strdup(obj->author);
|
||||
theme->theme.obj.id = sec_strdup(obj->id);
|
||||
theme->theme.obj.name = sec_strdup(obj->name);
|
||||
theme->theme.obj.author = sec_strdup(obj->author);
|
||||
theme->theme.description = sec_strdup(obj->description);
|
||||
theme->theme.version = versionNumb;
|
||||
theme->theme.obj.version = versionNumb;
|
||||
_theme_list = eina_list_append(_theme_list, theme);
|
||||
|
||||
extra_json_list_part_free(&template, obj);
|
||||
|
@ -122,10 +122,10 @@ _fill_backgrounds(Eina_Strbuf *buf)
|
|||
|
||||
versionNumb = atoi(eina_strbuf_string_get(obj->version));
|
||||
|
||||
background->background.author = sec_strdup(obj->author);
|
||||
background->background.id = sec_strdup(obj->id);
|
||||
background->background.name = sec_strdup(obj->name);
|
||||
background->background.version = versionNumb;
|
||||
background->background.obj.author = sec_strdup(obj->author);
|
||||
background->background.obj.id = sec_strdup(obj->id);
|
||||
background->background.obj.name = sec_strdup(obj->name);
|
||||
background->background.obj.version = versionNumb;
|
||||
|
||||
_background_list = eina_list_append(_background_list, background);
|
||||
|
||||
|
@ -325,7 +325,7 @@ EAPI Extra_Theme *extra_theme_get(const char *id)
|
|||
Eina_List *item;
|
||||
|
||||
EINA_LIST_FOREACH(extra_themes_list(), item, theme)
|
||||
if (!strcmp(id, theme->id))
|
||||
if (!strcmp(id, theme->obj.id))
|
||||
return theme;
|
||||
|
||||
return NULL;
|
||||
|
@ -403,7 +403,7 @@ extra_theme_preview_get(Extra_Theme *theme)
|
|||
//download is in progress do not return the path
|
||||
if (priv->preview) return NULL;
|
||||
|
||||
local = _extra_preview_local_generate("themes", theme->id, theme->version);
|
||||
local = _extra_preview_local_generate("themes", theme->obj.id, theme->obj.version);
|
||||
if (!ecore_file_exists(local))
|
||||
{
|
||||
free(local);
|
||||
|
@ -413,8 +413,8 @@ extra_theme_preview_get(Extra_Theme *theme)
|
|||
{
|
||||
if (!priv->cache_preview)
|
||||
{
|
||||
src = _extra_preview_remote_generate("themes", theme->id);
|
||||
dst = _extra_preview_local_generate("themes", theme->id, theme->version);
|
||||
src = _extra_preview_remote_generate("themes", theme->obj.id);
|
||||
dst = _extra_preview_local_generate("themes", theme->obj.id, theme->obj.version);
|
||||
|
||||
extra_file_cache_download(&p, src, dst, &priv->cache_preview);
|
||||
|
||||
|
@ -439,8 +439,8 @@ extra_theme_preview_download(Extra_Progress *progress, Extra_Theme *theme)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
remote = _extra_preview_remote_generate("themes", theme->id);
|
||||
dst = _extra_preview_local_generate("themes", theme->id, theme->version);
|
||||
remote = _extra_preview_remote_generate("themes", theme->obj.id);
|
||||
dst = _extra_preview_local_generate("themes", theme->obj.id, theme->obj.version);
|
||||
|
||||
extra_file_download(progress, remote, dst, &priv->preview);
|
||||
|
||||
|
@ -460,7 +460,7 @@ extra_theme_download_url_get(Extra_Theme *theme)
|
|||
|
||||
buf = eina_strbuf_new();
|
||||
eina_strbuf_append(buf, "http://" HOSTNAME "/themes/");
|
||||
eina_strbuf_append_printf(buf, "%s-%d.edj", theme->id, theme->version);
|
||||
eina_strbuf_append_printf(buf, "%s-%d.edj", theme->obj.id, theme->obj.version);
|
||||
|
||||
url = eina_strbuf_string_steal(buf);
|
||||
eina_strbuf_free(buf);
|
||||
|
@ -605,7 +605,7 @@ extra_theme_installed_old(Extra_Theme *t)
|
|||
if (!strcmp(eina_strbuf_string_get(buf), file))
|
||||
continue;
|
||||
|
||||
if (eina_str_has_prefix(file, t->id) &&
|
||||
if (eina_str_has_prefix(file, t->obj.id) &&
|
||||
eina_str_has_extension(file, "edj"))
|
||||
{
|
||||
b = EINA_TRUE;
|
||||
|
@ -635,7 +635,7 @@ extra_background_get(const char *id)
|
|||
|
||||
EINA_LIST_FOREACH(_background_list, n, b)
|
||||
{
|
||||
if (!strcmp(id, b->id))
|
||||
if (!strcmp(id, b->obj.id))
|
||||
return b;
|
||||
}
|
||||
|
||||
|
@ -652,7 +652,7 @@ extra_background_download_url_get(Extra_Background *background)
|
|||
|
||||
buf = eina_strbuf_new();
|
||||
eina_strbuf_append(buf, "http://" HOSTNAME "/backgrounds/");
|
||||
eina_strbuf_append_printf(buf, "%s-%d.edj", background->id, background->version);
|
||||
eina_strbuf_append_printf(buf, "%s-%d.edj", background->obj.id, background->obj.version);
|
||||
|
||||
url = eina_strbuf_string_steal(buf);
|
||||
eina_strbuf_free(buf);
|
||||
|
@ -672,7 +672,7 @@ extra_background_install_path_get(Extra_Background *background)
|
|||
|
||||
eina_strbuf_append(buf, eina_environment_home_get());
|
||||
eina_strbuf_append(buf, "/.e/e/backgrounds/");
|
||||
eina_strbuf_append_printf(buf, "%s-%d.edj", background->id, background->version);
|
||||
eina_strbuf_append_printf(buf, "%s-%d.edj", background->obj.id, background->obj.version);
|
||||
|
||||
path = eina_strbuf_string_steal(buf);
|
||||
eina_strbuf_free(buf);
|
||||
|
@ -732,7 +732,7 @@ extra_background_preview_get(Extra_Background *background)
|
|||
|
||||
if (priv->preview) return NULL;
|
||||
|
||||
local = _extra_preview_local_generate("backgrounds", background->id, background->version);
|
||||
local = _extra_preview_local_generate("backgrounds", background->obj.id, background->obj.version);
|
||||
if (!ecore_file_exists(local))
|
||||
{
|
||||
free(local);
|
||||
|
@ -742,8 +742,8 @@ extra_background_preview_get(Extra_Background *background)
|
|||
{
|
||||
if (!priv->cache_preview)
|
||||
{
|
||||
src = _extra_preview_remote_generate("backgrounds", background->id);
|
||||
dst = _extra_preview_local_generate("backgrounds", background->id, background->version);
|
||||
src = _extra_preview_remote_generate("backgrounds", background->obj.id);
|
||||
dst = _extra_preview_local_generate("backgrounds", background->obj.id, background->obj.version);
|
||||
|
||||
extra_file_cache_download(&p, src, dst, &priv->cache_preview);
|
||||
|
||||
|
@ -768,8 +768,8 @@ extra_background_preview_download(Extra_Progress *progress, Extra_Background *ba
|
|||
return NULL;
|
||||
}
|
||||
|
||||
remote = _extra_preview_remote_generate("backgrounds", background->id);
|
||||
local = _extra_preview_local_generate("backgrounds", background->id, background->version);
|
||||
remote = _extra_preview_remote_generate("backgrounds", background->obj.id);
|
||||
local = _extra_preview_local_generate("backgrounds", background->obj.id, background->obj.version);
|
||||
|
||||
extra_file_download(progress, remote, local, &priv->preview);
|
||||
|
||||
|
|
|
@ -41,21 +41,24 @@ extern "C" {
|
|||
typedef void (*Extra_Progress_Cb)(void *data, double progress);
|
||||
typedef void (*Extra_Done_Cb)(void *data);
|
||||
|
||||
typedef struct _Extra_Theme
|
||||
typedef struct _Extra_Base_Object
|
||||
{
|
||||
const char *id;
|
||||
const char *name;
|
||||
const char *author;
|
||||
int version;
|
||||
|
||||
} Extra_Base_Object;
|
||||
|
||||
typedef struct _Extra_Theme
|
||||
{
|
||||
Extra_Base_Object obj;
|
||||
const char *description;
|
||||
} Extra_Theme;
|
||||
|
||||
typedef struct _Extra_Background
|
||||
{
|
||||
const char *id;
|
||||
const char *name;
|
||||
const char *author;
|
||||
int version;
|
||||
Extra_Base_Object obj;
|
||||
} Extra_Background;
|
||||
|
||||
typedef struct _Extra_Progress
|
||||
|
|
Loading…
Reference in New Issue