forked from enlightenment/enlightenment
179 lines
4.1 KiB
C
179 lines
4.1 KiB
C
#include "e.h"
|
|
#include "e_mod_main.h"
|
|
|
|
/* gadcon requirements */
|
|
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
|
|
static void _gc_shutdown(E_Gadcon_Client *gcc);
|
|
static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
|
|
static char *_gc_label(E_Gadcon_Client_Class *client_class);
|
|
static Evas_Object *_gc_icon(E_Gadcon_Client_Class *client_class, Evas *evas);
|
|
static const char *_gc_id_new(E_Gadcon_Client_Class *client_class);
|
|
|
|
/* and actually define the gadcon class that this module provides (just 1) */
|
|
static const E_Gadcon_Client_Class _gadcon_class =
|
|
{
|
|
GADCON_CLIENT_CLASS_VERSION,
|
|
"clock",
|
|
{
|
|
_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL, NULL
|
|
},
|
|
E_GADCON_CLIENT_STYLE_PLAIN
|
|
};
|
|
|
|
/* actual module specifics */
|
|
typedef struct _Instance Instance;
|
|
|
|
struct _Instance
|
|
{
|
|
E_Gadcon_Client *gcc;
|
|
Evas_Object *o_clock, *o_cal;
|
|
E_Gadcon_Popup *popup;
|
|
};
|
|
|
|
static E_Module *clock_module = NULL;
|
|
|
|
static void
|
|
_clock_popup_new(Instance *inst)
|
|
{
|
|
Evas *evas;
|
|
|
|
if (inst->popup) return;
|
|
inst->popup = e_gadcon_popup_new(inst->gcc);
|
|
evas = inst->popup->win->evas;
|
|
inst->o_cal = e_widget_table_add(evas, 0);
|
|
e_widget_size_min_set(inst->o_cal, 100, 100);
|
|
e_gadcon_popup_content_set(inst->popup, inst->o_cal);
|
|
e_gadcon_popup_show(inst->popup);
|
|
}
|
|
|
|
static void
|
|
_clock_popup_free(Instance *inst)
|
|
{
|
|
if (!inst->popup) return;
|
|
if (inst->popup) e_object_del(E_OBJECT(inst->popup));
|
|
inst->popup = NULL;
|
|
}
|
|
|
|
static void
|
|
_clock_cb_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
|
|
{
|
|
Instance *inst = data;
|
|
Evas_Event_Mouse_Down *ev = event;
|
|
|
|
if (ev->button != 1) return;
|
|
if (inst->popup) _clock_popup_free(inst);
|
|
else _clock_popup_new(inst);
|
|
}
|
|
|
|
static E_Gadcon_Client *
|
|
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
|
{
|
|
Evas_Object *o;
|
|
E_Gadcon_Client *gcc;
|
|
Instance *inst;
|
|
|
|
inst = E_NEW(Instance, 1);
|
|
|
|
o = edje_object_add(gc->evas);
|
|
e_theme_edje_object_set(o, "base/theme/modules/clock",
|
|
"e/modules/clock/main");
|
|
evas_object_show(o);
|
|
|
|
gcc = e_gadcon_client_new(gc, name, id, style, o);
|
|
gcc->data = inst;
|
|
|
|
inst->gcc = gcc;
|
|
inst->o_clock = o;
|
|
|
|
evas_object_event_callback_add(inst->o_clock,
|
|
EVAS_CALLBACK_MOUSE_DOWN,
|
|
_clock_cb_mouse_down,
|
|
inst);
|
|
|
|
e_gadcon_client_util_menu_attach(gcc);
|
|
|
|
return gcc;
|
|
}
|
|
|
|
static void
|
|
_gc_shutdown(E_Gadcon_Client *gcc)
|
|
{
|
|
Instance *inst;
|
|
|
|
inst = gcc->data;
|
|
evas_object_del(inst->o_clock);
|
|
_clock_popup_free(inst);
|
|
free(inst);
|
|
}
|
|
|
|
static void
|
|
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient __UNUSED__)
|
|
{
|
|
Instance *inst;
|
|
Evas_Coord mw, mh;
|
|
|
|
inst = gcc->data;
|
|
mw = 0, mh = 0;
|
|
edje_object_size_min_get(inst->o_clock, &mw, &mh);
|
|
if ((mw < 1) || (mh < 1))
|
|
edje_object_size_min_calc(inst->o_clock, &mw, &mh);
|
|
if (mw < 4) mw = 4;
|
|
if (mh < 4) mh = 4;
|
|
e_gadcon_client_aspect_set(gcc, mw, mh);
|
|
e_gadcon_client_min_size_set(gcc, mw, mh);
|
|
}
|
|
|
|
static char *
|
|
_gc_label(E_Gadcon_Client_Class *client_class __UNUSED__)
|
|
{
|
|
return _("Clock");
|
|
}
|
|
|
|
static Evas_Object *
|
|
_gc_icon(E_Gadcon_Client_Class *client_class __UNUSED__, Evas *evas)
|
|
{
|
|
Evas_Object *o;
|
|
char buf[4096];
|
|
|
|
o = edje_object_add(evas);
|
|
snprintf(buf, sizeof(buf), "%s/e-module-clock.edj",
|
|
e_module_dir_get(clock_module));
|
|
edje_object_file_set(o, buf, "icon");
|
|
return o;
|
|
}
|
|
|
|
static const char *
|
|
_gc_id_new(E_Gadcon_Client_Class *client_class __UNUSED__)
|
|
{
|
|
return _gadcon_class.name;
|
|
}
|
|
|
|
/* module setup */
|
|
EAPI E_Module_Api e_modapi =
|
|
{
|
|
E_MODULE_API_VERSION,
|
|
"Clock"
|
|
};
|
|
|
|
EAPI void *
|
|
e_modapi_init(E_Module *m)
|
|
{
|
|
clock_module = m;
|
|
e_gadcon_provider_register(&_gadcon_class);
|
|
return m;
|
|
}
|
|
|
|
EAPI int
|
|
e_modapi_shutdown(E_Module *m __UNUSED__)
|
|
{
|
|
clock_module = NULL;
|
|
e_gadcon_provider_unregister(&_gadcon_class);
|
|
return 1;
|
|
}
|
|
|
|
EAPI int
|
|
e_modapi_save(E_Module *m __UNUSED__)
|
|
{
|
|
return 1;
|
|
}
|