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
|
2011-01-05 10:05:59 -08:00
|
|
|
* Copyright (C) 2004-2011 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"
|
2006-02-18 00:30:09 -08:00
|
|
|
#include "e16-ecore_list.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"
|
2007-01-16 17:10:44 -08:00
|
|
|
#include "settings.h"
|
2005-02-15 14:19:52 -08:00
|
|
|
#include "snaps.h"
|
2006-04-16 06:27:38 -07:00
|
|
|
#include "timers.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
|
|
|
|
2005-11-05 09:12:53 -08:00
|
|
|
#define SET_OFF 0
|
|
|
|
#define SET_ON 1
|
|
|
|
#define SET_TOGGLE 2
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
static Ecore_List *group_list = NULL;
|
|
|
|
|
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;
|
|
|
|
|
2008-10-18 09:10:11 -07:00
|
|
|
static void AddEwinToGroup(EWin * ewin, Group * g);
|
2005-10-30 11:40:49 -08:00
|
|
|
static void RemoveEwinFromGroup(EWin * ewin, Group * g);
|
|
|
|
|
2005-11-19 07:47:10 -08:00
|
|
|
int
|
|
|
|
GroupsGetSwapmove(void)
|
|
|
|
{
|
|
|
|
return Conf_groups.swapmove;
|
|
|
|
}
|
|
|
|
|
2004-06-06 09:38:17 -07:00
|
|
|
static Group *
|
2008-10-18 09:10:11 -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
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
if (!group_list)
|
|
|
|
group_list = ecore_list_new();
|
|
|
|
ecore_list_append(group_list, g);
|
|
|
|
|
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
|
|
|
|
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);
|
2007-07-25 13:02:57 -07:00
|
|
|
ecore_list_node_remove(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
|
|
|
|
GroupMatchId(const void *data, const void *match)
|
|
|
|
{
|
|
|
|
return ((const Group *)data)->index != (int)(long)match;
|
|
|
|
}
|
|
|
|
|
2008-10-18 09:10:11 -07:00
|
|
|
static Group *
|
2006-02-18 00:30:09 -08:00
|
|
|
GroupFind(int gid)
|
|
|
|
{
|
2007-01-16 17:10:44 -08:00
|
|
|
return (Group *) ecore_list_find(group_list, GroupMatchId,
|
|
|
|
(void *)(long)gid);
|
2006-02-18 00:30:09 -08:00
|
|
|
}
|
|
|
|
|
2008-10-18 09:16:47 -07:00
|
|
|
void
|
|
|
|
GroupRemember(int gid)
|
|
|
|
{
|
|
|
|
Group *g;
|
|
|
|
|
|
|
|
g = GroupFind(gid);
|
|
|
|
if (!g)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g->save = 1;
|
|
|
|
}
|
|
|
|
|
2007-02-26 19:52:46 -08:00
|
|
|
static Group *
|
|
|
|
GroupFind2(const char *groupid)
|
|
|
|
{
|
|
|
|
int gid;
|
|
|
|
|
|
|
|
if (groupid[0] == '*' || groupid[0] == '\0')
|
|
|
|
return Mode_groups.current;
|
|
|
|
|
|
|
|
gid = -1;
|
|
|
|
sscanf(groupid, "%d", &gid);
|
|
|
|
if (gid <= 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return GroupFind(gid);
|
|
|
|
}
|
|
|
|
|
2009-01-24 00:31:50 -08:00
|
|
|
#if ENABLE_DIALOGS
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
1999-09-08 17:39:43 -07:00
|
|
|
CopyGroupConfig(GroupConfig * src, GroupConfig * dest)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
1999-09-08 17:39:43 -07:00
|
|
|
if (!(src && dest))
|
|
|
|
return;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
1999-09-08 17:39:43 -07:00
|
|
|
memcpy(dest, src, sizeof(GroupConfig));
|
|
|
|
}
|
2009-01-24 00:31:50 -08:00
|
|
|
#endif /* ENABLE_DIALOGS */
|
1999-09-08 17:39:43 -07:00
|
|
|
|
2005-10-30 11:40:49 -08:00
|
|
|
static void
|
1999-09-08 17:39:43 -07:00
|
|
|
BreakWindowGroup(EWin * ewin, Group * g)
|
|
|
|
{
|
2008-11-08 04:21:10 -08:00
|
|
|
int i, j;
|
1999-09-08 17:39:43 -07:00
|
|
|
EWin *ewin2;
|
2008-11-08 04:21:10 -08:00
|
|
|
Group *g2;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2008-11-08 07:47:09 -08:00
|
|
|
Dprintf("ewin=%p group=%p gid=%d\n", ewin, g, g->index);
|
2008-11-08 04:21:10 -08:00
|
|
|
if (!ewin || !ewin->groups)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (j = 0; j < ewin->num_groups; j++)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2008-11-08 04:21:10 -08:00
|
|
|
g2 = ewin->groups[j];
|
|
|
|
if (g && g != g2)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (i = 0; i < g2->num_members; i++)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2008-11-08 04:21:10 -08:00
|
|
|
ewin2 = g2->members[0];
|
|
|
|
RemoveEwinFromGroup(ewin2, g2);
|
|
|
|
SnapshotEwinUpdate(ewin2, SNAP_USE_GROUPS);
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2008-10-18 09:10:11 -07:00
|
|
|
static void
|
|
|
|
BuildWindowGroup(EWin ** ewins, int num, int gid)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
int i;
|
2006-02-18 00:30:09 -08:00
|
|
|
Group *group;
|
1999-08-26 11:56:06 -07:00
|
|
|
|
2008-10-18 09:10:11 -07:00
|
|
|
Mode_groups.current = group = GroupCreate(gid);
|
1999-08-26 11:56:06 -07:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
for (i = 0; i < num; i++)
|
2006-02-18 00:30:09 -08:00
|
|
|
AddEwinToGroup(ewins[i], group);
|
|
|
|
}
|
|
|
|
|
|
|
|
Group **
|
|
|
|
GroupsGetList(int *pnum)
|
|
|
|
{
|
|
|
|
return (Group **) ecore_list_items_get(group_list, pnum);
|
|
|
|
}
|
|
|
|
|
2008-10-18 09:13:54 -07:00
|
|
|
Group *const *
|
|
|
|
EwinGetGroups(const EWin * ewin, int *num)
|
|
|
|
{
|
|
|
|
*num = ewin->num_groups;
|
|
|
|
return ewin->groups;
|
|
|
|
}
|
|
|
|
|
2009-01-24 00:31:50 -08:00
|
|
|
#if ENABLE_DIALOGS
|
2008-10-18 09:13:54 -07:00
|
|
|
static Group **
|
2006-02-18 00:30:09 -08:00
|
|
|
ListWinGroups(const EWin * ewin, char group_select, int *num)
|
|
|
|
{
|
|
|
|
Group **groups = NULL;
|
|
|
|
Group **groups2 = NULL;
|
|
|
|
int i, j, killed = 0;
|
|
|
|
|
|
|
|
switch (group_select)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
case GROUP_SELECT_EWIN_ONLY:
|
2007-01-16 17:10:44 -08:00
|
|
|
groups = EMALLOC(Group *, ewin->num_groups);
|
2006-02-18 00:30:09 -08:00
|
|
|
if (!groups)
|
|
|
|
break;
|
|
|
|
memcpy(groups, ewin->groups, sizeof(Group *) * ewin->num_groups);
|
|
|
|
*num = ewin->num_groups;
|
|
|
|
break;
|
|
|
|
case GROUP_SELECT_ALL_EXCEPT_EWIN:
|
|
|
|
groups2 = GroupsGetList(num);
|
|
|
|
if (!groups2)
|
|
|
|
break;
|
|
|
|
|
|
|
|
for (i = 0; i < (*num); 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
|
|
|
}
|
2007-01-16 17:10:44 -08:00
|
|
|
groups = EMALLOC(Group *, *num - killed);
|
2006-02-18 00:30:09 -08:00
|
|
|
if (groups)
|
|
|
|
{
|
|
|
|
j = 0;
|
|
|
|
for (i = 0; i < (*num); i++)
|
|
|
|
if (groups2[i])
|
|
|
|
groups[j++] = groups2[i];
|
|
|
|
(*num) -= killed;
|
|
|
|
}
|
|
|
|
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
|
|
|
static void
|
2008-11-08 07:47:09 -08:00
|
|
|
_GroupAddEwin(Group * g, EWin * ewin)
|
1999-10-02 14:59:10 -07:00
|
|
|
{
|
|
|
|
int i;
|
1999-08-20 05:23:26 -07:00
|
|
|
|
2008-11-08 07:47:09 -08:00
|
|
|
for (i = 0; i < ewin->num_groups; i++)
|
|
|
|
if (ewin->groups[i] == g)
|
|
|
|
return;
|
|
|
|
|
|
|
|
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
|
|
|
|
AddEwinToGroup(EWin * ewin, Group * g)
|
|
|
|
{
|
|
|
|
if (!ewin || !g)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_GroupAddEwin(g, ewin);
|
|
|
|
SnapshotEwinUpdate(ewin, SNAP_USE_GROUPS);
|
1999-10-02 14:59:10 -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];
|
|
|
|
g = GroupFind(gid);
|
|
|
|
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 */
|
|
|
|
BuildWindowGroup(&ewin, 1, gid);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_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
|
|
|
}
|
|
|
|
|
2005-10-30 11:40:49 -08:00
|
|
|
static int
|
2005-11-05 09:12:53 -08: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++)
|
|
|
|
{
|
|
|
|
if (EwinInGroup(ewin2, ewin1->groups[i]))
|
|
|
|
return ewin1->groups[i];
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-10-02 14:59:10 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RemoveEwinFromGroup(EWin * ewin, Group * g)
|
|
|
|
{
|
2004-06-06 09:38:17 -07:00
|
|
|
int i, j, k, i2;
|
1999-10-02 14:59:10 -07:00
|
|
|
|
2004-06-06 09:38:17 -07:00
|
|
|
if (!ewin || !g)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (k = 0; k < ewin->num_groups; k++)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-06-06 09:38:17 -07:00
|
|
|
/* is the window actually part of the given group */
|
|
|
|
if (ewin->groups[k] != g)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (i = 0; i < g->num_members; i++)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2004-06-06 09:38:17 -07:00
|
|
|
if (g->members[i] != ewin)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* remove it from the group */
|
|
|
|
for (j = i; j < g->num_members - 1; j++)
|
|
|
|
g->members[j] = g->members[j + 1];
|
|
|
|
g->num_members--;
|
|
|
|
if (g->num_members > 0)
|
2007-01-16 17:10:44 -08:00
|
|
|
g->members = EREALLOC(EWin *, g->members, g->num_members);
|
2008-10-18 09:16:47 -07:00
|
|
|
else if (g->save)
|
|
|
|
{
|
|
|
|
Efree(g->members);
|
|
|
|
g->members = NULL;
|
|
|
|
}
|
2004-06-06 09:38:17 -07:00
|
|
|
else
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2004-06-06 09:38:17 -07:00
|
|
|
GroupDestroy(g);
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2004-06-06 09:38:17 -07:00
|
|
|
|
|
|
|
/* and remove the group from the groups that the window is in */
|
|
|
|
for (i2 = k; i2 < ewin->num_groups - 1; i2++)
|
|
|
|
ewin->groups[i2] = ewin->groups[i2 + 1];
|
|
|
|
ewin->num_groups--;
|
|
|
|
if (ewin->num_groups <= 0)
|
|
|
|
{
|
|
|
|
Efree(ewin->groups);
|
|
|
|
ewin->groups = NULL;
|
|
|
|
ewin->num_groups = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ewin->groups =
|
2007-01-16 17:10:44 -08:00
|
|
|
EREALLOC(Group *, ewin->groups, ewin->num_groups);
|
2004-06-06 09:38:17 -07:00
|
|
|
|
2008-10-18 09:13:54 -07:00
|
|
|
GroupsSave();
|
2004-06-06 09:38:17 -07:00
|
|
|
return;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-10-02 14:59:10 -07:00
|
|
|
}
|
|
|
|
|
2004-06-06 09:38:17 -07:00
|
|
|
void
|
|
|
|
GroupsEwinRemove(EWin * ewin)
|
|
|
|
{
|
|
|
|
int num, i;
|
|
|
|
|
|
|
|
num = ewin->num_groups;
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
RemoveEwinFromGroup(ewin, ewin->groups[0]);
|
|
|
|
}
|
|
|
|
|
2009-01-24 00:31:50 -08:00
|
|
|
#if ENABLE_DIALOGS
|
2004-12-28 15:46:49 -08:00
|
|
|
static char **
|
1999-10-02 14:59:10 -07:00
|
|
|
GetWinGroupMemberNames(Group ** groups, int num)
|
|
|
|
{
|
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
|
|
|
}
|
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
|
2005-11-05 09:12:53 -08:00
|
|
|
ShowHideWinGroups(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
|
|
|
|
|
|
|
|
#define ShowHideWinGroups(ewin, group_index, onoff)
|
|
|
|
|
|
|
|
#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
|
|
|
|
2007-07-25 13:02:57 -07:00
|
|
|
if (ecore_list_count(group_list) <= 0)
|
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
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
ECORE_LIST_FOR_EACH(group_list, g)
|
|
|
|
{
|
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:"))
|
|
|
|
{
|
2008-10-18 09:10:11 -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
|
|
|
|
|
1999-10-02 14:59:10 -07:00
|
|
|
static int tmp_group_index;
|
|
|
|
static int tmp_index;
|
|
|
|
static EWin *tmp_ewin;
|
|
|
|
static Group **tmp_groups;
|
2006-07-26 21:52:50 -07:00
|
|
|
static int tmp_group_num;
|
1999-10-02 14:59:10 -07:00
|
|
|
static int tmp_action;
|
1999-08-20 05:23:26 -07:00
|
|
|
|
1999-10-02 14:59:10 -07:00
|
|
|
static void
|
2004-12-28 15:46:49 -08:00
|
|
|
ChooseGroup(Dialog * d __UNUSED__, int val, void *data __UNUSED__)
|
1999-10-02 14:59:10 -07:00
|
|
|
{
|
|
|
|
if (((val == 0) || (val == 2)) && tmp_groups)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2005-11-05 09:12:53 -08:00
|
|
|
ShowHideWinGroups(tmp_ewin, tmp_index, SET_OFF);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-11-02 12:56:39 -08:00
|
|
|
if (val == 0)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
if (tmp_groups)
|
|
|
|
{
|
|
|
|
switch (tmp_action)
|
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
case GROUP_OP_ADD:
|
2003-05-22 12:15:03 -07:00
|
|
|
AddEwinToGroup(tmp_ewin, tmp_groups[tmp_group_index]);
|
|
|
|
break;
|
2004-12-28 15:46:49 -08:00
|
|
|
case GROUP_OP_DEL:
|
2003-05-22 12:15:03 -07:00
|
|
|
RemoveEwinFromGroup(tmp_ewin, tmp_groups[tmp_group_index]);
|
|
|
|
break;
|
2004-12-28 15:46:49 -08:00
|
|
|
case GROUP_OP_BREAK:
|
2003-05-22 12:15:03 -07:00
|
|
|
BreakWindowGroup(tmp_ewin, tmp_groups[tmp_group_index]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-10-02 14:59:10 -07:00
|
|
|
if (((val == 0) || (val == 2)) && tmp_groups)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
Efree(tmp_groups);
|
|
|
|
tmp_groups = NULL;
|
2007-02-26 19:52:46 -08:00
|
|
|
|
2008-10-18 09:13:54 -07:00
|
|
|
GroupsSave();
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-10-02 14:59:10 -07:00
|
|
|
}
|
|
|
|
|
2004-06-06 09:38:17 -07:00
|
|
|
static void
|
2004-12-28 15:46:49 -08:00
|
|
|
GroupCallback(Dialog * d __UNUSED__, int val, void *data __UNUSED__)
|
1999-10-02 14:59:10 -07:00
|
|
|
{
|
2005-11-05 09:12:53 -08:00
|
|
|
ShowHideWinGroups(tmp_ewin, tmp_index, SET_OFF);
|
|
|
|
ShowHideWinGroups(tmp_ewin, val, SET_ON);
|
1999-10-02 14:59:10 -07:00
|
|
|
tmp_index = val;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
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;
|
2007-01-16 17:10:44 -08:00
|
|
|
const char *message = (const char *)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);
|
|
|
|
DialogItemSetText(di, message);
|
|
|
|
|
|
|
|
num_groups = tmp_group_num;
|
|
|
|
group_member_strings = GetWinGroupMemberNames(tmp_groups, num_groups);
|
|
|
|
|
|
|
|
radio = di = DialogAddItem(table, DITEM_RADIOBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
|
|
|
DialogItemSetCallback(di, GroupCallback, 0, (void *)d);
|
|
|
|
DialogItemSetText(di, group_member_strings[0]);
|
|
|
|
DialogItemRadioButtonSetFirst(di, radio);
|
|
|
|
DialogItemRadioButtonGroupSetVal(di, 0);
|
|
|
|
|
|
|
|
for (i = 1; i < num_groups; i++)
|
|
|
|
{
|
|
|
|
di = DialogAddItem(table, DITEM_RADIOBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
|
|
|
DialogItemSetCallback(di, GroupCallback, i, NULL);
|
|
|
|
DialogItemSetText(di, group_member_strings[i]);
|
|
|
|
DialogItemRadioButtonSetFirst(di, radio);
|
|
|
|
DialogItemRadioButtonGroupSetVal(di, i);
|
|
|
|
}
|
|
|
|
DialogItemRadioButtonGroupSetValPtr(radio, &tmp_group_index);
|
|
|
|
|
|
|
|
StrlistFree(group_member_strings, num_groups);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const DialogDef DlgGroupChoose = {
|
|
|
|
"GROUP_SELECTION",
|
|
|
|
NULL,
|
|
|
|
N_("Window Group Selection"),
|
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,
|
|
|
|
DLG_OC, ChooseGroup,
|
2006-07-26 21:52:50 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
ChooseGroupDialog(EWin * ewin, const char *message, char group_select,
|
|
|
|
int action)
|
|
|
|
{
|
|
|
|
int num_groups;
|
1999-10-02 14:59:10 -07:00
|
|
|
|
|
|
|
if (!ewin)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tmp_ewin = ewin;
|
|
|
|
tmp_group_index = tmp_index = 0;
|
|
|
|
tmp_action = action;
|
|
|
|
tmp_groups = ListWinGroups(ewin, group_select, &num_groups);
|
2006-07-26 21:52:50 -07:00
|
|
|
tmp_group_num = num_groups;
|
1999-10-02 14:59:10 -07:00
|
|
|
|
1999-12-06 09:12:20 -08:00
|
|
|
if ((num_groups == 0)
|
2004-12-28 15:46:49 -08:00
|
|
|
&& (action == GROUP_OP_BREAK || action == GROUP_OP_DEL))
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-01-03 04:21:52 -08:00
|
|
|
DialogOK(_("Window Group Error"),
|
|
|
|
_
|
2010-05-09 12:03:19 -07:00
|
|
|
("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."));
|
2003-05-22 12:15:03 -07:00
|
|
|
return;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-10-02 14:59:10 -07:00
|
|
|
if ((num_groups == 0) && (group_select == GROUP_SELECT_ALL_EXCEPT_EWIN))
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-01-03 04:21:52 -08:00
|
|
|
DialogOK(_("Window Group Error"),
|
2010-05-09 12:03:19 -07:00
|
|
|
_("Currently, no groups exist or this window\n"
|
|
|
|
"already belongs to all existing groups.\n"
|
|
|
|
"You have to start other groups first."));
|
2003-05-22 12:15:03 -07:00
|
|
|
return;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-10-02 14:59:10 -07:00
|
|
|
if (!tmp_groups)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
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
|
|
|
|
2005-11-05 09:12:53 -08:00
|
|
|
ShowHideWinGroups(ewin, 0, SET_ON);
|
1999-09-08 17:39:43 -07:00
|
|
|
|
2006-07-26 21:52:50 -07:00
|
|
|
DialogShowSimple(&DlgGroupChoose, (void *)message);
|
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;
|
|
|
|
unsigned int current;
|
|
|
|
} EwinGroupDlgData;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
static void
|
2005-11-05 09:12:53 -08:00
|
|
|
CB_ConfigureGroup(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);
|
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;
|
|
|
|
|
|
|
|
if (val < 2 && ewin)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2005-11-05 09:12:53 -08:00
|
|
|
CopyGroupConfig(&(dd->cfg), &(dd->cfgs[dd->current]));
|
|
|
|
for (i = 0; i < ewin->num_groups; i++)
|
|
|
|
CopyGroupConfig(dd->cfgs + i, &(ewin->groups[i]->cfg));
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
2005-11-05 09:12:53 -08:00
|
|
|
if ((val == 0) || (val == 2))
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2005-11-05 09:12:53 -08:00
|
|
|
ShowHideWinGroups(ewin, dd->current, SET_OFF);
|
|
|
|
Efree(dd->cfgs);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
autosave();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
GroupSelectCallback(Dialog * d, int val, void *data __UNUSED__)
|
|
|
|
{
|
2009-11-05 10:45:58 -08:00
|
|
|
EwinGroupDlgData *dd = DLG_DATA_GET(d, EwinGroupDlgData);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-11-05 09:12:53 -08:00
|
|
|
CopyGroupConfig(&(dd->cfg), &(dd->cfgs[dd->current]));
|
|
|
|
CopyGroupConfig(&(dd->cfgs[val]), &(dd->cfg));
|
|
|
|
DialogRedraw(d);
|
|
|
|
ShowHideWinGroups(dd->ewin, dd->current, SET_OFF);
|
|
|
|
ShowHideWinGroups(dd->ewin, val, SET_ON);
|
|
|
|
dd->current = 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
|
|
|
{
|
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
|
|
|
EwinGroupDlgData *dd;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-05 10:45:58 -08:00
|
|
|
dd = DLG_DATA_SET(d, EwinGroupDlgData);
|
2005-11-05 09:12:53 -08:00
|
|
|
if (!dd)
|
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
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;
|
|
|
|
dd->current = 0;
|
2004-12-28 15:46:49 -08:00
|
|
|
for (i = 0; i < ewin->num_groups; i++)
|
2005-11-05 09:12:53 -08:00
|
|
|
CopyGroupConfig(&(ewin->groups[i]->cfg), dd->cfgs + i);
|
|
|
|
CopyGroupConfig(dd->cfgs, &(dd->cfg));
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-11-05 09:12:53 -08:00
|
|
|
ShowHideWinGroups(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
|
|
|
|
2005-11-05 09:12:53 -08:00
|
|
|
group_member_strings =
|
|
|
|
GetWinGroupMemberNames(ewin->groups, ewin->num_groups);
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
radio = di = DialogAddItem(table, DITEM_RADIOBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-11-05 09:12:53 -08:00
|
|
|
DialogItemSetCallback(di, GroupSelectCallback, 0, d);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, group_member_strings[0]);
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemRadioButtonSetFirst(di, radio);
|
|
|
|
DialogItemRadioButtonGroupSetVal(di, 0);
|
|
|
|
|
|
|
|
for (i = 1; i < ewin->num_groups; i++)
|
|
|
|
{
|
|
|
|
di = DialogAddItem(table, DITEM_RADIOBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-11-05 09:12:53 -08:00
|
|
|
DialogItemSetCallback(di, GroupSelectCallback, 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);
|
|
|
|
}
|
|
|
|
DialogItemRadioButtonGroupSetValPtr(radio, &tmp_index);
|
|
|
|
|
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",
|
|
|
|
NULL,
|
|
|
|
N_("Window Group Settings"),
|
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,
|
|
|
|
DLG_OAC, CB_ConfigureGroup,
|
2006-07-20 20:17:18 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
SettingsGroups(EWin * ewin)
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static GroupConfig tmp_group_cfg;
|
|
|
|
static char tmp_group_swap;
|
|
|
|
static void
|
|
|
|
CB_ConfigureDefaultGroupSettings(Dialog * d __UNUSED__, int val,
|
|
|
|
void *data __UNUSED__)
|
|
|
|
{
|
|
|
|
if (val < 2)
|
|
|
|
{
|
2005-11-19 07:47:10 -08:00
|
|
|
CopyGroupConfig(&tmp_group_cfg, &(Conf_groups.dflt));
|
|
|
|
Conf_groups.swapmove = tmp_group_swap;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
autosave();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-08-07 20:58:42 -07:00
|
|
|
_DlgFillGroupDefaults(Dialog * d __UNUSED__, DItem * table,
|
|
|
|
void *data __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2006-07-20 20:17:18 -07:00
|
|
|
DItem *di;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-11-19 07:47:10 -08:00
|
|
|
CopyGroupConfig(&(Conf_groups.dflt), &tmp_group_cfg);
|
|
|
|
tmp_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"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &(tmp_group_cfg.set_border));
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Iconifying"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &(tmp_group_cfg.iconify));
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Killing"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &(tmp_group_cfg.kill));
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Moving"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &(tmp_group_cfg.move));
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Raising/Lowering"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &(tmp_group_cfg.raise));
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Sticking"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &(tmp_group_cfg.stick));
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Shading"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &(tmp_group_cfg.shade));
|
|
|
|
|
|
|
|
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"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &(tmp_group_swap));
|
|
|
|
}
|
|
|
|
|
2006-07-20 20:17:18 -07:00
|
|
|
const DialogDef DlgGroupDefaults = {
|
|
|
|
"CONFIGURE_DEFAULT_GROUP_CONTROL",
|
|
|
|
N_("Groups"),
|
|
|
|
N_("Default Group Control Settings"),
|
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,
|
|
|
|
DLG_OAC, CB_ConfigureDefaultGroupSettings,
|
2006-07-20 20:17:18 -07:00
|
|
|
};
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
|
|
|
GroupsConfigure(const char *params)
|
|
|
|
{
|
|
|
|
char s[128];
|
|
|
|
const char *p;
|
|
|
|
int l;
|
|
|
|
EWin *ewin;
|
|
|
|
|
|
|
|
p = params;
|
|
|
|
l = 0;
|
|
|
|
s[0] = '\0';
|
|
|
|
sscanf(p, "%100s %n", s, &l);
|
|
|
|
|
2008-10-18 09:04:09 -07:00
|
|
|
ewin = GetContextEwin();
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!strcmp(s, "group"))
|
|
|
|
{
|
2008-10-18 09:04:09 -07:00
|
|
|
SettingsGroups(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
|
|
|
{
|
2007-02-26 19:52:46 -08:00
|
|
|
ChooseGroupDialog(ewin,
|
|
|
|
_("Pick the group the window will belong to:"),
|
|
|
|
GROUP_SELECT_ALL_EXCEPT_EWIN, GROUP_OP_ADD);
|
|
|
|
}
|
|
|
|
else if (!strcmp(s, "del"))
|
|
|
|
{
|
|
|
|
ChooseGroupDialog(ewin,
|
|
|
|
_("Select the group to remove the window from:"),
|
|
|
|
GROUP_SELECT_EWIN_ONLY, GROUP_OP_DEL);
|
|
|
|
}
|
|
|
|
else if (!strcmp(s, "break"))
|
|
|
|
{
|
|
|
|
ChooseGroupDialog(ewin, _("Select the group to break:"),
|
|
|
|
GROUP_SELECT_EWIN_ONLY, 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
|
|
|
|
GroupShow(Group * g)
|
|
|
|
{
|
|
|
|
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_GroupInfo(const char *params)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
Group *group;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
if (params)
|
|
|
|
{
|
2007-02-26 19:52:46 -08:00
|
|
|
group = GroupFind2(params);
|
2006-02-18 00:30:09 -08:00
|
|
|
if (group)
|
|
|
|
GroupShow(group);
|
|
|
|
else
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("Error: no such group: %s\n", params);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-07-25 13:02:57 -07:00
|
|
|
IpcPrintf("Number of groups: %d\n", ecore_list_count(group_list));
|
2006-02-18 00:30:09 -08:00
|
|
|
ECORE_LIST_FOR_EACH(group_list, group) GroupShow(group);
|
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"))
|
|
|
|
{
|
2008-10-18 09:10:11 -07:00
|
|
|
BuildWindowGroup(&ewin, 1, -1);
|
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"))
|
|
|
|
{
|
2007-02-26 19:52:46 -08:00
|
|
|
group = GroupFind2(groupid);
|
2004-12-28 15:46:49 -08:00
|
|
|
AddEwinToGroup(ewin, group);
|
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"))
|
|
|
|
{
|
2007-02-26 19:52:46 -08:00
|
|
|
group = GroupFind2(groupid);
|
2004-12-28 15:46:49 -08:00
|
|
|
RemoveEwinFromGroup(ewin, group);
|
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"))
|
|
|
|
{
|
2007-02-26 19:52:46 -08:00
|
|
|
group = GroupFind2(groupid);
|
2004-12-28 15:46:49 -08:00
|
|
|
BreakWindowGroup(ewin, 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"))
|
|
|
|
{
|
2005-11-05 09:12:53 -08:00
|
|
|
ShowHideWinGroups(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)
|
|
|
|
{
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("Error: no group 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
|
|
|
|
|
|
|
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-02-26 19:52:46 -08: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;
|
|
|
|
}
|
|
|
|
|
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, "num_members"))
|
|
|
|
{
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("num_members: %d\n", group->num_members);
|
2004-12-28 15:46:49 -08:00
|
|
|
onoff = -1;
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2009-01-24 00:31:50 -08:00
|
|
|
#if ENABLE_DIALOGS
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
2007-05-18 01:25:06 -07:00
|
|
|
GroupsIpc(const char *params)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
const char *p;
|
|
|
|
char cmd[128], prm[128];
|
|
|
|
int len;
|
|
|
|
|
|
|
|
cmd[0] = prm[0] = '\0';
|
|
|
|
p = params;
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
len = 0;
|
|
|
|
sscanf(p, "%100s %100s %n", cmd, prm, &len);
|
|
|
|
p += len;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p || cmd[0] == '?')
|
|
|
|
{
|
|
|
|
/* Show groups */
|
|
|
|
}
|
|
|
|
else if (!strncmp(cmd, "cfg", 2))
|
|
|
|
{
|
|
|
|
GroupsConfigure(prm);
|
|
|
|
}
|
|
|
|
}
|
2009-01-24 00:31:50 -08:00
|
|
|
#endif /* ENABLE_DIALOGS */
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-10-30 11:40:49 -08:00
|
|
|
static const IpcItem GroupsIpcArray[] = {
|
2009-01-24 00:31:50 -08:00
|
|
|
#if ENABLE_DIALOGS
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
GroupsIpc,
|
|
|
|
"groups", "grp",
|
|
|
|
"Configure window groups",
|
|
|
|
" groups cfg Configure groups\n"}
|
|
|
|
,
|
2009-01-24 00:31:50 -08:00
|
|
|
#endif /* ENABLE_DIALOGS */
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
IPC_GroupInfo,
|
|
|
|
"group_info", "gl",
|
|
|
|
"Retrieve some info on groups",
|
|
|
|
"use \"group_info [group_index]\"\n"}
|
|
|
|
,
|
|
|
|
{
|
|
|
|
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"
|
|
|
|
" group <groupid> num_members <on/off/?>\n"
|
|
|
|
" group <groupid> iconify <on/off/?>\n"
|
|
|
|
" group <groupid> kill <on/off/?>\n" " group <groupid> move <on/off/?>\n"
|
|
|
|
" 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
|
|
|
};
|