Enlightenment CVS committal Author : iamsthitha Project : e_modules Module : mpdule
Dir : e_modules/mpdule Modified Files: e_mod_main.c mpdule.edc Log Message: Now with a Popup! (And a very simple theme for the popup) =================================================================== RCS file: /cvs/e/e_modules/mpdule/e_mod_main.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- e_mod_main.c 10 Dec 2007 05:39:02 -0000 1.2 +++ e_mod_main.c 12 Dec 2007 03:14:10 -0000 1.3 @@ -26,6 +26,8 @@ /* 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 @@ { 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_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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { 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 @@ 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 @@ 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", ""); } } @@ -557,4 +630,24 @@ { 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; } =================================================================== RCS file: /cvs/e/e_modules/mpdule/mpdule.edc,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- mpdule.edc 10 Dec 2007 02:43:23 -0000 1.1 +++ mpdule.edc 12 Dec 2007 03:14:10 -0000 1.2 @@ -1,5 +1,16 @@ fonts { font: "VeraMono.ttf" "VeraMono"; + font: "VeraBd.ttf" "VeraBold"; +} +spectra { +} +color_classes { +} +images { +} +data { +} +styles { } /* Available labels: @@ -14,146 +25,530 @@ mpdule.time mpdule.file */ -collections -{ - group - { - name: "modules/mpdule/main"; - parts - { - part - { - name: "base"; - type: RECT; - mouse_events: 0; - description { - state: "default" 0.0; - color: 255 255 255 255; - rel1 { - relative: 0.0 0.0; - } - rel2 { - relative: 1.0 1.0; - } - } - } - part - { - name: "item_clip"; - type: RECT; - mouse_events: 1; - description { - state: "default" 0.0; - color: 255 255 255 0; - rel1 { - relative: 0.0 0.0; - } - rel2 { - relative: 1.0 1.0; - } - } - } - part - { - name: "mpdule.artist"; - type: TEXT; - effect: OUTLINE_SOFT_SHADOW; - clip_to: "base"; - mouse_events: 1; - description - { - state: "default" 0.0; - visible: 1; - align: 0.5 0.5; - rel1 - { - relative: 0.0 0.0; - offset: 0 4; - } - rel2 - { - relative: 1.0 0.5; - offset: -1 -3; - } - color: 255 255 255 255; - color2: 0 0 0 96; - color3: 0 0 0 32; - text { - text: ""; - font: "VeraMono"; - size: 10; - min: 1 1; - align: 0.5 0.5; - text_class: "mpdule"; - } - } - description - { - state: "hidden" 0.0; - inherit: "default" 0.0; - visible: 0; - } - description - { - state: "visible" 0.0; - inherit: "default" 0.0; - visible: 1; - } - } - part - { - name: "mpdule.title"; - type: TEXT; - clip_to: "base"; - effect: OUTLINE_SOFT_SHADOW; - mouse_events: 1; - description - { - state: "default" 0.0; - visible: 1; - align: 0.5 0.5; - rel1 - { - relative: 0.0 0.5; - offset: 0 4; - } - rel2 - { - relative: 1.0 1.0; - offset: -1 -3; - } - color: 255 255 255 255; - color2: 0 0 0 96; - color3: 0 0 0 32; - text { - text: ""; - font: "VeraMono"; - size: 9; - min: 1 1; - align: 0.5 0.5; - text_class: "mpdule"; - } - } - description - { - state: "hidden" 0.0; - inherit: "default" 0.0; - visible: 0; - } - description - { - state: "visible" 0.0; - inherit: "default" 0.0; - visible: 1; - } - } - } - /* Close Parts */ - programs - { - } - /* Close Programs */ - } - /* Close Group */ +collections { + group { + name: "modules/mpdule/main"; + parts { + part { + name: "base"; + type: RECT; + mouse_events: 0; + description { + state: "default" 0.00; + visible: 1; + rel1 { + relative: 0.00 0.00; + offset: 0 0; + } + rel2 { + relative: 1.00 1.00; + offset: -1 -1; + } + } + } + part { + name: "item_clip"; + type: RECT; + description { + state: "default" 0.00; + visible: 1; + rel1 { + relative: 0.00 0.00; + offset: 0 0; + } + rel2 { + relative: 1.00 1.00; + offset: -1 -1; + } + color: 255 255 255 0; + } + } + part { + name: "mpdule.artist"; + type: TEXT; + effect: OUTLINE_SOFT_SHADOW; + clip_to: "base"; + description { + state: "default" 0.00; + visible: 1; + rel1 { + relative: 0.00 0.00; + offset: 0 4; + } + rel2 { + relative: 1.00 0.50; + offset: -1 -3; + } + color2: 0 0 0 96; + color3: 0 0 0 32; + text { + text: ""; + text_class: "mpdule"; + font: "VeraMono"; + size: 10; + min: 1 1; + align: 0.50 0.50; + } + } + description { + state: "hidden" 0.00; + visible: 0; + rel1 { + relative: 0.00 0.00; + offset: 0 4; + } + rel2 { + relative: 1.00 0.50; + offset: -1 -3; + } + color2: 0 0 0 96; + color3: 0 0 0 32; + text { + text: ""; + text_class: "mpdule"; + font: "VeraMono"; + size: 10; + min: 1 1; + align: 0.50 0.50; + } + } + description { + state: "visible" 0.00; + visible: 1; + rel1 { + relative: 0.00 0.00; + offset: 0 4; + } + rel2 { + relative: 1.00 0.50; + offset: -1 -3; + } + color2: 0 0 0 96; + color3: 0 0 0 32; + text { + text: ""; + text_class: "mpdule"; + font: "VeraMono"; + size: 10; + min: 1 1; + align: 0.50 0.50; + } + } + } + part { + name: "mpdule.title"; + type: TEXT; + effect: OUTLINE_SOFT_SHADOW; + clip_to: "base"; + description { + state: "default" 0.00; + visible: 1; + rel1 { + relative: 0.00 0.50; + offset: 0 4; + } + rel2 { + relative: 1.00 1.00; + offset: -1 -3; + } + color2: 0 0 0 96; + color3: 0 0 0 32; + text { + text: ""; + text_class: "mpdule"; + font: "VeraMono"; + size: 9; + min: 1 1; + align: 0.50 0.50; + } + } + description { + state: "hidden" 0.00; + visible: 0; + rel1 { + relative: 0.00 0.50; + offset: 0 4; + } + rel2 { + relative: 1.00 1.00; + offset: -1 -3; + } + color2: 0 0 0 96; + color3: 0 0 0 32; + text { + text: ""; + text_class: "mpdule"; + font: "VeraMono"; + size: 9; + min: 1 1; + align: 0.50 0.50; + } + } + description { + state: "visible" 0.00; + visible: 1; + rel1 { + relative: 0.00 0.50; + offset: 0 4; + } + rel2 { + relative: 1.00 1.00; + offset: -1 -3; + } + color2: 0 0 0 96; + color3: 0 0 0 32; + text { + text: ""; + text_class: "mpdule"; + font: "VeraMono"; + size: 9; + min: 1 1; + align: 0.50 0.50; + } + } + } + } + programs { + } + } + group { + name: "modules/mpdule/popup"; + parts { + part { + name: "base"; + type: RECT; + mouse_events: 0; + description { + state: "default" 0.00; + visible: 1; + min: 200 65; + rel1 { + relative: 0.00 0.00; + offset: 5 5; + } + rel2 { + relative: 1.00 1.00; + offset: -5 -5; + } + } + } + part { + name: "labels"; + type: RECT; + mouse_events: 0; + description { + state: "default" 0.00; + visible: 1; + rel1 { + relative: 0.00 0.00; + offset: 0 0; + to: "base"; + } + rel2 { + relative: 0.25 1.00; + offset: 0 0; + to: "base"; + } + color: 255 255 255 0; + } + } + part { + name: "values"; + type: RECT; + mouse_events: 0; + description { + state: "default" 0.00; + visible: 1; + rel1 { + relative: 0.25 0.00; + offset: 0 0; + to: "base"; + } + rel2 { + relative: 1.00 1.00; + offset: 0 0; + to: "base"; + } + color: 255 255 255 0; + } + } + part { + name: "item_clip"; + type: RECT; + description { + state: "default" 0.00; + visible: 1; + min: 5 5; + rel1 { + relative: 0.00 0.00; + offset: 0 0; + } + rel2 { + relative: 1.00 1.00; + offset: -1 -1; + } + color: 255 255 255 0; + } + } + part { + name: "mpdule.artist_label"; + type: TEXT; + effect: SHADOW; + clip_to: "base"; + description { + state: "default" 0.00; + visible: 1; + align: 0.00 0.50; + fixed: 1 1; + rel1 { + relative: -0.00 0.00; + offset: 0 0; + to: "labels"; + } + rel2 { + relative: 1.00 0.00; + offset: 0 16; + to: "labels"; + } + color: 0 0 0 255; + color3: 255 255 255 128; + text { + text: "Artist:"; + text_class: "mpdule"; + font: "VeraMono"; + size: 10; + min: 1 1; + align: 1.0 0.50; + } + } + } + part { + name: "mpdule.title_label"; + type: TEXT; + effect: SHADOW; + clip_to: "base"; + description { + state: "default" 0.00; + visible: 1; + align: 0.00 0.50; + rel1 { + relative: 0.00 1.00; + offset: 0 0; + to_x: "labels"; + to_y: "mpdule.artist_label"; + } + rel2 { + relative: 1.00 1.00; + offset: 0 12; + to_x: "labels"; + to_y: "mpdule.artist_label"; + } + color: 0 0 0 255; + color3: 255 255 255 128; + text { + text: "Title:"; + text_class: "mpdule"; + font: "VeraMono"; + size: 10; + min: 1 1; + align: 1.0 0.50; + } + } + } + part { + name: "mpdule.album_label"; + type: TEXT; + mouse_events: 0; + effect: SHADOW; + clip_to: "base"; + description { + state: "default" 0.00; + visible: 1; + align: 0.00 0.50; + rel1 { + relative: 0.00 1.00; + offset: 0 0; + to_x: "labels"; + to_y: "mpdule.title_label"; + } + rel2 { + relative: 1.00 1.00; + offset: 0 12; + to_x: "labels"; + to_y: "mpdule.title_label"; + } + color: 0 0 0 255; + color3: 255 255 255 128; + text { + text: "Album:"; + text_class: "mpdule"; + font: "VeraMono"; + size: 10; + min: 1 1; + align: 1.0 0.50; + } + } + } + part { + name: "mpdule.genre_label"; + type: TEXT; + mouse_events: 0; + effect: SHADOW; + clip_to: "base"; + description { + state: "default" 0.00; + visible: 1; + align: 0.00 0.50; + rel1 { + relative: 0.00 1.00; + offset: 0 0; + to_x: "labels"; + to_y: "mpdule.album_label"; + } + rel2 { + relative: 1.00 1.00; + offset: 0 12; + to_x: "labels"; + to_y: "mpdule.album_label"; + } + color: 0 0 0 255; + color3: 255 255 255 128; + text { + text: "Genre:"; + text_class: "mpdule"; + font: "VeraMono"; + size: 10; + min: 1 1; + align: 1.0 0.50; + } + } + } + part { + name: "mpdule.artist"; + type: TEXT; + effect: NONE; + clip_to: "base"; + description { + state: "default" 0.00; + visible: 1; + align: 0.00 0.50; + rel1 { + relative: 0.00 0.00; + offset: 0 0; + to_x: "values"; + to_y: "mpdule.artist_label"; + } + rel2 { + relative: 1.00 1.00; + to_x: "values"; + to_y: "mpdule.artist_label"; + } + color: 0 0 0 255; + text { + text: ""; + text_class: "mpdule"; + font: "VeraBold"; + size: 10; + min: 1 1; + align: 0.0 0.50; + } + } + } + part { + name: "mpdule.title"; + type: TEXT; + effect: NONE; + clip_to: "base"; + description { + state: "default" 0.00; + visible: 1; + align: 0.00 0.50; + rel1 { + relative: 0.00 0.00; + offset: 0 0; + to_x: "values"; + to_y: "mpdule.title_label"; + } + rel2 { + relative: 1.00 1.00; + to_x: "values"; + to_y: "mpdule.title_label"; + } + color: 0 0 0 255; + text { + text: ""; + text_class: "mpdule"; + font: "VeraBold"; + size: 10; + min: 1 1; + align: 0.0 0.50; + } + } + } + part { + name: "mpdule.album"; + type: TEXT; + effect: NONE; + clip_to: "base"; + description { + state: "default" 0.00; + visible: 1; + align: 0.00 0.50; + rel1 { + relative: 0.00 0.00; + offset: 0 0; + to_x: "values"; + to_y: "mpdule.album_label"; + } + rel2 { + relative: 1.00 1.00; + to_x: "values"; + to_y: "mpdule.album_label"; + } + color: 0 0 0 255; + text { + text: ""; + text_class: "mpdule"; + font: "VeraBold"; + size: 10; + min: 1 1; + align: 0.0 0.50; + } + } + } + part { + name: "mpdule.genre"; + type: TEXT; + effect: NONE; + clip_to: "base"; + description { + state: "default" 0.00; + visible: 1; + align: 0.00 0.50; + rel1 { + relative: 0.00 0.00; + offset: 0 0; + to_x: "values"; + to_y: "mpdule.genre_label"; + } + rel2 { + relative: 1.00 1.00; + to_x: "values"; + to_y: "mpdule.genre_label"; + } + color: 0 0 0 255; + text { + text: ""; + text_class: "mpdule"; + font: "VeraBold"; + size: 10; + min: 1 1; + align: 0.0 0.50; + } + } + } + } + programs { + } + } } -/* Close Coll */ ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs