summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Bouchaud <michael.bouchaud@ext.actia.fr>2017-02-20 00:46:34 +0100
committerMichaƫl Bouchaud (yoz) <yoz@efl.so>2017-02-20 02:23:16 +0100
commit51a5ec4e6a9b8b8de5f2fd677f15896cd012cd50 (patch)
tree22323251aa048799a565b99524b1d21b0e4ed3d5
parent0a739058953f4569e082479ad9c8036daf9a9586 (diff)
e_client_volume: display a control per stream in the popup volume
This commit enhance the e_client_volume popup. Now you could see which sink belongs to an e_client and allow you to control it. Sadly I haven't added a scroller to this popup, I will add it later. Lots of calcs is needed to display it correctly.
-rw-r--r--src/modules/mixer/e_mod_main.c217
1 files changed, 217 insertions, 0 deletions
diff --git a/src/modules/mixer/e_mod_main.c b/src/modules/mixer/e_mod_main.c
index aa9b6194c..846d06aa7 100644
--- a/src/modules/mixer/e_mod_main.c
+++ b/src/modules/mixer/e_mod_main.c
@@ -95,6 +95,8 @@ struct _Client_Mixer
95 Evas_Object *volume; 95 Evas_Object *volume;
96 Evas_Object *mute; 96 Evas_Object *mute;
97 E_Client *ec; 97 E_Client *ec;
98 Evas_Object *bx;
99 Eina_List *sinks;
98}; 100};
99 101
100static Context *mixer_context = NULL; 102static Context *mixer_context = NULL;
@@ -1059,11 +1061,42 @@ _bd_hook_mute_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED
1059 e_client_volume_mute_set(ec, elm_check_state_get(obj)); 1061 e_client_volume_mute_set(ec, elm_check_state_get(obj));
1060} 1062}
1061 1063
1064static void
1065_bd_hook_sink_volume_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
1066{
1067 E_Client_Volume_Sink *sink;
1068 Evas_Object *check;
1069
1070 sink = data;
1071
1072 check = evas_object_data_get(obj, "e_sink_check");
1073
1074 e_client_volume_sink_set(sink,
1075 elm_slider_value_get(obj),
1076 elm_check_state_get(check));
1077}
1078
1079static void
1080_bd_hook_sink_mute_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
1081{
1082 E_Client_Volume_Sink *sink;
1083 Evas_Object *slider;
1084
1085 sink = data;
1086 slider = evas_object_data_get(obj, "e_sink_volume");
1087
1088 e_client_volume_sink_set(sink,
1089 elm_slider_value_get(slider),
1090 elm_check_state_get(obj));
1091}
1092
1062static Eina_Bool 1093static Eina_Bool
1063_e_client_volume_changed(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) 1094_e_client_volume_changed(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
1064{ 1095{
1065 E_Event_Client *ev; 1096 E_Event_Client *ev;
1066 Client_Mixer *cm; 1097 Client_Mixer *cm;
1098 E_Client_Volume_Sink *sink;
1099 Evas_Object *o;
1067 Eina_List *l; 1100 Eina_List *l;
1068 1101
1069 ev = event; 1102 ev = event;
@@ -1073,6 +1106,13 @@ _e_client_volume_changed(void *data EINA_UNUSED, int type EINA_UNUSED, void *eve
1073 if (cm->ec == ev->ec) 1106 if (cm->ec == ev->ec)
1074 { 1107 {
1075 elm_slider_value_set(cm->volume, cm->ec->volume); 1108 elm_slider_value_set(cm->volume, cm->ec->volume);
1109 EINA_LIST_FOREACH(cm->sinks, l, o)
1110 {
1111 int volume;
1112 sink = evas_object_data_get(o, "e_sink");
1113 e_client_volume_sink_get(sink, &volume, NULL);
1114 elm_slider_value_set(o, volume);
1115 }
1076 break; 1116 break;
1077 } 1117 }
1078 } 1118 }
@@ -1085,7 +1125,10 @@ _e_client_mute_changed(void *data EINA_UNUSED, int type EINA_UNUSED, void *event
1085{ 1125{
1086 E_Event_Client *ev; 1126 E_Event_Client *ev;
1087 Client_Mixer *cm; 1127 Client_Mixer *cm;
1128 E_Client_Volume_Sink *sink;
1129 Evas_Object *o, *check;
1088 Eina_List *l; 1130 Eina_List *l;
1131 Eina_Bool mute;
1089 1132
1090 ev = event; 1133 ev = event;
1091 1134
@@ -1094,6 +1137,160 @@ _e_client_mute_changed(void *data EINA_UNUSED, int type EINA_UNUSED, void *event
1094 if (cm->ec == ev->ec) 1137 if (cm->ec == ev->ec)
1095 { 1138 {
1096 elm_check_state_set(cm->mute, !!cm->ec->mute); 1139 elm_check_state_set(cm->mute, !!cm->ec->mute);
1140 elm_object_disabled_set(cm->volume, !!cm->ec->mute);
1141 EINA_LIST_FOREACH(cm->sinks, l, o)
1142 {
1143 sink = evas_object_data_get(o, "e_sink");
1144 check = evas_object_data_get(o, "e_sink_check");
1145 e_client_volume_sink_get(sink, NULL, &mute);
1146 elm_check_state_set(check, mute);
1147 elm_object_disabled_set(o, mute);
1148 }
1149 break;
1150 }
1151 }
1152
1153 return ECORE_CALLBACK_PASS_ON;
1154}
1155
1156static void
1157_e_client_mixer_sink_append(E_Client_Volume_Sink *sink, Client_Mixer *cm)
1158{
1159 Evas_Object *lbl, *slider, *check, *sep;
1160 int volume;
1161 int min, max;
1162 Eina_Bool mute;
1163
1164 min = e_client_volume_sink_min_get(sink);
1165 max = e_client_volume_sink_max_get(sink);
1166 e_client_volume_sink_get(sink, &volume, &mute);
1167
1168 sep = elm_separator_add(cm->bx);
1169 elm_separator_horizontal_set(sep, EINA_TRUE);
1170 evas_object_size_hint_weight_set(sep, 0.0, EVAS_HINT_EXPAND);
1171 evas_object_size_hint_align_set(sep, EVAS_HINT_FILL, EVAS_HINT_FILL);
1172 elm_box_pack_end(cm->bx, sep);
1173 evas_object_show(sep);
1174
1175 lbl = elm_label_add(cm->bx);
1176 elm_object_text_set(lbl, e_client_volume_sink_name_get(sink));
1177 evas_object_size_hint_align_set(lbl, 0.0, EVAS_HINT_FILL);
1178 elm_box_pack_end(cm->bx, lbl);
1179 evas_object_show(lbl);
1180
1181 slider = elm_slider_add(cm->bx);
1182 elm_slider_horizontal_set(slider, EINA_TRUE);
1183 elm_slider_min_max_set(slider, min, max);
1184 elm_slider_span_size_set(slider, max * elm_config_scale_get());
1185 elm_slider_unit_format_set(slider, "%.0f");
1186 elm_slider_indicator_format_set(slider, "%.0f");
1187 evas_object_size_hint_weight_set(slider, 0.0, EVAS_HINT_EXPAND);
1188 evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, EVAS_HINT_FILL);
1189 elm_slider_value_set(slider, volume);
1190 evas_object_smart_callback_add(slider, "changed",
1191 _bd_hook_sink_volume_changed, sink);
1192 elm_box_pack_end(cm->bx, slider);
1193 evas_object_show(slider);
1194
1195 check = elm_check_add(cm->bx);
1196 elm_object_text_set(check, _("Mute"));
1197 evas_object_size_hint_align_set(check, 0.0, EVAS_HINT_FILL);
1198 elm_check_state_set(check, !!mute);
1199 elm_object_disabled_set(slider, !!mute);
1200 evas_object_smart_callback_add(check, "changed",
1201 _bd_hook_sink_mute_changed, sink);
1202
1203 elm_box_pack_end(cm->bx, check);
1204 evas_object_show(check);
1205
1206 evas_object_data_set(slider, "e_sink", sink);
1207 evas_object_data_set(slider, "e_sink_check", check);
1208 evas_object_data_set(slider, "e_sink_label", lbl);
1209 evas_object_data_set(slider, "e_sink_separator", sep);
1210 evas_object_data_set(check, "e_sink_volume", slider);
1211 cm->sinks = eina_list_append(cm->sinks, slider);
1212}
1213
1214static Eina_Bool
1215_e_client_volume_sink_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
1216{
1217 E_Event_Client_Volume_Sink *ev;
1218 Client_Mixer *cm;
1219 Eina_List *l;
1220
1221 ev = event;
1222
1223 EINA_LIST_FOREACH(_client_mixers, l, cm)
1224 {
1225 if (cm->ec == ev->ec)
1226 {
1227 _e_client_mixer_sink_append(ev->sink, cm);
1228 }
1229 }
1230 return ECORE_CALLBACK_PASS_ON;
1231}
1232
1233static Eina_Bool
1234_e_client_volume_sink_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
1235{
1236 E_Event_Client_Volume_Sink *ev;
1237 E_Client_Volume_Sink *sink;
1238 Client_Mixer *cm;
1239 Evas_Object *o, *lbl, *check;
1240 Eina_List *l;
1241
1242 ev = event;
1243
1244 EINA_LIST_FOREACH(_client_mixers, l, cm)
1245 {
1246 if (cm->ec == ev->ec)
1247 {
1248 EINA_LIST_FOREACH(cm->sinks, l, o)
1249 {
1250 sink = evas_object_data_get(o, "e_sink");
1251 if (sink == ev->sink)
1252 {
1253 lbl = evas_object_data_get(o, "e_sink_label");
1254 check = evas_object_data_get(o, "e_sink_check");
1255 evas_object_del(lbl);
1256 evas_object_del(o);
1257 evas_object_del(check);
1258 cm->sinks = eina_list_remove_list(cm->sinks, l);
1259 }
1260 }
1261 break;
1262 }
1263 }
1264 return ECORE_CALLBACK_PASS_ON;
1265}
1266
1267static Eina_Bool
1268_e_client_volume_sink_changed(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
1269{
1270 E_Event_Client_Volume_Sink *ev;
1271 Client_Mixer *cm;
1272 E_Client_Volume_Sink *sink;
1273 Evas_Object *o, *check;
1274 Eina_List *l;
1275 int volume;
1276 Eina_Bool mute;
1277
1278 ev = event;
1279
1280 EINA_LIST_FOREACH(_client_mixers, l, cm)
1281 {
1282 if (cm->ec == ev->ec)
1283 {
1284 EINA_LIST_FOREACH(cm->sinks, l, o)
1285 {
1286 sink = evas_object_data_get(o, "e_sink");
1287 if (sink != ev->sink) continue;
1288 check = evas_object_data_get(o, "e_sink_check");
1289 e_client_volume_sink_get(sink, &volume, &mute);
1290 elm_slider_value_set(o, volume);
1291 elm_object_disabled_set(o, mute);
1292 elm_check_state_set(check, mute);
1293 }
1097 break; 1294 break;
1098 } 1295 }
1099 } 1296 }
@@ -1142,6 +1339,7 @@ _bd_hook_cb(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *it EINA_UNUSED)
1142{ 1339{
1143 E_Client *ec; 1340 E_Client *ec;
1144 Client_Mixer *cm; 1341 Client_Mixer *cm;
1342 E_Client_Volume_Sink *sink;
1145 Evas_Object *win, *popup, *bx, *o; 1343 Evas_Object *win, *popup, *bx, *o;
1146 Eina_List *l; 1344 Eina_List *l;
1147 int w, h; 1345 int w, h;
@@ -1163,6 +1361,13 @@ _bd_hook_cb(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *it EINA_UNUSED)
1163 elm_box_horizontal_set(bx, EINA_FALSE); 1361 elm_box_horizontal_set(bx, EINA_FALSE);
1164 elm_object_content_set(win, bx); 1362 elm_object_content_set(win, bx);
1165 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1363 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1364 cm->bx = bx;
1365
1366 o = elm_label_add(bx);
1367 elm_object_text_set(o, _("Main"));
1368 evas_object_size_hint_align_set(o, 0.0, EVAS_HINT_FILL);
1369 elm_box_pack_end(bx, o);
1370 evas_object_show(o);
1166 1371
1167 o = elm_slider_add(bx); 1372 o = elm_slider_add(bx);
1168 elm_slider_horizontal_set(o, EINA_TRUE); 1373 elm_slider_horizontal_set(o, EINA_TRUE);
@@ -1182,11 +1387,17 @@ _bd_hook_cb(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *it EINA_UNUSED)
1182 elm_object_text_set(o, _("Mute")); 1387 elm_object_text_set(o, _("Mute"));
1183 evas_object_size_hint_align_set(o, 0.0, EVAS_HINT_FILL); 1388 evas_object_size_hint_align_set(o, 0.0, EVAS_HINT_FILL);
1184 elm_check_state_set(o, !!ec->mute); 1389 elm_check_state_set(o, !!ec->mute);
1390 elm_object_disabled_set(o, !!ec->mute);
1185 evas_object_smart_callback_add(o, "changed", _bd_hook_mute_changed, ec); 1391 evas_object_smart_callback_add(o, "changed", _bd_hook_mute_changed, ec);
1186 elm_box_pack_end(bx, o); 1392 elm_box_pack_end(bx, o);
1187 evas_object_show(o); 1393 evas_object_show(o);
1188 cm->mute = o; 1394 cm->mute = o;
1189 1395
1396 EINA_LIST_FOREACH(ec->sinks, l, sink)
1397 {
1398 _e_client_mixer_sink_append(sink, cm);
1399 }
1400
1190 evas_object_show(bx); 1401 evas_object_show(bx);
1191 evas_object_size_hint_min_get(bx, &w, &h); 1402 evas_object_size_hint_min_get(bx, &w, &h);
1192 evas_object_resize(win, w, h); 1403 evas_object_resize(win, w, h);
@@ -1297,6 +1508,12 @@ e_modapi_init(E_Module *m)
1297 _e_client_mute_changed, NULL); 1508 _e_client_mute_changed, NULL);
1298 E_LIST_HANDLER_APPEND(_client_handlers, E_EVENT_CLIENT_REMOVE, 1509 E_LIST_HANDLER_APPEND(_client_handlers, E_EVENT_CLIENT_REMOVE,
1299 _e_client_remove, NULL); 1510 _e_client_remove, NULL);
1511 E_LIST_HANDLER_APPEND(_client_handlers, E_EVENT_CLIENT_VOLUME_SINK_ADD,
1512 _e_client_volume_sink_add, NULL);
1513 E_LIST_HANDLER_APPEND(_client_handlers, E_EVENT_CLIENT_VOLUME_SINK_DEL,
1514 _e_client_volume_sink_del, NULL);
1515 E_LIST_HANDLER_APPEND(_client_handlers, E_EVENT_CLIENT_VOLUME_SINK_CHANGED,
1516 _e_client_volume_sink_changed, NULL);
1300 1517
1301 return m; 1518 return m;
1302 1519