2 * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
3 * Copyright (C) 2004-2009 Kim Woelders
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies of the Software, its documentation and marketing & publicity
14 * materials, and acknowledgment shall be given in the documentation, materials
15 * and software packages that this Software was used.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #include "e16-ecore_list.h"
36 #define DEBUG_GROUPS 0
38 #define Dprintf(fmt, ...) Eprintf("%s: " fmt, __func__, __VA_ARGS__)
40 #define Dprintf(fmt...)
43 #define USE_GROUP_SHOWHIDE 1 /* Enable group borders */
49 static Ecore_List *group_list = NULL;
60 static void AddEwinToGroup(EWin * ewin, Group * g);
61 static void RemoveEwinFromGroup(EWin * ewin, Group * g);
64 GroupsGetSwapmove(void)
66 return Conf_groups.swapmove;
75 g = ECALLOC(Group, 1);
80 group_list = ecore_list_new();
81 ecore_list_append(group_list, g);
85 /* Create new group id */
87 g->index = (int)((GetTime() - (floor(t / 1000) * 1000)) * 10000);
88 /* g->index = (int)(GetTime() * 100); */
92 /* Use given group id */
95 g->cfg.iconify = Conf_groups.dflt.iconify;
96 g->cfg.kill = Conf_groups.dflt.kill;
97 g->cfg.move = Conf_groups.dflt.move;
98 g->cfg.raise = Conf_groups.dflt.raise;
99 g->cfg.set_border = Conf_groups.dflt.set_border;
100 g->cfg.stick = Conf_groups.dflt.stick;
101 g->cfg.shade = Conf_groups.dflt.shade;
103 Dprintf("grp=%p gid=%d\n", g, g->index);
108 GroupDestroy(Group * g)
113 Dprintf("grp=%p gid=%d\n", g, g->index);
114 ecore_list_node_remove(group_list, g);
116 if (g == Mode_groups.current)
117 Mode_groups.current = NULL;
124 GroupMatchId(const void *data, const void *match)
126 return ((const Group *)data)->index != (int)(long)match;
132 return (Group *) ecore_list_find(group_list, GroupMatchId,
137 GroupRemember(int gid)
149 GroupFind2(const char *groupid)
153 if (groupid[0] == '*' || groupid[0] == '\0')
154 return Mode_groups.current;
157 sscanf(groupid, "%d", &gid);
161 return GroupFind(gid);
166 CopyGroupConfig(GroupConfig * src, GroupConfig * dest)
171 memcpy(dest, src, sizeof(GroupConfig));
173 #endif /* ENABLE_DIALOGS */
176 BreakWindowGroup(EWin * ewin, Group * g)
182 Dprintf("ewin=%p group=%p gid=%d\n", ewin, g, g->index);
183 if (!ewin || !ewin->groups)
186 for (j = 0; j < ewin->num_groups; j++)
188 g2 = ewin->groups[j];
192 for (i = 0; i < g2->num_members; i++)
194 ewin2 = g2->members[0];
195 RemoveEwinFromGroup(ewin2, g2);
196 SnapshotEwinUpdate(ewin2, SNAP_USE_GROUPS);
202 BuildWindowGroup(EWin ** ewins, int num, int gid)
207 Mode_groups.current = group = GroupCreate(gid);
209 for (i = 0; i < num; i++)
210 AddEwinToGroup(ewins[i], group);
214 GroupsGetList(int *pnum)
216 return (Group **) ecore_list_items_get(group_list, pnum);
220 EwinGetGroups(const EWin * ewin, int *num)
222 *num = ewin->num_groups;
228 ListWinGroups(const EWin * ewin, char group_select, int *num)
230 Group **groups = NULL;
231 Group **groups2 = NULL;
232 int i, j, killed = 0;
234 switch (group_select)
236 case GROUP_SELECT_EWIN_ONLY:
237 groups = EMALLOC(Group *, ewin->num_groups);
240 memcpy(groups, ewin->groups, sizeof(Group *) * ewin->num_groups);
241 *num = ewin->num_groups;
243 case GROUP_SELECT_ALL_EXCEPT_EWIN:
244 groups2 = GroupsGetList(num);
248 for (i = 0; i < (*num); i++)
250 for (j = 0; j < ewin->num_groups; j++)
252 if (ewin->groups[j] == groups2[i])
259 groups = EMALLOC(Group *, *num - killed);
263 for (i = 0; i < (*num); i++)
265 groups[j++] = groups2[i];
270 case GROUP_SELECT_ALL:
272 groups = GroupsGetList(num);
278 #endif /* ENABLE_DIALOGS */
281 _GroupAddEwin(Group * g, EWin * ewin)
285 for (i = 0; i < ewin->num_groups; i++)
286 if (ewin->groups[i] == g)
290 ewin->groups = EREALLOC(Group *, ewin->groups, ewin->num_groups);
291 ewin->groups[ewin->num_groups - 1] = g;
293 g->members = EREALLOC(EWin *, g->members, g->num_members);
294 g->members[g->num_members - 1] = ewin;
298 AddEwinToGroup(EWin * ewin, Group * g)
303 _GroupAddEwin(g, ewin);
304 SnapshotEwinUpdate(ewin, SNAP_USE_GROUPS);
308 GroupsEwinAdd(EWin * ewin, const int *pgid, int ngid)
313 for (i = 0; i < ngid; i++)
317 Dprintf("ewin=%p gid=%d grp=%p\n", ewin, gid, g);
320 /* This should not happen, but may if group/snap configs are corrupted */
321 BuildWindowGroup(&ewin, 1, gid);
325 _GroupAddEwin(g, ewin);
328 SnapshotEwinUpdate(ewin, SNAP_USE_GROUPS);
332 EwinInGroup(const EWin * ewin, const Group * g)
338 for (i = 0; i < g->num_members; i++)
340 if (g->members[i] == ewin)
348 EwinsInGroup(const EWin * ewin1, const EWin * ewin2)
354 for (i = 0; i < ewin1->num_groups; i++)
356 if (EwinInGroup(ewin2, ewin1->groups[i]))
357 return ewin1->groups[i];
364 RemoveEwinFromGroup(EWin * ewin, Group * g)
371 for (k = 0; k < ewin->num_groups; k++)
373 /* is the window actually part of the given group */
374 if (ewin->groups[k] != g)
377 for (i = 0; i < g->num_members; i++)
379 if (g->members[i] != ewin)
382 /* remove it from the group */
383 for (j = i; j < g->num_members - 1; j++)
384 g->members[j] = g->members[j + 1];
386 if (g->num_members > 0)
387 g->members = EREALLOC(EWin *, g->members, g->num_members);
398 /* and remove the group from the groups that the window is in */
399 for (i2 = k; i2 < ewin->num_groups - 1; i2++)
400 ewin->groups[i2] = ewin->groups[i2 + 1];
402 if (ewin->num_groups <= 0)
406 ewin->num_groups = 0;
410 EREALLOC(Group *, ewin->groups, ewin->num_groups);
419 GroupsEwinRemove(EWin * ewin)
423 num = ewin->num_groups;
424 for (i = 0; i < num; i++)
425 RemoveEwinFromGroup(ewin, ewin->groups[0]);
430 GetWinGroupMemberNames(Group ** groups, int num)
433 char **group_member_strings;
436 group_member_strings = ECALLOC(char *, num);
438 if (!group_member_strings)
441 for (i = 0; i < num; i++)
443 group_member_strings[i] = EMALLOC(char, 1024);
445 if (!group_member_strings[i])
449 for (j = 0; j < groups[i]->num_members; j++)
451 name = EwinGetTitle(groups[i]->members[j]);
452 if (!name) /* Should never happen */
454 len += Esnprintf(group_member_strings[i] + len, 1024 - len,
461 return group_member_strings;
463 #endif /* ENABLE_DIALOGS */
465 #if USE_GROUP_SHOWHIDE
467 ShowHideWinGroups(EWin * ewin, int group_index, char onoff)
471 const Border *b = NULL;
473 if (!ewin || group_index >= ewin->num_groups)
478 gwins = ListWinGroupMembersForEwin(ewin, GROUP_ACTION_ANY, 0, &num);
482 gwins = ewin->groups[group_index]->members;
483 num = ewin->groups[group_index]->num_members;
486 if (onoff == SET_TOGGLE)
487 onoff = (ewin->border == ewin->normal_border) ? SET_ON : SET_OFF;
489 for (i = 0; i < num; i++)
492 b = BorderFind(gwins[i]->border->group_border_name);
494 b = gwins[i]->normal_border;
496 EwinBorderChange(gwins[i], b, 0);
503 #define ShowHideWinGroups(ewin, group_index, onoff)
505 #endif /* USE_GROUP_SHOWHIDE */
514 if (ecore_list_count(group_list) <= 0)
517 Esnprintf(s, sizeof(s), "%s.groups", EGetSavePrefix());
522 ECORE_LIST_FOR_EACH(group_list, g)
527 fprintf(f, "NEW: %i\n", g->index);
528 fprintf(f, "ICONIFY: %i\n", g->cfg.iconify);
529 fprintf(f, "KILL: %i\n", g->cfg.kill);
530 fprintf(f, "MOVE: %i\n", g->cfg.move);
531 fprintf(f, "RAISE: %i\n", g->cfg.raise);
532 fprintf(f, "SET_BORDER: %i\n", g->cfg.set_border);
533 fprintf(f, "STICK: %i\n", g->cfg.stick);
534 fprintf(f, "SHADE: %i\n", g->cfg.shade);
547 Esnprintf(s, sizeof(s), "%s.groups", EGetSavePrefix());
552 while (fgets(s, sizeof(s), f))
558 s[strlen(s) - 1] = 0;
560 sscanf(s, "%100s %d", ss, &ii);
562 if (!strcmp(ss, "NEW:"))
570 if (!strcmp(ss, "ICONIFY:"))
574 else if (!strcmp(ss, "KILL:"))
578 else if (!strcmp(ss, "MOVE:"))
582 else if (!strcmp(ss, "RAISE:"))
586 else if (!strcmp(ss, "SET_BORDER:"))
588 g->cfg.set_border = ii;
590 else if (!strcmp(ss, "STICK:"))
594 else if (!strcmp(ss, "SHADE:"))
604 #define GROUP_OP_ADD 1
605 #define GROUP_OP_DEL 2
606 #define GROUP_OP_BREAK 3
608 static int tmp_group_index;
609 static int tmp_index;
610 static EWin *tmp_ewin;
611 static Group **tmp_groups;
612 static int tmp_group_num;
613 static int tmp_action;
616 ChooseGroup(Dialog * d __UNUSED__, int val, void *data __UNUSED__)
618 if (((val == 0) || (val == 2)) && tmp_groups)
620 ShowHideWinGroups(tmp_ewin, tmp_index, SET_OFF);
629 AddEwinToGroup(tmp_ewin, tmp_groups[tmp_group_index]);
632 RemoveEwinFromGroup(tmp_ewin, tmp_groups[tmp_group_index]);
635 BreakWindowGroup(tmp_ewin, tmp_groups[tmp_group_index]);
642 if (((val == 0) || (val == 2)) && tmp_groups)
652 GroupCallback(Dialog * d __UNUSED__, int val, void *data __UNUSED__)
654 ShowHideWinGroups(tmp_ewin, tmp_index, SET_OFF);
655 ShowHideWinGroups(tmp_ewin, val, SET_ON);
660 _DlgFillGroupChoose(Dialog * d, DItem * table, void *data)
664 char **group_member_strings;
665 const char *message = (const char *)data;
667 DialogItemTableSetOptions(table, 2, 0, 0, 0);
669 di = DialogAddItem(table, DITEM_TEXT);
670 DialogItemSetColSpan(di, 2);
671 DialogItemSetAlign(di, 0, 512);
672 DialogItemSetText(di, message);
674 num_groups = tmp_group_num;
675 group_member_strings = GetWinGroupMemberNames(tmp_groups, num_groups);
677 radio = di = DialogAddItem(table, DITEM_RADIOBUTTON);
678 DialogItemSetColSpan(di, 2);
679 DialogItemSetCallback(di, GroupCallback, 0, (void *)d);
680 DialogItemSetText(di, group_member_strings[0]);
681 DialogItemRadioButtonSetFirst(di, radio);
682 DialogItemRadioButtonGroupSetVal(di, 0);
684 for (i = 1; i < num_groups; i++)
686 di = DialogAddItem(table, DITEM_RADIOBUTTON);
687 DialogItemSetColSpan(di, 2);
688 DialogItemSetCallback(di, GroupCallback, i, NULL);
689 DialogItemSetText(di, group_member_strings[i]);
690 DialogItemRadioButtonSetFirst(di, radio);
691 DialogItemRadioButtonGroupSetVal(di, i);
693 DialogItemRadioButtonGroupSetValPtr(radio, &tmp_group_index);
695 StrlistFree(group_member_strings, num_groups);
698 static const DialogDef DlgGroupChoose = {
701 N_("Window Group Selection"),
702 SOUND_SETTINGS_GROUP,
704 N_("Enlightenment Window Group\n" "Selection Dialog\n"),
710 ChooseGroupDialog(EWin * ewin, const char *message, char group_select,
719 tmp_group_index = tmp_index = 0;
721 tmp_groups = ListWinGroups(ewin, group_select, &num_groups);
722 tmp_group_num = num_groups;
724 if ((num_groups == 0)
725 && (action == GROUP_OP_BREAK || action == GROUP_OP_DEL))
727 DialogOK(_("Window Group Error"),
729 ("\n This window currently does not belong to any groups. \n"
730 " You can only destroy groups or remove windows from groups \n"
731 " through a window that actually belongs to at least one group.\n\n"));
734 if ((num_groups == 0) && (group_select == GROUP_SELECT_ALL_EXCEPT_EWIN))
736 DialogOK(_("Window Group Error"),
737 _("\n Currently, no groups exist or this window \n"
738 " already belongs to all existing groups. \n"
739 " You have to start other groups first. \n\n"));
744 DialogOK(_("Window Group Error"),
746 ("\n Currently, no groups exist. You have to start a group first.\n\n"));
750 ShowHideWinGroups(ewin, 0, SET_ON);
752 DialogShowSimple(&DlgGroupChoose, (void *)message);
757 GroupConfig cfg; /* Dialog data for current group */
758 GroupConfig *cfgs; /* Work copy of ewin group cfgs */
760 unsigned int current;
764 CB_ConfigureGroup(Dialog * d, int val, void *data __UNUSED__)
766 EwinGroupDlgData *dd = (EwinGroupDlgData *) DialogGetData(d);
774 ewin = EwinFindByPtr(dd->ewin);
775 if (ewin && ewin->num_groups != dd->ngrp)
780 CopyGroupConfig(&(dd->cfg), &(dd->cfgs[dd->current]));
781 for (i = 0; i < ewin->num_groups; i++)
782 CopyGroupConfig(dd->cfgs + i, &(ewin->groups[i]->cfg));
784 if ((val == 0) || (val == 2))
786 ShowHideWinGroups(ewin, dd->current, SET_OFF);
789 DialogSetData(d, NULL);
795 GroupSelectCallback(Dialog * d, int val, void *data __UNUSED__)
797 EwinGroupDlgData *dd = (EwinGroupDlgData *) DialogGetData(d);
799 CopyGroupConfig(&(dd->cfg), &(dd->cfgs[dd->current]));
800 CopyGroupConfig(&(dd->cfgs[val]), &(dd->cfg));
802 ShowHideWinGroups(dd->ewin, dd->current, SET_OFF);
803 ShowHideWinGroups(dd->ewin, val, SET_ON);
808 _DlgFillGroups(Dialog * d, DItem * table, void *data)
810 EWin *ewin = (EWin *) data;
813 char **group_member_strings;
814 EwinGroupDlgData *dd;
816 dd = ECALLOC(EwinGroupDlgData, 1);
821 dd->cfgs = EMALLOC(GroupConfig, ewin->num_groups);
822 dd->ngrp = ewin->num_groups;
824 for (i = 0; i < ewin->num_groups; i++)
825 CopyGroupConfig(&(ewin->groups[i]->cfg), dd->cfgs + i);
826 CopyGroupConfig(dd->cfgs, &(dd->cfg));
827 DialogSetData(d, dd);
829 ShowHideWinGroups(ewin, 0, SET_ON);
831 DialogItemTableSetOptions(table, 2, 0, 0, 0);
833 di = DialogAddItem(table, DITEM_TEXT);
834 DialogItemSetColSpan(di, 2);
835 DialogItemSetAlign(di, 0, 512);
836 DialogItemSetText(di, _(" Pick the group to configure: "));
838 group_member_strings =
839 GetWinGroupMemberNames(ewin->groups, ewin->num_groups);
841 radio = di = DialogAddItem(table, DITEM_RADIOBUTTON);
842 DialogItemSetColSpan(di, 2);
843 DialogItemSetCallback(di, GroupSelectCallback, 0, d);
844 DialogItemSetText(di, group_member_strings[0]);
845 DialogItemRadioButtonSetFirst(di, radio);
846 DialogItemRadioButtonGroupSetVal(di, 0);
848 for (i = 1; i < ewin->num_groups; i++)
850 di = DialogAddItem(table, DITEM_RADIOBUTTON);
851 DialogItemSetColSpan(di, 2);
852 DialogItemSetCallback(di, GroupSelectCallback, i, d);
853 DialogItemSetText(di, group_member_strings[i]);
854 DialogItemRadioButtonSetFirst(di, radio);
855 DialogItemRadioButtonGroupSetVal(di, i);
857 DialogItemRadioButtonGroupSetValPtr(radio, &tmp_index);
859 StrlistFree(group_member_strings, ewin->num_groups);
861 di = DialogAddItem(table, DITEM_SEPARATOR);
862 DialogItemSetColSpan(di, 2);
864 di = DialogAddItem(table, DITEM_TEXT);
865 DialogItemSetColSpan(di, 2);
866 DialogItemSetAlign(di, 0, 512);
867 DialogItemSetText(di, _(" The following actions are \n"
868 " applied to all group members: "));
870 di = DialogAddItem(table, DITEM_CHECKBUTTON);
871 DialogItemSetColSpan(di, 2);
872 DialogItemSetText(di, _("Changing Border Style"));
873 DialogItemCheckButtonSetPtr(di, &(dd->cfg.set_border));
875 di = DialogAddItem(table, DITEM_CHECKBUTTON);
876 DialogItemSetColSpan(di, 2);
877 DialogItemSetText(di, _("Iconifying"));
878 DialogItemCheckButtonSetPtr(di, &(dd->cfg.iconify));
880 di = DialogAddItem(table, DITEM_CHECKBUTTON);
881 DialogItemSetColSpan(di, 2);
882 DialogItemSetText(di, _("Killing"));
883 DialogItemCheckButtonSetPtr(di, &(dd->cfg.kill));
885 di = DialogAddItem(table, DITEM_CHECKBUTTON);
886 DialogItemSetColSpan(di, 2);
887 DialogItemSetText(di, _("Moving"));
888 DialogItemCheckButtonSetPtr(di, &(dd->cfg.move));
890 di = DialogAddItem(table, DITEM_CHECKBUTTON);
891 DialogItemSetColSpan(di, 2);
892 DialogItemSetText(di, _("Raising/Lowering"));
893 DialogItemCheckButtonSetPtr(di, &(dd->cfg.raise));
895 di = DialogAddItem(table, DITEM_CHECKBUTTON);
896 DialogItemSetColSpan(di, 2);
897 DialogItemSetText(di, _("Sticking"));
898 DialogItemCheckButtonSetPtr(di, &(dd->cfg.stick));
900 di = DialogAddItem(table, DITEM_CHECKBUTTON);
901 DialogItemSetColSpan(di, 2);
902 DialogItemSetText(di, _("Shading"));
903 DialogItemCheckButtonSetPtr(di, &(dd->cfg.shade));
906 static const DialogDef DlgGroups = {
909 N_("Window Group Settings"),
910 SOUND_SETTINGS_GROUP,
912 N_("Enlightenment Window Group\n" "Settings Dialog\n"),
914 DLG_OAC, CB_ConfigureGroup,
918 SettingsGroups(EWin * ewin)
923 if (ewin->num_groups == 0)
925 DialogOK(_("Window Group Error"),
927 ("\n This window currently does not belong to any groups. \n\n"));
931 DialogShowSimple(&DlgGroups, ewin);
934 static GroupConfig tmp_group_cfg;
935 static char tmp_group_swap;
937 CB_ConfigureDefaultGroupSettings(Dialog * d __UNUSED__, int val,
938 void *data __UNUSED__)
942 CopyGroupConfig(&tmp_group_cfg, &(Conf_groups.dflt));
943 Conf_groups.swapmove = tmp_group_swap;
949 _DlgFillGroupDefaults(Dialog * d __UNUSED__, DItem * table,
950 void *data __UNUSED__)
954 CopyGroupConfig(&(Conf_groups.dflt), &tmp_group_cfg);
955 tmp_group_swap = Conf_groups.swapmove;
957 DialogItemTableSetOptions(table, 2, 0, 0, 0);
959 di = DialogAddItem(table, DITEM_TEXT);
960 DialogItemSetColSpan(di, 2);
961 DialogItemSetAlign(di, 0, 512);
962 DialogItemSetText(di, _(" Per-group settings: "));
964 di = DialogAddItem(table, DITEM_SEPARATOR);
965 DialogItemSetColSpan(di, 2);
967 di = DialogAddItem(table, DITEM_CHECKBUTTON);
968 DialogItemSetColSpan(di, 2);
969 DialogItemSetText(di, _("Changing Border Style"));
970 DialogItemCheckButtonSetPtr(di, &(tmp_group_cfg.set_border));
972 di = DialogAddItem(table, DITEM_CHECKBUTTON);
973 DialogItemSetColSpan(di, 2);
974 DialogItemSetText(di, _("Iconifying"));
975 DialogItemCheckButtonSetPtr(di, &(tmp_group_cfg.iconify));
977 di = DialogAddItem(table, DITEM_CHECKBUTTON);
978 DialogItemSetColSpan(di, 2);
979 DialogItemSetText(di, _("Killing"));
980 DialogItemCheckButtonSetPtr(di, &(tmp_group_cfg.kill));
982 di = DialogAddItem(table, DITEM_CHECKBUTTON);
983 DialogItemSetColSpan(di, 2);
984 DialogItemSetText(di, _("Moving"));
985 DialogItemCheckButtonSetPtr(di, &(tmp_group_cfg.move));
987 di = DialogAddItem(table, DITEM_CHECKBUTTON);
988 DialogItemSetColSpan(di, 2);
989 DialogItemSetText(di, _("Raising/Lowering"));
990 DialogItemCheckButtonSetPtr(di, &(tmp_group_cfg.raise));
992 di = DialogAddItem(table, DITEM_CHECKBUTTON);
993 DialogItemSetColSpan(di, 2);
994 DialogItemSetText(di, _("Sticking"));
995 DialogItemCheckButtonSetPtr(di, &(tmp_group_cfg.stick));
997 di = DialogAddItem(table, DITEM_CHECKBUTTON);
998 DialogItemSetColSpan(di, 2);
999 DialogItemSetText(di, _("Shading"));
1000 DialogItemCheckButtonSetPtr(di, &(tmp_group_cfg.shade));
1002 di = DialogAddItem(table, DITEM_SEPARATOR);
1003 DialogItemSetColSpan(di, 2);
1005 di = DialogAddItem(table, DITEM_TEXT);
1006 DialogItemSetColSpan(di, 2);
1007 DialogItemSetAlign(di, 0, 512);
1008 DialogItemSetText(di, _(" Global settings: "));
1010 di = DialogAddItem(table, DITEM_CHECKBUTTON);
1011 DialogItemSetColSpan(di, 2);
1012 DialogItemSetText(di, _("Swap Window Locations"));
1013 DialogItemCheckButtonSetPtr(di, &(tmp_group_swap));
1016 const DialogDef DlgGroupDefaults = {
1017 "CONFIGURE_DEFAULT_GROUP_CONTROL",
1019 N_("Default Group Control Settings"),
1020 SOUND_SETTINGS_GROUP,
1022 N_("Enlightenment Default\n" "Group Control Settings Dialog\n"),
1023 _DlgFillGroupDefaults,
1024 DLG_OAC, CB_ConfigureDefaultGroupSettings,
1028 GroupsConfigure(const char *params)
1038 sscanf(p, "%100s %n", s, &l);
1041 ewin = GetContextEwin();
1043 if (!strcmp(s, "group"))
1045 SettingsGroups(ewin);
1047 else if (!strcmp(s, "add"))
1049 ChooseGroupDialog(ewin,
1050 _("Pick the group the window will belong to:"),
1051 GROUP_SELECT_ALL_EXCEPT_EWIN, GROUP_OP_ADD);
1053 else if (!strcmp(s, "del"))
1055 ChooseGroupDialog(ewin,
1056 _("Select the group to remove the window from:"),
1057 GROUP_SELECT_EWIN_ONLY, GROUP_OP_DEL);
1059 else if (!strcmp(s, "break"))
1061 ChooseGroupDialog(ewin, _("Select the group to break:"),
1062 GROUP_SELECT_EWIN_ONLY, GROUP_OP_BREAK);
1065 #endif /* ENABLE_DIALOGS */
1072 GroupShow(Group * g)
1076 for (j = 0; j < g->num_members; j++)
1077 IpcPrintf("%d: %s\n", g->index, EwinGetIcccmName(g->members[j]));
1079 IpcPrintf(" index: %d\n" " num_members: %d\n"
1080 " iconify: %d\n" " kill: %d\n"
1081 " move: %d\n" " raise: %d\n"
1082 " set_border: %d\n" " stick: %d\n"
1084 g->index, g->num_members,
1085 g->cfg.iconify, g->cfg.kill,
1086 g->cfg.move, g->cfg.raise,
1087 g->cfg.set_border, g->cfg.stick, g->cfg.shade);
1091 IPC_GroupInfo(const char *params)
1097 group = GroupFind2(params);
1101 IpcPrintf("Error: no such group: %s", params);
1105 IpcPrintf("Number of groups: %d\n", ecore_list_count(group_list));
1106 ECORE_LIST_FOR_EACH(group_list, group) GroupShow(group);
1111 IPC_GroupOps(const char *params)
1113 Group *group = Mode_groups.current;
1115 char operation[128];
1122 IpcPrintf("Error: no window specified");
1126 windowid[0] = operation[0] = groupid[0] = '\0';
1127 sscanf(params, "%100s %100s %100s", windowid, operation, groupid);
1129 sscanf(windowid, "%x", &win);
1133 IpcPrintf("Error: no operation specified");
1137 ewin = EwinFindByExpr(windowid);
1140 IpcPrintf("Error: no such window: %s", windowid);
1144 if (!strcmp(operation, "start"))
1146 BuildWindowGroup(&ewin, 1, -1);
1147 IpcPrintf("start %8x", win);
1149 else if (!strcmp(operation, "add"))
1151 group = GroupFind2(groupid);
1152 AddEwinToGroup(ewin, group);
1153 IpcPrintf("add %8x", win);
1155 else if (!strcmp(operation, "del"))
1157 group = GroupFind2(groupid);
1158 RemoveEwinFromGroup(ewin, group);
1159 IpcPrintf("del %8x", win);
1161 else if (!strcmp(operation, "break"))
1163 group = GroupFind2(groupid);
1164 BreakWindowGroup(ewin, group);
1165 IpcPrintf("break %8x", win);
1167 else if (!strcmp(operation, "showhide"))
1169 ShowHideWinGroups(ewin, -1, SET_TOGGLE);
1170 IpcPrintf("showhide %8x", win);
1174 IpcPrintf("Error: no such operation: %s", operation);
1181 IPC_Group(const char *params)
1184 char operation[128];
1191 IpcPrintf("Error: no group specified");
1195 groupid[0] = operation[0] = param1[0] = '\0';
1196 sscanf(params, "%100s %100s %100s", groupid, operation, param1);
1200 IpcPrintf("Error: no operation specified");
1204 group = GroupFind2(groupid);
1207 IpcPrintf("Error: no such group: %s", groupid);
1213 IpcPrintf("Error: no mode specified");
1218 if (!strcmp(param1, "on"))
1220 else if (!strcmp(param1, "off"))
1223 if (onoff == -1 && strcmp(param1, "?"))
1225 IpcPrintf("Error: unknown mode specified");
1227 else if (!strcmp(operation, "num_members"))
1229 IpcPrintf("num_members: %d", group->num_members);
1232 else if (!strcmp(operation, "iconify"))
1235 group->cfg.iconify = onoff;
1237 onoff = group->cfg.iconify;
1239 else if (!strcmp(operation, "kill"))
1242 group->cfg.kill = onoff;
1244 onoff = group->cfg.kill;
1246 else if (!strcmp(operation, "move"))
1249 group->cfg.move = onoff;
1251 onoff = group->cfg.move;
1253 else if (!strcmp(operation, "raise"))
1256 group->cfg.raise = onoff;
1258 onoff = group->cfg.raise;
1260 else if (!strcmp(operation, "set_border"))
1263 group->cfg.set_border = onoff;
1265 onoff = group->cfg.set_border;
1267 else if (!strcmp(operation, "stick"))
1270 group->cfg.stick = onoff;
1272 onoff = group->cfg.stick;
1274 else if (!strcmp(operation, "shade"))
1277 group->cfg.shade = onoff;
1279 onoff = group->cfg.shade;
1283 IpcPrintf("Error: no such operation: %s", operation);
1288 IpcPrintf("%s: on", operation);
1289 else if (onoff == 0)
1290 IpcPrintf("%s: off", operation);
1295 GroupsIpc(const char *params)
1298 char cmd[128], prm[128];
1301 cmd[0] = prm[0] = '\0';
1306 sscanf(p, "%100s %100s %n", cmd, prm, &len);
1310 if (!p || cmd[0] == '?')
1314 else if (!strncmp(cmd, "cfg", 2))
1316 GroupsConfigure(prm);
1319 #endif /* ENABLE_DIALOGS */
1321 static const IpcItem GroupsIpcArray[] = {
1326 "Configure window groups",
1327 " groups cfg Configure groups\n"}
1329 #endif /* ENABLE_DIALOGS */
1333 "Retrieve some info on groups",
1334 "use \"group_info [group_index]\"\n"}
1340 "use \"group_op <windowid> <property> [<value>]\" to perform "
1341 "group operations on a window.\n" "Available group_op commands are:\n"
1342 " group_op <windowid> start\n"
1343 " group_op <windowid> add [<group_index>]\n"
1344 " group_op <windowid> del [<group_index>]\n"
1345 " group_op <windowid> break [<group_index>]\n"
1346 " group_op <windowid> showhide\n"}
1352 "use \"group <groupid> <property> <value>\" to set group properties.\n"
1353 "Available group commands are:\n"
1354 " group <groupid> num_members <on/off/?>\n"
1355 " group <groupid> iconify <on/off/?>\n"
1356 " group <groupid> kill <on/off/?>\n" " group <groupid> move <on/off/?>\n"
1357 " group <groupid> raise <on/off/?>\n"
1358 " group <groupid> set_border <on/off/?>\n"
1359 " group <groupid> stick <on/off/?>\n"
1360 " group <groupid> shade <on/off/?>\n"}
1363 #define N_IPC_FUNCS (sizeof(GroupsIpcArray)/sizeof(IpcItem))
1366 * Configuration items
1368 static const CfgItem GroupsCfgItems[] = {
1369 CFG_ITEM_BOOL(Conf_groups, dflt.iconify, 1),
1370 CFG_ITEM_BOOL(Conf_groups, dflt.kill, 0),
1371 CFG_ITEM_BOOL(Conf_groups, dflt.move, 1),
1372 CFG_ITEM_BOOL(Conf_groups, dflt.raise, 0),
1373 CFG_ITEM_BOOL(Conf_groups, dflt.set_border, 1),
1374 CFG_ITEM_BOOL(Conf_groups, dflt.stick, 1),
1375 CFG_ITEM_BOOL(Conf_groups, dflt.shade, 1),
1376 CFG_ITEM_BOOL(Conf_groups, swapmove, 1),
1378 #define N_CFG_ITEMS (sizeof(GroupsCfgItems)/sizeof(CfgItem))
1380 extern const EModule ModGroups;
1381 const EModule ModGroups = {
1384 {N_IPC_FUNCS, GroupsIpcArray},
1385 {N_CFG_ITEMS, GroupsCfgItems}