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",
|
"wl_shell",
|
||||||
"xkbswitch",
|
"xkbswitch",
|
||||||
"echievements",
|
"echievements",
|
||||||
|
"music-control",
|
||||||
NULL // end marker
|
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_CFLAGS = $(AM_CFLAGS) -Wno-unused-parameter
|
||||||
music_control_module_la_LIBADD = @MUSIC_CONTROL_LIBS@
|
music_control_module_la_LIBADD = @MUSIC_CONTROL_LIBS@
|
||||||
music_control_module_la_SOURCES = music-control/e_mod_main.h \
|
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 {
|
images {
|
||||||
image: "images/icon.png" COMP;
|
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 {
|
collections {
|
||||||
|
@ -22,54 +26,96 @@ collections {
|
||||||
}
|
}
|
||||||
group {
|
group {
|
||||||
name: "modules/music-control/main";
|
name: "modules/music-control/main";
|
||||||
min: 16 16;
|
|
||||||
max: 128 128;
|
|
||||||
parts {
|
parts {
|
||||||
part {
|
part {
|
||||||
name: "icon";
|
name: "icon";
|
||||||
mouse_events: 0;
|
|
||||||
type: IMAGE;
|
type: IMAGE;
|
||||||
description {
|
description {
|
||||||
state: "default" 0.0;
|
state: "default" 0.0;
|
||||||
aspect: 1.0 1.0;
|
aspect: 1.0 1.0;
|
||||||
aspect_preference: BOTH;
|
aspect_preference: BOTH;
|
||||||
rel1.offset: 2 2;
|
rel1.relative: 0 0;
|
||||||
rel2.offset: -3 -3;
|
rel2.relative: 1 1;
|
||||||
image.normal: "images/icon.png";
|
image.normal: "images/icon.png";
|
||||||
}
|
}
|
||||||
description {
|
}
|
||||||
state: "bigger" 0.0;
|
}
|
||||||
inherit: "default" 0.0;
|
}
|
||||||
rel1.offset: -2 -2;
|
group {
|
||||||
rel2.offset: 3 3;
|
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 {
|
part {
|
||||||
name: "event";
|
type: IMAGE;
|
||||||
mouse_events: 1;
|
name: "play_btn";
|
||||||
type: RECT;
|
description {
|
||||||
description {
|
state: "default" 0;
|
||||||
state: "default" 0.0;
|
aspect: 1.0 1.0;
|
||||||
color: 255 255 255 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 {
|
programs {
|
||||||
program {
|
program {
|
||||||
name: "mouse_in";
|
signal: "mouse,clicked,*";
|
||||||
signal: "mouse,in";
|
source: "previous_btn";
|
||||||
source: "event";
|
action: SIGNAL_EMIT "btn,clicked" "previous";
|
||||||
action: STATE_SET "bigger" 0.0;
|
|
||||||
transition: LINEAR 0.1;
|
|
||||||
target: "icon";
|
|
||||||
}
|
}
|
||||||
program {
|
program {
|
||||||
name: "mouse_out";
|
signal: "mouse,clicked,*";
|
||||||
signal: "mouse,out";
|
source: "play_btn";
|
||||||
source: "event";
|
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;
|
action: STATE_SET "default" 0.0;
|
||||||
transition: LINEAR 0.2;
|
transition: LINEAR 0.1;
|
||||||
target: "icon";
|
target: "play_btn";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -1,5 +1,4 @@
|
||||||
#include "e.h"
|
#include "private.h"
|
||||||
#include "e_mod_main.h"
|
|
||||||
|
|
||||||
static E_Module *music_control_mod = NULL;
|
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 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);
|
const char *
|
||||||
}
|
music_control_edj_path_get(void)
|
||||||
|
|
||||||
static const char *
|
|
||||||
_edj_path_get(void)
|
|
||||||
{
|
{
|
||||||
#define TF "/e-module-music-control.edj"
|
#define TF "/e-module-music-control.edj"
|
||||||
size_t dirlen;
|
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 = calloc(1, sizeof(E_Music_Control_Instance));
|
||||||
inst->ctxt = ctxt;
|
inst->ctxt = ctxt;
|
||||||
inst->gadget = edje_object_add(gc->evas);
|
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");
|
"modules/music-control/main");
|
||||||
/*e_theme_edje_object_set(inst->gadget, "base/theme/modules/music-control",
|
/*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 = e_gadcon_client_new(gc, name, id, style, inst->gadget);
|
||||||
inst->gcc->data = inst;
|
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;
|
return inst->gcc;
|
||||||
}
|
}
|
||||||
|
@ -72,6 +65,7 @@ _gc_shutdown(E_Gadcon_Client *gcc)
|
||||||
inst = gcc->data;
|
inst = gcc->data;
|
||||||
|
|
||||||
evas_object_del(inst->gadget);
|
evas_object_del(inst->gadget);
|
||||||
|
if (inst->popup) music_control_popup_del(inst);
|
||||||
ctxt->instances = eina_list_remove(ctxt->instances, inst);
|
ctxt->instances = eina_list_remove(ctxt->instances, inst);
|
||||||
|
|
||||||
free(inst);
|
free(inst);
|
||||||
|
@ -94,7 +88,7 @@ static Evas_Object *
|
||||||
_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas)
|
_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas)
|
||||||
{
|
{
|
||||||
Evas_Object *o = edje_object_add(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;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,20 +3,6 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <e.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 extern E_Module_Api e_modapi;
|
||||||
EAPI void *e_modapi_init(E_Module *m);
|
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