mpdule: rework popup
Now create the popup only when displaying it. This fixes issues with compositing. SVN revision: 84405
This commit is contained in:
parent
809774ad86
commit
7e6f939907
298
src/e_mod_main.c
298
src/e_mod_main.c
|
@ -68,6 +68,17 @@ struct _Instance
|
|||
Ecore_Timer *update_timer;
|
||||
Config_Item *ci;
|
||||
E_Gadcon_Popup *popup;
|
||||
Eina_Bool popup_creation_in_progress;
|
||||
char *status;
|
||||
char *artist;
|
||||
char *title;
|
||||
char *album;
|
||||
char *track;
|
||||
char *date;
|
||||
char *genre;
|
||||
char *composer;
|
||||
char *time;
|
||||
char *file;
|
||||
};
|
||||
|
||||
static void _mpdule_connect(Instance *inst);
|
||||
|
@ -75,7 +86,7 @@ static void _mpdule_disconnect(Instance *inst);
|
|||
static void _mpdule_update_song(Instance *inst);
|
||||
static Eina_Bool _mpdule_update_song_cb(void *data);
|
||||
static void _mpdule_popup_destroy(Instance *inst);
|
||||
static void _mpdule_popup_create(Instance *inst, const char *dir);
|
||||
static void _mpdule_popup_create(Instance *inst);
|
||||
|
||||
static E_Gadcon_Client *
|
||||
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
||||
|
@ -105,8 +116,6 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
|||
inst->gcc = gcc;
|
||||
inst->mpdule = o;
|
||||
|
||||
_mpdule_popup_create(inst, buf);
|
||||
|
||||
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,
|
||||
|
@ -153,6 +162,16 @@ _gc_shutdown(E_Gadcon_Client *gcc)
|
|||
_mpdule_cb_mouse_out);
|
||||
_mpdule_popup_destroy(inst);
|
||||
evas_object_del(inst->mpdule);
|
||||
free(inst->status);
|
||||
free(inst->artist);
|
||||
free(inst->title);
|
||||
free(inst->album);
|
||||
free(inst->track);
|
||||
free(inst->date);
|
||||
free(inst->genre);
|
||||
free(inst->composer);
|
||||
free(inst->time);
|
||||
free(inst->file);
|
||||
free(inst);
|
||||
gcc->data = NULL;
|
||||
}
|
||||
|
@ -199,13 +218,13 @@ _mpdule_cb_mouse_down(void *data, Evas *e, Evas_Object *obj,
|
|||
void *event_info)
|
||||
{
|
||||
Evas_Event_Mouse_Down *ev = event_info;
|
||||
Instance *inst = data;
|
||||
|
||||
if ((ev->button == 3) && (!mpdule_config->menu))
|
||||
{
|
||||
E_Menu *m;
|
||||
E_Menu_Item *mi;
|
||||
int x, y, w, h;
|
||||
Instance *inst = data;
|
||||
|
||||
m = e_menu_new();
|
||||
mi = e_menu_item_new(m);
|
||||
|
@ -228,7 +247,8 @@ _mpdule_cb_mouse_down(void *data, Evas *e, Evas_Object *obj,
|
|||
}
|
||||
else if (ev->button == 1)
|
||||
{
|
||||
//e_gadcon_popup_toggle_pinned(inst->popup);
|
||||
if (inst->popup) _mpdule_popup_destroy(inst);
|
||||
else _mpdule_popup_create(inst);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,7 +260,10 @@ _mpdule_cb_mouse_in(void *data, Evas *e, Evas_Object *obj,
|
|||
|
||||
if ((!inst) || (!inst->ci->show_popup))
|
||||
return;
|
||||
e_gadcon_popup_show(inst->popup);
|
||||
if (!inst->popup)
|
||||
{
|
||||
_mpdule_popup_create(inst);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -249,9 +272,12 @@ _mpdule_cb_mouse_out(void *data, Evas *e, Evas_Object *obj,
|
|||
{
|
||||
Instance *inst = data;
|
||||
|
||||
if ((!inst) || ((!inst->ci->show_popup) && (inst->popup)))
|
||||
if ((!inst) || ((!inst->ci->show_popup) && (!inst->popup)))
|
||||
return;
|
||||
e_gadcon_popup_hide(inst->popup);
|
||||
if (inst->popup)
|
||||
{
|
||||
_mpdule_popup_destroy(inst);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -288,22 +314,16 @@ _mpdule_config_updated(Config_Item *ci)
|
|||
_mpdule_connect(inst);
|
||||
_mpdule_update_song(inst);
|
||||
if (inst->update_timer)
|
||||
ecore_timer_interval_set(inst->update_timer, ci->poll_time);
|
||||
else
|
||||
inst->update_timer =
|
||||
ecore_timer_add(ci->poll_time, _mpdule_update_song_cb,
|
||||
inst);
|
||||
if (inst->ci->show_popup)
|
||||
{
|
||||
if (!inst->popup)
|
||||
{
|
||||
_mpdule_popup_create(inst, NULL);
|
||||
}
|
||||
ecore_timer_interval_set(inst->update_timer, ci->poll_time);
|
||||
}
|
||||
else
|
||||
{
|
||||
_mpdule_popup_destroy(inst);
|
||||
inst->update_timer =
|
||||
ecore_timer_add(ci->poll_time, _mpdule_update_song_cb,
|
||||
inst);
|
||||
}
|
||||
_mpdule_popup_destroy(inst);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -461,35 +481,50 @@ _mpdule_update_song(Instance *inst)
|
|||
{
|
||||
mpd_Status *status = mpd_getStatus(mpd);
|
||||
|
||||
free(inst->status); inst->status = NULL;
|
||||
free(inst->artist); inst->artist = NULL;
|
||||
free(inst->title); inst->title = NULL;
|
||||
free(inst->album); inst->album = NULL;
|
||||
free(inst->track); inst->track = NULL;
|
||||
free(inst->date); inst->date = NULL;
|
||||
free(inst->genre); inst->genre = NULL;
|
||||
free(inst->composer); inst->composer = NULL;
|
||||
free(inst->time); inst->time = NULL;
|
||||
free(inst->file); inst->file = NULL;
|
||||
|
||||
if (status)
|
||||
{
|
||||
if (status->state == MPD_STATUS_STATE_UNKNOWN)
|
||||
{
|
||||
inst->status = strdup(D_("Unknown"));
|
||||
edje_object_part_text_set(mpdule, "mpdule.status",
|
||||
D_("Unknown"));
|
||||
inst->status);
|
||||
edje_object_part_text_set(o_popup, "mpdule.status",
|
||||
D_("Unknown"));
|
||||
inst->status);
|
||||
}
|
||||
else if (status->state == MPD_STATUS_STATE_STOP)
|
||||
{
|
||||
inst->status = strdup(D_("Stopped"));
|
||||
edje_object_part_text_set(mpdule, "mpdule.status",
|
||||
D_("Stopped"));
|
||||
inst->status);
|
||||
edje_object_part_text_set(o_popup, "mpdule.status",
|
||||
D_("Stopped"));
|
||||
inst->status);
|
||||
}
|
||||
else if (status->state == MPD_STATUS_STATE_PLAY)
|
||||
{
|
||||
inst->status = strdup(D_("Playing"));
|
||||
edje_object_part_text_set(mpdule, "mpdule.status",
|
||||
D_("Playing"));
|
||||
inst->status);
|
||||
edje_object_part_text_set(o_popup, "mpdule.status",
|
||||
D_("Playing"));
|
||||
inst->status);
|
||||
}
|
||||
else if (status->state == MPD_STATUS_STATE_PAUSE)
|
||||
{
|
||||
inst->status = strdup(D_("Paused"));
|
||||
edje_object_part_text_set(mpdule, "mpdule.status",
|
||||
D_("Paused"));
|
||||
inst->status);
|
||||
edje_object_part_text_set(o_popup, "mpdule.status",
|
||||
D_("Paused"));
|
||||
inst->status);
|
||||
}
|
||||
|
||||
if (status->state > MPD_STATUS_STATE_STOP)
|
||||
|
@ -504,134 +539,33 @@ _mpdule_update_song(Instance *inst)
|
|||
{
|
||||
mpd_Song *song = entity->info.song;
|
||||
|
||||
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);
|
||||
//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",
|
||||
"");
|
||||
}
|
||||
#define FILL_IN(_var) \
|
||||
if (song->_var) \
|
||||
{ \
|
||||
inst->_var = strdup(song->_var); \
|
||||
edje_object_part_text_set(mpdule, "mpdule."#_var, \
|
||||
song->_var); \
|
||||
edje_object_part_text_set(o_popup, "mpdule."#_var, \
|
||||
song->_var); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
edje_object_part_text_set(mpdule, "mpdule."#_var, \
|
||||
""); \
|
||||
edje_object_part_text_set(o_popup, "mpdule."#_var, \
|
||||
""); \
|
||||
}
|
||||
|
||||
FILL_IN(artist);
|
||||
FILL_IN(title);
|
||||
FILL_IN(album);
|
||||
FILL_IN(track);
|
||||
FILL_IN(date);
|
||||
FILL_IN(genre);
|
||||
FILL_IN(composer);
|
||||
//FILL_IN(time);
|
||||
FILL_IN(file);
|
||||
#undef FILL_IN
|
||||
}
|
||||
|
||||
mpd_freeInfoEntity(entity);
|
||||
|
@ -743,52 +677,47 @@ _mpdule_popup_destroy(Instance *inst)
|
|||
{
|
||||
if (inst->popup)
|
||||
{
|
||||
e_object_del(E_OBJECT(inst->popup));
|
||||
E_Gadcon_Popup *popup = inst->popup;
|
||||
|
||||
inst->popup = NULL;
|
||||
}
|
||||
if (inst->o_popup)
|
||||
{
|
||||
evas_object_del(inst->o_popup);
|
||||
inst->o_popup = NULL;
|
||||
e_object_del(E_OBJECT(popup));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_mpdule_popup_create(Instance *inst, const char *dir)
|
||||
_mpdule_popup_create(Instance *inst)
|
||||
{
|
||||
_mpdule_popup_destroy(inst);
|
||||
if (inst->popup)
|
||||
return;
|
||||
|
||||
if (inst->ci->show_popup)
|
||||
{
|
||||
Evas *evas;
|
||||
Evas_Object *o_popup;
|
||||
|
||||
if (inst->popup_creation_in_progress)
|
||||
return;
|
||||
inst->popup_creation_in_progress = EINA_TRUE;
|
||||
|
||||
inst->popup = e_gadcon_popup_new(inst->gcc);
|
||||
evas = inst->popup->win->evas;
|
||||
ERR("evas:%p", evas);
|
||||
o_popup = edje_object_add(evas);
|
||||
if (!e_theme_edje_object_set
|
||||
(o_popup, "base/theme/modules/mpdule", "modules/mpdule/popup"))
|
||||
{
|
||||
if (dir)
|
||||
{
|
||||
edje_object_file_set(o_popup, dir, "modules/mpdule/popup");
|
||||
}
|
||||
else
|
||||
{
|
||||
char buf[4096];
|
||||
char buf[4096];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/mpdule.edj",
|
||||
e_module_dir_get(mpdule_config->module));
|
||||
edje_object_file_set(o_popup, buf, "modules/mpdule/popup");
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "%s/mpdule.edj",
|
||||
e_module_dir_get(mpdule_config->module));
|
||||
edje_object_file_set(o_popup, buf, "modules/mpdule/popup");
|
||||
}
|
||||
edje_object_part_text_set(o_popup, "mpdule.artist_label", D_("Artist:"));
|
||||
edje_object_part_text_set(o_popup, "mpdule.title_label", D_("Title:"));
|
||||
edje_object_part_text_set(o_popup, "mpdule.album_label", D_("Album:"));
|
||||
edje_object_part_text_set(o_popup, "mpdule.genre_label", D_("Genre:"));
|
||||
evas_object_show(o_popup);
|
||||
e_gadcon_popup_content_set(inst->popup, o_popup);
|
||||
e_gadcon_popup_show(inst->popup);
|
||||
edje_object_size_min_calc(o_popup, NULL, NULL);
|
||||
inst->o_popup = o_popup;
|
||||
edje_object_signal_callback_add(o_popup, "mpdule,play", "",
|
||||
|
@ -801,5 +730,24 @@ _mpdule_popup_create(Instance *inst, const char *dir)
|
|||
_mpdule_cb_next, inst);
|
||||
edje_object_signal_callback_add(o_popup, "mpdule,previous", "",
|
||||
_mpdule_cb_previous, inst);
|
||||
|
||||
#define DISPLAY_INFO(_var) \
|
||||
if (inst->_var) \
|
||||
{ \
|
||||
edje_object_part_text_set(o_popup, "mpdule."#_var, \
|
||||
inst->_var); \
|
||||
}
|
||||
DISPLAY_INFO(artist);
|
||||
DISPLAY_INFO(title);
|
||||
DISPLAY_INFO(album);
|
||||
DISPLAY_INFO(track);
|
||||
DISPLAY_INFO(date);
|
||||
DISPLAY_INFO(genre);
|
||||
DISPLAY_INFO(composer);
|
||||
//DISPLAY_INFO(time);
|
||||
DISPLAY_INFO(file);
|
||||
#undef DISPLAY_INFO
|
||||
|
||||
inst->popup_creation_in_progress = EINA_FALSE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue