clock popups
This commit is contained in:
parent
459cf14f08
commit
0a4bb33218
|
@ -72,69 +72,82 @@ static void
|
|||
_clock_settings_cb(void *d1, void *d2 EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = d1;
|
||||
//e_int_config_clock_module(NULL, inst->cfg);
|
||||
e_object_del(E_OBJECT(inst->popup));
|
||||
|
||||
z_gadget_configure(inst->o_clock);
|
||||
elm_ctxpopup_dismiss(inst->popup);
|
||||
inst->popup = NULL;
|
||||
inst->o_popclock = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_popclock_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *info EINA_UNUSED)
|
||||
_clock_popup_dismissed(void *data EINA_UNUSED, Evas_Object *obj, void *info EINA_UNUSED)
|
||||
{
|
||||
evas_object_del(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_clock_edje_init(Instance *inst, Evas_Object *o)
|
||||
{
|
||||
char todaystr[128];
|
||||
|
||||
time_string_format(inst, todaystr, sizeof(todaystr) - 1);
|
||||
if (inst->cfg->digital_clock)
|
||||
e_theme_edje_object_set(o, "base/theme/modules/clock",
|
||||
"e/modules/clock/digital");
|
||||
else
|
||||
e_theme_edje_object_set(o, "base/theme/modules/clock",
|
||||
"e/modules/clock/main");
|
||||
if (inst->cfg->show_date)
|
||||
elm_layout_signal_emit(o, "e,state,date,on", "e");
|
||||
else
|
||||
elm_layout_signal_emit(o, "e,state,date,off", "e");
|
||||
if (inst->cfg->digital_24h)
|
||||
elm_layout_signal_emit(o, "e,state,24h,on", "e");
|
||||
else
|
||||
elm_layout_signal_emit(o, "e,state,24h,off", "e");
|
||||
if (inst->cfg->show_seconds)
|
||||
elm_layout_signal_emit(o, "e,state,seconds,on", "e");
|
||||
else
|
||||
elm_layout_signal_emit(o, "e,state,seconds,off", "e");
|
||||
|
||||
elm_object_part_text_set(o, "e.text.today", todaystr);
|
||||
edje_object_message_signal_process(elm_layout_edje_get(o));
|
||||
}
|
||||
|
||||
static void
|
||||
_clock_popup_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
if (inst->o_popclock == obj)
|
||||
{
|
||||
inst->o_popclock = NULL;
|
||||
}
|
||||
|
||||
if (obj != inst->popup) return;
|
||||
inst->o_table = inst->o_popclock = inst->o_cal = NULL;
|
||||
}
|
||||
|
||||
EINTERN void
|
||||
clock_popup_new(Instance *inst)
|
||||
{
|
||||
/*
|
||||
Evas *evas;
|
||||
Evas_Object *o, *oi;
|
||||
char todaystr[128];
|
||||
|
||||
if (inst->popup) return;
|
||||
|
||||
time_string_format(inst, todaystr, sizeof(todaystr) - 1);
|
||||
|
||||
inst->madj = 0;
|
||||
|
||||
time_instance_update(inst);
|
||||
|
||||
inst->popup = e_gadcon_popup_new(inst->gcc, 0);
|
||||
inst->popup = elm_ctxpopup_add(inst->o_clock);
|
||||
elm_object_style_set(inst->popup, "noblock");
|
||||
evas_object_smart_callback_add(inst->popup, "dismissed", _clock_popup_dismissed, inst);
|
||||
evas_object_event_callback_add(inst->popup, EVAS_CALLBACK_DEL, _clock_popup_del, inst);
|
||||
evas = e_comp->evas;
|
||||
|
||||
inst->o_table = elm_table_add(e_comp->elm);
|
||||
inst->o_table = elm_table_add(inst->popup);
|
||||
|
||||
oi = elm_layout_add(inst->o_table);
|
||||
inst->o_popclock = oi;
|
||||
evas_object_size_hint_weight_set(oi, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(oi, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_event_callback_add(oi, EVAS_CALLBACK_DEL, _popclock_del_cb, inst);
|
||||
E_EXPAND(oi);
|
||||
E_FILL(oi);
|
||||
|
||||
if (inst->cfg->digital_clock)
|
||||
e_theme_edje_object_set(oi, "base/theme/modules/clock",
|
||||
"e/modules/clock/digital");
|
||||
else
|
||||
e_theme_edje_object_set(oi, "base/theme/modules/clock",
|
||||
"e/modules/clock/main");
|
||||
if (inst->cfg->show_date)
|
||||
elm_object_signal_emit(oi, "e,state,date,on", "e");
|
||||
else
|
||||
elm_object_signal_emit(oi, "e,state,date,off", "e");
|
||||
if (inst->cfg->digital_24h)
|
||||
elm_object_signal_emit(oi, "e,state,24h,on", "e");
|
||||
else
|
||||
elm_object_signal_emit(oi, "e,state,24h,off", "e");
|
||||
if (inst->cfg->show_seconds)
|
||||
elm_object_signal_emit(oi, "e,state,seconds,on", "e");
|
||||
else
|
||||
elm_object_signal_emit(oi, "e,state,seconds,off", "e");
|
||||
|
||||
elm_object_part_text_set(oi, "e.text.today", todaystr);
|
||||
_clock_edje_init(inst, oi);
|
||||
|
||||
elm_layout_sizing_eval(oi);
|
||||
elm_table_pack(inst->o_table, oi, 0, 0, 1, 1);
|
||||
|
@ -164,10 +177,36 @@ clock_popup_new(Instance *inst)
|
|||
elm_table_pack(inst->o_table, oi, 0, 1, 1, 1);
|
||||
evas_object_show(oi);
|
||||
|
||||
evas_smart_objects_calculate(evas);
|
||||
e_gadcon_popup_content_set(inst->popup, inst->o_table);
|
||||
e_gadcon_popup_show(inst->popup);
|
||||
*/
|
||||
elm_object_content_set(inst->popup, inst->o_table);
|
||||
elm_ctxpopup_hover_parent_set(inst->popup, e_comp->elm);
|
||||
evas_object_layer_set(inst->popup, evas_object_layer_get(inst->o_clock));
|
||||
{
|
||||
int x, y, w, h;
|
||||
Z_Gadget_Site_Orient orient;
|
||||
Z_Gadget_Site_Anchor an;
|
||||
Evas_Object *site;
|
||||
|
||||
evas_object_geometry_get(inst->o_clock, &x, &y, &w, &h);
|
||||
site = z_gadget_site_get(inst->o_clock);
|
||||
orient = z_gadget_site_orient_get(site);
|
||||
an = z_gadget_site_anchor_get(site);
|
||||
if (an & Z_GADGET_SITE_ANCHOR_TOP)
|
||||
y += h;
|
||||
if (an & Z_GADGET_SITE_ANCHOR_LEFT)
|
||||
x += w;
|
||||
if (orient == Z_GADGET_SITE_ORIENT_HORIZONTAL)
|
||||
{
|
||||
x += w / 2;
|
||||
elm_ctxpopup_direction_priority_set(inst->popup, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_DOWN, 0, 0);
|
||||
}
|
||||
else if (orient == Z_GADGET_SITE_ORIENT_VERTICAL)
|
||||
{
|
||||
y += h / 2;
|
||||
elm_ctxpopup_direction_priority_set(inst->popup, ELM_CTXPOPUP_DIRECTION_RIGHT, ELM_CTXPOPUP_DIRECTION_LEFT, 0, 0);
|
||||
}
|
||||
evas_object_move(inst->popup, x, y);
|
||||
}
|
||||
evas_object_show(inst->popup);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -219,74 +258,19 @@ e_int_clock_instances_redo(Eina_Bool all)
|
|||
{
|
||||
Eina_List *l;
|
||||
Instance *inst;
|
||||
char todaystr[128];
|
||||
|
||||
EINA_LIST_FOREACH(clock_instances, l, inst)
|
||||
{
|
||||
Evas_Object *o = inst->o_clock;
|
||||
|
||||
if ((!all) && (!inst->cfg->changed)) continue;
|
||||
time_string_format(inst, todaystr, sizeof(todaystr) - 1);
|
||||
if (inst->cfg->digital_clock)
|
||||
e_theme_edje_object_set(o, "base/theme/modules/clock",
|
||||
"e/modules/clock/digital");
|
||||
else
|
||||
e_theme_edje_object_set(o, "base/theme/modules/clock",
|
||||
"e/modules/clock/main");
|
||||
if (inst->cfg->show_date)
|
||||
elm_layout_signal_emit(o, "e,state,date,on", "e");
|
||||
else
|
||||
elm_layout_signal_emit(o, "e,state,date,off", "e");
|
||||
if (inst->cfg->digital_24h)
|
||||
elm_layout_signal_emit(o, "e,state,24h,on", "e");
|
||||
else
|
||||
elm_layout_signal_emit(o, "e,state,24h,off", "e");
|
||||
if (inst->cfg->show_seconds)
|
||||
elm_layout_signal_emit(o, "e,state,seconds,on", "e");
|
||||
else
|
||||
elm_layout_signal_emit(o, "e,state,seconds,off", "e");
|
||||
|
||||
elm_object_part_text_set(o, "e.text.today", todaystr);
|
||||
edje_object_message_signal_process(elm_layout_edje_get(o));
|
||||
_clock_edje_init(inst, o);
|
||||
_eval_instance_size(inst);
|
||||
|
||||
if (inst->o_popclock)
|
||||
{
|
||||
o = inst->o_popclock;
|
||||
|
||||
if (inst->cfg->digital_clock)
|
||||
e_theme_edje_object_set(o, "base/theme/modules/clock",
|
||||
"e/modules/clock/digital");
|
||||
else
|
||||
e_theme_edje_object_set(o, "base/theme/modules/clock",
|
||||
"e/modules/clock/main");
|
||||
if (inst->cfg->show_date)
|
||||
edje_object_signal_emit(o, "e,state,date,on", "e");
|
||||
else
|
||||
edje_object_signal_emit(o, "e,state,date,off", "e");
|
||||
if (inst->cfg->digital_24h)
|
||||
edje_object_signal_emit(o, "e,state,24h,on", "e");
|
||||
else
|
||||
edje_object_signal_emit(o, "e,state,24h,off", "e");
|
||||
if (inst->cfg->show_seconds)
|
||||
edje_object_signal_emit(o, "e,state,seconds,on", "e");
|
||||
else
|
||||
edje_object_signal_emit(o, "e,state,seconds,off", "e");
|
||||
|
||||
edje_object_part_text_set(o, "e.text.today", todaystr);
|
||||
edje_object_message_signal_process(o);
|
||||
_clock_edje_init(inst, inst->o_popclock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EINTERN void
|
||||
clock_popup_free(Instance *inst)
|
||||
{
|
||||
if (!inst->popup) return;
|
||||
E_FREE_FUNC(inst->popup, e_object_del);
|
||||
inst->o_popclock = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_clock_menu_cb_cfg(void *data, E_Menu *menu EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
|
||||
|
@ -305,35 +289,12 @@ _clock_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_U
|
|||
|
||||
if (ev->button == 1)
|
||||
{
|
||||
if (inst->popup) clock_popup_free(inst);
|
||||
else clock_popup_new(inst);
|
||||
}
|
||||
else if (ev->button == 3)
|
||||
if (inst->popup)
|
||||
{
|
||||
#warning FIXME
|
||||
#if 0
|
||||
E_Zone *zone;
|
||||
E_Menu *m;
|
||||
E_Menu_Item *mi;
|
||||
int x, y;
|
||||
|
||||
zone = e_zone_current_get();
|
||||
|
||||
m = e_menu_new();
|
||||
|
||||
mi = e_menu_item_new(m);
|
||||
e_menu_item_label_set(mi, _("Settings"));
|
||||
e_util_menu_item_theme_icon_set(mi, "configure");
|
||||
e_menu_item_callback_set(mi, _clock_menu_cb_cfg, inst);
|
||||
|
||||
m = e_gadcon_client_util_menu_items_append(inst->gcc, m, 0);
|
||||
|
||||
e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &x, &y, NULL, NULL);
|
||||
e_menu_activate_mouse(m, zone, x + ev->output.x, y + ev->output.y,
|
||||
1, 1, E_MENU_POP_DIRECTION_AUTO, ev->timestamp);
|
||||
evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button,
|
||||
EVAS_BUTTON_NONE, ev->timestamp, NULL);
|
||||
#endif
|
||||
elm_ctxpopup_dismiss(inst->popup);
|
||||
inst->popup = NULL;
|
||||
}
|
||||
else clock_popup_new(inst);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -349,7 +310,7 @@ clock_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
|
|||
Instance *inst = data;
|
||||
|
||||
clock_instances = eina_list_remove(clock_instances, inst);
|
||||
clock_popup_free(inst);
|
||||
evas_object_del(inst->popup);
|
||||
time_daynames_clear(inst);
|
||||
free(inst);
|
||||
}
|
||||
|
@ -410,37 +371,16 @@ clock_create(Evas_Object *parent, unsigned int *id, Z_Gadget_Site_Orient orient)
|
|||
{
|
||||
Evas_Object *o;
|
||||
Instance *inst;
|
||||
char todaystr[128];
|
||||
const char *sig = NULL;
|
||||
|
||||
inst = E_NEW(Instance, 1);
|
||||
inst->cfg = _conf_item_get(id);
|
||||
|
||||
time_string_format(inst, todaystr, sizeof(todaystr) - 1);
|
||||
|
||||
o = elm_layout_add(parent);
|
||||
inst->o_clock = o = elm_layout_add(parent);
|
||||
elm_layout_signal_callback_add(o, "e,state,sizing,changed", "*",
|
||||
_clock_sizing_changed_cb, inst);
|
||||
if (inst->cfg->digital_clock)
|
||||
e_theme_edje_object_set(o, "base/theme/modules/clock",
|
||||
"e/modules/clock/digital");
|
||||
else
|
||||
e_theme_edje_object_set(o, "base/theme/modules/clock",
|
||||
"e/modules/clock/main");
|
||||
if (inst->cfg->show_date)
|
||||
elm_layout_signal_emit(o, "e,state,date,on", "e");
|
||||
else
|
||||
elm_layout_signal_emit(o, "e,state,date,off", "e");
|
||||
if (inst->cfg->digital_24h)
|
||||
elm_layout_signal_emit(o, "e,state,24h,on", "e");
|
||||
else
|
||||
elm_layout_signal_emit(o, "e,state,24h,off", "e");
|
||||
if (inst->cfg->show_seconds)
|
||||
elm_layout_signal_emit(o, "e,state,seconds,on", "e");
|
||||
else
|
||||
elm_layout_signal_emit(o, "e,state,seconds,off", "e");
|
||||
|
||||
elm_object_part_text_set(o, "e.text.today", todaystr);
|
||||
_clock_edje_init(inst, o);
|
||||
|
||||
switch (orient)
|
||||
{
|
||||
|
@ -458,7 +398,6 @@ clock_create(Evas_Object *parent, unsigned int *id, Z_Gadget_Site_Orient orient)
|
|||
|
||||
elm_layout_signal_emit(inst->o_clock, sig, "e");
|
||||
|
||||
inst->o_clock = o;
|
||||
evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, clock_del, inst);
|
||||
evas_object_smart_callback_add(parent, "gadget_added", _clock_gadget_added_cb, inst);
|
||||
evas_object_data_set(o, "clock", inst);
|
||||
|
|
|
@ -44,9 +44,8 @@ struct _Config_Item
|
|||
|
||||
struct _Instance
|
||||
{
|
||||
E_Gadcon_Client *gcc;
|
||||
Evas_Object *o_clock, *o_table, *o_popclock, *o_cal;
|
||||
E_Gadcon_Popup *popup;
|
||||
Evas_Object *popup;
|
||||
|
||||
int madj;
|
||||
|
||||
|
@ -71,7 +70,6 @@ EINTERN void time_shutdown(void);
|
|||
|
||||
EINTERN Evas_Object *clock_create(Evas_Object *parent, unsigned int *id, Z_Gadget_Site_Orient orient);
|
||||
EINTERN void clock_popup_new(Instance *inst);
|
||||
EINTERN void clock_popup_free(Instance *inst);
|
||||
|
||||
extern Config *clock_config;
|
||||
extern Eina_List *clock_instances;
|
||||
|
|
|
@ -14,7 +14,10 @@ _e_mod_action_cb(E_Object *obj EINA_UNUSED, const char *params, ...)
|
|||
|
||||
EINA_LIST_FOREACH(clock_instances, l, inst)
|
||||
if (inst->popup)
|
||||
clock_popup_free(inst);
|
||||
{
|
||||
elm_ctxpopup_dismiss(inst->popup);
|
||||
inst->popup = NULL;
|
||||
}
|
||||
else
|
||||
clock_popup_new(inst);
|
||||
}
|
||||
|
|
|
@ -662,15 +662,8 @@ _gadget_act_configure_object_del(void *data, Evas *e EINA_UNUSED, Evas_Object *o
|
|||
}
|
||||
|
||||
static void
|
||||
_gadget_act_configure(E_Object *obj, const char *params EINA_UNUSED, E_Binding_Event_Mouse_Button *ev EINA_UNUSED)
|
||||
_gadget_configure(Z_Gadget_Config *zgc)
|
||||
{
|
||||
Z_Gadget_Config *zgc;
|
||||
Evas_Object *g;
|
||||
|
||||
if (obj->type != Z_GADGET_TYPE) return;
|
||||
|
||||
g = e_object_data_get(obj);
|
||||
zgc = evas_object_data_get(g, "__z_gadget");
|
||||
if (!zgc->configure) return;
|
||||
if (zgc->cfg_object)
|
||||
{
|
||||
|
@ -683,6 +676,19 @@ _gadget_act_configure(E_Object *obj, const char *params EINA_UNUSED, E_Binding_E
|
|||
evas_object_event_callback_add(zgc->cfg_object, EVAS_CALLBACK_DEL, _gadget_act_configure_object_del, zgc);
|
||||
}
|
||||
|
||||
static void
|
||||
_gadget_act_configure(E_Object *obj, const char *params EINA_UNUSED, E_Binding_Event_Mouse_Button *ev EINA_UNUSED)
|
||||
{
|
||||
Z_Gadget_Config *zgc;
|
||||
Evas_Object *g;
|
||||
|
||||
if (obj->type != Z_GADGET_TYPE) return;
|
||||
|
||||
g = e_object_data_get(obj);
|
||||
zgc = evas_object_data_get(g, "__z_gadget");
|
||||
_gadget_configure(zgc);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_site_mouse_up(Z_Gadget_Site *zgs, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
|
||||
{
|
||||
|
@ -869,6 +875,17 @@ z_gadget_configure_cb_set(Evas_Object *g, Z_Gadget_Configure_Cb cb)
|
|||
zgc->configure = cb;
|
||||
}
|
||||
|
||||
Z_API void
|
||||
z_gadget_configure(Evas_Object *g)
|
||||
{
|
||||
Z_Gadget_Config *zgc;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(g);
|
||||
zgc = evas_object_data_get(g, "__z_gadget");
|
||||
EINA_SAFETY_ON_NULL_RETURN(zgc);
|
||||
_gadget_configure(zgc);
|
||||
}
|
||||
|
||||
Z_API void
|
||||
z_gadget_type_add(const char *type, Z_Gadget_Create_Cb callback)
|
||||
{
|
||||
|
|
|
@ -22,15 +22,16 @@ gadget_demo(void)
|
|||
ly = elm_layout_add(e_comp->elm);
|
||||
e_theme_edje_object_set(ly, NULL, "e/shelf/default/base");
|
||||
|
||||
site = z_gadget_site_add(ly, Z_GADGET_SITE_ORIENT_VERTICAL);
|
||||
z_gadget_site_anchor_set(site, Z_GADGET_SITE_ANCHOR_LEFT);
|
||||
site = z_gadget_site_add(ly, Z_GADGET_SITE_ORIENT_HORIZONTAL);
|
||||
z_gadget_site_anchor_set(site, Z_GADGET_SITE_ANCHOR_TOP);
|
||||
elm_object_part_content_set(ly, "e.swallow.content", site);
|
||||
elm_layout_signal_emit(ly, "e,state,orientation,left", "e");
|
||||
evas_object_geometry_set(ly, 0, 0, 48, e_comp->h);
|
||||
elm_layout_signal_emit(ly, "e,state,orientation,top", "e");
|
||||
evas_object_geometry_set(ly, 0, 0, e_comp->w, 48);
|
||||
//evas_object_geometry_set(ly, 0, 0, 48, e_comp->h);
|
||||
evas_object_show(ly);
|
||||
shelf = e_comp_object_util_add(ly, E_COMP_OBJECT_TYPE_NONE);
|
||||
evas_object_data_set(shelf, "comp_skip", (void*)1);
|
||||
evas_object_layer_set(shelf, E_LAYER_DESKTOP);
|
||||
evas_object_layer_set(shelf, E_LAYER_POPUP);
|
||||
evas_object_lower(shelf);
|
||||
|
||||
evas_object_clip_set(shelf, e_comp_zone_xy_get(0, 0)->bg_clip_object);
|
||||
|
|
|
@ -41,8 +41,13 @@ Z_API void z_gadget_site_anchor_set(Evas_Object *obj, Z_Gadget_Site_Anchor an);
|
|||
Z_API Z_Gadget_Site_Orient z_gadget_site_orient_get(Evas_Object *obj);
|
||||
Z_API Z_Gadget_Site_Gravity z_gadget_site_gravity_get(Evas_Object *obj);
|
||||
Z_API void z_gadget_site_gadget_add(Evas_Object *obj, const char *type);
|
||||
|
||||
|
||||
Z_API void z_gadget_configure_cb_set(Evas_Object *g, Z_Gadget_Configure_Cb cb);
|
||||
Z_API void z_gadget_configure(Evas_Object *g);
|
||||
Z_API Evas_Object *z_gadget_site_get(Evas_Object *g);
|
||||
|
||||
|
||||
Z_API void z_gadget_type_add(const char *type, Z_Gadget_Create_Cb callback);
|
||||
Z_API void z_gadget_type_del(const char *type);
|
||||
|
||||
|
|
Loading…
Reference in New Issue