Add different icons for different layout modes in mode-toggle module.

Add code to handle layout changes & update icon.
Implement new Ecore_X Illume Modes.
Make mode toggle actually cycle through modes and change accordingly.



SVN revision: 44769
This commit is contained in:
Christopher Michael 2009-12-29 22:23:15 +00:00
parent a3b7ffe569
commit 67a4f2caa0
7 changed files with 103 additions and 20 deletions

View File

@ -20,6 +20,7 @@ static void _il_ind_win_menu_append(Il_Ind_Win *iwin, E_Menu *mn);
static void _il_ind_win_cb_menu_pre(void *data, E_Menu *mn);
static void _il_ind_win_cb_menu_items_append(void *data, E_Gadcon_Client *gcc, E_Menu *mn);
static void _il_ind_win_cb_menu_contents(void *data, E_Menu *mn, E_Menu_Item *mi);
static int _il_ind_win_is_locked(void);
static int my = 0;
@ -108,12 +109,16 @@ e_mod_ind_win_new(void)
e_gadcon_ecore_evas_set(iwin->gadcon, iwin->win->ecore_evas);
e_gadcon_util_menu_attach_func_set(iwin->gadcon,
_il_ind_win_cb_menu_items_append, iwin);
e_gadcon_populate(iwin->gadcon);
e_win_size_min_set(iwin->win, zone->w, 32);
e_win_show(iwin->win);
if (_il_ind_win_is_locked())
ecore_x_e_illume_drag_locked_set(iwin->win->border->client.win, 1);
else
ecore_x_e_illume_drag_locked_set(iwin->win->border->client.win, 0);
return iwin;
}
@ -220,7 +225,7 @@ _il_ind_win_cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event)
if (bd->y != ny)
{
e_border_move(bd, bd->x, ny);
e_border_move(bd, bd->zone->x, ny);
my = py;
}
}
@ -348,3 +353,16 @@ _il_ind_win_cb_menu_contents(void *data, E_Menu *mn, E_Menu_Item *mi)
if (!iwin->gadcon->config_dialog)
e_int_gadcon_config_shelf(iwin->gadcon);
}
static int
_il_ind_win_is_locked(void)
{
Ecore_X_Window xwin;
Ecore_X_Illume_Mode mode;
xwin = ecore_x_window_root_first_get();
mode = ecore_x_e_illume_mode_get(xwin);
if (mode == ECORE_X_ILLUME_MODE_DUAL_TOP)
return 0;
return 1;
}

View File

@ -7,6 +7,7 @@ struct _Instance
{
E_Gadcon_Client *gcc;
Evas_Object *o_btn;
Ecore_Event_Handler *hdl;
};
/* local function prototypes */
@ -17,6 +18,8 @@ static char *_gc_label(E_Gadcon_Client_Class *cc);
static Evas_Object *_gc_icon(E_Gadcon_Client_Class *cc, Evas *evas);
static const char *_gc_id_new(E_Gadcon_Client_Class *cc);
static void _cb_btn_click(void *data, void *data2);
static int _cb_event_client_message(void *data, int type, void *event);
static void _set_icon(Instance *inst);
/* local variables */
static Eina_List *instances = NULL;
@ -61,20 +64,19 @@ static E_Gadcon_Client *
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
{
Instance *inst;
Evas_Object *icon;
char buff[PATH_MAX];
snprintf(buff, sizeof(buff), "%s/e-module-illume-mode-toggle.edj", mod_dir);
inst = E_NEW(Instance, 1);
inst->o_btn = e_widget_button_add(gc->evas, NULL, NULL,
_cb_btn_click, inst, NULL);
icon = e_icon_add(evas_object_evas_get(inst->o_btn));
e_icon_file_edje_set(icon, buff, "icon");
e_widget_button_icon_set(inst->o_btn, icon);
_set_icon(inst);
inst->gcc = e_gadcon_client_new(gc, name, id, style, inst->o_btn);
inst->gcc->data = inst;
inst->hdl = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
_cb_event_client_message, inst);
instances = eina_list_append(instances, inst);
return inst->gcc;
}
@ -87,6 +89,8 @@ _gc_shutdown(E_Gadcon_Client *gcc)
if (!(inst = gcc->data)) return;
instances = eina_list_remove(instances, inst);
if (inst->o_btn) evas_object_del(inst->o_btn);
if (inst->hdl) ecore_event_handler_del(inst->hdl);
inst->hdl = NULL;
E_FREE(inst);
}
@ -133,10 +137,45 @@ _cb_btn_click(void *data, void *data2)
xwin = ecore_x_window_root_first_get();
mode = ecore_x_e_illume_mode_get(xwin);
if (mode <= ECORE_X_ILLUME_MODE_SINGLE)
mode = ECORE_X_ILLUME_MODE_DUAL;
else
mode += 1;
if (mode > ECORE_X_ILLUME_MODE_DUAL_LEFT)
mode = ECORE_X_ILLUME_MODE_SINGLE;
ecore_x_e_illume_mode_set(xwin, mode);
ecore_x_e_illume_mode_send(xwin, mode);
}
static int
_cb_event_client_message(void *data, int type, void *event)
{
Ecore_X_Event_Client_Message *ev;
Instance *inst;
ev = event;
if (ev->message_type != ECORE_X_ATOM_E_ILLUME_MODE) return 1;
if (!(inst = data)) return 1;
_set_icon(inst);
return 1;
}
static void
_set_icon(Instance *inst)
{
Evas_Object *icon;
Ecore_X_Window xwin;
Ecore_X_Illume_Mode mode;
char buff[PATH_MAX];
snprintf(buff, sizeof(buff), "%s/e-module-illume-mode-toggle.edj", mod_dir);
icon = e_icon_add(evas_object_evas_get(inst->o_btn));
xwin = ecore_x_window_root_first_get();
mode = ecore_x_e_illume_mode_get(xwin);
if (mode == ECORE_X_ILLUME_MODE_SINGLE)
e_icon_file_edje_set(icon, buff, "single");
else if (mode == ECORE_X_ILLUME_MODE_DUAL_TOP)
e_icon_file_edje_set(icon, buff, "dual_top");
else if (mode == ECORE_X_ILLUME_MODE_DUAL_LEFT)
e_icon_file_edje_set(icon, buff, "dual_left");
e_widget_button_icon_set(inst->o_btn, icon);
}

View File

@ -27,6 +27,8 @@ void
e_mod_layout_init(void)
{
Eina_List *l;
Ecore_X_Illume_Mode mode;
Ecore_X_Window xwin;
hook1 = e_border_hook_add(E_BORDER_HOOK_EVAL_POST_FETCH,
_e_mod_layout_cb_hook_post_fetch, NULL);
@ -53,6 +55,18 @@ e_mod_layout_init(void)
(handlers, ecore_event_handler_add
(ECORE_X_EVENT_CLIENT_MESSAGE, _cb_event_client_message, NULL));
xwin = ecore_x_window_root_first_get();
if (il_cfg->policy.mode.dual == 0)
mode = ECORE_X_ILLUME_MODE_SINGLE;
else
{
if (il_cfg->policy.mode.side == 0)
mode = ECORE_X_ILLUME_MODE_DUAL_TOP;
else
mode = ECORE_X_ILLUME_MODE_DUAL_LEFT;
}
ecore_x_e_illume_mode_set(xwin, mode);
illume_layout_illume_init();
}
@ -293,17 +307,21 @@ _cb_event_client_message(void *data, int type, void *event)
if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_MODE_SINGLE)
il_cfg->policy.mode.dual = 0;
else if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_MODE_DUAL)
il_cfg->policy.mode.dual = 1;
else if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_MODE_DUAL_TOP)
{
il_cfg->policy.mode.dual = 1;
il_cfg->policy.mode.side = 0;
lock = 0;
}
else if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_MODE_DUAL_LEFT)
{
il_cfg->policy.mode.dual = 1;
il_cfg->policy.mode.side = 1;
}
else /* unknown */
il_cfg->policy.mode.dual = 0;
e_config_save_queue();
if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_MODE_DUAL)
{
if (il_cfg->policy.mode.side == 0) lock = 0;
}
zone = e_zone_current_get(e_container_current_get(e_manager_current_get()));
bd = e_mod_border_top_shelf_get(zone);
if (bd)

View File

@ -230,6 +230,7 @@ _drag_end(E_Border *bd)
{
/* HANDLE A BORDER DRAG BEING ENDED */
ecore_x_e_illume_drag_set(bd->client.win, 0);
// _zone_layout(bd->zone);
}
static void

View File

@ -19,6 +19,8 @@ EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume2" };
EAPI void *
e_modapi_init(E_Module *m)
{
e_module_priority_set(m, 100);
/* init the config subsystem */
if (!il_config_init(m)) return NULL;

View File

@ -104,8 +104,13 @@ _il_config_policy_settings_change_timeout(void *data)
e_config_save_queue();
_ps_change_timer = NULL;
if (il_cfg->policy.mode.dual)
mode = ECORE_X_ILLUME_MODE_DUAL;
if (il_cfg->policy.mode.dual)
{
if (il_cfg->policy.mode.side == 0)
mode = ECORE_X_ILLUME_MODE_DUAL_TOP;
else
mode = ECORE_X_ILLUME_MODE_DUAL_LEFT;
}
else
mode = ECORE_X_ILLUME_MODE_SINGLE;