by the power of the mixer code that I reused, the clock gadget popup will now hide whenever you do anything other than quietly admire its majesty

SVN revision: 76609
This commit is contained in:
Mike Blumenkrantz 2012-09-13 13:21:31 +00:00
parent 153079e8bd
commit 097e570c03
1 changed files with 106 additions and 36 deletions

View File

@ -4,27 +4,6 @@
#include <sys/time.h>
#include <time.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 const char *_gc_label(const E_Gadcon_Client_Class *client_class);
static Evas_Object *_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas);
static const char *_gc_id_new(const E_Gadcon_Client_Class *client_class);
static Config_Item *_conf_item_get(const char *id);
/* 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;
@ -33,6 +12,12 @@ struct _Instance
E_Gadcon_Client *gcc;
Evas_Object *o_clock, *o_table, *o_popclock, *o_cal;
E_Gadcon_Popup *popup;
struct
{
Ecore_X_Window win;
Ecore_Event_Handler *mouse_up;
Ecore_Event_Handler *key_down;
} input;
int madj;
@ -46,6 +31,16 @@ struct _Instance
Config_Item *cfg;
};
/* 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 const char *_gc_label(const E_Gadcon_Client_Class *client_class);
static Evas_Object *_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas);
static const char *_gc_id_new(const E_Gadcon_Client_Class *client_class);
static Config_Item *_conf_item_get(const char *id);
static void _clock_popup_free(Instance *inst);
Config *clock_config = NULL;
static E_Config_DD *conf_edd = NULL;
@ -54,6 +49,18 @@ static Eina_List *clock_instances = NULL;
static E_Action *act = NULL;
static Ecore_Timer *update_today = NULL;
/* 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
};
static void
_clear_timestrs(Instance *inst)
{
@ -244,8 +251,83 @@ _clock_settings_cb(void *d1, void *d2 __UNUSED__)
{
Instance *inst = d1;
e_int_config_clock_module(inst->popup->win->zone->container, inst->cfg);
e_object_del(E_OBJECT(inst->popup));
_clock_popup_free(inst);
}
static void
_clock_popup_input_window_destroy(Instance *inst)
{
e_grabinput_release(0, inst->input.win);
ecore_x_window_free(inst->input.win);
inst->input.win = 0;
ecore_event_handler_del(inst->input.mouse_up);
inst->input.mouse_up = NULL;
ecore_event_handler_del(inst->input.key_down);
inst->input.key_down = NULL;
}
static void
_clock_popup_free(Instance *inst)
{
if (!inst->popup) return;
_clock_popup_input_window_destroy(inst);
if (inst->popup) e_object_del(E_OBJECT(inst->popup));
inst->popup = NULL;
inst->o_popclock = NULL;
}
static Eina_Bool
_clock_popup_input_window_mouse_up_cb(void *data, int type __UNUSED__, void *event)
{
Ecore_Event_Mouse_Button *ev = event;
Instance *inst = data;
if (ev->window != inst->input.win)
return ECORE_CALLBACK_PASS_ON;
_clock_popup_free(inst);
return ECORE_CALLBACK_PASS_ON;
}
static Eina_Bool
_clock_popup_input_window_key_down_cb(void *data, int type __UNUSED__, void *event __UNUSED__)
{
Instance *inst = data;
_clock_popup_free(inst);
return ECORE_CALLBACK_RENEW;
}
static void
_clock_popup_input_window_create(Instance *inst)
{
Ecore_X_Window_Configure_Mask mask;
Ecore_X_Window w, popup_w;
E_Manager *man;
man = e_manager_current_get();
w = ecore_x_window_input_new(man->root, 0, 0, man->w, man->h);
mask = (ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE |
ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING);
popup_w = inst->popup->win->evas_win;
ecore_x_window_configure(w, mask, 0, 0, 0, 0, 0, popup_w,
ECORE_X_WINDOW_STACK_BELOW);
ecore_x_window_show(w);
inst->input.mouse_up =
ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP,
_clock_popup_input_window_mouse_up_cb, inst);
inst->input.key_down =
ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
_clock_popup_input_window_key_down_cb, inst);
inst->input.win = w;
e_grabinput_get(0, 0, inst->input.win);
}
static void
@ -323,6 +405,7 @@ _clock_popup_new(Instance *inst)
e_gadcon_popup_content_set(inst->popup, inst->o_table);
e_gadcon_popup_show(inst->popup);
_clock_popup_input_window_create(inst);
}
static void
@ -485,26 +568,13 @@ _update_today_timer(void *data __UNUSED__)
return EINA_TRUE;
}
static void
_clock_popup_free(Instance *inst)
{
if (!inst->popup) return;
if (inst->popup) e_object_del(E_OBJECT(inst->popup));
inst->popup = NULL;
inst->o_popclock = NULL;
}
static void
_clock_menu_cb_cfg(void *data, E_Menu *menu __UNUSED__, E_Menu_Item *mi __UNUSED__)
{
Instance *inst = data;
E_Container *con;
if (inst->popup)
{
e_object_del(E_OBJECT(inst->popup));
inst->popup = NULL;
}
_clock_popup_free(inst);
con = e_container_current_get(e_manager_current_get());
e_int_config_clock_module(con, inst->cfg);
}