summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlavio Ceolin <flavio.ceolin@gmail.com>2014-05-01 18:49:27 -0300
committerFlavio Ceolin <flavio.ceolin@gmail.com>2014-05-01 18:49:27 -0300
commitb5f515a035906e9af2e63abdc816af5920b1c4e8 (patch)
treeb5dfcec479075fdb50a7a88f2c139d29fedb2e02 /src
parent8946de8120a4fa763b639dc2ab68f71510d9be11 (diff)
[module] Adding desktop notification for volume changes
Diffstat (limited to 'src')
-rw-r--r--src/module/e_mod_main.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/src/module/e_mod_main.c b/src/module/e_mod_main.c
index e5d72ca..6f2ad75 100644
--- a/src/module/e_mod_main.c
+++ b/src/module/e_mod_main.c
@@ -81,11 +81,52 @@ struct _Instance
81 Evas_Object *check; 81 Evas_Object *check;
82 82
83 int mute; 83 int mute;
84 unsigned int notification_id;
84}; 85};
85 86
86static Context *mixer_context = NULL; 87static Context *mixer_context = NULL;
87 88
88static void 89static void
90_notify_cb(void *data, unsigned int id)
91{
92 Instance *inst = data;
93 inst->notification_id = id;
94}
95
96static void
97_notify(const int val, Instance *inst)
98{
99 E_Notification_Notify n;
100 char *icon, buf[56];
101 int ret;
102
103 memset(&n, 0, sizeof(E_Notification_Notify));
104 if (val > 100 || val < 0)
105 return;
106
107 ret = snprintf(buf, (sizeof(buf) - 1), "%s: %d%%", _("New volume"), val);
108 if ((ret < 0) || ((unsigned int)ret > sizeof(buf)))
109 return;
110 //Names are taken from FDO icon naming scheme
111 if (val == 0)
112 icon = "audio-volume-muted";
113 else if ((val > 33) && (val < 66))
114 icon = "audio-volume-medium";
115 else if (val < 33)
116 icon = "audio-volume-low";
117 else
118 icon = "audio-volume-high";
119
120 n.app_name = _("EPulse");
121 n.replaces_id = inst->notification_id;
122 n.icon.icon = icon;
123 n.sumary = _("Volume changed");
124 n.body = buf;
125 n.timeout = 2000;
126 e_notification_client_send(&n, _notify_cb, inst);
127}
128
129static void
89_mixer_popup_update(Instance *inst, int mute, int vol) 130_mixer_popup_update(Instance *inst, int mute, int vol)
90{ 131{
91 e_widget_check_checked_set(inst->check, mute); 132 e_widget_check_checked_set(inst->check, mute);
@@ -114,6 +155,8 @@ _mixer_gadget_update(void)
114 if (inst->popup) 155 if (inst->popup)
115 _mixer_popup_update(inst, mixer_context->sink_default->mute, 156 _mixer_popup_update(inst, mixer_context->sink_default->mute,
116 msg->val[1]); 157 msg->val[1]);
158 else
159 _notify(mixer_context->sink_default->mute ? 0 : msg->val[1], inst);
117 } 160 }
118} 161}
119 162
@@ -124,7 +167,6 @@ _volume_increase_cb(E_Object *obj EINA_UNUSED, const char *params EINA_UNUSED)
124 pa_cvolume_inc(&(s->volume), VOLUME_STEP); 167 pa_cvolume_inc(&(s->volume), VOLUME_STEP);
125 168
126 epulse_sink_volume_set(s->index, s->volume); 169 epulse_sink_volume_set(s->index, s->volume);
127 _mixer_gadget_update();
128} 170}
129 171
130static void 172static void
@@ -134,7 +176,6 @@ _volume_decrease_cb(E_Object *obj EINA_UNUSED, const char *params EINA_UNUSED)
134 pa_cvolume_dec(&(s->volume), VOLUME_STEP); 176 pa_cvolume_dec(&(s->volume), VOLUME_STEP);
135 177
136 epulse_sink_volume_set(s->index, s->volume); 178 epulse_sink_volume_set(s->index, s->volume);
137 _mixer_gadget_update();
138} 179}
139 180
140static void 181static void
@@ -148,8 +189,6 @@ _volume_mute_cb(E_Object *obj EINA_UNUSED, const char *params EINA_UNUSED)
148 s->mute = !s->mute; 189 s->mute = !s->mute;
149 return; 190 return;
150 } 191 }
151
152 _mixer_gadget_update();
153} 192}
154 193
155static void 194static void