1999-10-04 15:06:00 -07:00
|
|
|
/*
|
2007-01-13 11:14:29 -08:00
|
|
|
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
|
2020-02-07 21:36:03 -08:00
|
|
|
* Copyright (C) 2004-2020 Kim Woelders
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies of the Software, its documentation and marketing & publicity
|
|
|
|
* materials, and acknowledgment shall be given in the documentation, materials
|
|
|
|
* and software packages that this Software was used.
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
1999-08-17 15:56:46 -07:00
|
|
|
#include "E.h"
|
2005-12-22 10:43:15 -08:00
|
|
|
#include "borders.h"
|
2005-10-29 01:48:40 -07:00
|
|
|
#include "dialog.h"
|
2005-07-16 09:57:45 -07:00
|
|
|
#include "emodule.h"
|
|
|
|
#include "ewins.h"
|
2005-11-19 07:47:10 -08:00
|
|
|
#include "groups.h"
|
2013-06-06 13:37:06 -07:00
|
|
|
#include "list.h"
|
2007-01-16 17:10:44 -08:00
|
|
|
#include "settings.h"
|
2005-02-15 14:19:52 -08:00
|
|
|
#include "snaps.h"
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2008-11-08 07:47:09 -08:00
|
|
|
#define DEBUG_GROUPS 0
|
|
|
|
#if DEBUG_GROUPS
|
|
|
|
#define Dprintf(fmt, ...) Eprintf("%s: " fmt, __func__, __VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define Dprintf(fmt...)
|
|
|
|
#endif
|
|
|
|
|
2008-11-22 13:16:55 -08:00
|
|
|
#define USE_GROUP_SHOWHIDE 1 /* Enable group borders */
|
2007-02-28 18:13:35 -08:00
|
|
|
|
2020-02-07 21:36:03 -08:00
|
|
|
#define GROUP_SELECT_ALL 0
|
|
|
|
#define GROUP_SELECT_EWIN_ONLY 1
|
|
|
|
#define GROUP_SELECT_ALL_EXCEPT_EWIN 2
|
|
|
|
|
2005-11-05 09:12:53 -08:00
|
|
|
#define SET_OFF 0
|
|
|
|
#define SET_ON 1
|
|
|
|
#define SET_TOGGLE 2
|
|
|
|
|
2020-02-07 21:36:03 -08:00
|
|
|
typedef struct _groupconfig {
|
|
|
|
char iconify;
|
|
|
|
char kill;
|
|
|
|
char move;
|
|
|
|
char raise;
|
|
|
|
char set_border;
|
|
|
|
char shade;
|
|
|
|
char stick;
|
|
|
|
} GroupConfig;
|
|
|
|
|
|
|
|
struct _group {
|
|
|
|
dlist_t list;
|
|
|
|
int index;
|
|
|
|
EWin **members;
|
|
|
|
int num_members;
|
|
|
|
GroupConfig cfg;
|
|
|
|
char save; /* Used in snapshot - must save */
|
|
|
|
};
|
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
static LIST_HEAD(group_list);
|
2006-02-18 00:30:09 -08:00
|
|
|
|
2008-03-23 04:54:24 -07:00
|
|
|
static struct {
|
2005-11-19 07:47:10 -08:00
|
|
|
GroupConfig dflt;
|
|
|
|
char swapmove;
|
|
|
|
} Conf_groups;
|
|
|
|
|
2008-03-23 04:54:24 -07:00
|
|
|
static struct {
|
2005-11-19 07:47:10 -08:00
|
|
|
Group *current;
|
|
|
|
} Mode_groups;
|
|
|
|
|
|
|
|
int
|
|
|
|
GroupsGetSwapmove(void)
|
|
|
|
{
|
|
|
|
return Conf_groups.swapmove;
|
|
|
|
}
|
|
|
|
|
2004-06-06 09:38:17 -07:00
|
|
|
static Group *
|
2020-05-03 00:36:21 -07:00
|
|
|
_GroupCreate(int gid)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
Group *g;
|
|
|
|
|
2008-10-18 09:16:47 -07:00
|
|
|
g = ECALLOC(Group, 1);
|
1999-08-17 15:56:46 -07:00
|
|
|
if (!g)
|
2005-01-25 13:58:28 -08:00
|
|
|
return NULL;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_APPEND(Group, &group_list, g);
|
2006-02-18 00:30:09 -08:00
|
|
|
|
2008-10-18 09:10:11 -07:00
|
|
|
if (gid == -1)
|
|
|
|
{
|
|
|
|
/* Create new group id */
|
2011-01-05 10:05:59 -08:00
|
|
|
/* ... using us time. Should really be checked for uniqueness. */
|
|
|
|
g->index = (int)GetTimeUs();
|
2008-10-18 09:10:11 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Use given group id */
|
|
|
|
g->index = gid;
|
|
|
|
}
|
2005-11-19 07:47:10 -08:00
|
|
|
g->cfg.iconify = Conf_groups.dflt.iconify;
|
|
|
|
g->cfg.kill = Conf_groups.dflt.kill;
|
|
|
|
g->cfg.move = Conf_groups.dflt.move;
|
|
|
|
g->cfg.raise = Conf_groups.dflt.raise;
|
|
|
|
g->cfg.set_border = Conf_groups.dflt.set_border;
|
|
|
|
g->cfg.stick = Conf_groups.dflt.stick;
|
|
|
|
g->cfg.shade = Conf_groups.dflt.shade;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2008-11-08 07:47:09 -08:00
|
|
|
Dprintf("grp=%p gid=%d\n", g, g->index);
|
2005-01-25 13:58:28 -08:00
|
|
|
return g;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2004-06-06 09:38:17 -07:00
|
|
|
static void
|
2020-05-03 00:36:21 -07:00
|
|
|
_GroupDestroy(Group * g)
|
1999-08-20 05:23:26 -07:00
|
|
|
{
|
2004-06-06 09:38:17 -07:00
|
|
|
if (!g)
|
|
|
|
return;
|
|
|
|
|
2008-11-08 07:47:09 -08:00
|
|
|
Dprintf("grp=%p gid=%d\n", g, g->index);
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_REMOVE(Group, &group_list, g);
|
2006-02-18 00:30:09 -08:00
|
|
|
|
2005-11-19 07:47:10 -08:00
|
|
|
if (g == Mode_groups.current)
|
|
|
|
Mode_groups.current = NULL;
|
2008-02-23 04:09:38 -08:00
|
|
|
Efree(g->members);
|
|
|
|
|
2004-06-06 09:38:17 -07:00
|
|
|
Efree(g);
|
1999-08-20 05:23:26 -07:00
|
|
|
}
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
static int
|
2020-05-03 00:36:21 -07:00
|
|
|
_GroupMatchId(const void *data, const void *match)
|
2006-02-18 00:30:09 -08:00
|
|
|
{
|
2012-01-08 04:54:08 -08:00
|
|
|
return ((const Group *)data)->index != PTR2INT(match);
|
2006-02-18 00:30:09 -08:00
|
|
|
}
|
|
|
|
|
2008-10-18 09:10:11 -07:00
|
|
|
static Group *
|
2020-05-03 00:36:21 -07:00
|
|
|
_GroupFind(int gid)
|
2006-02-18 00:30:09 -08:00
|
|
|
{
|
2020-05-03 00:36:21 -07:00
|
|
|
return LIST_FIND(Group, &group_list, _GroupMatchId, INT2PTR(gid));
|
2006-02-18 00:30:09 -08:00
|
|
|
}
|
|
|
|
|
2020-02-07 21:36:03 -08:00
|
|
|
EWin *const *
|
|
|
|
GroupGetMembers(const Group * g, int *num)
|
|
|
|
{
|
|
|
|
*num = g->num_members;
|
|
|
|
return g->members;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
GroupRemember(Group * g)
|
|
|
|
{
|
|
|
|
g->save = 1;
|
|
|
|
return g->index;
|
|
|
|
}
|
|
|
|
|
2008-10-18 09:16:47 -07:00
|
|
|
void
|
2020-02-07 21:36:03 -08:00
|
|
|
GroupRememberByGid(int gid)
|
2008-10-18 09:16:47 -07:00
|
|
|
{
|
|
|
|
Group *g;
|
|
|
|
|
2020-05-03 00:36:21 -07:00
|
|
|
g = _GroupFind(gid);
|
2008-10-18 09:16:47 -07:00
|
|
|
if (!g)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g->save = 1;
|
|
|
|
}
|
|
|
|
|
2020-02-07 21:36:03 -08:00
|
|
|
int
|
|
|
|
GroupMatchAction(const Group * g, int action)
|
|
|
|
{
|
|
|
|
int match;
|
|
|
|
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
match = 0;
|
|
|
|
break;
|
|
|
|
case GROUP_ACTION_SET_WINDOW_BORDER:
|
|
|
|
match = g->cfg.set_border;
|
|
|
|
break;
|
|
|
|
case GROUP_ACTION_ICONIFY:
|
|
|
|
match = g->cfg.iconify;
|
|
|
|
break;
|
|
|
|
case GROUP_ACTION_MOVE:
|
|
|
|
match = g->cfg.move;
|
|
|
|
break;
|
|
|
|
case GROUP_ACTION_STACKING:
|
|
|
|
match = g->cfg.raise;
|
|
|
|
break;
|
|
|
|
case GROUP_ACTION_STICK:
|
|
|
|
match = g->cfg.stick;
|
|
|
|
break;
|
|
|
|
case GROUP_ACTION_SHADE:
|
|
|
|
match = g->cfg.shade;
|
|
|
|
break;
|
|
|
|
case GROUP_ACTION_KILL:
|
|
|
|
match = g->cfg.kill;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return match;
|
|
|
|
}
|
|
|
|
|
2007-02-26 19:52:46 -08:00
|
|
|
static Group *
|
2020-05-03 00:36:21 -07:00
|
|
|
_GroupFind2(const char *groupid)
|
2007-02-26 19:52:46 -08:00
|
|
|
{
|
|
|
|
int gid;
|
|
|
|
|
|
|
|
if (groupid[0] == '*' || groupid[0] == '\0')
|
|
|
|
return Mode_groups.current;
|
|
|
|
|
2020-05-03 23:01:37 -07:00
|
|
|
gid = 0;
|
2007-02-26 19:52:46 -08:00
|
|
|
sscanf(groupid, "%d", &gid);
|
2020-05-03 23:01:37 -07:00
|
|
|
if (gid == 0)
|
2007-02-26 19:52:46 -08:00
|
|
|
return NULL;
|
|
|
|
|
2020-05-03 00:36:21 -07:00
|
|
|
return _GroupFind(gid);
|
2007-02-26 19:52:46 -08:00
|
|
|
}
|
|
|
|
|
2020-05-03 01:06:26 -07:00
|
|
|
static int
|
|
|
|
_EwinGroupIndex(const EWin * ewin, const Group * g)
|
2020-05-02 23:56:25 -07:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ewin->num_groups; i++)
|
|
|
|
if (ewin->groups[i] == g)
|
2020-05-03 01:06:26 -07:00
|
|
|
return i;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_GroupEwinIndex(const Group * g, const EWin * ewin)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < g->num_members; i++)
|
|
|
|
if (g->members[i] == ewin)
|
|
|
|
return i;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_GroupAddEwin(Group * g, EWin * ewin)
|
|
|
|
{
|
|
|
|
if (_EwinGroupIndex(ewin, g) >= 0)
|
|
|
|
return; /* Already there */
|
2020-05-02 23:56:25 -07:00
|
|
|
|
|
|
|
ewin->num_groups++;
|
|
|
|
ewin->groups = EREALLOC(Group *, ewin->groups, ewin->num_groups);
|
|
|
|
ewin->groups[ewin->num_groups - 1] = g;
|
|
|
|
g->num_members++;
|
|
|
|
g->members = EREALLOC(EWin *, g->members, g->num_members);
|
|
|
|
g->members[g->num_members - 1] = ewin;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-05-03 00:36:21 -07:00
|
|
|
_GroupEwinAdd(Group * g, EWin * ewin)
|
2020-05-02 23:56:25 -07:00
|
|
|
{
|
|
|
|
if (!ewin || !g)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_GroupAddEwin(g, ewin);
|
|
|
|
SnapshotEwinUpdate(ewin, SNAP_USE_GROUPS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-05-03 00:36:21 -07:00
|
|
|
_GroupEwinRemove(Group * g, EWin * ewin)
|
2020-05-02 23:56:25 -07:00
|
|
|
{
|
2020-05-03 01:06:26 -07:00
|
|
|
int i, ie, ig;
|
2020-05-02 23:56:25 -07:00
|
|
|
|
|
|
|
if (!ewin || !g)
|
|
|
|
return;
|
|
|
|
|
2020-05-03 01:06:26 -07:00
|
|
|
ie = _EwinGroupIndex(ewin, g);
|
|
|
|
if (ie < 0)
|
2020-05-02 23:56:25 -07:00
|
|
|
{
|
2020-05-03 01:06:26 -07:00
|
|
|
/* Should not happen */
|
|
|
|
Dprintf("%s: g=%p gid=%8d: %s: Group not found?!?\n", __func__,
|
|
|
|
g, g->index, EoGetName(ewin));
|
|
|
|
return;
|
2020-05-02 23:56:25 -07:00
|
|
|
}
|
2020-05-03 01:06:26 -07:00
|
|
|
|
|
|
|
ig = _GroupEwinIndex(g, ewin);
|
|
|
|
if (ig < 0)
|
|
|
|
{
|
|
|
|
/* Should not happen */
|
|
|
|
Dprintf("%s: g=%p gid=%8d: %s: Ewin not found?!?\n", __func__,
|
|
|
|
g, g->index, EoGetName(ewin));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Dprintf("%s: gid=%8d index=%d/%d: %s\n", __func__,
|
|
|
|
g->index, ie, ig, EoGetName(ewin));
|
|
|
|
|
|
|
|
/* remove it from the group */
|
|
|
|
g->num_members--;
|
|
|
|
for (i = ig; i < g->num_members; i++)
|
|
|
|
g->members[i] = g->members[i + 1];
|
|
|
|
|
|
|
|
if (g->num_members > 0)
|
|
|
|
g->members = EREALLOC(EWin *, g->members, g->num_members);
|
|
|
|
else if (g->save)
|
|
|
|
EFREE_NULL(g->members);
|
|
|
|
else
|
|
|
|
_GroupDestroy(g);
|
|
|
|
|
|
|
|
/* and remove the group from the groups that the window is in */
|
|
|
|
ewin->num_groups--;
|
|
|
|
for (i = ie; i < ewin->num_groups; i++)
|
|
|
|
ewin->groups[i] = ewin->groups[i + 1];
|
|
|
|
|
|
|
|
if (ewin->num_groups > 0)
|
|
|
|
ewin->groups = EREALLOC(Group *, ewin->groups, ewin->num_groups);
|
|
|
|
else
|
|
|
|
EFREE_NULL(ewin->groups);
|
|
|
|
|
|
|
|
GroupsSave();
|
2020-05-02 23:56:25 -07:00
|
|
|
}
|
|
|
|
|
2005-10-30 11:40:49 -08:00
|
|
|
static void
|
2020-05-03 10:42:03 -07:00
|
|
|
_GroupDelete(Group * g)
|
1999-09-08 17:39:43 -07:00
|
|
|
{
|
2020-05-03 10:42:03 -07:00
|
|
|
EWin *ewin;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2020-05-03 10:42:03 -07:00
|
|
|
if (!g)
|
2008-11-08 04:21:10 -08:00
|
|
|
return;
|
|
|
|
|
2020-05-03 10:42:03 -07:00
|
|
|
Dprintf("group=%p gid=%d\n", g, g->index);
|
2008-11-08 04:21:10 -08:00
|
|
|
|
2020-05-03 23:14:02 -07:00
|
|
|
g->save = 1;
|
|
|
|
while (g->num_members > 0)
|
2020-05-03 10:42:03 -07:00
|
|
|
{
|
|
|
|
ewin = g->members[0];
|
|
|
|
_GroupEwinRemove(g, ewin);
|
|
|
|
SnapshotEwinUpdate(ewin, SNAP_USE_GROUPS);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2020-05-03 23:14:02 -07:00
|
|
|
_GroupDestroy(g);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
Group **
|
|
|
|
GroupsGetList(int *pnum)
|
|
|
|
{
|
2013-06-06 13:37:06 -07:00
|
|
|
return LIST_GET_ITEMS(Group, &group_list, pnum);
|
2006-02-18 00:30:09 -08:00
|
|
|
}
|
|
|
|
|
2009-01-24 00:31:50 -08:00
|
|
|
#if ENABLE_DIALOGS
|
2008-10-18 09:13:54 -07:00
|
|
|
static Group **
|
2020-05-03 00:36:21 -07:00
|
|
|
_EwinListGroups(const EWin * ewin, char group_select, int *num)
|
2006-02-18 00:30:09 -08:00
|
|
|
{
|
2012-12-24 02:41:50 -08:00
|
|
|
Group **groups;
|
|
|
|
Group **groups2;
|
|
|
|
int i, j, n, killed;
|
|
|
|
|
|
|
|
groups = NULL;
|
|
|
|
*num = 0;
|
2006-02-18 00:30:09 -08:00
|
|
|
|
|
|
|
switch (group_select)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
case GROUP_SELECT_EWIN_ONLY:
|
2009-11-08 09:23:29 -08:00
|
|
|
*num = n = ewin->num_groups;
|
|
|
|
if (n <= 0)
|
|
|
|
break;
|
|
|
|
groups = EMALLOC(Group *, n);
|
2006-02-18 00:30:09 -08:00
|
|
|
if (!groups)
|
|
|
|
break;
|
2009-11-08 09:23:29 -08:00
|
|
|
memcpy(groups, ewin->groups, n * sizeof(Group *));
|
2006-02-18 00:30:09 -08:00
|
|
|
break;
|
|
|
|
case GROUP_SELECT_ALL_EXCEPT_EWIN:
|
|
|
|
groups2 = GroupsGetList(num);
|
|
|
|
if (!groups2)
|
|
|
|
break;
|
2012-12-24 02:41:50 -08:00
|
|
|
n = *num;
|
|
|
|
for (i = killed = 0; i < n; i++)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
for (j = 0; j < ewin->num_groups; j++)
|
|
|
|
{
|
|
|
|
if (ewin->groups[j] == groups2[i])
|
|
|
|
{
|
|
|
|
groups2[i] = NULL;
|
|
|
|
killed++;
|
|
|
|
}
|
|
|
|
}
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2012-12-24 02:41:50 -08:00
|
|
|
if (n - killed > 0)
|
2006-02-18 00:30:09 -08:00
|
|
|
{
|
2012-12-24 02:41:50 -08:00
|
|
|
groups = EMALLOC(Group *, n - killed);
|
|
|
|
if (groups)
|
|
|
|
{
|
|
|
|
for (i = j = 0; i < n; i++)
|
|
|
|
if (groups2[i])
|
|
|
|
groups[j++] = groups2[i];
|
|
|
|
*num = n - killed;
|
|
|
|
}
|
2006-02-18 00:30:09 -08:00
|
|
|
}
|
|
|
|
Efree(groups2);
|
|
|
|
break;
|
|
|
|
case GROUP_SELECT_ALL:
|
|
|
|
default:
|
|
|
|
groups = GroupsGetList(num);
|
|
|
|
break;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2006-02-18 00:30:09 -08:00
|
|
|
|
|
|
|
return groups;
|
1999-10-02 14:59:10 -07:00
|
|
|
}
|
2009-01-24 00:31:50 -08:00
|
|
|
#endif /* ENABLE_DIALOGS */
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2008-10-18 09:10:11 -07:00
|
|
|
void
|
2008-11-08 07:47:09 -08:00
|
|
|
GroupsEwinAdd(EWin * ewin, const int *pgid, int ngid)
|
2008-10-18 09:10:11 -07:00
|
|
|
{
|
2008-11-08 07:47:09 -08:00
|
|
|
Group *g;
|
|
|
|
int i, gid;
|
2008-10-18 09:10:11 -07:00
|
|
|
|
2008-11-08 07:47:09 -08:00
|
|
|
for (i = 0; i < ngid; i++)
|
2008-10-18 09:10:11 -07:00
|
|
|
{
|
2008-11-08 07:47:09 -08:00
|
|
|
gid = pgid[i];
|
2020-05-03 00:36:21 -07:00
|
|
|
g = _GroupFind(gid);
|
2008-11-08 07:47:09 -08:00
|
|
|
Dprintf("ewin=%p gid=%d grp=%p\n", ewin, gid, g);
|
|
|
|
if (!g)
|
|
|
|
{
|
|
|
|
/* This should not happen, but may if group/snap configs are corrupted */
|
2020-05-03 00:36:21 -07:00
|
|
|
g = _GroupCreate(gid);
|
2008-11-08 07:47:09 -08:00
|
|
|
}
|
2020-05-03 00:02:06 -07:00
|
|
|
_GroupAddEwin(g, ewin);
|
2008-10-18 09:10:11 -07:00
|
|
|
}
|
2008-11-08 07:47:09 -08:00
|
|
|
SnapshotEwinUpdate(ewin, SNAP_USE_GROUPS);
|
2008-10-18 09:10:11 -07:00
|
|
|
}
|
|
|
|
|
2020-05-02 23:56:25 -07:00
|
|
|
void
|
|
|
|
GroupsEwinRemove(EWin * ewin)
|
|
|
|
{
|
2020-05-03 12:05:21 -07:00
|
|
|
while (ewin->num_groups > 0)
|
2020-05-03 00:36:21 -07:00
|
|
|
_GroupEwinRemove(ewin->groups[0], ewin);
|
2020-05-02 23:56:25 -07:00
|
|
|
}
|
|
|
|
|
2005-10-30 11:40:49 -08:00
|
|
|
static int
|
2020-05-03 00:36:21 -07:00
|
|
|
_EwinInGroup(const EWin * ewin, const Group * g)
|
1999-10-02 14:59:10 -07:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (ewin && g)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < g->num_members; i++)
|
|
|
|
{
|
|
|
|
if (g->members[i] == ewin)
|
|
|
|
return 1;
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-10-02 14:59:10 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Group *
|
2005-11-05 09:12:53 -08:00
|
|
|
EwinsInGroup(const EWin * ewin1, const EWin * ewin2)
|
1999-10-02 14:59:10 -07:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (ewin1 && ewin2)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < ewin1->num_groups; i++)
|
|
|
|
{
|
2020-05-03 00:36:21 -07:00
|
|
|
if (_EwinInGroup(ewin2, ewin1->groups[i]))
|
2003-05-22 12:15:03 -07:00
|
|
|
return ewin1->groups[i];
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-10-02 14:59:10 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-01-24 00:31:50 -08:00
|
|
|
#if ENABLE_DIALOGS
|
2004-12-28 15:46:49 -08:00
|
|
|
static char **
|
2020-05-03 00:36:21 -07:00
|
|
|
_GrouplistMemberNames(Group ** groups, int num)
|
1999-10-02 14:59:10 -07:00
|
|
|
{
|
2007-03-04 15:35:02 -08:00
|
|
|
int i, j, len;
|
2005-10-30 11:40:49 -08:00
|
|
|
char **group_member_strings;
|
2007-03-04 15:35:02 -08:00
|
|
|
const char *name;
|
2005-10-30 11:40:49 -08:00
|
|
|
|
2007-01-16 17:10:44 -08:00
|
|
|
group_member_strings = ECALLOC(char *, num);
|
|
|
|
|
2005-10-30 11:40:49 -08:00
|
|
|
if (!group_member_strings)
|
|
|
|
return NULL;
|
1999-10-02 14:59:10 -07:00
|
|
|
|
|
|
|
for (i = 0; i < num; i++)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2007-01-16 17:10:44 -08:00
|
|
|
group_member_strings[i] = EMALLOC(char, 1024);
|
|
|
|
|
2005-10-30 11:40:49 -08:00
|
|
|
if (!group_member_strings[i])
|
|
|
|
break;
|
2003-05-22 12:15:03 -07:00
|
|
|
|
2007-03-04 15:35:02 -08:00
|
|
|
len = 0;
|
2003-05-22 12:15:03 -07:00
|
|
|
for (j = 0; j < groups[i]->num_members; j++)
|
|
|
|
{
|
2007-03-04 15:35:02 -08:00
|
|
|
name = EwinGetTitle(groups[i]->members[j]);
|
|
|
|
if (!name) /* Should never happen */
|
|
|
|
continue;
|
|
|
|
len += Esnprintf(group_member_strings[i] + len, 1024 - len,
|
|
|
|
"%s\n", name);
|
|
|
|
if (len >= 1024)
|
|
|
|
break;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2020-05-04 06:34:28 -07:00
|
|
|
if (len == 0)
|
|
|
|
snprintf(group_member_strings[i], 1024, "(empty)");
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-10-02 14:59:10 -07:00
|
|
|
|
|
|
|
return group_member_strings;
|
|
|
|
}
|
2009-01-24 00:31:50 -08:00
|
|
|
#endif /* ENABLE_DIALOGS */
|
1999-10-02 14:59:10 -07:00
|
|
|
|
2007-02-28 18:13:35 -08:00
|
|
|
#if USE_GROUP_SHOWHIDE
|
2005-10-30 11:40:49 -08:00
|
|
|
static void
|
2020-05-03 00:36:21 -07:00
|
|
|
_EwinGroupsShowHide(EWin * ewin, int group_index, char onoff)
|
1999-10-02 14:59:10 -07:00
|
|
|
{
|
|
|
|
EWin **gwins;
|
|
|
|
int i, num;
|
2004-12-28 15:46:49 -08:00
|
|
|
const Border *b = NULL;
|
1999-10-02 14:59:10 -07:00
|
|
|
|
2005-11-05 09:12:53 -08:00
|
|
|
if (!ewin || group_index >= ewin->num_groups)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (group_index < 0)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2005-11-05 09:12:53 -08:00
|
|
|
gwins = ListWinGroupMembersForEwin(ewin, GROUP_ACTION_ANY, 0, &num);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-10-02 14:59:10 -07:00
|
|
|
else
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2005-11-05 09:12:53 -08:00
|
|
|
gwins = ewin->groups[group_index]->members;
|
|
|
|
num = ewin->groups[group_index]->num_members;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-10-02 14:59:10 -07:00
|
|
|
|
2008-11-22 13:16:55 -08:00
|
|
|
if (onoff == SET_TOGGLE)
|
|
|
|
onoff = (ewin->border == ewin->normal_border) ? SET_ON : SET_OFF;
|
1999-10-02 14:59:10 -07:00
|
|
|
|
|
|
|
for (i = 0; i < num; i++)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2008-11-22 13:16:55 -08:00
|
|
|
if (onoff == SET_ON)
|
|
|
|
b = BorderFind(gwins[i]->border->group_border_name);
|
|
|
|
else
|
|
|
|
b = gwins[i]->normal_border;
|
2003-05-22 12:15:03 -07:00
|
|
|
|
2008-11-22 13:16:55 -08:00
|
|
|
EwinBorderChange(gwins[i], b, 0);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2005-11-05 09:12:53 -08:00
|
|
|
if (group_index < 0)
|
1999-10-02 14:59:10 -07:00
|
|
|
Efree(gwins);
|
|
|
|
}
|
2007-02-28 18:13:35 -08:00
|
|
|
#else
|
|
|
|
|
2020-05-03 00:36:21 -07:00
|
|
|
#define _EwinGroupsShowHide(ewin, group_index, onoff)
|
2007-02-28 18:13:35 -08:00
|
|
|
|
|
|
|
#endif /* USE_GROUP_SHOWHIDE */
|
1999-10-02 14:59:10 -07:00
|
|
|
|
|
|
|
void
|
2008-10-18 09:13:54 -07:00
|
|
|
GroupsSave(void)
|
1999-10-02 14:59:10 -07:00
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
Group *g;
|
2004-12-28 15:46:49 -08:00
|
|
|
FILE *f;
|
|
|
|
char s[1024];
|
1999-10-02 14:59:10 -07:00
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
if (LIST_IS_EMPTY(&group_list))
|
2004-12-28 15:46:49 -08:00
|
|
|
return;
|
|
|
|
|
|
|
|
Esnprintf(s, sizeof(s), "%s.groups", EGetSavePrefix());
|
|
|
|
f = fopen(s, "w");
|
|
|
|
if (!f)
|
2006-02-18 00:30:09 -08:00
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_FOR_EACH(Group, &group_list, g)
|
2006-02-18 00:30:09 -08:00
|
|
|
{
|
2008-10-18 09:16:47 -07:00
|
|
|
if (!g->save)
|
2006-02-18 00:30:09 -08:00
|
|
|
continue;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
fprintf(f, "NEW: %i\n", g->index);
|
|
|
|
fprintf(f, "ICONIFY: %i\n", g->cfg.iconify);
|
|
|
|
fprintf(f, "KILL: %i\n", g->cfg.kill);
|
|
|
|
fprintf(f, "MOVE: %i\n", g->cfg.move);
|
|
|
|
fprintf(f, "RAISE: %i\n", g->cfg.raise);
|
|
|
|
fprintf(f, "SET_BORDER: %i\n", g->cfg.set_border);
|
|
|
|
fprintf(f, "STICK: %i\n", g->cfg.stick);
|
|
|
|
fprintf(f, "SHADE: %i\n", g->cfg.shade);
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
fclose(f);
|
1999-10-02 14:59:10 -07:00
|
|
|
}
|
|
|
|
|
2010-04-02 08:28:20 -07:00
|
|
|
static int
|
|
|
|
_GroupsLoad(FILE * fs)
|
1999-10-02 14:59:10 -07:00
|
|
|
{
|
|
|
|
char s[1024];
|
2004-12-28 15:46:49 -08:00
|
|
|
Group *g = NULL;
|
1999-10-02 14:59:10 -07:00
|
|
|
|
2010-04-02 08:28:20 -07:00
|
|
|
while (fgets(s, sizeof(s), fs))
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2007-02-25 20:16:29 -08:00
|
|
|
char ss[128];
|
|
|
|
int ii;
|
2003-05-22 12:15:03 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if (strlen(s) > 0)
|
|
|
|
s[strlen(s) - 1] = 0;
|
2007-02-25 20:16:29 -08:00
|
|
|
ii = 0;
|
|
|
|
sscanf(s, "%100s %d", ss, &ii);
|
2003-05-22 12:15:03 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!strcmp(ss, "NEW:"))
|
|
|
|
{
|
2020-05-03 00:36:21 -07:00
|
|
|
g = _GroupCreate(ii);
|
2007-02-25 20:16:29 -08:00
|
|
|
continue;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2007-02-25 20:16:29 -08:00
|
|
|
if (!g)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!strcmp(ss, "ICONIFY:"))
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2007-02-25 20:16:29 -08:00
|
|
|
g->cfg.iconify = ii;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(ss, "KILL:"))
|
|
|
|
{
|
2007-02-25 20:16:29 -08:00
|
|
|
g->cfg.kill = ii;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(ss, "MOVE:"))
|
|
|
|
{
|
2007-02-25 20:16:29 -08:00
|
|
|
g->cfg.move = ii;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(ss, "RAISE:"))
|
|
|
|
{
|
2007-02-25 20:16:29 -08:00
|
|
|
g->cfg.raise = ii;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(ss, "SET_BORDER:"))
|
|
|
|
{
|
2007-02-25 20:16:29 -08:00
|
|
|
g->cfg.set_border = ii;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(ss, "STICK:"))
|
|
|
|
{
|
2007-02-25 20:16:29 -08:00
|
|
|
g->cfg.stick = ii;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(ss, "SHADE:"))
|
|
|
|
{
|
2007-02-25 20:16:29 -08:00
|
|
|
g->cfg.shade = ii;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2010-04-02 08:28:20 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GroupsLoad(void)
|
|
|
|
{
|
|
|
|
char s[4096];
|
|
|
|
|
|
|
|
Esnprintf(s, sizeof(s), "%s.groups", EGetSavePrefix());
|
|
|
|
|
|
|
|
ConfigFileLoad(s, NULL, _GroupsLoad, 0);
|
1999-10-02 14:59:10 -07:00
|
|
|
}
|
1999-08-20 05:23:26 -07:00
|
|
|
|
2009-01-24 00:31:50 -08:00
|
|
|
#if ENABLE_DIALOGS
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
#define GROUP_OP_ADD 1
|
|
|
|
#define GROUP_OP_DEL 2
|
|
|
|
#define GROUP_OP_BREAK 3
|
|
|
|
|
2009-11-08 09:23:29 -08:00
|
|
|
typedef struct {
|
|
|
|
EWin *ewin;
|
|
|
|
int action;
|
|
|
|
const char *message;
|
|
|
|
Group **groups;
|
|
|
|
int group_num;
|
|
|
|
int cur_grp; /* Current group */
|
|
|
|
int prv_grp; /* Previous group */
|
|
|
|
} GroupSelDlgData;
|
1999-08-20 05:23:26 -07:00
|
|
|
|
1999-10-02 14:59:10 -07:00
|
|
|
static void
|
2014-04-25 11:20:20 -07:00
|
|
|
_DlgApplyGroupChoose(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
|
1999-10-02 14:59:10 -07:00
|
|
|
{
|
2009-11-08 09:23:29 -08:00
|
|
|
GroupSelDlgData *dd = DLG_DATA_GET(d, GroupSelDlgData);
|
|
|
|
|
2014-04-25 11:20:20 -07:00
|
|
|
if (!dd->groups)
|
|
|
|
return;
|
2009-11-08 09:23:29 -08:00
|
|
|
|
2014-04-25 11:20:20 -07:00
|
|
|
switch (dd->action)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2014-04-25 11:20:20 -07:00
|
|
|
case GROUP_OP_ADD:
|
2020-05-03 00:36:21 -07:00
|
|
|
_GroupEwinAdd(dd->groups[dd->cur_grp], dd->ewin);
|
2014-04-25 11:20:20 -07:00
|
|
|
break;
|
|
|
|
case GROUP_OP_DEL:
|
2020-05-03 00:36:21 -07:00
|
|
|
_GroupEwinRemove(dd->groups[dd->cur_grp], dd->ewin);
|
2014-04-25 11:20:20 -07:00
|
|
|
break;
|
|
|
|
case GROUP_OP_BREAK:
|
2020-05-03 10:42:03 -07:00
|
|
|
_GroupDelete(dd->groups[dd->cur_grp]);
|
2014-04-25 11:20:20 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2009-11-08 09:23:29 -08:00
|
|
|
|
2014-04-25 11:20:20 -07:00
|
|
|
GroupsSave();
|
|
|
|
}
|
2007-02-26 19:52:46 -08:00
|
|
|
|
2014-04-25 11:20:20 -07:00
|
|
|
static void
|
|
|
|
_DlgExitGroupChoose(Dialog * d)
|
|
|
|
{
|
|
|
|
GroupSelDlgData *dd = DLG_DATA_GET(d, GroupSelDlgData);
|
|
|
|
|
|
|
|
if (!dd->groups)
|
|
|
|
return;
|
2020-05-03 00:36:21 -07:00
|
|
|
_EwinGroupsShowHide(dd->ewin, dd->cur_grp, SET_OFF);
|
2014-04-25 11:20:20 -07:00
|
|
|
Efree(dd->groups);
|
1999-10-02 14:59:10 -07:00
|
|
|
}
|
|
|
|
|
2004-06-06 09:38:17 -07:00
|
|
|
static void
|
2020-05-03 00:36:21 -07:00
|
|
|
_DlgSelectCbGroupChoose(Dialog * d, int val, void *data __UNUSED__)
|
1999-10-02 14:59:10 -07:00
|
|
|
{
|
2009-11-08 09:23:29 -08:00
|
|
|
GroupSelDlgData *dd = DLG_DATA_GET(d, GroupSelDlgData);
|
|
|
|
|
|
|
|
/* val is equal to dd->cur_grp */
|
2020-05-03 00:36:21 -07:00
|
|
|
_EwinGroupsShowHide(dd->ewin, dd->prv_grp, SET_OFF);
|
|
|
|
_EwinGroupsShowHide(dd->ewin, val, SET_ON);
|
2009-11-08 09:23:29 -08:00
|
|
|
dd->prv_grp = val;
|
1999-10-02 14:59:10 -07:00
|
|
|
}
|
|
|
|
|
2005-10-30 11:40:49 -08:00
|
|
|
static void
|
2006-07-26 21:52:50 -07:00
|
|
|
_DlgFillGroupChoose(Dialog * d, DItem * table, void *data)
|
1999-10-02 14:59:10 -07:00
|
|
|
{
|
2014-04-25 14:07:58 -07:00
|
|
|
GroupSelDlgData *dd = DLG_DATA_GET(d, GroupSelDlgData);
|
2006-07-26 21:52:50 -07:00
|
|
|
DItem *di, *radio;
|
1999-10-02 14:59:10 -07:00
|
|
|
int i, num_groups;
|
|
|
|
char **group_member_strings;
|
2009-11-08 09:23:29 -08:00
|
|
|
|
|
|
|
*dd = *(GroupSelDlgData *) data;
|
2006-07-26 21:52:50 -07:00
|
|
|
|
|
|
|
DialogItemTableSetOptions(table, 2, 0, 0, 0);
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_TEXT);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
|
|
|
DialogItemSetAlign(di, 0, 512);
|
2009-11-08 09:23:29 -08:00
|
|
|
DialogItemSetText(di, dd->message);
|
2006-07-26 21:52:50 -07:00
|
|
|
|
2009-11-08 09:23:29 -08:00
|
|
|
num_groups = dd->group_num;
|
2020-05-03 00:36:21 -07:00
|
|
|
group_member_strings = _GrouplistMemberNames(dd->groups, num_groups);
|
2012-12-24 02:41:50 -08:00
|
|
|
if (!group_member_strings)
|
|
|
|
return; /* Silence clang - It should not be possible to go here */
|
2006-07-26 21:52:50 -07:00
|
|
|
|
2009-11-08 09:23:29 -08:00
|
|
|
radio = NULL; /* Avoid warning */
|
|
|
|
for (i = 0; i < num_groups; i++)
|
2006-07-26 21:52:50 -07:00
|
|
|
{
|
|
|
|
di = DialogAddItem(table, DITEM_RADIOBUTTON);
|
2009-11-08 09:23:29 -08:00
|
|
|
if (i == 0)
|
|
|
|
radio = di;
|
2006-07-26 21:52:50 -07:00
|
|
|
DialogItemSetColSpan(di, 2);
|
2020-05-03 00:36:21 -07:00
|
|
|
DialogItemSetCallback(di, _DlgSelectCbGroupChoose, i, NULL);
|
2006-07-26 21:52:50 -07:00
|
|
|
DialogItemSetText(di, group_member_strings[i]);
|
|
|
|
DialogItemRadioButtonSetFirst(di, radio);
|
|
|
|
DialogItemRadioButtonGroupSetVal(di, i);
|
|
|
|
}
|
2009-11-08 09:23:29 -08:00
|
|
|
DialogItemRadioButtonGroupSetValPtr(radio, &dd->cur_grp);
|
2006-07-26 21:52:50 -07:00
|
|
|
|
|
|
|
StrlistFree(group_member_strings, num_groups);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const DialogDef DlgGroupChoose = {
|
|
|
|
"GROUP_SELECTION",
|
2014-04-25 14:07:58 -07:00
|
|
|
NULL, N_("Window Group Selection"),
|
|
|
|
sizeof(GroupSelDlgData),
|
2008-12-14 08:44:45 -08:00
|
|
|
SOUND_SETTINGS_GROUP,
|
2006-07-26 21:52:50 -07:00
|
|
|
"pix/group.png",
|
2010-05-09 12:03:19 -07:00
|
|
|
N_("Enlightenment Window Group\n" "Selection Dialog"),
|
2006-08-07 20:58:42 -07:00
|
|
|
_DlgFillGroupChoose,
|
2014-04-25 11:20:20 -07:00
|
|
|
DLG_OC, _DlgApplyGroupChoose, _DlgExitGroupChoose
|
2006-07-26 21:52:50 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2020-05-03 00:58:10 -07:00
|
|
|
_EwinGroupChooseDialog(EWin * ewin, int action)
|
2006-07-26 21:52:50 -07:00
|
|
|
{
|
2009-11-08 09:23:29 -08:00
|
|
|
int group_sel;
|
|
|
|
GroupSelDlgData gsdd, *dd = &gsdd;
|
1999-10-02 14:59:10 -07:00
|
|
|
|
2020-05-03 00:58:10 -07:00
|
|
|
if (!ewin)
|
1999-10-02 14:59:10 -07:00
|
|
|
return;
|
2020-05-03 00:58:10 -07:00
|
|
|
dd->ewin = ewin;
|
1999-10-02 14:59:10 -07:00
|
|
|
|
2009-11-08 09:23:29 -08:00
|
|
|
dd->action = action;
|
|
|
|
dd->cur_grp = dd->prv_grp = 0;
|
1999-10-02 14:59:10 -07:00
|
|
|
|
2009-11-08 09:23:29 -08:00
|
|
|
switch (action)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2009-11-08 09:23:29 -08:00
|
|
|
default:
|
2003-05-22 12:15:03 -07:00
|
|
|
return;
|
2009-11-08 09:23:29 -08:00
|
|
|
case GROUP_OP_ADD:
|
|
|
|
dd->message = _("Pick the group the window will belong to:");
|
|
|
|
group_sel = GROUP_SELECT_ALL_EXCEPT_EWIN;
|
|
|
|
break;
|
|
|
|
case GROUP_OP_DEL:
|
|
|
|
dd->message = _("Select the group to remove the window from:");
|
|
|
|
group_sel = GROUP_SELECT_EWIN_ONLY;
|
|
|
|
break;
|
|
|
|
case GROUP_OP_BREAK:
|
|
|
|
dd->message = _("Select the group to break:");
|
|
|
|
group_sel = GROUP_SELECT_EWIN_ONLY;
|
|
|
|
break;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2009-11-08 09:23:29 -08:00
|
|
|
|
2020-05-03 00:36:21 -07:00
|
|
|
dd->groups = _EwinListGroups(dd->ewin, group_sel, &dd->group_num);
|
2009-11-08 09:23:29 -08:00
|
|
|
|
|
|
|
if (!dd->groups)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2009-11-08 09:23:29 -08:00
|
|
|
if (action == GROUP_OP_BREAK || action == GROUP_OP_DEL)
|
|
|
|
{
|
|
|
|
DialogOK(_("Window Group Error"),
|
|
|
|
_
|
|
|
|
("This window currently does not belong to any groups.\n"
|
|
|
|
"You can only destroy groups or remove windows from groups\n"
|
|
|
|
"through a window that actually belongs to at least one group."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (group_sel == GROUP_SELECT_ALL_EXCEPT_EWIN)
|
|
|
|
{
|
|
|
|
DialogOK(_("Window Group Error"),
|
|
|
|
_("Currently, no groups exist or this window\n"
|
|
|
|
"already belongs to all existing groups.\n"
|
|
|
|
"You have to start other groups first."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-01-03 04:21:52 -08:00
|
|
|
DialogOK(_("Window Group Error"),
|
|
|
|
_
|
2010-05-09 12:03:19 -07:00
|
|
|
("Currently, no groups exist. You have to start a group first."));
|
2003-05-22 12:15:03 -07:00
|
|
|
return;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-20 05:23:26 -07:00
|
|
|
|
2020-05-03 00:36:21 -07:00
|
|
|
_EwinGroupsShowHide(dd->ewin, 0, SET_ON);
|
1999-09-08 17:39:43 -07:00
|
|
|
|
2009-11-08 09:23:29 -08:00
|
|
|
DialogShowSimple(&DlgGroupChoose, dd);
|
1999-10-02 14:59:10 -07:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2008-03-23 04:54:24 -07:00
|
|
|
typedef struct {
|
2005-11-05 09:12:53 -08:00
|
|
|
EWin *ewin;
|
|
|
|
GroupConfig cfg; /* Dialog data for current group */
|
|
|
|
GroupConfig *cfgs; /* Work copy of ewin group cfgs */
|
|
|
|
int ngrp;
|
2009-11-08 09:23:29 -08:00
|
|
|
int cur_grp; /* Current group */
|
|
|
|
int prv_grp; /* Previous group */
|
2005-11-05 09:12:53 -08:00
|
|
|
} EwinGroupDlgData;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
static void
|
2014-04-25 11:20:20 -07:00
|
|
|
_DlgApplyGroups(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-05 10:45:58 -08:00
|
|
|
EwinGroupDlgData *dd = DLG_DATA_GET(d, EwinGroupDlgData);
|
2005-11-05 09:12:53 -08:00
|
|
|
EWin *ewin;
|
2004-12-28 15:46:49 -08:00
|
|
|
int i;
|
|
|
|
|
2005-11-05 09:12:53 -08:00
|
|
|
/* Check ewin */
|
|
|
|
ewin = EwinFindByPtr(dd->ewin);
|
|
|
|
if (ewin && ewin->num_groups != dd->ngrp)
|
|
|
|
ewin = NULL;
|
|
|
|
|
2014-04-25 11:20:20 -07:00
|
|
|
if (ewin)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-08 09:23:29 -08:00
|
|
|
dd->cfgs[dd->cur_grp] = dd->cfg;
|
2005-11-05 09:12:53 -08:00
|
|
|
for (i = 0; i < ewin->num_groups; i++)
|
2009-11-08 09:23:29 -08:00
|
|
|
ewin->groups[i]->cfg = dd->cfgs[i];
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
2014-04-25 11:20:20 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
autosave();
|
|
|
|
}
|
|
|
|
|
2014-04-25 11:20:20 -07:00
|
|
|
static void
|
|
|
|
_DlgExitGroups(Dialog * d)
|
|
|
|
{
|
|
|
|
EwinGroupDlgData *dd = DLG_DATA_GET(d, EwinGroupDlgData);
|
|
|
|
EWin *ewin;
|
|
|
|
|
|
|
|
ewin = EwinFindByPtr(dd->ewin);
|
2020-05-03 00:36:21 -07:00
|
|
|
_EwinGroupsShowHide(ewin, dd->cur_grp, SET_OFF);
|
2014-04-25 11:20:20 -07:00
|
|
|
|
|
|
|
Efree(dd->cfgs);
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
2020-05-03 00:36:21 -07:00
|
|
|
_DlgSelectCbGroups(Dialog * d, int val, void *data __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-05 10:45:58 -08:00
|
|
|
EwinGroupDlgData *dd = DLG_DATA_GET(d, EwinGroupDlgData);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-08 09:23:29 -08:00
|
|
|
/* val is equal to dd->cur_grp */
|
|
|
|
dd->cfgs[dd->prv_grp] = dd->cfg;
|
|
|
|
dd->cfg = dd->cfgs[val];
|
2005-11-05 09:12:53 -08:00
|
|
|
DialogRedraw(d);
|
2020-05-03 00:36:21 -07:00
|
|
|
_EwinGroupsShowHide(dd->ewin, dd->prv_grp, SET_OFF);
|
|
|
|
_EwinGroupsShowHide(dd->ewin, val, SET_ON);
|
2009-11-08 09:23:29 -08:00
|
|
|
dd->prv_grp = val;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-07-20 20:17:18 -07:00
|
|
|
_DlgFillGroups(Dialog * d, DItem * table, void *data)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2014-04-25 14:07:58 -07:00
|
|
|
EwinGroupDlgData *dd = DLG_DATA_GET(d, EwinGroupDlgData);
|
2007-01-16 17:10:44 -08:00
|
|
|
EWin *ewin = (EWin *) data;
|
2006-07-20 20:17:18 -07:00
|
|
|
DItem *radio, *di;
|
2004-12-28 15:46:49 -08:00
|
|
|
int i;
|
|
|
|
char **group_member_strings;
|
|
|
|
|
2005-11-05 09:12:53 -08:00
|
|
|
dd->ewin = ewin;
|
2007-01-16 17:10:44 -08:00
|
|
|
dd->cfgs = EMALLOC(GroupConfig, ewin->num_groups);
|
2005-11-05 09:12:53 -08:00
|
|
|
dd->ngrp = ewin->num_groups;
|
2009-11-08 09:23:29 -08:00
|
|
|
dd->cur_grp = dd->prv_grp = 0;
|
2004-12-28 15:46:49 -08:00
|
|
|
for (i = 0; i < ewin->num_groups; i++)
|
2009-11-08 09:23:29 -08:00
|
|
|
dd->cfgs[i] = ewin->groups[i]->cfg;
|
|
|
|
dd->cfg = dd->cfgs[0];
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2020-05-03 00:36:21 -07:00
|
|
|
_EwinGroupsShowHide(ewin, 0, SET_ON);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
DialogItemTableSetOptions(table, 2, 0, 0, 0);
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_TEXT);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
|
|
|
DialogItemSetAlign(di, 0, 512);
|
2010-05-09 12:03:19 -07:00
|
|
|
DialogItemSetText(di, _("Pick the group to configure:"));
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2020-05-03 00:36:21 -07:00
|
|
|
group_member_strings = _GrouplistMemberNames(ewin->groups, ewin->num_groups);
|
2012-12-24 02:41:50 -08:00
|
|
|
if (!group_member_strings)
|
|
|
|
return; /* Silence clang - It should not be possible to go here */
|
2005-11-05 09:12:53 -08:00
|
|
|
|
2009-11-08 09:23:29 -08:00
|
|
|
radio = NULL; /* Avoid warning */
|
|
|
|
for (i = 0; i < ewin->num_groups; i++)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
di = DialogAddItem(table, DITEM_RADIOBUTTON);
|
2009-11-08 09:23:29 -08:00
|
|
|
if (i == 0)
|
|
|
|
radio = di;
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetColSpan(di, 2);
|
2020-05-03 00:36:21 -07:00
|
|
|
DialogItemSetCallback(di, _DlgSelectCbGroups, i, d);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, group_member_strings[i]);
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemRadioButtonSetFirst(di, radio);
|
|
|
|
DialogItemRadioButtonGroupSetVal(di, i);
|
|
|
|
}
|
2009-11-08 09:23:29 -08:00
|
|
|
DialogItemRadioButtonGroupSetValPtr(radio, &dd->cur_grp);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-11-05 09:12:53 -08:00
|
|
|
StrlistFree(group_member_strings, ewin->num_groups);
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
di = DialogAddItem(table, DITEM_SEPARATOR);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_TEXT);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
|
|
|
DialogItemSetAlign(di, 0, 512);
|
2010-05-09 12:03:19 -07:00
|
|
|
DialogItemSetText(di, _("The following actions are\n"
|
|
|
|
"applied to all group members:"));
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-11-05 09:12:53 -08:00
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Changing Border Style"));
|
2005-11-05 09:12:53 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &(dd->cfg.set_border));
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-11-05 09:12:53 -08:00
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Iconifying"));
|
2005-11-05 09:12:53 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &(dd->cfg.iconify));
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-11-05 09:12:53 -08:00
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Killing"));
|
2005-11-05 09:12:53 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &(dd->cfg.kill));
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-11-05 09:12:53 -08:00
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Moving"));
|
2005-11-05 09:12:53 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &(dd->cfg.move));
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-11-05 09:12:53 -08:00
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Raising/Lowering"));
|
2005-11-05 09:12:53 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &(dd->cfg.raise));
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-11-05 09:12:53 -08:00
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Sticking"));
|
2005-11-05 09:12:53 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &(dd->cfg.stick));
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-11-05 09:12:53 -08:00
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Shading"));
|
2005-11-05 09:12:53 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &(dd->cfg.shade));
|
2006-07-20 20:17:18 -07:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-07-20 20:17:18 -07:00
|
|
|
static const DialogDef DlgGroups = {
|
|
|
|
"CONFIGURE_GROUP",
|
2014-04-25 14:07:58 -07:00
|
|
|
NULL, N_("Window Group Settings"),
|
|
|
|
sizeof(EwinGroupDlgData),
|
2008-12-14 08:44:45 -08:00
|
|
|
SOUND_SETTINGS_GROUP,
|
2006-07-26 21:52:50 -07:00
|
|
|
"pix/group.png",
|
2010-05-09 12:03:19 -07:00
|
|
|
N_("Enlightenment Window Group\n" "Settings Dialog"),
|
2006-08-07 20:58:42 -07:00
|
|
|
_DlgFillGroups,
|
2014-04-25 11:20:20 -07:00
|
|
|
DLG_OAC, _DlgApplyGroups, _DlgExitGroups
|
2006-07-20 20:17:18 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2020-05-03 00:58:10 -07:00
|
|
|
_EwinGroupsConfig(EWin * ewin)
|
2006-07-20 20:17:18 -07:00
|
|
|
{
|
|
|
|
if (!ewin)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ewin->num_groups == 0)
|
|
|
|
{
|
|
|
|
DialogOK(_("Window Group Error"),
|
2010-05-09 12:03:19 -07:00
|
|
|
_("This window currently does not belong to any groups."));
|
2006-07-20 20:17:18 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DialogShowSimple(&DlgGroups, ewin);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2009-11-08 09:23:29 -08:00
|
|
|
typedef struct {
|
|
|
|
GroupConfig group_cfg;
|
|
|
|
char group_swap;
|
|
|
|
} GroupCfgDlgData;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
2014-04-25 11:20:20 -07:00
|
|
|
_DlgApplyGroupDefaults(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-08 09:23:29 -08:00
|
|
|
GroupCfgDlgData *dd = DLG_DATA_GET(d, GroupCfgDlgData);
|
|
|
|
|
|
|
|
Conf_groups.dflt = dd->group_cfg;
|
|
|
|
Conf_groups.swapmove = dd->group_swap;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
autosave();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-11-08 09:23:29 -08:00
|
|
|
_DlgFillGroupDefaults(Dialog * d, DItem * table, void *data __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2014-04-25 14:07:58 -07:00
|
|
|
GroupCfgDlgData *dd = DLG_DATA_GET(d, GroupCfgDlgData);
|
2006-07-20 20:17:18 -07:00
|
|
|
DItem *di;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-08 09:23:29 -08:00
|
|
|
dd->group_cfg = Conf_groups.dflt;
|
|
|
|
dd->group_swap = Conf_groups.swapmove;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
DialogItemTableSetOptions(table, 2, 0, 0, 0);
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_TEXT);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
|
|
|
DialogItemSetAlign(di, 0, 512);
|
2010-05-09 12:03:19 -07:00
|
|
|
DialogItemSetText(di, _("Per-group settings:"));
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_SEPARATOR);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Changing Border Style"));
|
2009-11-08 09:23:29 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &dd->group_cfg.set_border);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Iconifying"));
|
2009-11-08 09:23:29 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &dd->group_cfg.iconify);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Killing"));
|
2009-11-08 09:23:29 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &dd->group_cfg.kill);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Moving"));
|
2009-11-08 09:23:29 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &dd->group_cfg.move);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Raising/Lowering"));
|
2009-11-08 09:23:29 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &dd->group_cfg.raise);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Sticking"));
|
2009-11-08 09:23:29 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &dd->group_cfg.stick);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Shading"));
|
2009-11-08 09:23:29 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &dd->group_cfg.shade);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_SEPARATOR);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_TEXT);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
|
|
|
DialogItemSetAlign(di, 0, 512);
|
2010-05-09 12:03:19 -07:00
|
|
|
DialogItemSetText(di, _("Global settings:"));
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Swap Window Locations"));
|
2009-11-08 09:23:29 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &dd->group_swap);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2006-07-20 20:17:18 -07:00
|
|
|
const DialogDef DlgGroupDefaults = {
|
|
|
|
"CONFIGURE_DEFAULT_GROUP_CONTROL",
|
2014-04-25 14:07:58 -07:00
|
|
|
N_("Groups"), N_("Default Group Control Settings"),
|
|
|
|
sizeof(GroupCfgDlgData),
|
2008-12-14 08:44:45 -08:00
|
|
|
SOUND_SETTINGS_GROUP,
|
2006-07-26 21:52:50 -07:00
|
|
|
"pix/group.png",
|
2010-05-09 12:03:19 -07:00
|
|
|
N_("Enlightenment Default\n" "Group Control Settings Dialog"),
|
2006-08-07 20:58:42 -07:00
|
|
|
_DlgFillGroupDefaults,
|
2014-04-25 11:20:20 -07:00
|
|
|
DLG_OAC, _DlgApplyGroupDefaults, NULL
|
2006-07-20 20:17:18 -07:00
|
|
|
};
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
2020-05-03 00:36:21 -07:00
|
|
|
_GroupsConfigure(const char *params)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
char s[128];
|
|
|
|
const char *p;
|
|
|
|
int l;
|
2020-05-03 00:58:10 -07:00
|
|
|
EWin *ewin;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
p = params;
|
|
|
|
l = 0;
|
|
|
|
s[0] = '\0';
|
|
|
|
sscanf(p, "%100s %n", s, &l);
|
2020-05-03 00:58:10 -07:00
|
|
|
p += l;
|
|
|
|
|
|
|
|
ewin = GetContextEwin();
|
|
|
|
if (*p)
|
|
|
|
{
|
|
|
|
ewin = EwinFindByExpr(p);
|
|
|
|
if (!ewin)
|
|
|
|
{
|
|
|
|
IpcPrintf("Error: no such window: %s\n", p);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
if (!strcmp(s, "group"))
|
|
|
|
{
|
2020-05-03 00:58:10 -07:00
|
|
|
_EwinGroupsConfig(ewin);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
2007-02-26 19:52:46 -08:00
|
|
|
else if (!strcmp(s, "add"))
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2020-05-03 00:58:10 -07:00
|
|
|
_EwinGroupChooseDialog(ewin, GROUP_OP_ADD);
|
2007-02-26 19:52:46 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(s, "del"))
|
|
|
|
{
|
2020-05-03 00:58:10 -07:00
|
|
|
_EwinGroupChooseDialog(ewin, GROUP_OP_DEL);
|
2007-02-26 19:52:46 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(s, "break"))
|
|
|
|
{
|
2020-05-03 00:58:10 -07:00
|
|
|
_EwinGroupChooseDialog(ewin, GROUP_OP_BREAK);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
}
|
2009-01-24 00:31:50 -08:00
|
|
|
#endif /* ENABLE_DIALOGS */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Groups module
|
|
|
|
*/
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
static void
|
2020-05-03 00:36:21 -07:00
|
|
|
_GroupShow(Group * g)
|
2006-02-18 00:30:09 -08:00
|
|
|
{
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 0; j < g->num_members; j++)
|
2006-11-26 04:42:05 -08:00
|
|
|
IpcPrintf("%d: %s\n", g->index, EwinGetIcccmName(g->members[j]));
|
2006-02-18 00:30:09 -08:00
|
|
|
|
|
|
|
IpcPrintf(" index: %d\n" " num_members: %d\n"
|
|
|
|
" iconify: %d\n" " kill: %d\n"
|
|
|
|
" move: %d\n" " raise: %d\n"
|
|
|
|
" set_border: %d\n" " stick: %d\n"
|
2009-03-21 02:53:08 -07:00
|
|
|
" shade: %d\n",
|
2006-02-18 00:30:09 -08:00
|
|
|
g->index, g->num_members,
|
|
|
|
g->cfg.iconify, g->cfg.kill,
|
|
|
|
g->cfg.move, g->cfg.raise,
|
2009-03-21 02:53:08 -07:00
|
|
|
g->cfg.set_border, g->cfg.stick, g->cfg.shade);
|
2006-02-18 00:30:09 -08:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
2007-05-18 01:25:06 -07:00
|
|
|
IPC_GroupOps(const char *params)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2010-01-29 11:45:04 -08:00
|
|
|
Group *group;
|
2007-02-25 20:16:29 -08:00
|
|
|
char windowid[128];
|
|
|
|
char operation[128];
|
|
|
|
char groupid[128];
|
2004-12-28 15:46:49 -08:00
|
|
|
unsigned int win;
|
|
|
|
EWin *ewin;
|
|
|
|
|
|
|
|
if (!params)
|
|
|
|
{
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("Error: no window specified\n");
|
2004-12-28 15:46:49 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-02-25 20:16:29 -08:00
|
|
|
windowid[0] = operation[0] = groupid[0] = '\0';
|
|
|
|
sscanf(params, "%100s %100s %100s", windowid, operation, groupid);
|
|
|
|
win = 0;
|
2004-12-28 15:46:49 -08:00
|
|
|
sscanf(windowid, "%x", &win);
|
|
|
|
|
|
|
|
if (!operation[0])
|
|
|
|
{
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("Error: no operation specified\n");
|
2004-12-28 15:46:49 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-04 15:35:02 -08:00
|
|
|
ewin = EwinFindByExpr(windowid);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!ewin)
|
|
|
|
{
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("Error: no such window: %s\n", windowid);
|
2004-12-28 15:46:49 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(operation, "start"))
|
|
|
|
{
|
2020-05-03 00:36:21 -07:00
|
|
|
group = _GroupCreate(-1);
|
2020-05-03 00:02:06 -07:00
|
|
|
Mode_groups.current = group;
|
2020-05-03 00:36:21 -07:00
|
|
|
_GroupEwinAdd(group, ewin);
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("start %8x\n", win);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(operation, "add"))
|
|
|
|
{
|
2020-05-03 00:36:21 -07:00
|
|
|
group = _GroupFind2(groupid);
|
|
|
|
_GroupEwinAdd(group, ewin);
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("add %8x\n", win);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(operation, "del"))
|
|
|
|
{
|
2020-05-03 00:36:21 -07:00
|
|
|
group = _GroupFind2(groupid);
|
|
|
|
_GroupEwinRemove(group, ewin);
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("del %8x\n", win);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(operation, "break"))
|
|
|
|
{
|
2020-05-03 00:36:21 -07:00
|
|
|
group = _GroupFind2(groupid);
|
2020-05-03 10:42:03 -07:00
|
|
|
_GroupDelete(group);
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("break %8x\n", win);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(operation, "showhide"))
|
|
|
|
{
|
2020-05-03 00:36:21 -07:00
|
|
|
_EwinGroupsShowHide(ewin, -1, SET_TOGGLE);
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("showhide %8x\n", win);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("Error: no such operation: %s\n", operation);
|
2004-12-28 15:46:49 -08:00
|
|
|
return;
|
|
|
|
}
|
2008-10-18 09:13:54 -07:00
|
|
|
GroupsSave();
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-05-18 01:25:06 -07:00
|
|
|
IPC_Group(const char *params)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2007-02-25 20:16:29 -08:00
|
|
|
char groupid[128];
|
|
|
|
char operation[128];
|
|
|
|
char param1[128];
|
2004-12-28 15:46:49 -08:00
|
|
|
Group *group;
|
2007-02-25 20:16:29 -08:00
|
|
|
int onoff;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
if (!params)
|
|
|
|
{
|
2020-05-03 08:34:21 -07:00
|
|
|
IpcPrintf("Error: no operation specified\n");
|
2004-12-28 15:46:49 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-02-25 20:16:29 -08:00
|
|
|
groupid[0] = operation[0] = param1[0] = '\0';
|
|
|
|
sscanf(params, "%100s %100s %100s", groupid, operation, param1);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2020-05-03 08:34:21 -07:00
|
|
|
if (!strcmp(groupid, "info"))
|
|
|
|
{
|
|
|
|
IpcPrintf("Number of groups: %d\n", LIST_GET_COUNT(&group_list));
|
|
|
|
LIST_FOR_EACH(Group, &group_list, group) _GroupShow(group);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!operation[0])
|
|
|
|
{
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("Error: no operation specified\n");
|
2004-12-28 15:46:49 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-03 00:36:21 -07:00
|
|
|
group = _GroupFind2(groupid);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!group)
|
|
|
|
{
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("Error: no such group: %s\n", groupid);
|
2004-12-28 15:46:49 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-03 08:34:21 -07:00
|
|
|
if (!strcmp(operation, "info"))
|
|
|
|
{
|
|
|
|
_GroupShow(group);
|
|
|
|
return;
|
|
|
|
}
|
2020-05-03 23:13:22 -07:00
|
|
|
else if (!strcmp(operation, "del"))
|
|
|
|
{
|
|
|
|
_GroupDelete(group);
|
|
|
|
return;
|
|
|
|
}
|
2020-05-03 08:34:21 -07:00
|
|
|
|
2007-02-25 20:16:29 -08:00
|
|
|
if (!param1[0])
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("Error: no mode specified\n");
|
2004-12-28 15:46:49 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-02-25 20:16:29 -08:00
|
|
|
onoff = -1;
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!strcmp(param1, "on"))
|
|
|
|
onoff = 1;
|
|
|
|
else if (!strcmp(param1, "off"))
|
|
|
|
onoff = 0;
|
|
|
|
|
|
|
|
if (onoff == -1 && strcmp(param1, "?"))
|
|
|
|
{
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("Error: unknown mode specified\n");
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(operation, "iconify"))
|
|
|
|
{
|
|
|
|
if (onoff >= 0)
|
|
|
|
group->cfg.iconify = onoff;
|
|
|
|
else
|
|
|
|
onoff = group->cfg.iconify;
|
|
|
|
}
|
|
|
|
else if (!strcmp(operation, "kill"))
|
|
|
|
{
|
|
|
|
if (onoff >= 0)
|
|
|
|
group->cfg.kill = onoff;
|
|
|
|
else
|
|
|
|
onoff = group->cfg.kill;
|
|
|
|
}
|
|
|
|
else if (!strcmp(operation, "move"))
|
|
|
|
{
|
|
|
|
if (onoff >= 0)
|
|
|
|
group->cfg.move = onoff;
|
|
|
|
else
|
|
|
|
onoff = group->cfg.move;
|
|
|
|
}
|
|
|
|
else if (!strcmp(operation, "raise"))
|
|
|
|
{
|
|
|
|
if (onoff >= 0)
|
|
|
|
group->cfg.raise = onoff;
|
|
|
|
else
|
|
|
|
onoff = group->cfg.raise;
|
|
|
|
}
|
|
|
|
else if (!strcmp(operation, "set_border"))
|
|
|
|
{
|
|
|
|
if (onoff >= 0)
|
|
|
|
group->cfg.set_border = onoff;
|
|
|
|
else
|
|
|
|
onoff = group->cfg.set_border;
|
|
|
|
}
|
|
|
|
else if (!strcmp(operation, "stick"))
|
|
|
|
{
|
|
|
|
if (onoff >= 0)
|
|
|
|
group->cfg.stick = onoff;
|
|
|
|
else
|
|
|
|
onoff = group->cfg.stick;
|
|
|
|
}
|
|
|
|
else if (!strcmp(operation, "shade"))
|
|
|
|
{
|
|
|
|
if (onoff >= 0)
|
|
|
|
group->cfg.shade = onoff;
|
|
|
|
else
|
|
|
|
onoff = group->cfg.shade;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("Error: no such operation: %s\n", operation);
|
2004-12-28 15:46:49 -08:00
|
|
|
onoff = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (onoff == 1)
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("%s: on\n", operation);
|
2004-12-28 15:46:49 -08:00
|
|
|
else if (onoff == 0)
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("%s: off\n", operation);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-05-02 19:28:19 -07:00
|
|
|
IPC_GroupsConfig(const char *params)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
const char *p;
|
2020-05-02 19:28:19 -07:00
|
|
|
char cmd[128];
|
2004-12-28 15:46:49 -08:00
|
|
|
int len;
|
|
|
|
|
2020-05-02 19:28:19 -07:00
|
|
|
cmd[0] = '\0';
|
2004-12-28 15:46:49 -08:00
|
|
|
p = params;
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
len = 0;
|
2020-05-02 19:28:19 -07:00
|
|
|
sscanf(p, "%100s %n", cmd, &len);
|
2004-12-28 15:46:49 -08:00
|
|
|
p += len;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p || cmd[0] == '?')
|
|
|
|
{
|
|
|
|
/* Show groups */
|
|
|
|
}
|
2020-05-02 19:28:19 -07:00
|
|
|
#if ENABLE_DIALOGS
|
|
|
|
else if (!strcmp(cmd, "cfg"))
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2020-05-03 00:36:21 -07:00
|
|
|
_GroupsConfigure(p);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
2020-05-02 19:28:19 -07:00
|
|
|
#endif
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2005-10-30 11:40:49 -08:00
|
|
|
static const IpcItem GroupsIpcArray[] = {
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2020-05-02 19:28:19 -07:00
|
|
|
IPC_GroupsConfig,
|
2004-12-28 15:46:49 -08:00
|
|
|
"groups", "grp",
|
|
|
|
"Configure window groups",
|
2020-05-03 00:58:10 -07:00
|
|
|
" groups cfg group <windowid> Configure windows groups\n"
|
|
|
|
" groups cfg add <windowid> Add window to group\n"
|
|
|
|
" groups cfg del <windowid> Remove window from group\n"
|
|
|
|
" groups cfg break <windowid> Destroy one of the windows groups\n"}
|
2004-12-28 15:46:49 -08:00
|
|
|
,
|
|
|
|
{
|
|
|
|
IPC_GroupOps,
|
|
|
|
"group_op", "gop",
|
|
|
|
"Group operations",
|
|
|
|
"use \"group_op <windowid> <property> [<value>]\" to perform "
|
|
|
|
"group operations on a window.\n" "Available group_op commands are:\n"
|
|
|
|
" group_op <windowid> start\n"
|
|
|
|
" group_op <windowid> add [<group_index>]\n"
|
2005-03-28 04:51:16 -08:00
|
|
|
" group_op <windowid> del [<group_index>]\n"
|
2004-12-28 15:46:49 -08:00
|
|
|
" group_op <windowid> break [<group_index>]\n"
|
|
|
|
" group_op <windowid> showhide\n"}
|
|
|
|
,
|
|
|
|
{
|
|
|
|
IPC_Group,
|
|
|
|
"group", "gc",
|
|
|
|
"Group commands",
|
|
|
|
"use \"group <groupid> <property> <value>\" to set group properties.\n"
|
|
|
|
"Available group commands are:\n"
|
2020-05-03 08:34:21 -07:00
|
|
|
" group info\n"
|
|
|
|
" group <groupid> info\n"
|
2020-05-03 23:13:22 -07:00
|
|
|
" group <groupid> del\n"
|
2004-12-28 15:46:49 -08:00
|
|
|
" group <groupid> iconify <on/off/?>\n"
|
2020-05-03 08:34:21 -07:00
|
|
|
" group <groupid> kill <on/off/?>\n"
|
|
|
|
" group <groupid> move <on/off/?>\n"
|
2004-12-28 15:46:49 -08:00
|
|
|
" group <groupid> raise <on/off/?>\n"
|
|
|
|
" group <groupid> set_border <on/off/?>\n"
|
|
|
|
" group <groupid> stick <on/off/?>\n"
|
2009-03-21 02:53:08 -07:00
|
|
|
" group <groupid> shade <on/off/?>\n"}
|
2004-12-28 15:46:49 -08:00
|
|
|
,
|
|
|
|
};
|
|
|
|
#define N_IPC_FUNCS (sizeof(GroupsIpcArray)/sizeof(IpcItem))
|
|
|
|
|
2005-03-20 15:28:59 -08:00
|
|
|
/*
|
|
|
|
* Configuration items
|
|
|
|
*/
|
|
|
|
static const CfgItem GroupsCfgItems[] = {
|
2005-11-19 07:47:10 -08:00
|
|
|
CFG_ITEM_BOOL(Conf_groups, dflt.iconify, 1),
|
|
|
|
CFG_ITEM_BOOL(Conf_groups, dflt.kill, 0),
|
|
|
|
CFG_ITEM_BOOL(Conf_groups, dflt.move, 1),
|
|
|
|
CFG_ITEM_BOOL(Conf_groups, dflt.raise, 0),
|
|
|
|
CFG_ITEM_BOOL(Conf_groups, dflt.set_border, 1),
|
|
|
|
CFG_ITEM_BOOL(Conf_groups, dflt.stick, 1),
|
|
|
|
CFG_ITEM_BOOL(Conf_groups, dflt.shade, 1),
|
|
|
|
CFG_ITEM_BOOL(Conf_groups, swapmove, 1),
|
2005-03-20 15:28:59 -08:00
|
|
|
};
|
|
|
|
#define N_CFG_ITEMS (sizeof(GroupsCfgItems)/sizeof(CfgItem))
|
|
|
|
|
2007-01-16 17:10:44 -08:00
|
|
|
extern const EModule ModGroups;
|
2010-08-08 12:03:34 -07:00
|
|
|
|
2006-04-21 15:52:59 -07:00
|
|
|
const EModule ModGroups = {
|
2004-12-28 15:46:49 -08:00
|
|
|
"groups", "grp",
|
2008-10-18 09:13:54 -07:00
|
|
|
NULL,
|
2005-03-20 15:28:59 -08:00
|
|
|
{N_IPC_FUNCS, GroupsIpcArray},
|
|
|
|
{N_CFG_ITEMS, GroupsCfgItems}
|
2004-12-28 15:46:49 -08:00
|
|
|
};
|