Make the popup optional, small theme fix.

SVN revision: 42167
This commit is contained in:
Jaime Thomas 2009-09-01 18:23:05 +00:00
parent 073de78837
commit 46851ab31f
4 changed files with 116 additions and 29 deletions

View File

@ -475,6 +475,28 @@ collections
}
}
}
part
{
name:"event_grab";
type:RECT;
repeat_events:1;
description
{
state:"default" 0.00;
visible:1;
color:0 0 0 0;
rel1
{
relative:0.00 0.00;
offset:0 0;
}
rel2
{
relative:1.00 1.00;
offset:-1 -1;
}
}
}
}
programs
{
@ -482,7 +504,7 @@ collections
{
name:"show_controls";
signal:"mouse,in";
source:"item_clip";
source:"event_grab";
action:STATE_SET "show" 0.0;
transition:LINEAR 0.1;
target:"controls_clip";
@ -491,7 +513,7 @@ collections
{
name:"show_controls2";
signal:"mouse,in";
source:"item_clip";
source:"event_grab";
action:STATE_SET "hide" 0.0;
transition:LINEAR 0.1;
target:"item_clip";
@ -509,7 +531,7 @@ collections
{
name:"hide_controls";
signal:"mouse,out";
source:"controls_clip";
source:"event_grab";
action:STATE_SET "default" 0.0;
transition:LINEAR 0.1;
target:"controls_clip";
@ -518,7 +540,7 @@ collections
{
name:"hide_controls2";
signal:"mouse,out";
source:"controls_clip";
source:"event_grab";
action:STATE_SET "default" 0.0;
transition:LINEAR 0.1;
target:"item_clip";

View File

@ -1,3 +1,6 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include <e.h>
#include "e_mod_main.h"
@ -6,6 +9,7 @@ struct _E_Config_Dialog_Data
int poll_time;
char *hostname;
char *port;
int show_popup;
};
/* Protos */
@ -49,6 +53,7 @@ _fill_data (Config_Item * ci, E_Config_Dialog_Data * cfdata)
cfdata->hostname = strdup (ci->hostname);
snprintf (buf, sizeof (buf), "%d", ci->port);
cfdata->port = strdup (buf);
cfdata->show_popup = ci->show_popup;
}
static void *
@ -104,6 +109,9 @@ _basic_create_widgets (E_Config_Dialog * cfd, Evas * evas,
e_widget_frametable_object_append (of, port_entry, 0, 5, 1, 1, 1, 0, 1, 0);
e_widget_list_object_append (o, of, 1, 1, 0.5);
ob = e_widget_check_add(evas, D_("Show Popup:"), &(cfdata->show_popup));
e_widget_frametable_object_append(of, ob, 0, 6, 1, 1, 1, 0, 1, 0);
return o;
}
@ -118,6 +126,7 @@ _basic_apply_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata)
eina_stringshare_del (ci->hostname);
ci->hostname = eina_stringshare_add (cfdata->hostname);
ci->port = atoi (cfdata->port);
ci->show_popup = cfdata->show_popup;
e_config_save_queue ();
_mpdule_config_updated (ci);
return 1;

View File

@ -1,3 +1,6 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include <e.h>
#include "e_mod_main.h"
#if TIME_WITH_SYS_TIME
@ -76,16 +79,16 @@ static void _mpdule_disconnect (Instance * inst);
static void _mpdule_update_song (Instance * inst);
static int _mpdule_update_song_cb (void *data);
static void _mpdule_popup_destroy (Instance * inst);
static void _mpdule_popup_create (Instance * inst, const char *dir);
static E_Gadcon_Client *
_gc_init (E_Gadcon * gc, const char *name, const char *id, const char *style)
{
Evas_Object *o, *o_popup;
Evas_Object *o;
E_Gadcon_Client *gcc;
Evas *evas;
Instance *inst;
char buf[4096];
int w, h;
inst = E_NEW (Instance, 1);
@ -106,17 +109,7 @@ _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);
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;
_mpdule_popup_create(inst, buf);
evas_object_event_callback_add (o, EVAS_CALLBACK_MOUSE_DOWN,
_mpdule_cb_mouse_down, inst);
@ -134,16 +127,6 @@ _gc_init (E_Gadcon * gc, const char *name, const char *id, const char *style)
inst);
edje_object_signal_callback_add (o, "mpdule,previous", "",
_mpdule_cb_previous, inst);
edje_object_signal_callback_add (o_popup, "mpdule,play", "",
_mpdule_cb_play, inst);
edje_object_signal_callback_add (o_popup, "mpdule,stop", "",
_mpdule_cb_stop, inst);
edje_object_signal_callback_add (o_popup, "mpdule,pause", "",
_mpdule_cb_pause, inst);
edje_object_signal_callback_add (o_popup, "mpdule,next", "",
_mpdule_cb_next, inst);
edje_object_signal_callback_add (o_popup, "mpdule,previous", "",
_mpdule_cb_previous, inst);
_mpdule_connect (inst);
_mpdule_update_song (inst);
inst->update_timer = ecore_timer_add (inst->ci->poll_time,
@ -268,7 +251,7 @@ _mpdule_cb_mouse_in (void *data, Evas * e, Evas_Object * obj,
Instance *inst;
E_Gadcon_Popup *popup;
if (!(inst = data))
if ((!(inst = data)) || (!inst->ci->show_popup))
return;
popup = inst->popup;
e_gadcon_popup_show (inst->popup);
@ -281,7 +264,7 @@ _mpdule_cb_mouse_out (void *data, Evas * e, Evas_Object * obj,
Instance *inst;
E_Gadcon_Popup *popup;
if (!(inst = data))
if ((!(inst = data)) || ((!inst->ci->show_popup) && (inst->popup)))
return;
popup = inst->popup;
e_gadcon_popup_hide (inst->popup);
@ -328,6 +311,24 @@ _mpdule_config_updated (Config_Item * ci)
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);
}
}
else
{
if (inst->popup)
{
_mpdule_popup_destroy(inst);
}
if (inst->o_popup)
{
evas_object_del(inst->o_popup);
}
}
break;
}
}
@ -433,6 +434,7 @@ _mpdule_config_item_get (const char *id)
ci->poll_time = 1.0;
ci->hostname = eina_stringshare_add ("localhost");
ci->port = 6600;
ci->show_popup = 1;
mpdule_config->items = eina_list_append (mpdule_config->items, ci);
return ci;
@ -699,6 +701,7 @@ e_modapi_init (E_Module * m)
E_CONFIG_VAL (D, T, poll_time, DOUBLE);
E_CONFIG_VAL (D, T, hostname, STR);
E_CONFIG_VAL (D, T, port, INT);
E_CONFIG_VAL (D, T, show_popup, UCHAR);
conf_edd = E_CONFIG_DD_NEW ("MPDule_Config", Config);
#undef T
@ -719,6 +722,7 @@ e_modapi_init (E_Module * m)
ci->poll_time = 1.0;
ci->hostname = eina_stringshare_add ("localhost");
ci->port = 6600;
ci->show_popup = 1;
mpdule_config->items = eina_list_append (mpdule_config->items, ci);
}
@ -777,3 +781,51 @@ _mpdule_popup_destroy (Instance * inst)
return;
e_object_del (E_OBJECT (inst->popup));
}
static void
_mpdule_popup_create (Instance * inst, const char *dir)
{
Evas *evas;
Evas_Object *o_popup;
char buf[4096];
if (inst->ci->show_popup)
{
inst->popup = e_gadcon_popup_new (inst->gcc);
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"))
{
if (dir)
{
edje_object_file_set (o_popup, dir, "modules/mpdule/popup");
}
else
{
snprintf(buf, sizeof(buf), "%s/mpdule.edj",
e_module_dir_get(mpdule_config->module));
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, NULL, NULL);
inst->o_popup = o_popup;
edje_object_signal_callback_add (o_popup, "mpdule,play", "",
_mpdule_cb_play, inst);
edje_object_signal_callback_add (o_popup, "mpdule,stop", "",
_mpdule_cb_stop, inst);
edje_object_signal_callback_add (o_popup, "mpdule,pause", "",
_mpdule_cb_pause, inst);
edje_object_signal_callback_add (o_popup, "mpdule,next", "",
_mpdule_cb_next, inst);
edje_object_signal_callback_add (o_popup, "mpdule,previous", "",
_mpdule_cb_previous, inst);
}
else
{
inst->popup = NULL;
inst->o_popup = NULL;
}
}

View File

@ -1,3 +1,6 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#define D_(str) dgettext(PACKAGE, str)
#ifndef E_MOD_MAIN_H
@ -24,6 +27,7 @@ struct _Config_Item
double poll_time;
const char *hostname;
int port;
int show_popup;
};
EAPI extern E_Module_Api e_modapi;