summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlavio Ceolin <flavio.ceolin@gmail.com>2014-09-04 22:55:53 -0300
committerFlavio Ceolin <flavio.ceolin@gmail.com>2014-09-04 22:55:53 -0300
commit9ffc98ee4c8679f9efaa51a36c13f61e766296c1 (patch)
tree4826b17920e2a2c254440e846c7b54931249b1ea
parent6ddd8f82e4707ee72c5e16b4cbced05f88651321 (diff)
module: Make possible changing backend on the fly
-rw-r--r--src/module/e_mod_config.c12
-rw-r--r--src/module/e_mod_config.h4
-rw-r--r--src/module/e_mod_main.c11
3 files changed, 22 insertions, 5 deletions
diff --git a/src/module/e_mod_config.c b/src/module/e_mod_config.c
index 6dc6198..7e54961 100644
--- a/src/module/e_mod_config.c
+++ b/src/module/e_mod_config.c
@@ -7,6 +7,9 @@ typedef struct _Emix_Config
7{ 7{
8 const char *backend; 8 const char *backend;
9 int notify; 9 int notify;
10
11 emix_config_backend_changed cb;
12 const void *userdata;
10} Emix_Config; 13} Emix_Config;
11 14
12struct _E_Config_Dialog_Data 15struct _E_Config_Dialog_Data
@@ -54,7 +57,7 @@ _config_set(Emix_Config *config)
54} 57}
55 58
56void 59void
57emix_config_init(void) 60emix_config_init(emix_config_backend_changed cb, const void *userdata)
58{ 61{
59 const Eina_List *l; 62 const Eina_List *l;
60 63
@@ -69,7 +72,9 @@ emix_config_init(void)
69 _config->backend = eina_stringshare_add(l->data); 72 _config->backend = eina_stringshare_add(l->data);
70 } 73 }
71 74
72 DBG("Config loaded, backend to use: %s", _config->backend); 75 _config->cb = cb;
76 _config->userdata = userdata;
77 DBG("Config loaded, backend to use: %s", _config->backend);
73} 78}
74 79
75void 80void
@@ -146,7 +151,8 @@ _basic_apply_data(E_Config_Dialog *cfd EINA_UNUSED,
146 eina_stringshare_replace(&cfdata->config.backend, new_backend); 151 eina_stringshare_replace(&cfdata->config.backend, new_backend);
147 152
148 _config_set(&cfdata->config); 153 _config_set(&cfdata->config);
149 //TODO if the backend changed reload emix 154 if (_config->cb)
155 _config->cb(new_backend, (void *)_config->userdata);
150 return 1; 156 return 1;
151} 157}
152 158
diff --git a/src/module/e_mod_config.h b/src/module/e_mod_config.h
index 7116ae0..9962ea8 100644
--- a/src/module/e_mod_config.h
+++ b/src/module/e_mod_config.h
@@ -3,7 +3,9 @@
3 3
4#include <e.h> 4#include <e.h>
5 5
6void emix_config_init(void); 6typedef void (*emix_config_backend_changed)(const char *backend, void *data);
7
8void emix_config_init(emix_config_backend_changed cb, const void *userdata);
7void emix_config_shutdown(void); 9void emix_config_shutdown(void);
8const char *emix_config_backend_get(void); 10const char *emix_config_backend_get(void);
9Eina_Bool emix_config_notify_get(void); 11Eina_Bool emix_config_notify_get(void);
diff --git a/src/module/e_mod_main.c b/src/module/e_mod_main.c
index 439fcb9..5512404 100644
--- a/src/module/e_mod_main.c
+++ b/src/module/e_mod_main.c
@@ -688,6 +688,15 @@ _ready_cb(void *data EINA_UNUSED, int type EINA_UNUSED,
688 return ECORE_CALLBACK_DONE; 688 return ECORE_CALLBACK_DONE;
689} 689}
690 690
691static void
692_backend_changed(const char *backend, void *data EINA_UNUSED)
693{
694 _disconnected_cb(NULL, -1, NULL);
695
696 if (emix_backend_set(backend) == EINA_FALSE)
697 ERR("Could not load backend: %s", backend);
698}
699
691EAPI void * 700EAPI void *
692e_modapi_init(E_Module *m) 701e_modapi_init(E_Module *m)
693{ 702{
@@ -697,7 +706,7 @@ e_modapi_init(E_Module *m)
697 _e_emix_log_domain = eina_log_domain_register("emix_module", EINA_COLOR_RED); 706 _e_emix_log_domain = eina_log_domain_register("emix_module", EINA_COLOR_RED);
698 707
699 EINA_SAFETY_ON_FALSE_RETURN_VAL(emix_init(), NULL); 708 EINA_SAFETY_ON_FALSE_RETURN_VAL(emix_init(), NULL);
700 emix_config_init(); 709 emix_config_init(_backend_changed, NULL);
701 710
702 backend = emix_config_backend_get(); 711 backend = emix_config_backend_get();
703 if (!backend) 712 if (!backend)