examples: Fix path to edj theme files (theme examples)

A bit complex but should work in most cases (installed & not)
This commit is contained in:
Jean-Philippe Andre 2016-08-08 18:09:58 +09:00
parent 84938cbaf1
commit da21656ee2
2 changed files with 36 additions and 6 deletions

View File

@ -3,6 +3,8 @@
*/
#include <Elementary.h>
char edj_path[PATH_MAX];
static void
btn_extension_click_cb(void *data, Evas_Object *btn, void *ev)
{
@ -10,12 +12,12 @@ btn_extension_click_cb(void *data, Evas_Object *btn, void *ev)
if (!strncmp(lbl, "Load", 4))
{
elm_theme_extension_add(NULL, "./theme_example.edj");
elm_theme_extension_add(NULL, edj_path);
elm_object_text_set(btn, "Unload extension");
}
else if (!strncmp(lbl, "Unload", 6))
{
elm_theme_extension_del(NULL, "./theme_example.edj");
elm_theme_extension_del(NULL, edj_path);
elm_object_text_set(btn, "Load extension");
}
}
@ -41,7 +43,20 @@ elm_main(int argc, char *argv[])
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
elm_theme_extension_add(NULL, "./theme_example.edj");
#ifdef PACKAGE_DATA_DIR
elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
#endif
if (ecore_file_exists("./theme_example.edj"))
{
strcpy(edj_path, "./theme_example.edj");
}
else
{
elm_app_info_set(elm_main, "elementary", "examples/theme_example.edj");
snprintf(edj_path, sizeof(edj_path), "%s/examples/theme_example.edj",
elm_app_data_dir_get());
}
elm_theme_extension_add(NULL, edj_path);
win = elm_win_util_standard_add("theme", "Theme example");
elm_win_autodel_set(win, EINA_TRUE);

View File

@ -3,14 +3,16 @@
*/
#include <Elementary.h>
char edj_path[PATH_MAX];
static void
_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
{
static int loaded = 1;
if (loaded)
elm_theme_overlay_del(NULL, "./theme_example.edj");
elm_theme_overlay_del(NULL, edj_path);
else
elm_theme_overlay_add(NULL, "./theme_example.edj");
elm_theme_overlay_add(NULL, edj_path);
loaded = 1 - loaded;
}
@ -21,7 +23,20 @@ elm_main(int argc, char *argv[])
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
elm_theme_overlay_add(NULL, "./theme_example.edj");
#ifdef PACKAGE_DATA_DIR
elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
#endif
if (ecore_file_exists("./theme_example.edj"))
{
strcpy(edj_path, "./theme_example.edj");
}
else
{
elm_app_info_set(elm_main, "elementary", "examples/theme_example.edj");
snprintf(edj_path, sizeof(edj_path), "%s/examples/theme_example.edj",
elm_app_data_dir_get());
}
elm_theme_overlay_add(NULL, edj_path);
win = elm_win_util_standard_add("theme", "Theme example");
elm_win_autodel_set(win, EINA_TRUE);