forked from enlightenment/enlightenment
music-control - add auto-launch if player not configured from known
This commit is contained in:
parent
dafbe38291
commit
5ce109ab8f
1
TODO
1
TODO
|
@ -144,7 +144,6 @@ TODO:
|
||||||
* start: start menu could do with more featured content
|
* start: start menu could do with more featured content
|
||||||
* like you see on windows for example (search and multiple columns etc.)
|
* like you see on windows for example (search and multiple columns etc.)
|
||||||
* a touch screen android-style scrolling fullscreen app icon style
|
* a touch screen android-style scrolling fullscreen app icon style
|
||||||
* music-control: auto search for known mpris services
|
|
||||||
* music-control: allow manual addition of new named mpris services
|
* music-control: allow manual addition of new named mpris services
|
||||||
* wireless: fix on connman to work properly
|
* wireless: fix on connman to work properly
|
||||||
* probably redesign to have a single icon and on click pop up like bz5
|
* probably redesign to have a single icon and on click pop up like bz5
|
||||||
|
|
|
@ -318,26 +318,26 @@ prop_changed(void *data, Eldbus_Proxy *proxy EINA_UNUSED, void *event_info)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cb_name_owner_has(void *data, const Eldbus_Message *msg,
|
cb_name_owner_changed(void *data,
|
||||||
Eldbus_Pending *pending EINA_UNUSED)
|
const char *bus EINA_UNUSED,
|
||||||
|
const char *from EINA_UNUSED,
|
||||||
|
const char *to)
|
||||||
{
|
{
|
||||||
E_Music_Control_Module_Context *ctxt = data;
|
E_Music_Control_Module_Context *ctxt = data;
|
||||||
Eina_Bool owner_exists;
|
|
||||||
|
|
||||||
if (eldbus_message_error_get(msg, NULL, NULL)) return;
|
have_player = EINA_FALSE;
|
||||||
if (!eldbus_message_arguments_get(msg, "b", &owner_exists)) return;
|
if (to[0])
|
||||||
if (owner_exists)
|
|
||||||
{
|
{
|
||||||
media_player2_player_playback_status_propget
|
media_player2_player_playback_status_propget
|
||||||
(ctxt->mpris2_player, cb_playback_status_get, ctxt);
|
(ctxt->mpris2_player, cb_playback_status_get, ctxt);
|
||||||
media_player2_player_metadata_propget
|
media_player2_player_metadata_propget
|
||||||
(ctxt->mpris2_player, cb_metadata_get, ctxt);
|
(ctxt->mpris2_player, cb_metadata_get, ctxt);
|
||||||
|
have_player = EINA_TRUE;
|
||||||
}
|
}
|
||||||
have_player = owner_exists;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
music_control_launch(void)
|
music_control_launch(E_Music_Control_Instance *inst)
|
||||||
{
|
{
|
||||||
E_Music_Control_Module_Context *ctxt;
|
E_Music_Control_Module_Context *ctxt;
|
||||||
|
|
||||||
|
@ -346,26 +346,60 @@ music_control_launch(void)
|
||||||
if (have_player) return;
|
if (have_player) return;
|
||||||
if (ctxt->config->player_selected < 0)
|
if (ctxt->config->player_selected < 0)
|
||||||
{
|
{
|
||||||
|
Efreet_Desktop *desktop;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < PLAYER_COUNT; i++)
|
||||||
|
{
|
||||||
|
desktop = efreet_util_desktop_exec_find
|
||||||
|
(music_player_players[i].command);
|
||||||
|
if (desktop)
|
||||||
|
{
|
||||||
|
E_Zone *zone = e_gadcon_zone_get(inst->gcc->gadcon);
|
||||||
|
e_exec(zone, desktop, NULL/* command */,
|
||||||
|
NULL/* file list */, "module/music-control");
|
||||||
|
ctxt->config->player_selected = i;
|
||||||
|
music_control_dbus_init
|
||||||
|
(ctxt, music_player_players[i].dbus_name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (ctxt->config->player_selected < PLAYER_COUNT)
|
else if (ctxt->config->player_selected < PLAYER_COUNT)
|
||||||
{
|
{
|
||||||
ecore_exe_run
|
E_Zone *zone = e_gadcon_zone_get(inst->gcc->gadcon);
|
||||||
(music_player_players[ctxt->config->player_selected].command, NULL);
|
e_exec(zone, NULL/* efreet desktop*/,
|
||||||
|
music_player_players[ctxt->config->player_selected].command,
|
||||||
|
NULL/* file list */, "module/music-control");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Eina_Bool
|
Eina_Bool
|
||||||
music_control_dbus_init(E_Music_Control_Module_Context *ctxt, const char *bus)
|
music_control_dbus_init(E_Music_Control_Module_Context *ctxt, const char *bus)
|
||||||
{
|
{
|
||||||
|
if (!ctxt->conn)
|
||||||
ctxt->conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
|
ctxt->conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(ctxt->conn, EINA_FALSE);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(ctxt->conn, EINA_FALSE);
|
||||||
|
|
||||||
|
if (ctxt->mpris2_player)
|
||||||
|
mpris_media_player2_proxy_unref(ctxt->mpris2_player);
|
||||||
|
if (ctxt->mrpis2)
|
||||||
|
media_player2_player_proxy_unref(ctxt->mrpis2);
|
||||||
ctxt->mrpis2 = mpris_media_player2_proxy_get(ctxt->conn, bus, NULL);
|
ctxt->mrpis2 = mpris_media_player2_proxy_get(ctxt->conn, bus, NULL);
|
||||||
ctxt->mpris2_player = media_player2_player_proxy_get(ctxt->conn, bus, NULL);
|
ctxt->mpris2_player = media_player2_player_proxy_get(ctxt->conn, bus, NULL);
|
||||||
eldbus_proxy_event_callback_add(ctxt->mpris2_player,
|
eldbus_proxy_event_callback_add(ctxt->mpris2_player,
|
||||||
ELDBUS_PROXY_EVENT_PROPERTY_CHANGED,
|
ELDBUS_PROXY_EVENT_PROPERTY_CHANGED,
|
||||||
prop_changed, ctxt);
|
prop_changed, ctxt);
|
||||||
eldbus_name_owner_has(ctxt->conn, bus, cb_name_owner_has, ctxt);
|
if (ctxt->dbus_name)
|
||||||
|
{
|
||||||
|
eldbus_name_owner_changed_callback_del
|
||||||
|
(ctxt->conn, ctxt->dbus_name, cb_name_owner_changed, ctxt);
|
||||||
|
eina_stringshare_del(ctxt->dbus_name);
|
||||||
|
}
|
||||||
|
ctxt->dbus_name = eina_stringshare_add(bus);
|
||||||
|
eldbus_name_owner_changed_callback_add(ctxt->conn, bus,
|
||||||
|
cb_name_owner_changed,
|
||||||
|
ctxt, EINA_TRUE);
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +420,11 @@ e_modapi_init(E_Module *m)
|
||||||
E_CONFIG_VAL(D, T, player_selected, INT);
|
E_CONFIG_VAL(D, T, player_selected, INT);
|
||||||
E_CONFIG_VAL(D, T, pause_on_desklock, INT);
|
E_CONFIG_VAL(D, T, pause_on_desklock, INT);
|
||||||
ctxt->config = e_config_domain_load(MUSIC_CONTROL_DOMAIN, ctxt->conf_edd);
|
ctxt->config = e_config_domain_load(MUSIC_CONTROL_DOMAIN, ctxt->conf_edd);
|
||||||
if (!ctxt->config) ctxt->config = calloc(1, sizeof(Music_Control_Config));
|
if (!ctxt->config)
|
||||||
|
{
|
||||||
|
ctxt->config = calloc(1, sizeof(Music_Control_Config));
|
||||||
|
ctxt->config->player_selected = -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (ctxt->config->player_selected < 0)
|
if (ctxt->config->player_selected < 0)
|
||||||
{
|
{
|
||||||
|
@ -430,6 +468,9 @@ e_modapi_shutdown(E_Module *m EINA_UNUSED)
|
||||||
|
|
||||||
E_FREE_FUNC(desklock_handler, ecore_event_handler_del);
|
E_FREE_FUNC(desklock_handler, ecore_event_handler_del);
|
||||||
|
|
||||||
|
eldbus_name_owner_changed_callback_del
|
||||||
|
(ctxt->conn, ctxt->dbus_name, cb_name_owner_changed, ctxt);
|
||||||
|
eina_stringshare_del(ctxt->dbus_name);
|
||||||
media_player2_player_proxy_unref(ctxt->mpris2_player);
|
media_player2_player_proxy_unref(ctxt->mpris2_player);
|
||||||
mpris_media_player2_proxy_unref(ctxt->mrpis2);
|
mpris_media_player2_proxy_unref(ctxt->mrpis2);
|
||||||
eldbus_connection_unref(ctxt->conn);
|
eldbus_connection_unref(ctxt->conn);
|
||||||
|
|
|
@ -26,6 +26,7 @@ typedef struct _E_Music_Control_Module_Context
|
||||||
Eldbus_Proxy *mpris2_player;
|
Eldbus_Proxy *mpris2_player;
|
||||||
E_Config_DD *conf_edd;
|
E_Config_DD *conf_edd;
|
||||||
Music_Control_Config *config;
|
Music_Control_Config *config;
|
||||||
|
const char *dbus_name;
|
||||||
Eina_Bool actions_set E_BITFIELD;
|
Eina_Bool actions_set E_BITFIELD;
|
||||||
} E_Music_Control_Module_Context;
|
} E_Music_Control_Module_Context;
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ typedef struct _E_Music_Control_Instance
|
||||||
Evas_Object *content_popup;
|
Evas_Object *content_popup;
|
||||||
} E_Music_Control_Instance;
|
} E_Music_Control_Instance;
|
||||||
|
|
||||||
void music_control_launch(void);
|
void music_control_launch(E_Music_Control_Instance *inst);
|
||||||
void music_control_mouse_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
|
void music_control_mouse_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
|
||||||
const char *music_control_edj_path_get(void);
|
const char *music_control_edj_path_get(void);
|
||||||
void music_control_popup_del(E_Music_Control_Instance *inst);
|
void music_control_popup_del(E_Music_Control_Instance *inst);
|
||||||
|
|
|
@ -92,7 +92,7 @@ _label_clicked(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EI
|
||||||
{
|
{
|
||||||
E_Music_Control_Instance *inst = data;
|
E_Music_Control_Instance *inst = data;
|
||||||
music_control_popup_del(inst);
|
music_control_popup_del(inst);
|
||||||
music_control_launch();
|
music_control_launch(inst);
|
||||||
mpris_media_player2_raise_call(inst->ctxt->mrpis2);
|
mpris_media_player2_raise_call(inst->ctxt->mrpis2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,8 +229,6 @@ _cfg_data_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||||
E_FREE_FUNC(desklock_handler, ecore_event_handler_del);
|
E_FREE_FUNC(desklock_handler, ecore_event_handler_del);
|
||||||
|
|
||||||
inst->ctxt->playing = EINA_FALSE;
|
inst->ctxt->playing = EINA_FALSE;
|
||||||
mpris_media_player2_proxy_unref(inst->ctxt->mpris2_player);
|
|
||||||
media_player2_player_proxy_unref(inst->ctxt->mrpis2);
|
|
||||||
music_control_dbus_init(inst->ctxt,
|
music_control_dbus_init(inst->ctxt,
|
||||||
music_player_players[inst->ctxt->config->player_selected].dbus_name);
|
music_player_players[inst->ctxt->config->player_selected].dbus_name);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -261,6 +259,7 @@ music_control_mouse_down_cb(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj
|
||||||
|
|
||||||
if (ev->button == 1)
|
if (ev->button == 1)
|
||||||
{
|
{
|
||||||
|
music_control_launch(inst);
|
||||||
if (!inst->popup)
|
if (!inst->popup)
|
||||||
_popup_new(inst);
|
_popup_new(inst);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue