summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlavio Ceolin <flavio.ceolin@gmail.com>2014-09-17 11:31:21 -0300
committerFlavio Ceolin <flavio.ceolin@gmail.com>2014-09-17 11:31:21 -0300
commit15311693a04f19b9a782393c3475aa322f3913f2 (patch)
tree26d7d333f789b732566163e39628bd5e9b962392
parentb3ee061a1f1c9478661c4eaba2882fd50eec6a69 (diff)
module: Add mute on desklock option
-rw-r--r--src/module/e_mod_config.c17
-rw-r--r--src/module/e_mod_config.h1
-rw-r--r--src/module/e_mod_main.c27
3 files changed, 43 insertions, 2 deletions
diff --git a/src/module/e_mod_config.c b/src/module/e_mod_config.c
index 6dd33ac..ac27b04 100644
--- a/src/module/e_mod_config.c
+++ b/src/module/e_mod_config.c
@@ -7,6 +7,7 @@ typedef struct _Emix_Config
7{ 7{
8 const char *backend; 8 const char *backend;
9 int notify; 9 int notify;
10 int mute;
10 11
11 emix_config_backend_changed cb; 12 emix_config_backend_changed cb;
12 const void *userdata; 13 const void *userdata;
@@ -28,6 +29,7 @@ _emix_config_dd_new(void)
28 29
29 E_CONFIG_VAL(result, Emix_Config, backend, STR); 30 E_CONFIG_VAL(result, Emix_Config, backend, STR);
30 E_CONFIG_VAL(result, Emix_Config, notify, INT); 31 E_CONFIG_VAL(result, Emix_Config, notify, INT);
32 E_CONFIG_VAL(result, Emix_Config, mute, INT);
31 33
32 return result; 34 return result;
33} 35}
@@ -51,6 +53,12 @@ emix_config_notify_get(void)
51 return _config->notify; 53 return _config->notify;
52} 54}
53 55
56Eina_Bool
57emix_config_desklock_mute_get(void)
58{
59 return _config->mute;
60}
61
54static void 62static void
55_config_set(Emix_Config *config) 63_config_set(Emix_Config *config)
56{ 64{
@@ -58,8 +66,9 @@ _config_set(Emix_Config *config)
58 eina_stringshare_replace(&_config->backend, config->backend); 66 eina_stringshare_replace(&_config->backend, config->backend);
59 67
60 _config->notify = config->notify; 68 _config->notify = config->notify;
69 _config->mute = config->mute;
61 70
62 DBG("SAVING CONFIG %s %d", _config->backend, config->notify); 71 DBG("SAVING CONFIG %s %d %d", _config->backend, config->notify, config->mute);
63 e_config_domain_save("module.emix", cd, config); 72 e_config_domain_save("module.emix", cd, config);
64} 73}
65 74
@@ -102,6 +111,7 @@ _create_data(E_Config_Dialog *cfg EINA_UNUSED)
102 d = E_NEW(E_Config_Dialog_Data, 1); 111 d = E_NEW(E_Config_Dialog_Data, 1);
103 d->config.backend = eina_stringshare_add(_config->backend); 112 d->config.backend = eina_stringshare_add(_config->backend);
104 d->config.notify = _config->notify; 113 d->config.notify = _config->notify;
114 d->config.mute = _config->mute;
105 115
106 return d; 116 return d;
107} 117}
@@ -124,7 +134,10 @@ _basic_create_widgets(E_Config_Dialog *cfd EINA_UNUSED, Evas *evas,
124 134
125 o = e_widget_list_add(evas, 0, 0); 135 o = e_widget_list_add(evas, 0, 0);
126 136
127 l = e_widget_check_add(evas, "Notify on volume Change", &cfdata->config.notify); 137 l = e_widget_check_add(evas, "Notify on volume change", &cfdata->config.notify);
138 e_widget_list_object_append(o, l, 0, 0, 0);
139
140 l = e_widget_check_add(evas, "Mute on lock", &cfdata->config.mute);
128 e_widget_list_object_append(o, l, 0, 0, 0); 141 e_widget_list_object_append(o, l, 0, 0, 0);
129 142
130 l = e_widget_label_add(evas, "Backend to use:"); 143 l = e_widget_label_add(evas, "Backend to use:");
diff --git a/src/module/e_mod_config.h b/src/module/e_mod_config.h
index 4058618..f3ba786 100644
--- a/src/module/e_mod_config.h
+++ b/src/module/e_mod_config.h
@@ -9,6 +9,7 @@ void emix_config_init(emix_config_backend_changed cb, const void *userdata);
9void emix_config_shutdown(void); 9void emix_config_shutdown(void);
10const char *emix_config_backend_get(void); 10const char *emix_config_backend_get(void);
11void emix_config_backend_set(const char *backend); 11void emix_config_backend_set(const char *backend);
12Eina_Bool emix_config_desklock_mute_get(void);
12Eina_Bool emix_config_notify_get(void); 13Eina_Bool emix_config_notify_get(void);
13E_Config_Dialog* emix_config_popup_new(E_Comp *comp, const char*p); 14E_Config_Dialog* emix_config_popup_new(E_Comp *comp, const char*p);
14 15
diff --git a/src/module/e_mod_main.c b/src/module/e_mod_main.c
index a74c13c..dad0883 100644
--- a/src/module/e_mod_main.c
+++ b/src/module/e_mod_main.c
@@ -50,6 +50,7 @@ struct _Context
50 Ecore_Event_Handler *sink_added_handler; 50 Ecore_Event_Handler *sink_added_handler;
51 Ecore_Event_Handler *sink_changed_handler; 51 Ecore_Event_Handler *sink_changed_handler;
52 Ecore_Event_Handler *sink_removed_handler; 52 Ecore_Event_Handler *sink_removed_handler;
53 Ecore_Event_Handler *desklock_handler;
53 const Emix_Sink *sink_default; 54 const Emix_Sink *sink_default;
54 E_Module *module; 55 E_Module *module;
55 Eina_List *instances; 56 Eina_List *instances;
@@ -710,6 +711,30 @@ _ready_cb(void *data EINA_UNUSED, int type EINA_UNUSED,
710 return ECORE_CALLBACK_DONE; 711 return ECORE_CALLBACK_DONE;
711} 712}
712 713
714static Eina_Bool
715_desklock_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *info)
716{
717 E_Event_Desklock *ev = info;
718 static Eina_Bool _was_mute = EINA_FALSE;
719
720 if (emix_config_desklock_mute_get() == EINA_FALSE)
721 return ECORE_CALLBACK_PASS_ON;
722
723 if (ev->on)
724 {
725 _was_mute = mixer_context->sink_default->mute;
726 if (!_was_mute)
727 emix_sink_mute_set((Emix_Sink *)mixer_context->sink_default, EINA_TRUE);
728 }
729 else
730 {
731 if (!_was_mute)
732 emix_sink_mute_set((Emix_Sink *)mixer_context->sink_default, EINA_FALSE);
733 }
734
735 return ECORE_CALLBACK_PASS_ON;
736}
737
713static void 738static void
714_backend_changed(const char *backend, void *data EINA_UNUSED) 739_backend_changed(const char *backend, void *data EINA_UNUSED)
715{ 740{
@@ -800,6 +825,8 @@ e_modapi_init(E_Module *m)
800 NULL); 825 NULL);
801 mixer_context->ready_handler = 826 mixer_context->ready_handler =
802 ecore_event_handler_add(EMIX_READY_EVENT, _ready_cb, NULL); 827 ecore_event_handler_add(EMIX_READY_EVENT, _ready_cb, NULL);
828 mixer_context->desklock_handler =
829 ecore_event_handler_add(E_EVENT_DESKLOCK, _desklock_cb, NULL);
803 mixer_context->module = m; 830 mixer_context->module = m;
804 snprintf(buf, sizeof(buf), "%s/mixer.edj", 831 snprintf(buf, sizeof(buf), "%s/mixer.edj",
805 e_module_dir_get(mixer_context->module)); 832 e_module_dir_get(mixer_context->module));