forked from enlightenment/enlightenment
e/music-control: Add gadget GUI
Patch by: José Roberto de Souza <zehortigoza@profusion.mobi> SVN revision: 81989
This commit is contained in:
parent
996fdc6351
commit
53f67fa86b
|
@ -705,7 +705,7 @@ _e_module_whitelist_check(void)
|
|||
"wl_shell",
|
||||
"xkbswitch",
|
||||
"echievements",
|
||||
|
||||
"music-control",
|
||||
NULL // end marker
|
||||
};
|
||||
|
||||
|
|
|
@ -11,4 +11,6 @@ music_control_module_la_DEPENDENCIES = $(MDEPENDENCIES)
|
|||
music_control_module_la_CFLAGS = $(AM_CFLAGS) -Wno-unused-parameter
|
||||
music_control_module_la_LIBADD = @MUSIC_CONTROL_LIBS@
|
||||
music_control_module_la_SOURCES = music-control/e_mod_main.h \
|
||||
music-control/e_mod_main.c
|
||||
music-control/e_mod_main.c \
|
||||
music-control/private.h \
|
||||
music-control/ui.c
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
images {
|
||||
image: "images/icon.png" COMP;
|
||||
image: "images/previous.png" COMP;
|
||||
image: "images/next.png" COMP;
|
||||
image: "images/pause.png" COMP;
|
||||
image: "images/play.png" COMP;
|
||||
}
|
||||
|
||||
collections {
|
||||
|
@ -22,54 +26,96 @@ collections {
|
|||
}
|
||||
group {
|
||||
name: "modules/music-control/main";
|
||||
min: 16 16;
|
||||
max: 128 128;
|
||||
parts {
|
||||
part {
|
||||
name: "icon";
|
||||
mouse_events: 0;
|
||||
type: IMAGE;
|
||||
description {
|
||||
state: "default" 0.0;
|
||||
aspect: 1.0 1.0;
|
||||
aspect_preference: BOTH;
|
||||
rel1.offset: 2 2;
|
||||
rel2.offset: -3 -3;
|
||||
rel1.relative: 0 0;
|
||||
rel2.relative: 1 1;
|
||||
image.normal: "images/icon.png";
|
||||
}
|
||||
description {
|
||||
state: "bigger" 0.0;
|
||||
inherit: "default" 0.0;
|
||||
rel1.offset: -2 -2;
|
||||
rel2.offset: 3 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
group {
|
||||
name: "modules/music-control/popup";
|
||||
min: 150 30;
|
||||
parts {
|
||||
part {
|
||||
type: IMAGE;
|
||||
name: "previous_btn";
|
||||
description {
|
||||
state: "default" 0;
|
||||
aspect: 1.0 1.0;
|
||||
aspect_preference: BOTH;
|
||||
rel1.relative: 0.0 0.0;
|
||||
rel2.relative: 0.33 1.0;
|
||||
image.normal: "images/previous.png";
|
||||
}
|
||||
}
|
||||
part {
|
||||
name: "event";
|
||||
mouse_events: 1;
|
||||
type: RECT;
|
||||
description {
|
||||
state: "default" 0.0;
|
||||
color: 255 255 255 0;
|
||||
}
|
||||
type: IMAGE;
|
||||
name: "play_btn";
|
||||
description {
|
||||
state: "default" 0;
|
||||
aspect: 1.0 1.0;
|
||||
aspect_preference: BOTH;
|
||||
rel1.relative: 0.33 0.0;
|
||||
rel2.relative: 0.66 1.0;
|
||||
image.normal: "images/pause.png";
|
||||
}
|
||||
description {
|
||||
state: "play" 0.0;
|
||||
inherit: "default" 0.0;
|
||||
image.normal: "images/play.png";
|
||||
}
|
||||
}
|
||||
part {
|
||||
type: IMAGE;
|
||||
name: "next_btn";
|
||||
description {
|
||||
state: "default" 0;
|
||||
aspect: 1.0 1.0;
|
||||
aspect_preference: BOTH;
|
||||
rel1.relative: 0.66 0.0;
|
||||
rel2.relative: 1.0 1.0;
|
||||
image.normal: "images/next.png";
|
||||
}
|
||||
}
|
||||
}
|
||||
programs {
|
||||
program {
|
||||
name: "mouse_in";
|
||||
signal: "mouse,in";
|
||||
source: "event";
|
||||
action: STATE_SET "bigger" 0.0;
|
||||
transition: LINEAR 0.1;
|
||||
target: "icon";
|
||||
signal: "mouse,clicked,*";
|
||||
source: "previous_btn";
|
||||
action: SIGNAL_EMIT "btn,clicked" "previous";
|
||||
}
|
||||
program {
|
||||
name: "mouse_out";
|
||||
signal: "mouse,out";
|
||||
source: "event";
|
||||
signal: "mouse,clicked,*";
|
||||
source: "play_btn";
|
||||
action: SIGNAL_EMIT "btn,clicked" "play";
|
||||
}
|
||||
program {
|
||||
signal: "mouse,clicked,*";
|
||||
source: "next_btn";
|
||||
action: SIGNAL_EMIT "btn,clicked" "next";
|
||||
}
|
||||
program {
|
||||
signal: "btn,state,image,play";
|
||||
source: "play";
|
||||
action: STATE_SET "play" 0.0;
|
||||
transition: LINEAR 0.1;
|
||||
target: "play_btn";
|
||||
}
|
||||
program {
|
||||
signal: "btn,state,image,pause";
|
||||
source: "play";
|
||||
action: STATE_SET "default" 0.0;
|
||||
transition: LINEAR 0.2;
|
||||
target: "icon";
|
||||
transition: LINEAR 0.1;
|
||||
target: "play_btn";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -1,5 +1,4 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
#include "private.h"
|
||||
|
||||
static E_Module *music_control_mod = NULL;
|
||||
|
||||
|
@ -7,17 +6,9 @@ static char tmpbuf[4096]; /* general purpose buffer, just use immediately */
|
|||
|
||||
static const char _e_music_control_Name[] = "Music controller";
|
||||
|
||||
static void
|
||||
_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event)
|
||||
{
|
||||
E_Music_Control_Instance *inst = data;
|
||||
Evas_Event_Mouse_Down *ev = event;
|
||||
|
||||
printf("event mouse down button=%d\n", ev->button);
|
||||
}
|
||||
|
||||
static const char *
|
||||
_edj_path_get(void)
|
||||
const char *
|
||||
music_control_edj_path_get(void)
|
||||
{
|
||||
#define TF "/e-module-music-control.edj"
|
||||
size_t dirlen;
|
||||
|
@ -46,16 +37,18 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
|||
inst = calloc(1, sizeof(E_Music_Control_Instance));
|
||||
inst->ctxt = ctxt;
|
||||
inst->gadget = edje_object_add(gc->evas);
|
||||
edje_object_file_set(inst->gadget, _edj_path_get(),
|
||||
edje_object_file_set(inst->gadget, music_control_edj_path_get(),
|
||||
"modules/music-control/main");
|
||||
/*e_theme_edje_object_set(inst->gadget, "base/theme/modules/music-control",
|
||||
"e/modules/music-control/main");*/
|
||||
"e/modules/music-control/main");
|
||||
TODO append theme to data/themes/default.edc*/
|
||||
|
||||
inst->gcc = e_gadcon_client_new(gc, name, id, style, inst->gadget);
|
||||
inst->gcc->data = inst;
|
||||
|
||||
evas_object_event_callback_add(inst->gadget, EVAS_CALLBACK_MOUSE_DOWN, music_control_mouse_down_cb, inst);
|
||||
|
||||
evas_object_event_callback_add(inst->gadget, EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down, inst);
|
||||
ctxt->instances = eina_list_append(ctxt->instances, inst);
|
||||
|
||||
return inst->gcc;
|
||||
}
|
||||
|
@ -72,6 +65,7 @@ _gc_shutdown(E_Gadcon_Client *gcc)
|
|||
inst = gcc->data;
|
||||
|
||||
evas_object_del(inst->gadget);
|
||||
if (inst->popup) music_control_popup_del(inst);
|
||||
ctxt->instances = eina_list_remove(ctxt->instances, inst);
|
||||
|
||||
free(inst);
|
||||
|
@ -94,7 +88,7 @@ static Evas_Object *
|
|||
_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas)
|
||||
{
|
||||
Evas_Object *o = edje_object_add(evas);
|
||||
edje_object_file_set(o, _edj_path_get(), "icon");
|
||||
edje_object_file_set(o, music_control_edj_path_get(), "icon");
|
||||
return o;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,20 +3,6 @@
|
|||
|
||||
#include "config.h"
|
||||
#include <e.h>
|
||||
#include <eina_log.h>
|
||||
|
||||
typedef struct _E_Music_Control_Module_Context
|
||||
{
|
||||
Eina_List *instances;
|
||||
EDBus_Connection *conn;
|
||||
} E_Music_Control_Module_Context;
|
||||
|
||||
typedef struct _E_Music_Control_Instance
|
||||
{
|
||||
E_Music_Control_Module_Context *ctxt;
|
||||
E_Gadcon_Client *gcc;
|
||||
Evas_Object *gadget;
|
||||
} E_Music_Control_Instance;
|
||||
|
||||
EAPI extern E_Module_Api e_modapi;
|
||||
EAPI void *e_modapi_init(E_Module *m);
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 638 B |
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -0,0 +1,27 @@
|
|||
#ifndef MUSIC_CONTROL_PRIVATE_H
|
||||
#define MUSIC_CONTROL_PRIVATE_H
|
||||
|
||||
#include "e_mod_main.h"
|
||||
|
||||
typedef struct _E_Music_Control_Module_Context
|
||||
{
|
||||
Eina_List *instances;
|
||||
EDBus_Connection *conn;
|
||||
Eina_Bool playning:1;
|
||||
} E_Music_Control_Module_Context;
|
||||
|
||||
typedef struct _E_Music_Control_Instance
|
||||
{
|
||||
E_Music_Control_Module_Context *ctxt;
|
||||
E_Gadcon_Client *gcc;
|
||||
Evas_Object *gadget;
|
||||
E_Gadcon_Popup *popup;
|
||||
Evas_Object *content_popup;
|
||||
} E_Music_Control_Instance;
|
||||
|
||||
void music_control_mouse_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
|
||||
const char *music_control_edj_path_get(void);
|
||||
void music_control_popup_del(E_Music_Control_Instance *inst);
|
||||
void music_control_state_update_all(E_Music_Control_Module_Context *ctxt);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,73 @@
|
|||
#include "private.h"
|
||||
|
||||
static void
|
||||
_play_state_update(E_Music_Control_Instance *inst)
|
||||
{
|
||||
if (!inst->popup) return;
|
||||
if (inst->ctxt->playning)
|
||||
edje_object_signal_emit(inst->content_popup, "btn,state,image,pause", "play");
|
||||
else
|
||||
edje_object_signal_emit(inst->content_popup, "btn,state,image,play", "play");
|
||||
}
|
||||
|
||||
void
|
||||
music_control_state_update_all(E_Music_Control_Module_Context *ctxt)
|
||||
{
|
||||
E_Music_Control_Instance *inst;
|
||||
Eina_List *list;
|
||||
|
||||
EINA_LIST_FOREACH(ctxt->instances, list, inst)
|
||||
_play_state_update(inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_btn_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
{
|
||||
E_Music_Control_Instance *inst = data;
|
||||
|
||||
if (!strcmp(source, "play"))
|
||||
{
|
||||
inst->ctxt->playning = !inst->ctxt->playning;
|
||||
music_control_state_update_all(inst->ctxt);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_popup_new(E_Music_Control_Instance *inst)
|
||||
{
|
||||
Evas_Object *o;
|
||||
inst->popup = e_gadcon_popup_new(inst->gcc);
|
||||
|
||||
o = edje_object_add(inst->popup->win->evas);
|
||||
edje_object_file_set(o, music_control_edj_path_get(),
|
||||
"modules/music-control/popup");
|
||||
edje_object_signal_callback_add(o, "btn,clicked", "*", _btn_clicked, inst);
|
||||
|
||||
e_gadcon_popup_content_set(inst->popup, o);
|
||||
e_gadcon_popup_show(inst->popup);
|
||||
inst->content_popup = o;
|
||||
_play_state_update(inst);
|
||||
}
|
||||
|
||||
void
|
||||
music_control_popup_del(E_Music_Control_Instance *inst)
|
||||
{
|
||||
e_gadcon_popup_hide(inst->popup);
|
||||
e_object_del(E_OBJECT(inst->popup));
|
||||
inst->popup = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
music_control_mouse_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event)
|
||||
{
|
||||
E_Music_Control_Instance *inst = data;
|
||||
Evas_Event_Mouse_Down *ev = event;
|
||||
|
||||
if (ev->button == 1)
|
||||
{
|
||||
if (!inst->popup)
|
||||
_popup_new(inst);
|
||||
else
|
||||
music_control_popup_del(inst);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue