2007-08-04 21:41:55 -07:00
|
|
|
#include "e.h"
|
|
|
|
#include "e_mod_main.h"
|
|
|
|
|
|
|
|
/* actual module specifics */
|
|
|
|
static void _e_mod_action_winlist_cb(E_Object *obj, const char *params);
|
2010-08-19 14:09:58 -07:00
|
|
|
static void _e_mod_action_winlist_mouse_cb(E_Object *obj, const char *params,
|
|
|
|
Ecore_Event_Mouse_Button *ev);
|
|
|
|
static void _e_mod_action_winlist_key_cb(E_Object *obj, const char *params,
|
|
|
|
Ecore_Event_Key *ev);
|
2007-08-04 21:41:55 -07:00
|
|
|
|
|
|
|
static E_Module *conf_module = NULL;
|
2012-08-23 00:57:47 -07:00
|
|
|
const char *_winlist_act = NULL;
|
|
|
|
E_Action *_act_winlist = NULL;
|
2007-08-04 21:41:55 -07:00
|
|
|
|
|
|
|
/* module setup */
|
|
|
|
EAPI E_Module_Api e_modapi =
|
|
|
|
{
|
|
|
|
E_MODULE_API_VERSION,
|
2012-06-20 00:01:53 -07:00
|
|
|
"Winlist"
|
2007-08-04 21:41:55 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
EAPI void *
|
|
|
|
e_modapi_init(E_Module *m)
|
|
|
|
{
|
|
|
|
conf_module = m;
|
2011-04-30 06:35:25 -07:00
|
|
|
e_configure_registry_category_add("windows", 50, _("Windows"), NULL, "preferences-system-windows");
|
2012-07-09 22:38:08 -07:00
|
|
|
e_configure_registry_item_add("windows/window_list", 70, _("Window Switcher"), NULL, "preferences-winlist", e_int_config_winlist);
|
2007-08-04 21:41:55 -07:00
|
|
|
e_winlist_init();
|
2012-08-23 00:57:47 -07:00
|
|
|
_winlist_act = eina_stringshare_add("winlist");
|
2007-08-04 21:41:55 -07:00
|
|
|
/* add module supplied action */
|
2012-08-23 00:57:47 -07:00
|
|
|
_act_winlist = e_action_add(_winlist_act);
|
|
|
|
if (_act_winlist)
|
2007-08-04 21:41:55 -07:00
|
|
|
{
|
2012-08-23 00:57:47 -07:00
|
|
|
_act_winlist->func.go = _e_mod_action_winlist_cb;
|
|
|
|
_act_winlist->func.go_mouse = _e_mod_action_winlist_mouse_cb;
|
|
|
|
_act_winlist->func.go_key = _e_mod_action_winlist_key_cb;
|
2012-12-16 08:58:17 -08:00
|
|
|
e_action_predef_name_set(N_("Window : List"), N_("Next Window"),
|
2010-08-19 09:14:53 -07:00
|
|
|
"winlist", "next", NULL, 0);
|
2012-12-16 08:58:17 -08:00
|
|
|
e_action_predef_name_set(N_("Window : List"), N_("Previous Window"),
|
2012-06-20 00:01:53 -07:00
|
|
|
"winlist", "prev", NULL, 0);
|
2012-12-16 08:58:17 -08:00
|
|
|
e_action_predef_name_set(N_("Window : List"),
|
|
|
|
N_("Next window of same class"), "winlist",
|
2012-06-20 00:01:53 -07:00
|
|
|
"class-next", NULL, 0);
|
2012-12-16 08:58:17 -08:00
|
|
|
e_action_predef_name_set(N_("Window : List"),
|
|
|
|
N_("Previous window of same class"),
|
2012-06-20 00:01:53 -07:00
|
|
|
"winlist", "class-prev", NULL, 0);
|
2012-12-16 08:58:17 -08:00
|
|
|
e_action_predef_name_set(N_("Window : List"),
|
|
|
|
N_("Next window class"), "winlist",
|
2012-06-20 00:01:53 -07:00
|
|
|
"classes-next", NULL, 0);
|
2012-12-16 08:58:17 -08:00
|
|
|
e_action_predef_name_set(N_("Window : List"),
|
|
|
|
N_("Previous window class"),
|
2012-06-20 00:01:53 -07:00
|
|
|
"winlist", "classes-prev", NULL, 0);
|
2012-12-16 08:58:17 -08:00
|
|
|
e_action_predef_name_set(N_("Window : List"), N_("Window on the Left"),
|
2012-06-20 00:01:53 -07:00
|
|
|
"winlist", "left", NULL, 0);
|
2012-12-16 08:58:17 -08:00
|
|
|
e_action_predef_name_set(N_("Window : List"), N_("Window Down"),
|
2012-06-20 00:01:53 -07:00
|
|
|
"winlist", "down", NULL, 0);
|
2012-12-16 08:58:17 -08:00
|
|
|
e_action_predef_name_set(N_("Window : List"), N_("Window Up"),
|
2012-06-20 00:01:53 -07:00
|
|
|
"winlist", "up", NULL, 0);
|
2012-12-16 08:58:17 -08:00
|
|
|
e_action_predef_name_set(N_("Window : List"), N_("Window on the Right"),
|
2012-06-20 00:01:53 -07:00
|
|
|
"winlist", "right", NULL, 0);
|
2007-08-04 21:41:55 -07:00
|
|
|
}
|
|
|
|
e_module_delayed_set(m, 1);
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
2010-08-19 09:14:53 -07:00
|
|
|
e_modapi_shutdown(E_Module *m __UNUSED__)
|
2007-08-04 21:41:55 -07:00
|
|
|
{
|
2011-04-30 06:35:25 -07:00
|
|
|
E_Config_Dialog *cfd;
|
2012-06-20 00:01:53 -07:00
|
|
|
|
2007-08-04 21:41:55 -07:00
|
|
|
/* remove module-supplied action */
|
2012-08-23 00:57:47 -07:00
|
|
|
if (_act_winlist)
|
2007-08-04 21:41:55 -07:00
|
|
|
{
|
2012-12-16 08:58:17 -08:00
|
|
|
e_action_predef_name_del("Window : List", "Previous Window");
|
|
|
|
e_action_predef_name_del("Window : List", "Next Window");
|
|
|
|
e_action_predef_name_del("Window : List",
|
|
|
|
"Previous window of same class");
|
|
|
|
e_action_predef_name_del("Window : List",
|
|
|
|
"Next window of same class");
|
|
|
|
e_action_predef_name_del("Window : List", "Window on the Left");
|
|
|
|
e_action_predef_name_del("Window : List", "Window Down");
|
|
|
|
e_action_predef_name_del("Window : List", "Window Up");
|
|
|
|
e_action_predef_name_del("Window : List", "Window on the Right");
|
2012-06-20 00:01:53 -07:00
|
|
|
e_action_del("winlist");
|
2012-08-23 00:57:47 -07:00
|
|
|
_act_winlist = NULL;
|
2007-08-04 21:41:55 -07:00
|
|
|
}
|
|
|
|
e_winlist_shutdown();
|
2012-06-20 00:01:53 -07:00
|
|
|
|
|
|
|
while ((cfd = e_config_dialog_get("E", "windows/window_list")))
|
|
|
|
e_object_del(E_OBJECT(cfd));
|
2011-04-30 06:35:25 -07:00
|
|
|
e_configure_registry_item_del("windows/window_list");
|
|
|
|
e_configure_registry_category_del("windows");
|
2007-08-04 21:41:55 -07:00
|
|
|
conf_module = NULL;
|
2012-08-23 00:57:47 -07:00
|
|
|
eina_stringshare_replace(&_winlist_act, NULL);
|
2007-08-04 21:41:55 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
2010-08-19 09:14:53 -07:00
|
|
|
e_modapi_save(E_Module *m __UNUSED__)
|
2007-08-04 21:41:55 -07:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* action callback */
|
|
|
|
static void
|
2012-12-20 02:58:21 -08:00
|
|
|
_e_mod_action_winlist_cb_helper(E_Object *obj, const char *params, int modifiers, E_Winlist_Activate_Type type)
|
2007-08-04 21:41:55 -07:00
|
|
|
{
|
2007-09-13 14:20:14 -07:00
|
|
|
E_Zone *zone = NULL;
|
2012-12-20 02:58:21 -08:00
|
|
|
E_Winlist_Filter filter = E_WINLIST_FILTER_NONE;
|
|
|
|
int direction = 0; // -1 for prev, 1 for next;
|
|
|
|
int udlr = -1; // 0 for up, 1 for down, 2 for left, 3 for right
|
|
|
|
Eina_Bool ok = EINA_TRUE;
|
2010-07-07 14:36:23 -07:00
|
|
|
|
2007-08-04 21:41:55 -07:00
|
|
|
if (obj)
|
|
|
|
{
|
2012-06-20 00:01:53 -07:00
|
|
|
if (obj->type == E_MANAGER_TYPE)
|
|
|
|
zone = e_util_zone_current_get((E_Manager *)obj);
|
|
|
|
else if (obj->type == E_CONTAINER_TYPE)
|
|
|
|
zone = e_util_zone_current_get(((E_Container *)obj)->manager);
|
|
|
|
else if (obj->type == E_ZONE_TYPE)
|
|
|
|
zone = e_util_zone_current_get(((E_Zone *)obj)->container->manager);
|
|
|
|
else
|
|
|
|
zone = e_util_zone_current_get(e_manager_current_get());
|
2007-08-04 21:41:55 -07:00
|
|
|
}
|
2007-08-05 01:07:39 -07:00
|
|
|
if (!zone) zone = e_util_zone_current_get(e_manager_current_get());
|
2012-12-20 02:58:21 -08:00
|
|
|
if (!zone) return;
|
|
|
|
if (params)
|
2007-08-04 21:41:55 -07:00
|
|
|
{
|
2012-12-20 02:58:21 -08:00
|
|
|
if (!strcmp(params, "next"))
|
|
|
|
direction = 1;
|
|
|
|
else if (!strcmp(params, "prev"))
|
|
|
|
direction = -1;
|
|
|
|
else if (!strcmp(params, "class-next"))
|
|
|
|
direction = 1, filter = E_WINLIST_FILTER_CLASS_WINDOWS;
|
|
|
|
else if (!strcmp(params, "class-prev"))
|
|
|
|
direction = -1, filter = E_WINLIST_FILTER_CLASS_WINDOWS;
|
|
|
|
else if (!strcmp(params, "classes-next"))
|
|
|
|
direction = 1, filter = E_WINLIST_FILTER_CLASSES;
|
|
|
|
else if (!strcmp(params, "classes-prev"))
|
|
|
|
direction = -1, filter = E_WINLIST_FILTER_CLASSES;
|
|
|
|
else if (!strcmp(params, "up"))
|
|
|
|
udlr = 0;
|
|
|
|
else if (!strcmp(params, "down"))
|
|
|
|
udlr = 1;
|
|
|
|
else if (!strcmp(params, "left"))
|
|
|
|
udlr = 2;
|
|
|
|
else if (!strcmp(params, "right"))
|
|
|
|
udlr = 3;
|
|
|
|
else return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
direction = 1;
|
|
|
|
if (direction)
|
|
|
|
ok = !e_winlist_show(zone, filter);
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
if (!type) return;
|
|
|
|
if (!direction) return;
|
|
|
|
e_winlist_modifiers_set(modifiers, type);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (direction == 1)
|
|
|
|
e_winlist_next();
|
|
|
|
else if (direction == -1)
|
|
|
|
e_winlist_prev();
|
|
|
|
if (direction) return;
|
|
|
|
switch (udlr)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
e_winlist_up(zone);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
e_winlist_down(zone);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
e_winlist_left(zone);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
e_winlist_right(zone);
|
|
|
|
break;
|
2007-08-04 21:41:55 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-12-20 02:58:21 -08:00
|
|
|
_e_mod_action_winlist_cb(E_Object *obj, const char *params)
|
2007-08-04 21:41:55 -07:00
|
|
|
{
|
2012-12-20 02:58:21 -08:00
|
|
|
_e_mod_action_winlist_cb_helper(obj, params, 0, 0);
|
|
|
|
}
|
2010-07-07 14:36:23 -07:00
|
|
|
|
2012-12-20 02:58:21 -08:00
|
|
|
static void
|
|
|
|
_e_mod_action_winlist_mouse_cb(E_Object *obj, const char *params, Ecore_Event_Mouse_Button *ev)
|
|
|
|
{
|
|
|
|
_e_mod_action_winlist_cb_helper(obj, params, ev->modifiers, E_WINLIST_ACTIVATE_TYPE_MOUSE);
|
2007-08-04 21:41:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-03-16 09:24:43 -07:00
|
|
|
_e_mod_action_winlist_key_cb(E_Object *obj, const char *params, Ecore_Event_Key *ev)
|
2007-08-04 21:41:55 -07:00
|
|
|
{
|
2012-12-20 02:58:21 -08:00
|
|
|
_e_mod_action_winlist_cb_helper(obj, params, ev->modifiers, E_WINLIST_ACTIVATE_TYPE_KEY);
|
2007-08-04 21:41:55 -07:00
|
|
|
}
|
2012-06-20 00:01:53 -07:00
|
|
|
|