summaryrefslogtreecommitdiff
path: root/src/bin/common.c
blob: 7907d052987bfdb9da5baf44235be2bcee63972a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "common.h"

int _log_domain = -1;

Eina_Bool
emixer_common_init(const char *domain)
{
   EINA_SAFETY_ON_NULL_RETURN_VAL(domain, EINA_FALSE);
   if (!eina_init())
     {
        fprintf(stderr, "Could not init eina\n");
        return EINA_FALSE;
     }

   _log_domain = eina_log_domain_register(domain, NULL);
   if (_log_domain < 0)
     {
        EINA_LOG_CRIT("Could not create log domain '%s'", domain);
        goto err_log;
     }

   if (!ecore_init())
     {
        CRIT("Could not init ecore");
        goto err_ecore;
     }

   return EINA_TRUE;

 err_ecore:
   eina_log_domain_unregister(_log_domain);
   _log_domain = -1;
 err_log:
   eina_shutdown();
   return EINA_FALSE;
}

void
emixer_common_shutdown(void)
{
   eina_shutdown();

   eina_log_domain_unregister(_log_domain);
   _log_domain = -1;

   ecore_shutdown();
}

Evas_Object *
emixer_layout_add(Evas_Object *parent, const char *group,
                  const char *style)
{
   EINA_SAFETY_ON_NULL_RETURN_VAL(group, NULL);
   EINA_SAFETY_ON_NULL_RETURN_VAL(style, NULL);

   Evas_Object *layout = elm_layout_add(parent);
   if (!elm_layout_theme_set(layout, "layout", group, style))
     {
        CRIT("No theme for 'elm/layout/%s/%s' at %s", group, style,
             EMIXER_THEME);
        evas_object_del(layout);
        return NULL;
     }

   return layout;
}