|
|
|
@ -26,6 +26,8 @@ static const char *_gc_id_new(void); |
|
|
|
|
/* Module Protos */ |
|
|
|
|
static void _mpdule_cb_mouse_down (void *data, Evas * e, Evas_Object * obj, |
|
|
|
|
void *event_info); |
|
|
|
|
static void _mpdule_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info); |
|
|
|
|
static void _mpdule_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info); |
|
|
|
|
static void _mpdule_menu_cb_configure (void *data, E_Menu * m, |
|
|
|
|
E_Menu_Item * mi); |
|
|
|
|
static void _mpdule_menu_cb_post (void *data, E_Menu * m); |
|
|
|
@ -49,9 +51,11 @@ struct _Instance |
|
|
|
|
{ |
|
|
|
|
E_Gadcon_Client *gcc; |
|
|
|
|
Evas_Object *mpdule; |
|
|
|
|
Evas_Object *o_popup; |
|
|
|
|
mpd_Connection *mpd; |
|
|
|
|
Ecore_Timer *update_timer; |
|
|
|
|
Config_Item *ci; |
|
|
|
|
E_Gadcon_Popup *popup; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -59,14 +63,18 @@ static void _mpdule_connect (Instance * inst); |
|
|
|
|
static void _mpdule_disconnect (Instance * inst); |
|
|
|
|
static void _mpdule_update_song (Instance * inst); |
|
|
|
|
static void _mpdule_update_song_cb (void *data); |
|
|
|
|
static void _mpdule_popup_destroy(Instance *inst); |
|
|
|
|
static void _mpdule_popup_resize(Evas_Object *obj, int *w, int *h); |
|
|
|
|
|
|
|
|
|
static E_Gadcon_Client * |
|
|
|
|
_gc_init (E_Gadcon * gc, const char *name, const char *id, const char *style) |
|
|
|
|
{ |
|
|
|
|
Evas_Object *o; |
|
|
|
|
Evas_Object *o, *o_popup; |
|
|
|
|
E_Gadcon_Client *gcc; |
|
|
|
|
Evas *evas; |
|
|
|
|
Instance *inst; |
|
|
|
|
char buf[4096]; |
|
|
|
|
int w, h; |
|
|
|
|
|
|
|
|
|
inst = E_NEW (Instance, 1); |
|
|
|
|
|
|
|
|
@ -87,14 +95,29 @@ _gc_init (E_Gadcon * gc, const char *name, const char *id, const char *style) |
|
|
|
|
inst->gcc = gcc; |
|
|
|
|
inst->mpdule = o; |
|
|
|
|
|
|
|
|
|
inst->popup = e_gadcon_popup_new(inst->gcc, _mpdule_popup_resize); |
|
|
|
|
|
|
|
|
|
evas = inst->popup->win->evas; |
|
|
|
|
o_popup = edje_object_add (evas); |
|
|
|
|
if (!e_theme_edje_object_set |
|
|
|
|
(o_popup, "base/theme/modules/mpdule", "modules/mpdule/popup")) |
|
|
|
|
edje_object_file_set (o_popup, buf, "modules/mpdule/popup"); |
|
|
|
|
evas_object_show (o_popup); |
|
|
|
|
e_gadcon_popup_content_set(inst->popup, o_popup); |
|
|
|
|
edje_object_size_min_calc (o_popup, &w, &h); |
|
|
|
|
inst->o_popup = o_popup; |
|
|
|
|
|
|
|
|
|
evas_object_event_callback_add (o, EVAS_CALLBACK_MOUSE_DOWN, |
|
|
|
|
_mpdule_cb_mouse_down, inst); |
|
|
|
|
evas_object_event_callback_add(inst->mpdule, EVAS_CALLBACK_MOUSE_IN, |
|
|
|
|
_mpdule_cb_mouse_in, inst); |
|
|
|
|
evas_object_event_callback_add(inst->mpdule, EVAS_CALLBACK_MOUSE_OUT, |
|
|
|
|
_mpdule_cb_mouse_out, inst); |
|
|
|
|
_mpdule_connect(inst); |
|
|
|
|
_mpdule_update_song(inst); |
|
|
|
|
inst->update_timer = ecore_timer_add((double)inst->ci->poll_time, |
|
|
|
|
_mpdule_update_song_cb, inst); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mpdule_config->instances = |
|
|
|
|
evas_list_append (mpdule_config->instances, inst); |
|
|
|
|
return gcc; |
|
|
|
@ -114,7 +137,11 @@ _gc_shutdown (E_Gadcon_Client * gcc) |
|
|
|
|
|
|
|
|
|
evas_object_event_callback_del (inst->mpdule, EVAS_CALLBACK_MOUSE_DOWN, |
|
|
|
|
_mpdule_cb_mouse_down); |
|
|
|
|
|
|
|
|
|
evas_object_event_callback_del(inst->mpdule, EVAS_CALLBACK_MOUSE_IN, |
|
|
|
|
_mpdule_cb_mouse_in); |
|
|
|
|
evas_object_event_callback_del(inst->mpdule, EVAS_CALLBACK_MOUSE_OUT, |
|
|
|
|
_mpdule_cb_mouse_out); |
|
|
|
|
_mpdule_popup_destroy(inst); |
|
|
|
|
evas_object_del (inst->mpdule); |
|
|
|
|
free (inst); |
|
|
|
|
inst = NULL; |
|
|
|
@ -195,9 +222,37 @@ _mpdule_cb_mouse_down (void *data, Evas * e, Evas_Object * obj, |
|
|
|
|
E_MENU_POP_DIRECTION_DOWN, ev->timestamp); |
|
|
|
|
evas_event_feed_mouse_up (inst->gcc->gadcon->evas, ev->button, |
|
|
|
|
EVAS_BUTTON_NONE, ev->timestamp, NULL); |
|
|
|
|
} else if (ev->button == 1) { |
|
|
|
|
printf("POPUP3"); |
|
|
|
|
e_gadcon_popup_toggle_pinned(inst->popup); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
_mpdule_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info) |
|
|
|
|
{ |
|
|
|
|
Instance *inst; |
|
|
|
|
E_Gadcon_Popup *popup; |
|
|
|
|
|
|
|
|
|
printf("POPUP1"); |
|
|
|
|
if (!(inst = data)) return; |
|
|
|
|
popup = inst->popup; |
|
|
|
|
e_gadcon_popup_show(inst->popup); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
_mpdule_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info) |
|
|
|
|
{ |
|
|
|
|
Instance *inst; |
|
|
|
|
E_Gadcon_Popup *popup; |
|
|
|
|
|
|
|
|
|
printf("POPUP2"); |
|
|
|
|
if (!(inst = data)) return; |
|
|
|
|
popup = inst->popup; |
|
|
|
|
e_gadcon_popup_hide(inst->popup); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
_mpdule_menu_cb_post (void *data, E_Menu * m) |
|
|
|
|
{ |
|
|
|
@ -309,8 +364,11 @@ _mpdule_connect(Instance *inst) |
|
|
|
|
static void |
|
|
|
|
_mpdule_disconnect(Instance *inst) |
|
|
|
|
{ |
|
|
|
|
mpd_Connection *mpd; |
|
|
|
|
|
|
|
|
|
if (inst->mpd) { |
|
|
|
|
mpd_closeConnection(inst->mpd); |
|
|
|
|
mpd = inst->mpd; |
|
|
|
|
mpd_closeConnection(mpd); |
|
|
|
|
inst->mpd = NULL; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -330,11 +388,13 @@ _mpdule_update_song(Instance *inst) |
|
|
|
|
{ |
|
|
|
|
mpd_Connection *mpd; |
|
|
|
|
Evas_Object *mpdule; |
|
|
|
|
|
|
|
|
|
Evas_Object *o_popup; |
|
|
|
|
|
|
|
|
|
if (!inst->mpd) |
|
|
|
|
return; |
|
|
|
|
mpd = inst->mpd; |
|
|
|
|
mpdule = inst->mpdule; |
|
|
|
|
o_popup = inst->o_popup;
|
|
|
|
|
mpd_sendStatusCommand(mpd); |
|
|
|
|
if (mpd->error == 0) |
|
|
|
|
{ |
|
|
|
@ -345,18 +405,22 @@ _mpdule_update_song(Instance *inst) |
|
|
|
|
if (status->state == MPD_STATUS_STATE_UNKNOWN) |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.status", D_ ("Unknown")); |
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.status", D_ ("Unknown")); |
|
|
|
|
} |
|
|
|
|
else if (status->state == MPD_STATUS_STATE_STOP) |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.status", D_ ("Stopped")); |
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.status", D_ ("Stopped")); |
|
|
|
|
} |
|
|
|
|
else if (status->state == MPD_STATUS_STATE_PLAY) |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.status", D_ ("Playing")); |
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.status", D_ ("Playing")); |
|
|
|
|
} |
|
|
|
|
else if (status->state == MPD_STATUS_STATE_PAUSE) |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.status", D_ ("Paused")); |
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.status", D_ ("Paused")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (status->state > MPD_STATUS_STATE_STOP) |
|
|
|
@ -374,85 +438,94 @@ _mpdule_update_song(Instance *inst) |
|
|
|
|
if (song->artist) |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.artist", song->artist); |
|
|
|
|
|
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.artist", song->artist); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.artist", ""); |
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.artist", ""); |
|
|
|
|
} |
|
|
|
|
if (song->title) |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.title", song->title); |
|
|
|
|
|
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.title", song->title); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.title", ""); |
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.title", ""); |
|
|
|
|
} |
|
|
|
|
if (song->album) |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.album", song->album); |
|
|
|
|
|
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.album", song->album); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.album", ""); |
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.album", ""); |
|
|
|
|
} |
|
|
|
|
if (song->track) |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.track", song->track); |
|
|
|
|
|
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.track", song->track); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.track", ""); |
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.track", ""); |
|
|
|
|
} |
|
|
|
|
if (song->date) |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.date", song->date); |
|
|
|
|
|
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.date", song->date); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.date", ""); |
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.date", ""); |
|
|
|
|
} |
|
|
|
|
if (song->genre) |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.genre", song->genre); |
|
|
|
|
|
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.genre", song->genre); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.genre", ""); |
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.genre", ""); |
|
|
|
|
} |
|
|
|
|
if (song->composer) |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.composer", song->composer); |
|
|
|
|
|
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.composer", song->composer); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.composer", ""); |
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.composer", ""); |
|
|
|
|
} |
|
|
|
|
if (song->time) |
|
|
|
|
{ |
|
|
|
|
char * songtime; |
|
|
|
|
sprintf(songtime, "%i", song->time); |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.time", songtime); |
|
|
|
|
|
|
|
|
|
//char * songtime;
|
|
|
|
|
//sprintf(songtime, "%i", song->time);
|
|
|
|
|
//edje_object_part_text_set (mpdule, "mpdule.time", songtime);
|
|
|
|
|
//edje_object_part_text_set (o_popup, "mpdule.time", songtime);
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.time", ""); |
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.time", ""); |
|
|
|
|
} |
|
|
|
|
if (song->file) |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.file", song->file); |
|
|
|
|
|
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.file", song->file); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
edje_object_part_text_set (mpdule, "mpdule.file", ""); |
|
|
|
|
edje_object_part_text_set (o_popup, "mpdule.file", ""); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -558,3 +631,23 @@ e_modapi_save (E_Module * m) |
|
|
|
|
e_config_domain_save ("module.mpdule", conf_edd, mpdule_config); |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
_mpdule_popup_destroy(Instance *inst) |
|
|
|
|
{ |
|
|
|
|
if (!inst->popup) return; |
|
|
|
|
e_object_del(E_OBJECT(inst->popup)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
_mpdule_popup_resize(Evas_Object *obj, int *w, int *h) |
|
|
|
|
{ |
|
|
|
|
int x, y; |
|
|
|
|
if (!(*w)) *w = 0; |
|
|
|
|
if (!(*h)) *h = 0; |
|
|
|
|
printf("SIZES: %dx%d", w, h); |
|
|
|
|
edje_object_size_min_calc (obj, &x, &y); |
|
|
|
|
printf("SIZES2: %dx%d", x, y); |
|
|
|
|
*w = x; |
|
|
|
|
*h = y; |
|
|
|
|
} |
|
|
|
|