summaryrefslogtreecommitdiff
path: root/src/bin/utils.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2012-06-19 15:59:49 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2012-06-19 15:59:49 +0000
commit2cd2514538d5b59c4398de4974d8bf530ebc2a85 (patch)
tree54902456f373fe71fc32fc6e747bbbed805ac134 /src/bin/utils.c
parentc71424367db2ed6f794154aab3df82efb4513723 (diff)
utils/theme: unify code, error messages and allow fallback.
Introduced two nice helpers to aid common Edje handling: * apply theme, using fallback if main is not found; * reload theme if file changed. SVN revision: 72490
Diffstat (limited to 'src/bin/utils.c')
-rw-r--r--src/bin/utils.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/bin/utils.c b/src/bin/utils.c
new file mode 100644
index 0000000..136a664
--- /dev/null
+++ b/src/bin/utils.c
@@ -0,0 +1,52 @@
1#include "private.h"
2#include "utils.h"
3
4#include <Edje.h>
5
6Eina_Bool
7theme_apply(Evas_Object *edje, const Config *config, const char *group)
8{
9 const char *errmsg;
10
11 EINA_SAFETY_ON_NULL_RETURN_VAL(edje, EINA_FALSE);
12 EINA_SAFETY_ON_NULL_RETURN_VAL(config, EINA_FALSE);
13 EINA_SAFETY_ON_NULL_RETURN_VAL(group, EINA_FALSE);
14
15 if (edje_object_file_set(edje, config_theme_path_get(config), group))
16 return EINA_TRUE;
17
18 errmsg = edje_load_error_str(edje_object_load_error_get(edje));
19 INF("Cannot find theme: file=%s group=%s error='%s', trying default...",
20 config_theme_path_get(config), group, errmsg);
21
22 if (edje_object_file_set(edje, config_theme_path_default_get(config), group))
23 return EINA_TRUE;
24
25 errmsg = edje_load_error_str(edje_object_load_error_get(edje));
26 ERR("Could not load any theme for group=%s: %s", group, errmsg);
27 return EINA_FALSE;
28}
29
30void
31theme_reload(Evas_Object *edje)
32{
33 const char *file;
34 const char *group;
35
36 edje_object_file_get(edje, &file, &group);
37 INF("file=%s, group=%s", file, group);
38 edje_object_file_set(edje, file, group);
39}
40
41static void
42theme_reload_cb(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
43{
44 theme_reload(obj);
45}
46
47void
48theme_auto_reload_enable(Evas_Object *edje)
49{
50 edje_object_signal_callback_add
51 (edje, "edje,change,file", "edje", theme_reload_cb, NULL);
52}