Switch to new list implementation.

Faster, less code, less memory usage.
Not that it matters much - mostly for fun.
This commit is contained in:
Kim Woelders 2013-06-06 22:37:06 +02:00
parent 956b586383
commit e287b37e78
29 changed files with 741 additions and 1227 deletions

View File

@ -41,7 +41,7 @@ e16_SOURCES = \
dialog.c dialog.h \
dock.c \
draw.c \
e16-ecore_list.c e16-ecore_list.h \
list.c list.h \
econfig.c econfig.h \
edebug.h \
edge.c \

View File

@ -25,11 +25,11 @@
#include "aclass.h"
#include "conf.h"
#include "cursors.h"
#include "e16-ecore_list.h"
#include "emodule.h"
#include "ewins.h"
#include "file.h"
#include "grabs.h"
#include "list.h"
#include "timers.h"
#include <ctype.h>
@ -52,6 +52,7 @@ struct _action {
};
struct _actionclass {
dlist_t list;
char *name;
int num;
Action **actions;
@ -65,8 +66,8 @@ static void GrabActionKey(Action * aa);
static void BindingsSave(void);
static Ecore_List *aclass_list = NULL;
static Ecore_List *aclass_list_global = NULL;
static LIST_HEAD(aclass_list);
static LIST_HEAD(aclass_list_global);
static char mode_action_destroy = 0;
static char mode_keybinds_changed = 0;
@ -183,16 +184,12 @@ ActionclassCreate(const char *name, int global)
if (global)
{
if (!aclass_list_global)
aclass_list_global = ecore_list_new();
ecore_list_prepend(aclass_list_global, ac);
LIST_PREPEND(ActionClass, &aclass_list_global, ac);
ac->global = 1;
}
else
{
if (!aclass_list)
aclass_list = ecore_list_new();
ecore_list_prepend(aclass_list, ac);
LIST_PREPEND(ActionClass, &aclass_list, ac);
}
return ac;
@ -223,7 +220,7 @@ ActionclassDestroy(ActionClass * ac)
return;
}
ecore_list_node_remove(aclass_list, ac);
LIST_REMOVE(ActionClass, &aclass_list, ac);
ActionclassEmpty(ac);
Efree(ac->name);
@ -241,8 +238,8 @@ _ActionclassMatchName(const void *data, const void *match)
static ActionClass *
ActionclassFindGlobal(const char *name)
{
return (ActionClass *) ecore_list_find(aclass_list_global,
_ActionclassMatchName, name);
return LIST_FIND(ActionClass, &aclass_list_global,
_ActionclassMatchName, name);
}
ActionClass *
@ -250,8 +247,7 @@ ActionclassFind(const char *name)
{
if (!name)
return NULL;
return (ActionClass *) ecore_list_find(aclass_list, _ActionclassMatchName,
name);
return LIST_FIND(ActionClass, &aclass_list, _ActionclassMatchName, name);
}
static ActionClass *
@ -259,12 +255,11 @@ ActionclassFindAny(const char *name)
{
ActionClass *ac;
ac = (ActionClass *) ecore_list_find(aclass_list_global,
_ActionclassMatchName, name);
ac = LIST_FIND(ActionClass, &aclass_list_global,
_ActionclassMatchName, name);
if (ac)
return ac;
return (ActionClass *) ecore_list_find(aclass_list, _ActionclassMatchName,
name);
return LIST_FIND(ActionClass, &aclass_list, _ActionclassMatchName, name);
}
int
@ -339,8 +334,8 @@ AclassConfigLoad(FILE * fs)
case ACLASS_TYPE:
if (!ac || i2 == ACLASS_TYPE_ACLASS)
break;
ecore_list_node_remove(aclass_list, ActionclassFind(ac->name));
ecore_list_prepend(aclass_list_global, ac);
LIST_REMOVE(ActionClass, &aclass_list, ActionclassFind(ac->name));
LIST_PREPEND(ActionClass, &aclass_list_global, ac);
global = 1;
break;
@ -1142,7 +1137,7 @@ ActionclassesGlobalEvent(XEvent * ev)
int match;
match = 0;
ECORE_LIST_FOR_EACH(aclass_list_global, ac)
LIST_FOR_EACH(ActionClass, &aclass_list_global, ac)
match |= ActionclassEvent(ac, ev, GetFocusEwin());
return match;
@ -1212,19 +1207,20 @@ AclassIpc(const char *params)
if (prm[0] == '\0')
{
IpcPrintf("Normal:\n");
ECORE_LIST_FOR_EACH(aclass_list, ac) IpcPrintf("%s\n", ac->name);
LIST_FOR_EACH(ActionClass, &aclass_list, ac)
IpcPrintf("%s\n", ac->name);
IpcPrintf("Global:\n");
ECORE_LIST_FOR_EACH(aclass_list_global, ac) IpcPrintf("%s\n",
ac->name);
LIST_FOR_EACH(ActionClass, &aclass_list_global, ac)
IpcPrintf("%s\n", ac->name);
}
else if (!strcmp(prm, "all"))
{
ECORE_LIST_FOR_EACH(aclass_list, ac)
LIST_FOR_EACH(ActionClass, &aclass_list, ac)
{
IpcPrintf("\n");
AclassConfigWrite(ac, IpcPrintf);
}
ECORE_LIST_FOR_EACH(aclass_list_global, ac)
LIST_FOR_EACH(ActionClass, &aclass_list_global, ac)
{
IpcPrintf("\n");
AclassConfigWrite(ac, IpcPrintf);

View File

@ -26,11 +26,11 @@
#include "backgrounds.h"
#include "desktops.h"
#include "dialog.h"
#include "e16-ecore_list.h"
#include "eimage.h"
#include "emodule.h"
#include "file.h"
#include "iclass.h"
#include "list.h"
#include "settings.h"
#include "tclass.h"
#include "timers.h"
@ -45,6 +45,7 @@ typedef struct {
} BgPart;
struct _background {
dlist_t list;
char *name;
Pixmap pmap;
time_t last_viewed;
@ -59,7 +60,8 @@ struct _background {
unsigned int seq_no;
};
static Ecore_List *bg_list = NULL;
static LIST_HEAD(bg_list);
static Timer *bg_timer = NULL;
static unsigned int bg_seq_no = 0;
@ -255,7 +257,7 @@ BackgroundDestroy(Background * bg)
return -1;
}
ecore_list_node_remove(bg_list, bg);
LIST_REMOVE(Background, &bg_list, bg);
BackgroundFilesRemove(bg);
BackgroundPixmapFree(bg);
@ -333,9 +335,7 @@ BackgroundCreate(const char *name, unsigned int solid, const char *bgn,
bg->seq_no = ++bg_seq_no;
if (!bg_list)
bg_list = ecore_list_new();
ecore_list_prepend(bg_list, bg);
LIST_PREPEND(Background, &bg_list, bg);
return bg;
}
@ -388,13 +388,13 @@ _BackgroundMatchName(const void *data, const void *match)
Background *
BackgroundFind(const char *name)
{
return (Background *) ecore_list_find(bg_list, _BackgroundMatchName, name);
return LIST_FIND(Background, &bg_list, _BackgroundMatchName, name);
}
static Background *
BackgroundCheck(Background * bg)
{
return (Background *) ecore_list_goto(bg_list, bg);
return LIST_CHECK(Background, &bg_list, bg);
}
void
@ -1018,7 +1018,7 @@ BackgroundsInvalidate(int refresh)
{
Background *bg;
ECORE_LIST_FOR_EACH(bg_list, bg) BackgroundInvalidate(bg, refresh);
LIST_FOR_EACH(Background, &bg_list, bg) BackgroundInvalidate(bg, refresh);
}
static Background *
@ -1028,11 +1028,11 @@ BackgroundGetRandom(void)
int num;
unsigned int rnd;
num = ecore_list_count(bg_list);
num = LIST_GET_COUNT(&bg_list);
for (;;)
{
rnd = rand();
bg = (Background *) ecore_list_index_goto(bg_list, rnd % num);
rnd = rand() % num;
bg = LIST_GET_BY_INDEX(Background, &bg_list, rnd);
if (num <= 1 || !BackgroundIsNone(bg))
break;
}
@ -1252,11 +1252,7 @@ BackgroundsConfigSave(void)
FILE *fs;
Background *bg;
unsigned int j;
int i, num, r, g, b;
num = ecore_list_count(bg_list);
if (num <= 0)
return;
int r, g, b;
Etmp(st);
fs = fopen(st, "w");
@ -1264,55 +1260,50 @@ BackgroundsConfigSave(void)
return;
/* For obscure reasons, store backgrounds in reverse order. */
for (i = num - 1; i >= 0; i--)
{
bg = (Background *) ecore_list_index_goto(bg_list, i);
if (!bg)
LIST_FOR_EACH_REV(Background, &bg_list, bg)
{
/* Get full path to files */
_BackgroundGetBgFile(bg);
_BackgroundGetFgFile(bg);
/* Discard if bg file is given but cannot be found (ignore bad fg) */
if (bg->bg.file && !exists(bg->bg.file))
{
Eprintf("Discard broken background %s (%s)\n",
bg->name, bg->bg.file);
continue;
}
/* Get full path to files */
_BackgroundGetBgFile(bg);
_BackgroundGetFgFile(bg);
/* Discard if bg file is given but cannot be found (ignore bad fg) */
if (bg->bg.file && !exists(bg->bg.file))
{
Eprintf("Discard broken background %s (%s)\n",
bg->name, bg->bg.file);
continue;
}
fprintf(fs, "5 999\n");
fprintf(fs, "5 999\n");
fprintf(fs, "100 %s\n", bg->name);
COLOR32_TO_RGB(bg->bg_solid, r, g, b);
if (r != 0 || g != 0 || b != 0)
fprintf(fs, "%d %d %d %d\n", BG_RGB, r, g, b);
fprintf(fs, "100 %s\n", bg->name);
COLOR32_TO_RGB(bg->bg_solid, r, g, b);
if (r != 0 || g != 0 || b != 0)
fprintf(fs, "%d %d %d %d\n", BG_RGB, r, g, b);
if (bg->bg.file)
{
fprintf(fs, "%d %s\n", BG_BG_FILE, bg->bg.file);
fprintf(fs, "%d %d %d %d %d %d %d\n", BG_BG_PARAM,
bg->bg_tile, bg->bg.keep_aspect,
bg->bg.xjust, bg->bg.yjust, bg->bg.xperc, bg->bg.yperc);
}
if (bg->bg.file)
{
fprintf(fs, "%d %s\n", BG_BG_FILE, bg->bg.file);
fprintf(fs, "%d %d %d %d %d %d %d\n", BG_BG_PARAM,
bg->bg_tile, bg->bg.keep_aspect,
bg->bg.xjust, bg->bg.yjust, bg->bg.xperc, bg->bg.yperc);
}
if (bg->top.file)
{
fprintf(fs, "%d %s\n", BG_TOP_FILE, bg->top.file);
fprintf(fs, "%d %d %d %d %d %d\n", BG_TOP_PARAM,
bg->top.keep_aspect,
bg->top.xjust, bg->top.yjust, bg->top.xperc, bg->top.yperc);
}
if (bg->top.file)
{
fprintf(fs, "%d %s\n", BG_TOP_FILE, bg->top.file);
fprintf(fs, "%d %d %d %d %d %d\n", BG_TOP_PARAM,
bg->top.keep_aspect,
bg->top.xjust, bg->top.yjust,
bg->top.xperc, bg->top.yperc);
}
for (j = 0; j < N_BG_ASSIGNED; j++)
{
if (bg == bg_assigned[j])
fprintf(fs, "%d %u\n", BG_DESKNUM, j);
}
for (j = 0; j < N_BG_ASSIGNED; j++)
{
if (bg == bg_assigned[j])
fprintf(fs, "%d %u\n", BG_DESKNUM, j);
}
fprintf(fs, "1000\n");
}
fprintf(fs, "1000\n");
}
fclose(fs);
@ -1327,29 +1318,26 @@ BackgroundsConfigSave(void)
static void
BackgroundsCheckDups(void)
{
int ix;
Background *bg, *bgx;
Background *bg, *bgx, *btmp;
for (ix = 0;; ix++)
{
ecore_list_index_goto(bg_list, ix);
bg = (Background *) ecore_list_next(bg_list);
if (!bg)
break;
for (; (bgx = (Background *) ecore_list_next(bg_list));)
{
if (bgx->ref_count > 0 || bgx->referenced)
continue;
LIST_FOR_EACH(Background, &bg_list, bg)
{
bgx = LIST_NEXT(Background, &bg_list, bg);
for (; bgx; bgx = btmp)
{
btmp = LIST_NEXT(Background, &bg_list, bgx);
if (BackgroundCmp(bg, bgx))
continue;
if (bgx->ref_count > 0 || bgx->referenced)
continue;
if (BackgroundCmp(bg, bgx))
continue;
#if 0
Eprintf("Remove duplicate background %s (==%s)\n", bgx->name,
bg->name);
Eprintf("Remove duplicate background %s (==%s)\n", bgx->name,
bg->name);
#endif
BackgroundDestroy(bgx);
}
}
BackgroundDestroy(bgx);
}
}
}
static void
@ -1361,7 +1349,7 @@ BackgroundsAccounting(void)
DesksBackgroundRefresh(NULL, DESK_BG_TIMEOUT);
now = time(NULL);
ECORE_LIST_FOR_EACH(bg_list, bg)
LIST_FOR_EACH(Background, &bg_list, bg)
{
/* Skip if no pixmap or not timed out */
if (bg->pmap == None ||
@ -1602,21 +1590,17 @@ static void
CB_ConfigureDelBG(Dialog * d __UNUSED__, int val, void *data __UNUSED__)
{
Background *bg;
int i, num;
int lower, upper;
num = ecore_list_count(bg_list);
if (num <= 1)
return;
bg = (Background *) ecore_list_goto(bg_list, tmp_bg);
bg = LIST_CHECK(Background, &bg_list, tmp_bg);
if (!bg)
return;
if (BackgroundIsNone(bg))
return;
i = ecore_list_index(bg_list);
bg =
(Background *) ecore_list_index_goto(bg_list,
(i < num - 1) ? i + 1 : i - 1);
bg = LIST_NEXT(Background, &bg_list, tmp_bg);
if (!bg)
bg = LIST_PREV(Background, &bg_list, tmp_bg);
DeskBackgroundSet(DesksGetCurrent(), bg);
@ -1647,8 +1631,8 @@ CB_ConfigureFrontBG(Dialog * d __UNUSED__, int val __UNUSED__,
if (BackgroundIsNone(tmp_bg))
return; /* Don't move "None" background */
bg = ecore_list_node_remove(bg_list, tmp_bg);
ecore_list_prepend(bg_list, bg);
bg = LIST_REMOVE(Background, &bg_list, tmp_bg);
LIST_PREPEND(Background, &bg_list, bg);
BGSettingsGoTo(bg);
BG_RedrawView();
autosave();
@ -1666,7 +1650,7 @@ BG_RedrawView(void)
int mini_w = Mode.backgrounds.mini_w;
int mini_h = Mode.backgrounds.mini_h;
num = ecore_list_count(bg_list);
num = LIST_GET_COUNT(&bg_list);
if (num <= 0)
return;
@ -1683,7 +1667,7 @@ BG_RedrawView(void)
x = -(num * (mini_w + 8) - w) * tmp_bg_sel_sliderval / (4 * num);
ECORE_LIST_FOR_EACH(bg_list, bg)
LIST_FOR_EACH(Background, &bg_list, bg)
{
if (((x + mini_w + 8) >= 0) && (x < w))
{
@ -1747,7 +1731,7 @@ CB_BGScan(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
Mode.backgrounds.force_scan = 1;
ScanBackgroundMenu();
num = ecore_list_count(bg_list);
num = LIST_GET_COUNT(&bg_list);
DialogItemSliderSetBounds(bg_sel_slider, 0, num * 4);
DialogItemCallCallback(d, bg_sel_slider);
}
@ -1768,11 +1752,11 @@ CB_BGAreaEvent(DItem * di, int val __UNUSED__, void *data)
switch (ev->xbutton.button)
{
case 1:
num = ecore_list_count(bg_list);
num = LIST_GET_COUNT(&bg_list);
x = (num * (mini_w + 8) - w) * tmp_bg_sel_sliderval / (4 * num) +
ev->xbutton.x;
bg =
(Background *) ecore_list_index_goto(bg_list, x / (mini_w + 8));
x = x / (mini_w + 8);
bg = LIST_GET_BY_INDEX(Background, &bg_list, x);
if (!bg || bg == DeskBackgroundGet(DesksGetCurrent()))
break;
BgDialogSetNewCurrent(bg);
@ -1814,12 +1798,10 @@ BGSettingsGoTo(Background * bg)
if (!bg_sel_slider)
return;
bg = (Background *) ecore_list_goto(bg_list, bg);
if (!bg)
num = LIST_GET_COUNT(&bg_list);
i = LIST_GET_INDEX(Background, &bg_list, bg);
if (i < 0)
return;
i = ecore_list_index(bg_list);
num = ecore_list_count(bg_list);
i = ((4 * num + 20) * i) / num - 8;
if (i < 0)
i = 0;
@ -1834,13 +1816,18 @@ CB_BGNext(Dialog * d __UNUSED__, int val, void *data __UNUSED__)
{
Background *bg;
bg = (Background *) ecore_list_goto(bg_list, tmp_bg);
if (!bg)
return;
bg = tmp_bg;
if (val >= 0)
{
while (bg && val--)
bg = LIST_NEXT(Background, &bg_list, bg);
}
else
{
while (bg && val++)
bg = LIST_PREV(Background, &bg_list, bg);
}
bg =
(Background *) ecore_list_index_goto(bg_list,
ecore_list_index(bg_list) + val);
if (!bg)
return;
@ -1876,16 +1863,16 @@ CB_BGSortFile(Dialog * d __UNUSED__, int val __UNUSED__, void *data __UNUSED__)
Background **bglist;
int i, num;
bglist = (Background **) ecore_list_items_get(bg_list, &num);
bglist = LIST_GET_ITEMS(Background, &bg_list, &num);
if (!bglist)
return;
/* remove them all from the list */
for (i = 0; i < num; i++)
ecore_list_node_remove(bg_list, bglist[i]);
LIST_INIT(Background, &bg_list);
qsort(bglist, num - 1, sizeof(Background *), BG_SortFileCompare);
for (i = 0; i < num; i++)
ecore_list_append(bg_list, bglist[i]);
LIST_APPEND(Background, &bg_list, bglist[i]);
Efree(bglist);
BGSettingsGoTo(tmp_bg);
@ -1897,38 +1884,34 @@ static void
CB_BGSortAttrib(Dialog * d __UNUSED__, int val __UNUSED__,
void *data __UNUSED__)
{
Background **bglist;
Background **bglist, *bg;
int i, num;
bglist = (Background **) ecore_list_items_get(bg_list, &num);
bglist = LIST_GET_ITEMS(Background, &bg_list, &num);
if (!bglist)
return;
/* remove them all from the list */
for (i = 0; i < num; i++)
ecore_list_node_remove(bg_list, bglist[i]);
LIST_INIT(Background, &bg_list);
for (i = 0; i < num; i++)
{
Background *bg;
bg = bglist[i];
if ((bg) && (bg->bg_tile) && (bg->bg.xperc == 0) && (bg->bg.yperc == 0))
{
ecore_list_prepend(bg_list, bg);
LIST_APPEND(Background, &bg_list, bg);
bglist[i] = NULL;
}
}
for (i = 0; i < num; i++)
{
Background *bg;
bg = bglist[i];
if (bg)
{
ecore_list_prepend(bg_list, bg);
LIST_APPEND(Background, &bg_list, bg);
bglist[i] = NULL;
}
}
Efree(bglist);
BGSettingsGoTo(tmp_bg);
@ -1944,15 +1927,15 @@ CB_BGSortContent(Dialog * d __UNUSED__, int val __UNUSED__,
Background **bglist;
int i, num;
bglist = (Background **) ecore_list_items_get(bg_list, &num);
bglist = LIST_GET_ITEMS(Background, &bg_list, &num);
if (!bglist)
return;
/* remove them all from the list */
LIST_INIT(Background, &bg_list);
for (i = 0; i < num; i++)
ecore_list_node_remove(bg_list, bglist[i]);
for (i = 0; i < num; i++)
ecore_list_prepend(bg_list, bglist[i]);
LIST_PREPEND(Background, &bg_list, bglist[i]);
Efree(bglist);
autosave();
@ -2209,7 +2192,7 @@ _DlgFillBackground(Dialog * d, DItem * table, void *data)
DialogItemAreaSetEventFunc(di, CB_BGAreaEvent);
DialogItemAreaSetInitFunc(di, CB_InitView);
num = ecore_list_count(bg_list);
num = LIST_GET_COUNT(&bg_list);
di = bg_sel_slider = DialogAddItem(table, DITEM_SLIDER);
DialogItemSliderSetBounds(di, 0, num * 4);
DialogItemSliderSetUnits(di, 1);
@ -2458,7 +2441,7 @@ BackgroundsIpc(const char *params)
}
else if (!strncmp(cmd, "list", 2))
{
ECORE_LIST_FOR_EACH(bg_list, bg) IpcPrintf("%s\n", bg->name);
LIST_FOR_EACH(Background, &bg_list, bg) IpcPrintf("%s\n", bg->name);
}
else if (!strncmp(cmd, "load", 2))
{

View File

@ -25,13 +25,13 @@
#include "aclass.h"
#include "borders.h"
#include "cursors.h"
#include "e16-ecore_list.h"
#include "ewins.h"
#include "focus.h"
#include "grabs.h"
#include "hints.h"
#include "iclass.h"
#include "icons.h"
#include "list.h"
#include "snaps.h"
#include "tclass.h"
#include "timers.h"
@ -45,7 +45,7 @@
#define EWIN_BORDER_TITLE_EVENT_MASK \
(EWIN_BORDER_PART_EVENT_MASK)
static Ecore_List *border_list = NULL;
static LIST_HEAD(border_list);
static void BorderDestroy(Border * b);
static void BorderWinpartHandleEvents(Win win, XEvent * ev, void *prm);
@ -673,9 +673,7 @@ BorderCreate(const char *name)
if (!b)
return NULL;
if (!border_list)
border_list = ecore_list_new();
ecore_list_prepend(border_list, b);
LIST_PREPEND(Border, &border_list, b);
b->name = Estrdup(name);
b->group_border_name = NULL;
@ -698,7 +696,7 @@ BorderDestroy(Border * b)
return;
}
ecore_list_node_remove(border_list, (Border *) b);
LIST_REMOVE(Border, &border_list, b);
for (i = 0; i < b->num_winparts; i++)
{
@ -726,7 +724,7 @@ BorderFind(const char *name)
{
if (!name)
return NULL;
return (Border *) ecore_list_find(border_list, _BorderMatchName, name);
return LIST_FIND(Border, &border_list, _BorderMatchName, name);
}
static void
@ -1362,7 +1360,7 @@ BordersGetList(int *pnum)
{
Border **lst;
lst = (Border **) ecore_list_items_get(border_list, pnum);
lst = LIST_GET_ITEMS(Border, &border_list, pnum);
qsort(lst, *pnum, sizeof(Border *), _BorderNameCompare);
return lst;

View File

@ -27,6 +27,7 @@
#include <X11/Xlib.h>
#include "eimage.h"
#include "etypes.h"
#include "list.h"
typedef struct {
int min, max;
@ -57,6 +58,7 @@ typedef struct {
} WinPart;
struct _border {
dlist_t list;
char *name;
char *group_border_name;
EImageBorder border;

View File

@ -26,12 +26,12 @@
#include "buttons.h"
#include "cursors.h"
#include "desktops.h"
#include "e16-ecore_list.h"
#include "eimage.h"
#include "emodule.h"
#include "file.h"
#include "grabs.h"
#include "iclass.h"
#include "list.h"
#include "tclass.h"
#include "tooltips.h"
#include "xwin.h"
@ -53,6 +53,7 @@ typedef struct {
} BGeometry;
struct _button {
dlist_t list;
EObj o;
BGeometry geom;
ImageClass *iclass;
@ -75,7 +76,7 @@ struct _button {
unsigned int ref_count;
};
static Ecore_List *button_list = NULL;
static LIST_HEAD(button_list);
static struct {
Button *button;
@ -132,9 +133,7 @@ ButtonCreate(const char *name, int id, const char *iclass,
if (!b)
return b;
if (!button_list)
button_list = ecore_list_new();
ecore_list_append(button_list, b);
LIST_APPEND(Button, &button_list, b);
b->id = id;
@ -188,7 +187,7 @@ ButtonDestroy(Button * b)
return;
}
ecore_list_node_remove(button_list, b);
LIST_REMOVE(Button, &button_list, b);
EoFini(b);
@ -209,7 +208,7 @@ _ButtonMatchName(const void *data, const void *match)
Button *
ButtonFind(const char *name)
{
return (Button *) ecore_list_find(button_list, _ButtonMatchName, name);
return LIST_FIND(Button, &button_list, _ButtonMatchName, name);
}
static void
@ -449,7 +448,7 @@ ButtonsForeach(int id, Desk * dsk, void (*func) (Button * b))
{
Button *b;
ECORE_LIST_FOR_EACH(button_list, b)
LIST_FOR_EACH(Button, &button_list, b)
{
if (id >= 0 && id != b->id)
continue;
@ -464,7 +463,7 @@ ButtonsMoveStickyToDesk(Desk * dsk)
{
Button *b;
ECORE_LIST_FOR_EACH(button_list, b)
LIST_FOR_EACH(Button, &button_list, b)
{
if (!EoIsSticky(b) || ButtonIsInternal(b))
continue;
@ -617,7 +616,7 @@ ButtonGetAclass(void *data)
Button *b = (Button *) data;
/* Validate button */
if (!ecore_list_goto(button_list, b))
if (!LIST_CHECK(Button, &button_list, b))
return NULL;
return b->aclass;
@ -845,7 +844,7 @@ ButtonsConfigSave(void)
Button *b;
int flags;
if (ecore_list_count(button_list) <= 0)
if (LIST_IS_EMPTY(&button_list))
return;
Etmp(st);
@ -853,7 +852,7 @@ ButtonsConfigSave(void)
if (!fs)
return;
ECORE_LIST_FOR_EACH(button_list, b)
LIST_FOR_EACH(Button, &button_list, b)
{
if (b->id != 0 || b->internal)
continue;
@ -978,7 +977,7 @@ doHideShowButton(const char *params)
if (!params)
{
bmd.id = 0;
ecore_list_for_each(button_list, _ButtonHideShow, &bmd);
LIST_FOR_EACH(Button, &button_list, b) _ButtonHideShow(b, &bmd);
goto done;
}
@ -1000,7 +999,7 @@ doHideShowButton(const char *params)
return;
bmd.regex = ss;
ecore_list_for_each(button_list, _ButtonHideShow, &bmd);
LIST_FOR_EACH(Button, &button_list, b) _ButtonHideShow(b, &bmd);
}
else if (!strcmp(s, "all_buttons_except"))
{
@ -1010,11 +1009,11 @@ doHideShowButton(const char *params)
bmd.id = 0;
bmd.match = 0;
bmd.regex = ss;
ecore_list_for_each(button_list, _ButtonHideShow, &bmd);
LIST_FOR_EACH(Button, &button_list, b) _ButtonHideShow(b, &bmd);
}
else if (!strcmp(s, "all"))
{
ecore_list_for_each(button_list, _ButtonHideShow, &bmd);
LIST_FOR_EACH(Button, &button_list, b) _ButtonHideShow(b, &bmd);
}
done:
@ -1044,7 +1043,7 @@ ButtonsIpc(const char *params)
else if (!strncmp(cmd, "list", 2))
{
IpcPrintf("Win d s l x y w h name\n");
ECORE_LIST_FOR_EACH(button_list, b)
LIST_FOR_EACH(Button, &button_list, b)
IpcPrintf("%#lx %2d %2d %2d %5d+%5d %5dx%5d %s\n",
EoGetXwin(b), EoGetDeskNum(b), EoIsSticky(b),
EoGetLayer(b), EoGetX(b), EoGetY(b), EoGetW(b), EoGetH(b),

View File

@ -25,11 +25,12 @@
#include "comms.h"
#include "hints.h"
#include "ipc.h"
#include "e16-ecore_list.h"
#include "list.h"
#include "xprop.h"
#include "xwin.h"
typedef struct {
dlist_t list;
char *name;
Window xwin;
char *msg;
@ -41,7 +42,7 @@ typedef struct {
static void CommsSend(Client * c, const char *s);
static Ecore_List *client_list = NULL;
static LIST_HEAD(client_list);
static Win comms_win = NULL;
@ -59,9 +60,7 @@ ClientCreate(Window xwin)
c->name = Estrdup(st);
c->xwin = xwin;
if (!client_list)
client_list = ecore_list_new();
ecore_list_prepend(client_list, c);
LIST_PREPEND(Client, &client_list, c);
return c;
}
@ -72,7 +71,7 @@ ClientDestroy(Client * c)
if (!c)
return;
ecore_list_node_remove(client_list, c);
LIST_REMOVE(Client, &client_list, c);
Efree(c->name);
Efree(c->msg);
@ -141,8 +140,7 @@ ClientMatchWindow(const void *data, const void *match)
static Client *
ClientFind(Window xwin)
{
return (Client *) ecore_list_find(client_list, ClientMatchWindow,
(void *)xwin);
return LIST_FIND(Client, &client_list, ClientMatchWindow, (void *)xwin);
}
static char *

View File

@ -24,13 +24,13 @@
#include "E.h"
#include "container.h"
#include "dialog.h"
#include "e16-ecore_list.h"
#include "emodule.h"
#include "eobj.h"
#include "ewins.h"
#include "hints.h"
#include "iclass.h"
#include "icons.h"
#include "list.h"
#include "menus.h"
extern const ContainerOps IconboxOps;
@ -59,7 +59,7 @@ static const unsigned char _ic_state[4] =
ContainerCfg Conf_containers;
static Ecore_List *container_list = NULL;
static LIST_HEAD(container_list);
static int
_ContainerMatchName(const void *data, const void *match)
@ -70,8 +70,7 @@ _ContainerMatchName(const void *data, const void *match)
static Container *
ContainerFind(const char *name)
{
return (Container *) ecore_list_find(container_list, _ContainerMatchName,
name);
return LIST_FIND(Container, &container_list, _ContainerMatchName, name);
}
static Container *
@ -86,9 +85,7 @@ ContainerCreate(const char *name)
if (!ct)
return NULL;
if (!container_list)
container_list = ecore_list_new();
ecore_list_append(container_list, ct);
LIST_APPEND(Container, &container_list, ct);
ct->name = Estrdup(name);
ct->type = (name && !strcmp(name, "_ST_")) ?
@ -176,7 +173,7 @@ ContainerCreate(const char *name)
static void
ContainerDestroy(Container * ct, int exiting)
{
ecore_list_node_remove(container_list, ct);
LIST_REMOVE(Container, &container_list, ct);
ct->ops->Exit(ct, exiting);
@ -1204,9 +1201,9 @@ ContainersShow(void)
{
Container *ct;
if (ecore_list_count(container_list) > 0)
if (!LIST_IS_EMPTY(&container_list))
{
ECORE_LIST_FOR_EACH(container_list, ct) ContainerShow(ct);
LIST_FOR_EACH(Container, &container_list, ct) ContainerShow(ct);
}
else if (Conf.startup.firsttime)
{
@ -1219,9 +1216,10 @@ ContainersShow(void)
static void
ContainersDestroy(void)
{
Container *ct;
Container *ct, *tmp;
ECORE_LIST_FOR_EACH(container_list, ct) ContainerDestroy(ct, 1);
LIST_FOR_EACH_SAFE(Container, &container_list, ct, tmp)
ContainerDestroy(ct, 1);
}
static void
@ -1471,7 +1469,7 @@ CB_ConfigureContainer(Dialog * d, int val, void *data __UNUSED__)
if (val >= 2)
return;
ct = (Container *) ecore_list_goto(container_list, dd->ct);
ct = LIST_CHECK(Container, &container_list, dd->ct);
if (!ct)
return;
@ -1862,7 +1860,7 @@ ContainersConfigSave(void)
return;
/* We should check for errors... */
ECORE_LIST_FOR_EACH(container_list, ct)
LIST_FOR_EACH(Container, &container_list, ct)
{
fprintf(fs, "19 999\n");
fprintf(fs, "100 %s\n", ct->name);
@ -1906,7 +1904,7 @@ ContainersSighan(int sig, void *prm)
}
#if 0 /* FIXME */
ECORE_LIST_FOR_EACH(container_list, ct)
LIST_FOR_EACH(Container, &container_list, ct)
{
if (ct->ops)
ct->ops->Signal(ct, sig, prm);
@ -1936,7 +1934,7 @@ ContainersIterate(ContainerIterator * cti, int type, void *data)
{
Container *ct;
ECORE_LIST_FOR_EACH(container_list, ct)
LIST_FOR_EACH(Container, &container_list, ct)
{
if (ct->type != type)
continue;
@ -1950,7 +1948,7 @@ ContainersIterate(ContainerIterator * cti, int type, void *data)
Container **
ContainersGetList(int *pnum)
{
return (Container **) ecore_list_items_get(container_list, pnum);
return LIST_GET_ITEMS(Container, &container_list, pnum);
}
/*
@ -1988,7 +1986,7 @@ ContainerIpc(const char *params)
if (!prm[0])
{
num = ecore_list_count(container_list);
num = LIST_GET_COUNT(&container_list);
Esnprintf(prm, sizeof(prm), "_IB_%i", num);
}
ct = ContainerCreate(prm);

View File

@ -26,6 +26,7 @@
#include <X11/Xlib.h>
#include "eimage.h"
#include "list.h"
typedef struct _container Container;
@ -51,6 +52,7 @@ typedef struct {
} ContainerOps;
struct _container {
dlist_t list;
const ContainerOps *ops;
const char *wm_name;
const char *menu_title;

View File

@ -24,8 +24,8 @@
#include "E.h"
#include "conf.h"
#include "cursors.h"
#include "e16-ecore_list.h"
#include "emodule.h"
#include "list.h"
#include "xwin.h"
#include <X11/cursorfont.h>
#if USE_XRENDER
@ -33,6 +33,7 @@
#endif
struct _ecursor {
dlist_t list;
char *name;
Cursor cursor;
unsigned int ref_count;
@ -42,7 +43,7 @@ struct _ecursor {
int native_id;
};
static Ecore_List *cursor_list = NULL;
static LIST_HEAD(cursor_list);
#if USE_XRENDER
/* Assuming we have XRenderCreateCursor (render >= 0.5) */
@ -123,9 +124,7 @@ ECursorCreate(const char *name, const char *image, int native_id,
ec->bg = bg;
ec->native_id = native_id;
if (!cursor_list)
cursor_list = ecore_list_new();
ecore_list_prepend(cursor_list, ec);
LIST_PREPEND(ECursor, &cursor_list, ec);
}
static void
@ -140,7 +139,7 @@ ECursorDestroy(ECursor * ec)
return;
}
ecore_list_node_remove(cursor_list, ec);
LIST_REMOVE(ECursor, &cursor_list, ec);
Efree(ec->name);
Efree(ec->file);
@ -220,7 +219,7 @@ ECursorFind(const char *name)
{
if (!name || !name[0])
return NULL;
return (ECursor *) ecore_list_find(cursor_list, _ECursorMatchName, name);
return LIST_FIND(ECursor, &cursor_list, _ECursorMatchName, name);
}
ECursor *
@ -410,7 +409,7 @@ CursorsIpc(const char *params)
if (!strncmp(cmd, "list", 2))
{
ECORE_LIST_FOR_EACH(cursor_list, ec) IpcPrintf("%s\n", ec->name);
LIST_FOR_EACH(ECursor, &cursor_list, ec) IpcPrintf("%s\n", ec->name);
}
}

View File

@ -24,11 +24,11 @@
#include "E.h"
#if ENABLE_DIALOGS
#include "dialog.h"
#include "e16-ecore_list.h"
#include "eimage.h"
#include "ewins.h"
#include "hints.h"
#include "iclass.h"
#include "list.h"
#include "tclass.h"
#include "timers.h"
#include "xwin.h"
@ -151,6 +151,7 @@ typedef struct {
} DKeyBind;
struct _dialog {
dlist_t list;
EWin *ewin;
Win win;
int w, h;
@ -195,7 +196,7 @@ static void DialogAddFooter(Dialog * d, DItem * parent,
static void DialogAddHeader(Dialog * d, DItem * parent,
const char *img, const char *txt);
static Ecore_List *dialog_list = NULL;
static LIST_HEAD(dialog_list);
static char dialog_update_pending = 0;
@ -228,9 +229,7 @@ DialogCreate(const char *name)
if (!d)
return NULL;
if (!dialog_list)
dialog_list = ecore_list_new();
ecore_list_append(dialog_list, d);
LIST_APPEND(Dialog, &dialog_list, d);
d->name = Estrdup(name);
d->win = ECreateClientWindow(VROOT, -20, -20, 2, 2);
@ -248,7 +247,7 @@ DialogCreate(const char *name)
static void
DialogDestroy(Dialog * d)
{
ecore_list_node_remove(dialog_list, d);
LIST_REMOVE(Dialog, &dialog_list, d);
Efree(d->name);
Efree(d->title);
@ -273,7 +272,7 @@ _DialogMatchName(const void *data, const void *match)
Dialog *
DialogFind(const char *name)
{
return (Dialog *) ecore_list_find(dialog_list, _DialogMatchName, name);
return LIST_FIND(Dialog, &dialog_list, _DialogMatchName, name);
}
void
@ -1557,7 +1556,7 @@ _DialogsCheckUpdate(void *data __UNUSED__)
return;
dialog_update_pending = 0;
ECORE_LIST_FOR_EACH(dialog_list, d)
LIST_FOR_EACH(Dialog, &dialog_list, d)
{
if (d->update)
DialogUpdate(d);

View File

@ -1,769 +0,0 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler and various contributors (see AUTHORS)
* Copyright (C) 2006-2010 Kim Woelders
*
* Copyright (C) Nathan Ingersoll (author)
* Copyright (C) Ibukun Olumuyiwa (ewd -> ecore)
* Copyright (C) Dan Sinclair (various cleanups)
* Copyright (C) Kim Woelders (e16 port/additions)
*
* 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:
*
* 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.
*
* 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.
*/
/*
* Most of this was snatched from e17/libs/ecore/src/lib/ecore/ecore_list.c
* revision 1.21, and associated header files.
* The pertinent AUTHORS list is e17/libs/ecore/AUTHORS.
*/
#include <stdlib.h>
#include <string.h>
#include "e16-ecore_list.h"
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
typedef struct _ecore_list_node Ecore_List_Node;
struct _ecore_list_node {
void *data;
struct _ecore_list_node *next;
};
struct _ecore_list {
Ecore_List_Node *first; /* The first node in the list */
Ecore_List_Node *last; /* The last node in the list */
Ecore_List_Node *current; /* The current node in the list */
Ecore_Free_Cb free_func; /* The callback to free data in nodes */
int nodes; /* The number of nodes in the list */
int index; /* The position from the front of the
* list of current node */
};
/* Creating and destroying list nodes */
static Ecore_List_Node *_ecore_list_node_new(void);
static int _ecore_list_node_destroy(Ecore_List_Node * _e_node,
Ecore_Free_Cb free_func);
/**
* @defgroup Ecore_Data_List_Creation_Group List Creation/Destruction Functions
*
* Functions that create, initialize and destroy Ecore_Lists.
*/
/**
* Create and initialize a new list.
* @return A new initialized list on success, @c NULL on failure.
* @ingroup Ecore_Data_List_Creation_Group
*/
Ecore_List *
ecore_list_new(void)
{
Ecore_List *list;
list = (Ecore_List *) calloc(1, sizeof(Ecore_List));
return list;
}
/**
* Free a list and all of it's nodes.
* @param list The list to be freed.
* @ingroup Ecore_Data_List_Creation_Group
*/
void
ecore_list_destroy(Ecore_List * list)
{
void *data;
if (!list)
return;
while (list->first)
{
data = ecore_list_first_remove(list);
if (list->free_func)
list->free_func(data);
}
free(list);
}
/**
* Set the function for freeing data.
* @param list The list that will use this function when nodes are
* destroyed.
* @param free_func The function that will free the key data.
* @return @c TRUE on successful set, @c FALSE otherwise.
*/
int
ecore_list_free_cb_set(Ecore_List * list, Ecore_Free_Cb free_func)
{
if (!list)
return FALSE;
list->free_func = free_func;
return TRUE;
}
static int
_ecore_list_empty_is(Ecore_List * list)
{
return (list && list->nodes) ? FALSE : TRUE;
}
#if 0 /* Unused */
/**
* Checks the list for any nodes.
* @param list The list to check for nodes
* @return @c TRUE if no nodes in list, @c FALSE if the list contains nodes
*/
int
ecore_list_empty_is(Ecore_List * list)
{
return _ecore_list_empty_is(list);
}
#endif
/**
* Returns the number of the current node.
* @param list The list to return the number of the current node.
* @return The number of the current node in the list.
*/
int
ecore_list_index(Ecore_List * list)
{
return (list) ? list->index : 0;
}
/**
* Find the number of nodes in the list.
* @param list The list to find the number of nodes
* @return The number of nodes in the list.
*/
int
ecore_list_count(Ecore_List * list)
{
return (list) ? list->nodes : 0;
}
/**
* @defgroup Ecore_Data_List_Add_Item_Group List Item Adding Functions
*
* Functions that are used to add nodes to an Ecore_List.
*/
/* For adding items to the end of the list */
static int
_ecore_list_append_0(Ecore_List * list, Ecore_List_Node * end)
{
if (list->last)
list->last->next = end;
list->last = end;
if (!list->first)
{
list->first = end;
list->index = 0;
list->current = NULL;
}
if (list->index >= list->nodes)
list->index++;
list->nodes++;
return TRUE;
}
/**
* Append data to the list.
* @param list The list.
* @param data The data to append.
* @return @c FALSE if an error occurs, @c TRUE if appended successfully
* @ingroup Ecore_Data_List_Add_Item_Group
*/
int
ecore_list_append(Ecore_List * list, void *data)
{
int ret;
Ecore_List_Node *node;
node = _ecore_list_node_new();
node->data = data;
ret = _ecore_list_append_0(list, node);
return ret;
}
/* For adding items to the beginning of the list */
static int
_ecore_list_prepend_0(Ecore_List * list, Ecore_List_Node * start)
{
/* Put it at the beginning of the list */
start->next = list->first;
list->first = start;
/* If no last node, then the first node is the last node */
if (!list->last)
list->last = list->first;
list->nodes++;
list->index++;
return TRUE;
}
/**
* Prepend data to the beginning of the list.
* @param list The list.
* @param data The data to prepend.
* @return @c FALSE if an error occurs, @c TRUE if prepended successfully.
* @ingroup Ecore_Data_List_Add_Item_Group
*/
int
ecore_list_prepend(Ecore_List * list, void *data)
{
int ret;
Ecore_List_Node *node;
node = _ecore_list_node_new();
node->data = data;
ret = _ecore_list_prepend_0(list, node);
return ret;
}
#if 0 /* Unused */
/* For adding items in front of the current position in the list */
static int
_ecore_list_insert(Ecore_List * list, Ecore_List_Node * new_node)
{
/*
* If the current point is at the beginning of the list, then it's the
* same as prepending it to the list.
*/
if (list->current == list->first)
return _ecore_list_prepend_0(list, new_node);
if (!list->current)
{
int ret_value;
ret_value = _ecore_list_append_0(list, new_node);
list->current = list->last;
return ret_value;
}
/* Setup the fields of the new node */
new_node->next = list->current;
/* And hook the node into the list */
ecore_list_index_goto(list, ecore_list_index(list) - 1);
list->current->next = new_node;
/* Now move the current item to the inserted item */
list->current = new_node;
list->index++;
list->nodes++;
return TRUE;
}
/**
* Insert data in front of the current point in the list.
* @param list The list to hold the inserted @p data.
* @param data The data to insert into @p list.
* @return @c FALSE if there is an error, @c TRUE on success
* @ingroup Ecore_Data_List_Add_Item_Group
*/
int
ecore_list_insert(Ecore_List * list, void *data)
{
int ret;
Ecore_List_Node *node;
node = _ecore_list_node_new();
node->data = data;
ret = _ecore_list_insert(list, node);
return ret;
}
#endif
/**
* @defgroup Ecore_Data_List_Remove_Item_Group List Item Removing Functions
*
* Functions that remove nodes from an Ecore_List.
*/
/**
* Remove the current item from the list.
* @param list The list to remove the current item
* @return A pointer to the removed data on success, @c NULL on failure.
* @ingroup Ecore_Data_List_Remove_Item_Group
*/
void *
ecore_list_remove(Ecore_List * list)
{
void *ret;
Ecore_List_Node *old;
if (_ecore_list_empty_is(list))
return NULL;
if (!list->current)
return NULL;
if (list->current == list->first)
return ecore_list_first_remove(list);
if (list->current == list->last)
return ecore_list_last_remove(list);
old = list->current;
ecore_list_index_goto(list, list->index - 1);
list->current->next = old->next;
old->next = NULL;
ret = old->data;
old->data = NULL;
ecore_list_next(list);
_ecore_list_node_destroy(old, NULL);
list->nodes--;
return ret;
}
#if 0 /* Unused */
/**
* Remove and free the data in lists current position.
* @param list The list to remove and free the current item.
* @return @c TRUE on success, @c FALSE on error
* @ingroup Ecore_Data_List_Remove_Item_Group
*/
int
ecore_list_remove_destroy(Ecore_List * list)
{
void *data;
if (!list)
return FALSE;
data = ecore_list_remove(list);
if (list->free_func)
list->free_func(data);
return TRUE;
}
#endif
/**
* Remove the first item from the list.
* @param list The list to remove the current item
* @return Returns a pointer to the removed data on success, @c NULL on
* failure.
* @ingroup Ecore_Data_List_Remove_Item_Group
*/
void *
ecore_list_first_remove(Ecore_List * list)
{
void *ret;
Ecore_List_Node *old;
if (_ecore_list_empty_is(list))
return NULL;
old = list->first;
list->first = list->first->next;
if (list->current == old)
list->current = list->first;
else
list->index--;
if (list->last == old)
list->last = list->first;
ret = old->data;
old->data = NULL;
_ecore_list_node_destroy(old, NULL);
list->nodes--;
return ret;
}
/**
* Remove the last item from the list.
* @param list The list to remove the last node from
* @return A pointer to the removed data on success, @c NULL on failure.
* @ingroup Ecore_Data_List_Remove_Item_Group
*/
void *
ecore_list_last_remove(Ecore_List * list)
{
void *ret;
Ecore_List_Node *old, *prev;
if (_ecore_list_empty_is(list))
return NULL;
old = list->last;
if (list->current == old)
list->current = NULL;
if (list->first == old)
list->first = NULL;
for (prev = list->first; prev && prev->next != old; prev = prev->next)
;
list->last = prev;
if (prev)
prev->next = NULL;
old->next = NULL;
ret = old->data;
old->data = NULL;
_ecore_list_node_destroy(old, NULL);
list->nodes--;
return ret;
}
/**
* @defgroup Ecore_Data_List_Traverse_Group List Traversal Functions
*
* Functions that can be used to traverse an Ecore_List.
*/
/**
* Make the current item the item with the given index number.
* @param list The list.
* @param indx The position to move the current item.
* @return A pointer to new current item on success, @c NULL on failure.
* @ingroup Ecore_Data_List_Traverse_Group
*/
void *
ecore_list_index_goto(Ecore_List * list, int indx)
{
int i;
if (_ecore_list_empty_is(list))
return NULL;
if (indx > ecore_list_count(list) || indx < 0)
return NULL;
ecore_list_first_goto(list);
for (i = 0; i < indx && ecore_list_next(list); i++)
;
if (i >= list->nodes)
return NULL;
list->index = i;
return list->current->data;
}
/**
* Make the current item the node that contains @p data.
* @param list The list.
* @param data The data to find.
* @return A pointer to @p data on success, @c NULL on failure.
* @ingroup Ecore_Data_List_Traverse_Group
*/
void *
ecore_list_goto(Ecore_List * list, const void *data)
{
int indx;
Ecore_List_Node *node;
if (!list)
return NULL;
indx = 0;
node = list->first;
while (node && node->data)
{
Ecore_List_Node *next;
if (node->data == data)
break;
next = node->next;
node = next;
indx++;
}
if (!node)
return NULL;
list->current = node;
list->index = indx;
return list->current->data;
}
/**
* Make the current item the first item in the list
* @param list The list.
* @return A pointer to the first item on success, @c NULL on failure
* @ingroup Ecore_Data_List_Traverse_Group
*/
void *
ecore_list_first_goto(Ecore_List * list)
{
if (!list || !list->first)
return NULL;
list->current = list->first;
list->index = 0;
return list->current->data;
}
#if 0 /* Unused */
/**
* Make the current item the last item in the list.
* @param list The list.
* @return A pointer to the last item on success, @c NULL on failure.
* @ingroup Ecore_Data_List_Traverse_Group
*/
void *
ecore_list_last_goto(Ecore_List * list)
{
if (!list || !list->last)
return NULL;
list->current = list->last;
list->index = (list->nodes - 1);
return list->current->data;
}
#endif
#if 0 /* Unused */
/**
* Retrieve the data pointed to by the current item in @p list.
* @param list The list.
* @return Returns the data at current position, can be @c NULL.
*/
void *
ecore_list_current(Ecore_List * list)
{
return (list && list->current) ? list->current->data : NULL;
}
#endif
/**
* Retrieve the data pointed to by the current item, and make the next item
* the current item.
* @param list The list to retrieve data from.
* @return The current item in the list on success, @c NULL on failure.
*/
void *
ecore_list_next(Ecore_List * list)
{
void *data;
Ecore_List_Node *ret;
Ecore_List_Node *next;
if (!list || !list->current)
return NULL;
ret = list->current;
next = list->current->next;
list->current = next;
list->index++;
data = ret->data;
return data;
}
#if 0 /* Unused */
/**
* Remove all nodes from @p list.
* @param list The list.
* @return Returns @c TRUE on success, @c FALSE on error.
* @note The data for each item on the list is not freed by
* @c ecore_list_clear().
*/
int
ecore_list_clear(Ecore_List * list)
{
while (!ecore_list_empty_is(list))
ecore_list_first_remove(list);
return TRUE;
}
#endif
/**
* Execute function for each node in @p list.
* @param list The list.
* @param function The function to pass each node from @p list to.
* @return Returns @c TRUE on success, @c FALSE on failure.
* @ingroup Ecore_Data_List_Traverse_Group
*/
int
ecore_list_for_each(Ecore_List * list, Ecore_For_Each function, void *user_data)
{
Ecore_List_Node *node, *next;
if (!list || !function)
return FALSE;
for (node = list->first; node; node = next)
{
next = node->next;
function(node->data, user_data);
}
return TRUE;
}
/**
* Find data in @p list using the compare function @p func
* @param list The list.
* @param function The function to test each node of @p list with
* @param user_data Data to match against (used by @p function)
* @return the first matching data node, or NULL if none match
*/
void *
ecore_list_find(Ecore_List * list, Ecore_Compare_Cb function,
const void *user_data)
{
Ecore_List_Node *node, *next;
if (!list || !function)
return NULL;
for (node = list->first; node; node = next)
{
next = node->next;
if (!function(node->data, user_data))
return node->data;
}
return NULL;
}
/**
* @defgroup Ecore_Data_List_Node_Group List Node Functions
*
* Functions that are used in the creation, maintenance and destruction of
* Ecore_List nodes.
*/
/**
* Allocates and initializes a new list node.
* @return A new Ecore_List_Node on success, @c NULL otherwise.
* @ingroup Ecore_Data_List_Node_Group
*/
static Ecore_List_Node *
_ecore_list_node_new(void)
{
Ecore_List_Node *new_node;
new_node = (Ecore_List_Node *) calloc(1, sizeof(Ecore_List_Node));
return new_node;
}
/**
* Calls the function to free the data and the node.
* @param node Node to destroy.
* @param free_func Function to call if @p node points to data to free.
* @return @c TRUE.
* @ingroup Ecore_Data_List_Node_Group
*/
static int
_ecore_list_node_destroy(Ecore_List_Node * node, Ecore_Free_Cb free_func)
{
if (free_func && node->data)
free_func(node->data);
free(node);
return TRUE;
}
/*
* E16 additions
*/
void *
ecore_list_node_remove(Ecore_List * list, void *_data)
{
void *data;
data = ecore_list_goto(list, _data);
if (data)
ecore_list_remove(list);
return data;
}
void **
ecore_list_items_get(Ecore_List * list, int *pnum)
{
void **lst, *b;
int i, num;
*pnum = 0;
num = ecore_list_count(list);
if (num <= 0)
return NULL;
lst = (void **)malloc(num * sizeof(void *));
if (!lst)
return NULL;
for (i = 0, ecore_list_first_goto(list);
(b = ecore_list_next(list)) != NULL;)
lst[i++] = b;
*pnum = num;
return lst;
}

View File

@ -1,101 +0,0 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler and various contributors (see AUTHORS)
* Copyright (C) 2006-2010 Kim Woelders
*
* Copyright (C) Nathan Ingersoll (author)
* Copyright (C) Ibukun Olumuyiwa (ewd -> ecore)
* Copyright (C) Dan Sinclair (various cleanups)
* Copyright (C) Kim Woelders (e16 port/additions)
*
* 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:
*
* 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.
*
* 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.
*/
/*
* Most of this was snatched from e17/libs/ecore/src/lib/ecore/ecore_list.c
* revision 1.21, and associated header files.
* The pertinent AUTHORS list is e17/libs/ecore/AUTHORS.
*/
#ifndef _E16_ECORE_LIST_H_
#define _E16_ECORE_LIST_H_
typedef struct _ecore_list Ecore_List;
typedef int (*Ecore_Compare_Cb) (const void *data, const void *match);
typedef void (*Ecore_For_Each) (void *value, void *user_data);
typedef void (*Ecore_Free_Cb) (void *data);
/* Creating and initializing new list structures */
Ecore_List *ecore_list_new(void);
/* Adding items to the list */
int ecore_list_append(Ecore_List * list, void *_data);
int ecore_list_prepend(Ecore_List * list, void *_data);
int ecore_list_insert(Ecore_List * list, void *_data);
/* Removing items from the list */
int ecore_list_remove_destroy(Ecore_List * list);
void *ecore_list_remove(Ecore_List * list);
void *ecore_list_first_remove(Ecore_List * list);
void *ecore_list_last_remove(Ecore_List * list);
/* Retrieve the current position in the list */
void *ecore_list_current(Ecore_List * list);
int ecore_list_index(Ecore_List * list);
int ecore_list_count(Ecore_List * list);
/* Traversing the list */
int ecore_list_for_each(Ecore_List * list,
Ecore_For_Each function,
void *user_data);
void *ecore_list_first_goto(Ecore_List * list);
void *ecore_list_last_goto(Ecore_List * list);
void *ecore_list_index_goto(Ecore_List * list, int index);
void *ecore_list_goto(Ecore_List * list, const void *_data);
/* Traversing the list and returning data */
void *ecore_list_next(Ecore_List * list);
void *ecore_list_find(Ecore_List * list,
Ecore_Compare_Cb function,
const void *match);
/* Check to see if there is any data in the list */
int ecore_list_empty_is(Ecore_List * list);
/* Remove every node in the list without freeing the list itself */
int ecore_list_clear(Ecore_List * list);
/* Free the list and it's contents */
void ecore_list_destroy(Ecore_List * list);
int ecore_list_free_cb_set(Ecore_List * list,
Ecore_Free_Cb free_func);
/* e16 additions */
#if __cplusplus
#define ECORE_LIST_FOR_EACH(list, p) \
for (ecore_list_first_goto(list); (p = (typeof(p))ecore_list_next(list)) != NULL;)
#else
#define ECORE_LIST_FOR_EACH(list, p) \
for (ecore_list_first_goto(list); (p = ecore_list_next(list)) != NULL;)
#endif
void *ecore_list_node_remove(Ecore_List * list, void *_data);
void **ecore_list_items_get(Ecore_List * list, int *pnum);
#endif /* _E16_ECORE_LIST_H_ */

View File

@ -21,15 +21,16 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "E.h"
#include "e16-ecore_list.h"
#include "list.h"
#include "parse.h"
typedef struct {
dlist_t list;
char *name;
char *font;
} FontAlias;
static Ecore_List *font_list = NULL;
static LIST_HEAD(font_list);
static void
_FontAliasDestroy(void *data)
@ -45,7 +46,7 @@ _FontAliasDestroy(void *data)
}
static FontAlias *
FontAliasCreate(const char *name, const char *font)
_FontAliasCreate(const char *name, const char *font)
{
FontAlias *fa;
@ -56,12 +57,7 @@ FontAliasCreate(const char *name, const char *font)
fa->name = Estrdup(name);
fa->font = Estrdup(font);
if (!font_list)
{
font_list = ecore_list_new();
ecore_list_free_cb_set(font_list, _FontAliasDestroy);
}
ecore_list_prepend(font_list, fa);
LIST_PREPEND(FontAlias, &font_list, fa);
return fa;
}
@ -77,7 +73,7 @@ FontLookup(const char *name)
{
FontAlias *fa;
fa = (FontAlias *) ecore_list_find(font_list, _FontMatchName, name);
fa = LIST_FIND(FontAlias, &font_list, _FontMatchName, name);
return (fa) ? fa->font : NULL;
}
@ -110,7 +106,7 @@ _FontConfigLoad(FILE * fs)
if (strncmp(name, "font-", 5))
continue;
FontAliasCreate(name, font);
_FontAliasCreate(name, font);
}
return err;
@ -161,6 +157,11 @@ FontConfigLoad(void)
void
FontConfigUnload(void)
{
ecore_list_destroy(font_list);
font_list = NULL;
FontAlias *fa, *tmp;
LIST_FOR_EACH_SAFE(FontAlias, &font_list, fa, tmp)
{
LIST_REMOVE(FontAlias, &font_list, fa);
_FontAliasDestroy(fa);
}
}

View File

@ -24,10 +24,10 @@
#include "E.h"
#include "borders.h"
#include "dialog.h"
#include "e16-ecore_list.h"
#include "emodule.h"
#include "ewins.h"
#include "groups.h"
#include "list.h"
#include "settings.h"
#include "snaps.h"
@ -44,7 +44,7 @@
#define SET_ON 1
#define SET_TOGGLE 2
static Ecore_List *group_list = NULL;
static LIST_HEAD(group_list);
static struct {
GroupConfig dflt;
@ -73,9 +73,7 @@ GroupCreate(int gid)
if (!g)
return NULL;
if (!group_list)
group_list = ecore_list_new();
ecore_list_append(group_list, g);
LIST_APPEND(Group, &group_list, g);
if (gid == -1)
{
@ -107,7 +105,7 @@ GroupDestroy(Group * g)
return;
Dprintf("grp=%p gid=%d\n", g, g->index);
ecore_list_node_remove(group_list, g);
LIST_REMOVE(Group, &group_list, g);
if (g == Mode_groups.current)
Mode_groups.current = NULL;
@ -125,7 +123,7 @@ GroupMatchId(const void *data, const void *match)
static Group *
GroupFind(int gid)
{
return (Group *) ecore_list_find(group_list, GroupMatchId, INT2PTR(gid));
return LIST_FIND(Group, &group_list, GroupMatchId, INT2PTR(gid));
}
void
@ -208,7 +206,7 @@ BuildWindowGroup(EWin ** ewins, int num, int gid)
Group **
GroupsGetList(int *pnum)
{
return (Group **) ecore_list_items_get(group_list, pnum);
return LIST_GET_ITEMS(Group, &group_list, pnum);
}
Group *const *
@ -511,7 +509,7 @@ GroupsSave(void)
FILE *f;
char s[1024];
if (ecore_list_count(group_list) <= 0)
if (LIST_IS_EMPTY(&group_list))
return;
Esnprintf(s, sizeof(s), "%s.groups", EGetSavePrefix());
@ -519,7 +517,7 @@ GroupsSave(void)
if (!f)
return;
ECORE_LIST_FOR_EACH(group_list, g)
LIST_FOR_EACH(Group, &group_list, g)
{
if (!g->save)
continue;
@ -1103,8 +1101,8 @@ IPC_GroupInfo(const char *params)
}
else
{
IpcPrintf("Number of groups: %d\n", ecore_list_count(group_list));
ECORE_LIST_FOR_EACH(group_list, group) GroupShow(group);
IpcPrintf("Number of groups: %d\n", LIST_GET_COUNT(&group_list));
LIST_FOR_EACH(Group, &group_list, group) GroupShow(group);
}
}

View File

@ -23,6 +23,8 @@
*/
#ifndef _GROUPS_H_
#define _GROUPS_H_
#include "ewins.h"
#include "list.h"
#define GROUP_SELECT_ALL 0
#define GROUP_SELECT_EWIN_ONLY 1
@ -49,6 +51,7 @@ typedef struct _groupconfig {
} GroupConfig;
struct _group {
dlist_t list;
int index;
EWin **members;
int num_members;

View File

@ -25,10 +25,10 @@
#include "backgrounds.h"
#include "conf.h"
#include "desktops.h"
#include "e16-ecore_list.h"
#include "eimage.h"
#include "emodule.h"
#include "iclass.h"
#include "list.h"
#include "tclass.h"
#include "xwin.h"
@ -57,13 +57,14 @@ typedef struct {
} ImageStateArray;
struct _imageclass {
dlist_t list;
char *name;
ImageStateArray norm, active, sticky, sticky_active;
EImageBorder padding;
unsigned int ref_count;
};
static Ecore_List *iclass_list = NULL;
static LIST_HEAD(iclass_list);
static ImageClass *ImageclassGetFallback(void);
@ -327,9 +328,7 @@ ImageclassCreate(const char *name)
if (!ic)
return NULL;
if (!iclass_list)
iclass_list = ecore_list_new();
ecore_list_prepend(iclass_list, ic);
LIST_PREPEND(ImageClass, &iclass_list, ic);
ic->name = Estrdup(name);
@ -358,7 +357,7 @@ ImageclassDestroy(ImageClass * ic)
return;
}
ecore_list_node_remove(iclass_list, ic);
LIST_REMOVE(ImageClass, &iclass_list, ic);
Efree(ic->name);
@ -417,8 +416,7 @@ ImageclassFind(const char *name, int fallback)
ImageClass *ic = NULL;
if (name)
ic = (ImageClass *) ecore_list_find(iclass_list, _ImageclassMatchName,
name);
ic = LIST_FIND(ImageClass, &iclass_list, _ImageclassMatchName, name);
if (ic || !fallback)
return ic;
@ -1414,7 +1412,7 @@ ImageclassIpc(const char *params)
if (!strncmp(param1, "list", 2))
{
ECORE_LIST_FOR_EACH(iclass_list, ic) IpcPrintf("%s\n", ic->name);
LIST_FOR_EACH(ImageClass, &iclass_list, ic) IpcPrintf("%s\n", ic->name);
return;
}

117
src/list.c Normal file
View File

@ -0,0 +1,117 @@
/*
* Copyright (C) 2013 Kim Woelders
*
* 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:
*
* 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.
*
* 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.
*/
#include <stdlib.h>
#include "list.h"
#if LIST_NOINLINE_dlist_find
dlist_t *
dlist_find(const dlist_t * head, dlist_match_func_t * match, const void *prm)
{
dlist_t *etmp;
dlist_for_each(head, etmp)
{
if (match(etmp, prm) == 0)
return etmp;
}
return NULL;
}
#endif
#if LIST_NOINLINE_dlist_for_each_func
void
dlist_for_each_func(dlist_t * head, dlist_foreach_func_t * func, void *prm)
{
dlist_t *e, *tmp;
dlist_for_each_safe(head, e, tmp)
{
func(e, prm);
}
}
#endif
#if LIST_NOINLINE_dlist_get_index
int
dlist_get_index(const dlist_t * head, dlist_t * elem)
{
const dlist_t *e;
int i;
i = 0;
dlist_for_each(head, e)
{
i++;
if (e == elem)
return i;
}
return 0;
}
#endif
#if LIST_NOINLINE_dlist_get_by_index
dlist_t *
dlist_get_by_index(const dlist_t * head, int ix)
{
dlist_t *etmp;
int i;
i = 0;
dlist_for_each(head, etmp)
{
i++;
if (i == ix)
return etmp;
}
return NULL;
}
#endif
#if LIST_NOINLINE_dlist_get_items
dlist_t **
dlist_get_items(const dlist_t * head, int *pnum)
{
dlist_t *etmp;
dlist_t **lst;
int i, num;
lst = NULL;
num = dlist_get_count(head);
if (num <= 0)
goto done;
lst = (dlist_t **) malloc(num * sizeof(dlist_t *));
i = 0;
dlist_for_each(head, etmp)
{
lst[i++] = etmp;
}
done:
*pnum = num;
return lst;
}
#endif

296
src/list.h Normal file
View File

@ -0,0 +1,296 @@
/*
* Copyright (C) 2013 Kim Woelders
*
* 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:
*
* 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.
*
* 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.
*/
#ifndef LIST_H
#define LIST_H
#include <stddef.h>
typedef struct _dlist_t dlist_t;
struct _dlist_t {
struct _dlist_t *next, *prev;
};
#define dlist_for_each(head, elem) \
for (elem = (head)->next; elem != (head); elem = elem->next)
#define dlist_for_each_safe(head, elem, temp) \
for (elem = (head)->next, temp = elem->next; elem != (head); elem = temp, temp = elem->next)
static inline void
dlist_init(dlist_t * head)
{
head->next = head->prev = head;
}
static inline void
_dlist_insert(dlist_t * elem, dlist_t * prev, dlist_t * next)
{
next->prev = elem;
elem->next = next;
elem->prev = prev;
prev->next = elem;
}
static inline void
dlist_append(dlist_t * head, dlist_t * elem)
{
_dlist_insert(elem, head->prev, head);
}
static inline void
dlist_prepend(dlist_t * head, dlist_t * elem)
{
_dlist_insert(elem, head, head->next);
}
static inline void
_dlist_remove(dlist_t * prev, dlist_t * next)
{
next->prev = prev;
prev->next = next;
}
static inline dlist_t *
dlist_remove(dlist_t * elem)
{
if (elem)
_dlist_remove(elem->prev, elem->next);
return elem;
}
static inline int
dlist_is_empty(const dlist_t * head)
{
return head->next == head;
}
static inline unsigned int
dlist_get_count(const dlist_t * head)
{
unsigned int count = 0;
dlist_t *e;
dlist_for_each(head, e)
{
count++;
}
return count;
}
#define LIST_NOINLINE_dlist_find 0
typedef int (dlist_match_func_t) (const void *elem, const void *prm);
#if LIST_NOINLINE_dlist_find
dlist_t *dlist_find(const dlist_t * head,
dlist_match_func_t * match, const void *prm);
#else
static inline dlist_t *
dlist_find(const dlist_t * head, dlist_match_func_t * match, const void *prm)
{
dlist_t *e;
dlist_for_each(head, e)
{
if (match(e, prm) == 0)
return e;
}
return NULL;
}
#endif
#define LIST_NOINLINE_dlist_for_each_func 0
typedef void (dlist_foreach_func_t) (void *elem, void *prm);
#if LIST_NOINLINE_dlist_for_each_func
void dlist_for_each_func(dlist_t * head,
dlist_foreach_func_t * func, void *prm);
#else
static inline void
dlist_for_each_func(dlist_t * head, dlist_foreach_func_t * func, void *prm)
{
dlist_t *e, *tmp;
dlist_for_each_safe(head, e, tmp)
{
func(e, prm);
}
}
#endif
static inline dlist_t *
dlist_check(const dlist_t * head, dlist_t * elem)
{
dlist_t *e;
dlist_for_each(head, e)
{
if (e == elem)
return e;
}
return NULL;
}
#define LIST_NOINLINE_dlist_get_index 0
#if LIST_NOINLINE_dlist_get_index
int dlist_get_index(const dlist_t * head, dlist_t * elem);
#else
static inline int
dlist_get_index(const dlist_t * head, dlist_t * elem)
{
const dlist_t *e;
int i;
i = 0;
dlist_for_each(head, e)
{
if (e == elem)
return i;
i++;
}
return -1;
}
#endif
#define LIST_NOINLINE_dlist_get_by_index 0
#if LIST_NOINLINE_dlist_get_by_index
dlist_t *dlist_get_by_index(const dlist_t * head, int ix);
#else
static inline dlist_t *
dlist_get_by_index(const dlist_t * head, int ix)
{
dlist_t *etmp;
int i;
i = 0;
dlist_for_each(head, etmp)
{
if (i == ix)
return etmp;
i++;
}
return NULL;
}
#endif
#define LIST_NOINLINE_dlist_get_items 1
#if LIST_NOINLINE_dlist_get_items
dlist_t **dlist_get_items(const dlist_t * head, int *pnum);
#else
static inline dlist_t **
dlist_get_items(const dlist_t * head, int *pnum)
{
dlist_t *etmp;
dlist_t **lst;
int i, num;
lst = NULL;
num = dlist_get_count(head);
if (num <= 0)
goto done;
lst = (dlist_t **) malloc(num * sizeof(void *));
i = 0;
dlist_for_each(head, etmp)
{
lst[i++] = etmp;
}
done:
*pnum = num;
return lst;
}
#endif
#define LIST_HEAD(head) \
dlist_t head = { &head, &head }
#define LIST_INIT(type, head) \
dlist_init(head)
#define LIST_APPEND(type, head, elem) \
dlist_append(head, &((elem)->list))
#define LIST_PREPEND(type, head, elem) \
dlist_prepend(head, &((elem)->list))
#define LIST_REMOVE(type, head, elem) \
(type*)dlist_remove(&((elem)->list))
#define LIST_FIND(type, head, func, prm) \
(type*)dlist_find(head, func, prm)
#define LIST_CHECK(type, head, elem) \
(type*)dlist_check(head, &((elem)->list))
#define LIST_GET_INDEX(type, head, elem) \
dlist_get_index(head, &((elem)->list))
#define LIST_GET_BY_INDEX(type, head, ix) \
(type*)dlist_get_by_index(head, ix)
#define LIST_IS_EMPTY(head) \
dlist_is_empty(head)
#define LIST_GET_COUNT(head) \
dlist_get_count(head)
#define LIST_NEXT(type, head, elem) \
((elem->list.next != head) ? (type*)(elem)->list.next : NULL)
#define LIST_PREV(type, head, elem) \
((elem->list.prev != head) ? (type*)(elem)->list.prev : NULL)
#define LIST_GET_ITEMS(type, head, pnum) \
(type**)dlist_get_items(head, pnum)
#define LIST_FOR_EACH(type, head, elem) \
for (elem = (type*)((head)->next); \
&(elem)->list != (head); \
elem = (type*)((elem)->list.next))
#define LIST_FOR_EACH_REV(type, head, elem) \
for (elem = (type*)((head)->prev); \
&(elem)->list != (head); \
elem = (type*)((elem)->list.prev))
#define LIST_FOR_EACH_SAFE(type, head, elem, temp) \
for (elem = (type*)((head)->next), temp = (type*)((elem)->list.next); \
&(elem)->list != (head); \
elem = temp, temp = (type*)((elem)->list.next))
#define LIST_FOR_EACH_FUNC(type, head, func, prm) \
dlist_for_each_func(head, func, prm)
#endif /* LIST_H */

View File

@ -26,7 +26,6 @@
#include "borders.h"
#include "desktops.h"
#include "dialog.h"
#include "e16-ecore_list.h"
#include "eimage.h"
#include "emodule.h"
#include "eobj.h"
@ -35,6 +34,7 @@
#include "grabs.h"
#include "hints.h"
#include "iclass.h"
#include "list.h"
#include "menus.h"
#include "screen.h"
#include "settings.h"
@ -60,6 +60,7 @@ static struct {
} Mode_menus;
struct _menustyle {
dlist_t list;
char *name;
TextClass *tclass;
ImageClass *bg_iclass;
@ -92,6 +93,7 @@ struct _menuitem {
};
struct _menu {
dlist_t list;
EWin *ewin;
Win win;
PmapMask pmm;
@ -136,8 +138,8 @@ static void MenuMaskerHandleEvents(Win win, XEvent * ev, void *prm);
static void MenusHide(void);
static Ecore_List *menu_list = NULL;
static Ecore_List *menu_style_list = NULL;
static LIST_HEAD(menu_list);
static LIST_HEAD(menu_style_list);
static Timer *menu_timer_submenu = NULL;
static MenuItem *
@ -396,9 +398,7 @@ MenuStyleCreate(const char *name)
if (!ms)
return NULL;
if (!menu_style_list)
menu_style_list = ecore_list_new();
ecore_list_prepend(menu_style_list, ms);
LIST_PREPEND(MenuStyle, &menu_style_list, ms);
ms->name = Estrdup(name);
ms->iconpos = ICON_LEFT;
@ -436,13 +436,11 @@ MenuStyleFind(const char *name)
{
MenuStyle *ms;
ms = (MenuStyle *) ecore_list_find(menu_style_list, _MenuStyleMatchName,
name);
ms = LIST_FIND(MenuStyle, &menu_style_list, _MenuStyleMatchName, name);
if (ms)
return ms;
ms = (MenuStyle *) ecore_list_find(menu_style_list, _MenuStyleMatchName,
"__fb_ms");
ms = LIST_FIND(MenuStyle, &menu_style_list, _MenuStyleMatchName, "__fb_ms");
if (ms)
return ms;
@ -569,9 +567,7 @@ MenuCreate(const char *name, const char *title, Menu * parent, MenuStyle * ms)
MenuSetStyle(m, ms);
m->icon_size = -1; /* Use image size */
if (!menu_list)
menu_list = ecore_list_new();
ecore_list_append(menu_list, m);
LIST_APPEND(Menu, &menu_list, m);
return m;
}
@ -582,7 +578,7 @@ MenuDestroy(Menu * m)
if (!m)
return;
if (!ecore_list_goto(menu_list, m))
if (!LIST_CHECK(Menu, &menu_list, m))
return;
MenuHide(m);
@ -591,7 +587,7 @@ MenuDestroy(Menu * m)
if (m->ref_count)
return;
ecore_list_node_remove(menu_list, m);
LIST_REMOVE(Menu, &menu_list, m);
if (m->win)
EDestroyWindow(m->win);
@ -1055,7 +1051,7 @@ MenusDestroyLoaded(void)
for (;;)
{
restart:
ECORE_LIST_FOR_EACH(menu_list, m)
LIST_FOR_EACH(Menu, &menu_list, m)
{
if (m->internal)
continue;
@ -1090,7 +1086,7 @@ MenuFind(const char *name, const char *param)
{
Menu *m;
m = (Menu *) ecore_list_find(menu_list, _MenuMatchName, name);
m = LIST_FIND(Menu, &menu_list, _MenuMatchName, name);
if (m)
return (m);
@ -1175,7 +1171,7 @@ MenusTouch(void)
{
Menu *m;
ECORE_LIST_FOR_EACH(menu_list, m) m->redraw = 1;
LIST_FOR_EACH(Menu, &menu_list, m) m->redraw = 1;
}
/*
@ -1519,7 +1515,7 @@ SubmenuShowTimeout(void *data)
menu_timer_submenu = NULL;
if (!ecore_list_goto(menu_list, m))
if (!LIST_CHECK(Menu, &menu_list, m))
goto done;
ewin = m->ewin;
if (!EwinFindByPtr(ewin))
@ -1884,7 +1880,7 @@ MenusTimeout(void *data __UNUSED__)
for (;;)
{
restart:
ECORE_LIST_FOR_EACH(menu_list, m)
LIST_FOR_EACH(Menu, &menu_list, m)
{
if (m->shown || !m->filled ||
ts - m->last_access < MENU_UNLOAD_CHECK_INTERVAL)
@ -2058,7 +2054,7 @@ MenusIpc(const char *params)
{
#define SS(s) ((s) ? (s) : "-")
#define ST(s) ((s) ? (s->name) : "-")
ECORE_LIST_FOR_EACH(menu_list, m)
LIST_FOR_EACH(Menu, &menu_list, m)
IpcPrintf("%s(%s/%s): %s\n", m->name, SS(m->alias), ST(m->style),
SS(m->title));
}

View File

@ -25,7 +25,6 @@
#include "backgrounds.h"
#include "desktops.h"
#include "dialog.h"
#include "e16-ecore_list.h"
#include "ecompmgr.h"
#include "emodule.h"
#include "ewins.h"
@ -34,6 +33,7 @@
#include "hints.h"
#include "hiwin.h"
#include "iclass.h"
#include "list.h"
#include "menus.h"
#include "settings.h"
#include "timers.h"
@ -83,6 +83,7 @@ static struct {
} Mode_pagers;
typedef struct {
dlist_t list;
EWin *ewin;
Win win;
int w, h;
@ -112,7 +113,7 @@ static void PagerHiwinHide(void);
static void PagerEvent(Win win, XEvent * ev, void *prm);
static void PagerHiwinEvent(Win win, XEvent * ev, void *prm);
static Ecore_List *pager_list = NULL;
static LIST_HEAD(pager_list);
static Hiwin *hiwin = NULL;
@ -139,9 +140,7 @@ PagerCreate(void)
if (!p)
return NULL;
if (!pager_list)
pager_list = ecore_list_new();
ecore_list_append(pager_list, p);
LIST_APPEND(Pager, &pager_list, p);
p->name = NULL;
p->win = ECreateClientWindow(VROOT, 0, 0, 1, 1);
@ -154,7 +153,7 @@ PagerCreate(void)
static void
PagerDestroy(Pager * p)
{
ecore_list_node_remove(pager_list, p);
LIST_REMOVE(Pager, &pager_list, p);
PagerScanCancel(p);
Efree(p->name);
@ -788,7 +787,7 @@ PagersForeach(Desk * dsk, void (*func) (Pager * p, void *prm), void *prm)
data.dsk = dsk;
data.func = func;
data.prm = prm;
ecore_list_for_each(pager_list, _PagersForeachFunc, &data);
LIST_FOR_EACH_FUNC(Pager, &pager_list, _PagersForeachFunc, &data);
}
typedef struct {
@ -809,7 +808,7 @@ PagersUpdate(Desk * dsk, int why, int x1, int y1, int x2, int y2)
{
pager_update_data pud;
if (ecore_list_count(pager_list) <= 0)
if (LIST_IS_EMPTY(&pager_list))
return;
pud.why = why;
@ -1678,7 +1677,7 @@ PagersForDesktopCount(Desk * dsk)
Pager *p;
int num = 0;
ECORE_LIST_FOR_EACH(pager_list, p)
LIST_FOR_EACH(Pager, &pager_list, p)
{
if (p->dsk == dsk)
num++;

View File

@ -27,11 +27,11 @@
#include "buttons.h"
#include "cursors.h"
#include "desktops.h"
#include "e16-ecore_list.h"
#include "emodule.h"
#include "eobj.h"
#include "ewins.h"
#include "grabs.h"
#include "list.h"
#include "slide.h"
#include "xwin.h"
@ -41,6 +41,7 @@
PointerMotionMask)
typedef struct {
dlist_t list;
EObj o;
char *name;
char direction;
@ -52,7 +53,7 @@ typedef struct {
static void SlideoutCalcSize(Slideout * s);
static Ecore_List *slideout_list = NULL;
static LIST_HEAD(slideout_list);
static struct {
Slideout *active;
@ -411,9 +412,6 @@ SlideoutsConfigLoad(FILE * fs)
char s2[FILEPATH_LEN_MAX];
char name[FILEPATH_LEN_MAX];
if (!slideout_list)
slideout_list = ecore_list_new();
name[0] = '\0';
while (GetLine(s, sizeof(s), fs))
@ -423,7 +421,7 @@ SlideoutsConfigLoad(FILE * fs)
{
case CONFIG_CLOSE:
if (slideout)
ecore_list_prepend(slideout_list, slideout);
LIST_PREPEND(Slideout, &slideout_list, slideout);
goto done;
case CONFIG_CLASSNAME:
strcpy(name, s2);
@ -476,7 +474,7 @@ _SlideoutMatchName(const void *data, const void *match)
static Slideout *
SlideoutFind(const char *name)
{
return (Slideout *) ecore_list_find(slideout_list, _SlideoutMatchName, name);
return LIST_FIND(Slideout, &slideout_list, _SlideoutMatchName, name);
}
static void

View File

@ -25,17 +25,18 @@
#include "borders.h"
#include "desktops.h"
#include "dialog.h"
#include "e16-ecore_list.h"
#include "ewins.h"
#include "file.h"
#include "groups.h"
#include "ipc.h"
#include "list.h"
#include "settings.h"
#include "snaps.h"
#include "timers.h"
#include "xwin.h"
struct _snapshot {
dlist_t list;
char *name;
char *win_title;
char *win_name;
@ -70,7 +71,7 @@ struct _snapshot {
#endif
};
static Ecore_List *ss_list = NULL;
static LIST_HEAD(ss_list);
static Timer *ss_timer = NULL;
static Snapshot *
@ -82,9 +83,7 @@ _SnapCreate(const char *name)
if (!sn)
return NULL;
if (!ss_list)
ss_list = ecore_list_new();
ecore_list_append(ss_list, sn);
LIST_APPEND(Snapshot, &ss_list, sn);
sn->name = Estrdup(name);
@ -94,10 +93,7 @@ _SnapCreate(const char *name)
static void
_SnapDestroy(Snapshot * sn)
{
/* Just making sure */
sn = (Snapshot *) ecore_list_node_remove(ss_list, sn);
if (!sn)
return;
LIST_REMOVE(Snapshot, &ss_list, sn);
if (sn->used)
sn->used->snap = NULL;
@ -214,11 +210,11 @@ _SnapEwinFind(EWin * ewin)
if (ewin->snap)
return ewin->snap;
if (ecore_list_count(ss_list) <= 0)
if (LIST_IS_EMPTY(&ss_list))
return NULL;
/* If exec'ed by snap try matching command exactly */
sn = (Snapshot *) ecore_list_find(ss_list, _SnapEwinFindMatchCmd, ewin);
sn = LIST_FIND(Snapshot, &ss_list, _SnapEwinFindMatchCmd, ewin);
if (sn && sn->startup_id > 0)
{
/* Assuming we were started by snap */
@ -227,7 +223,7 @@ _SnapEwinFind(EWin * ewin)
}
if (!sn)
sn = (Snapshot *) ecore_list_find(ss_list, _SnapEwinFindMatch, ewin);
sn = LIST_FIND(Snapshot, &ss_list, _SnapEwinFindMatch, ewin);
if (sn && !(sn->match_flags & SNAP_MATCH_MULTIPLE))
{
@ -983,7 +979,7 @@ CB_RememberWindowSettings(Dialog * d __UNUSED__, int val __UNUSED__, void *data)
return;
/* Make sure its still there */
sn = (Snapshot *) ecore_list_goto(ss_list, rd->snap);
sn = LIST_CHECK(Snapshot, &ss_list, rd->snap);
if (!sn || !sn->used)
return;
@ -1001,7 +997,7 @@ _DlgFillRemember(Dialog * d __UNUSED__, DItem * table, void *data __UNUSED__)
DialogItemTableSetOptions(table, 3, 0, 0, 0);
num = ecore_list_count(ss_list);
num = LIST_GET_COUNT(&ss_list);
rd_ewin_list = EMALLOC(RememberWinList, num + 1);
if (num > 0)
@ -1014,7 +1010,7 @@ _DlgFillRemember(Dialog * d __UNUSED__, DItem * table, void *data __UNUSED__)
}
i = 0;
ECORE_LIST_FOR_EACH(ss_list, sn)
LIST_FOR_EACH(Snapshot, &ss_list, sn)
{
rd_ewin_list[i].snap = sn;
rd_ewin_list[i].remove = 0;
@ -1106,7 +1102,7 @@ SnapshotsSaveReal(void)
if (!f)
goto done;
ECORE_LIST_FOR_EACH(ss_list, sn)
LIST_FOR_EACH(Snapshot, &ss_list, sn)
{
fprintf(f, "NEW: %s\n", sn->name);
if (sn->used)
@ -1182,7 +1178,7 @@ SnapshotsSpawn(void)
{
Snapshot *sn;
ECORE_LIST_FOR_EACH(ss_list, sn)
LIST_FOR_EACH(Snapshot, &ss_list, sn)
{
if ((sn->use_flags & SNAP_USE_COMMAND) && (sn->cmd) &&
!sn->used && !(sn->match_flags & SNAP_MATCH_MULTIPLE))
@ -1682,6 +1678,7 @@ SnapshotsIpcFunc(const char *params)
const char *p;
char cmd[128], prm[4096];
int len;
Snapshot *sn;
cmd[0] = prm[0] = '\0';
p = params;
@ -1692,7 +1689,7 @@ SnapshotsIpcFunc(const char *params)
p += len;
}
if (ecore_list_count(ss_list) <= 0)
if (LIST_IS_EMPTY(&ss_list))
{
IpcPrintf("No remembered windows\n");
return;
@ -1700,10 +1697,10 @@ SnapshotsIpcFunc(const char *params)
if (!p || cmd[0] == '?')
{
ecore_list_for_each(ss_list, _SnapShow, NULL);
LIST_FOR_EACH(Snapshot, &ss_list, sn) _SnapShow(sn, NULL);
}
else
{
ecore_list_for_each(ss_list, _SnapShow, (void *)1L);
LIST_FOR_EACH(Snapshot, &ss_list, sn) _SnapShow(sn, (void *)1L);
}
}

View File

@ -24,8 +24,8 @@
#include "E.h"
#if HAVE_SOUND
#include "dialog.h"
#include "e16-ecore_list.h"
#include "emodule.h"
#include "list.h"
#include "settings.h"
#include "sound.h"
#include "sounds.h"
@ -41,6 +41,7 @@
#define N_SOUNDS (SOUND_NOT_USED - 1)
typedef struct {
dlist_t list;
char *name;
char *file;
Sample *sample;
@ -61,7 +62,7 @@ static struct {
#define SOUND_THEME_PATH ((Mode_sound.theme_path) ? Mode_sound.theme_path : Mode.theme.path)
static Ecore_List *sound_list = NULL;
static LIST_HEAD(sound_list);
#if USE_MODULES
static const SoundOps *ops = NULL;
@ -161,9 +162,7 @@ SclassCreate(const char *name, const char *file)
if (!sclass)
return NULL;
if (!sound_list)
sound_list = ecore_list_new();
ecore_list_prepend(sound_list, sclass);
LIST_PREPEND(SoundClass, &sound_list, sclass);
sclass->name = Estrdup(name);
sclass->file = Estrdup(file);
@ -178,7 +177,7 @@ SclassDestroy(SoundClass * sclass)
if (!sclass)
return;
ecore_list_node_remove(sound_list, sclass);
LIST_REMOVE(SoundClass, &sound_list, sclass);
_SclassSampleDestroy(sclass, NULL);
Efree(sclass->name);
Efree(sclass->file);
@ -233,7 +232,7 @@ _SclassMatchName(const void *data, const void *match)
static SoundClass *
SclassFind(const char *name)
{
return (SoundClass *) ecore_list_find(sound_list, _SclassMatchName, name);
return LIST_FIND(SoundClass, &sound_list, _SclassMatchName, name);
}
static void
@ -319,7 +318,9 @@ SoundInit(void)
static void
SoundExit(void)
{
ecore_list_for_each(sound_list, _SclassSampleDestroy, NULL);
SoundClass *sc;
LIST_FOR_EACH(SoundClass, &sound_list, sc) _SclassSampleDestroy(sc, NULL);
if (ops)
ops->Exit();
@ -383,7 +384,11 @@ _SoundConfigLoad(void)
static void
_SoundConfigUnload(void)
{
ecore_list_for_each(sound_list, _SclassDestroy, NULL);
SoundClass *sc, *tmp;
LIST_FOR_EACH_SAFE(SoundClass, &sound_list, sc, tmp)
_SclassDestroy(sc, NULL);
Mode_sound.cfg_loaded = 0;
}
@ -499,7 +504,7 @@ SoundIpc(const char *params)
}
else if (!strncmp(cmd, "list", 2))
{
ECORE_LIST_FOR_EACH(sound_list, sc) IpcPrintf("%s\n", sc->name);
LIST_FOR_EACH(SoundClass, &sound_list, sc) IpcPrintf("%s\n", sc->name);
}
else if (!strncmp(cmd, "new", 3))
{

View File

@ -23,15 +23,15 @@
*/
#include "E.h"
#include "conf.h"
#include "e16-ecore_list.h"
#include "emodule.h"
#include "iclass.h"
#include "list.h"
#include "tclass.h"
#include "xwin.h"
#define ENABLE_DESTROY 0 /* Broken */
static Ecore_List *tclass_list = NULL;
static LIST_HEAD(tclass_list);
static TextClass *TextclassGetFallback(void);
@ -102,9 +102,7 @@ TextclassCreate(const char *name)
if (!tc)
return NULL;
if (!tclass_list)
tclass_list = ecore_list_new();
ecore_list_prepend(tclass_list, tc);
LIST_PREPEND(TextClass, &tclass_list, tc);
tc->name = Estrdup(name);
tc->justification = 512;
@ -218,8 +216,7 @@ TextclassFind(const char *name, int fallback)
TextClass *tc = NULL;
if (name)
tc = (TextClass *) ecore_list_find(tclass_list, _TextclassMatchName,
name);
tc = LIST_FIND(TextClass, &tclass_list, _TextclassMatchName, name);
if (tc || !fallback)
return tc;
@ -401,7 +398,7 @@ TextclassIpc(const char *params)
if (!strncmp(param1, "list", 2))
{
ECORE_LIST_FOR_EACH(tclass_list, tc) IpcPrintf("%s\n", tc->name);
LIST_FOR_EACH(TextClass, &tclass_list, tc) IpcPrintf("%s\n", tc->name);
return;
}

View File

@ -26,6 +26,7 @@
#include "eimage.h"
#include "etypes.h"
#include "list.h"
#include "xwin.h"
#define FONT_TO_RIGHT 0
@ -74,6 +75,7 @@ struct _textstate {
};
struct _textclass {
dlist_t list;
char *name;
struct {
TextState *normal;

View File

@ -22,7 +22,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "E.h"
#include "e16-ecore_list.h"
#include "list.h"
#include "timers.h"
struct _timer {
@ -218,11 +218,12 @@ TimerSetInterval(Timer * timer, int dt_ms)
/*
* Idlers
*/
static Ecore_List *idler_list = NULL;
static LIST_HEAD(idler_list);
typedef void (IdlerFunc) (void *data);
struct _idler {
dlist_t list;
IdlerFunc *func;
void *data;
};
@ -239,10 +240,7 @@ IdlerAdd(IdlerFunc * func, void *data)
id->func = func;
id->data = data;
if (!idler_list)
idler_list = ecore_list_new();
ecore_list_append(idler_list, id);
LIST_APPEND(Idler, &idler_list, id);
return id;
}
@ -250,7 +248,7 @@ IdlerAdd(IdlerFunc * func, void *data)
void
IdlerDel(Idler * id)
{
ecore_list_node_remove(idler_list, id);
LIST_REMOVE(Idler, &idler_list, id);
Efree(id);
}
@ -267,9 +265,11 @@ _IdlerRun(void *_id, void *prm __UNUSED__)
void
IdlersRun(void)
{
Idler *id;
if (EDebug(EDBUG_TYPE_IDLERS))
Eprintf("%s B\n", __func__);
ecore_list_for_each(idler_list, _IdlerRun, NULL);
LIST_FOR_EACH(Idler, &idler_list, id) _IdlerRun(id, NULL);
if (EDebug(EDBUG_TYPE_IDLERS))
Eprintf("%s E\n", __func__);
}

View File

@ -25,17 +25,17 @@
#include "aclass.h"
#include "conf.h"
#include "dialog.h"
#include "e16-ecore_list.h"
#include "emodule.h"
#include "eobj.h"
#include "iclass.h"
#include "list.h"
#include "settings.h"
#include "tclass.h"
#include "timers.h"
#include "tooltips.h"
#include "xwin.h"
static Ecore_List *tt_list = NULL;
static LIST_HEAD(tt_list);
static Timer *tt_timer = NULL;
static struct {
@ -52,6 +52,7 @@ static struct {
} Mode_tooltips;
struct _tooltip {
dlist_t list;
const char *name;
ImageClass *iclass[5];
TextClass *tclass;
@ -114,9 +115,7 @@ TooltipCreate(const char *name, const char *ic0, const char *ic1,
tt->dist = dist;
if (!tt_list)
tt_list = ecore_list_new();
ecore_list_prepend(tt_list, tt);
LIST_PREPEND(ToolTip, &tt_list, tt);
return tt;
}
@ -672,7 +671,7 @@ _TooltipMatchName(const void *data, const void *match)
ToolTip *
TooltipFind(const char *name)
{
return (ToolTip *) ecore_list_find(tt_list, _TooltipMatchName, name);
return LIST_FIND(ToolTip, &tt_list, _TooltipMatchName, name);
}
/*
@ -686,7 +685,7 @@ TooltipsHide(void)
TooltipsSetPending(0, NULL, NULL);
ECORE_LIST_FOR_EACH(tt_list, tt) TooltipHide(tt);
LIST_FOR_EACH(ToolTip, &tt_list, tt) TooltipHide(tt);
}
void

View File

@ -25,15 +25,16 @@
#include "borders.h"
#include "conf.h"
#include "desktops.h"
#include "e16-ecore_list.h"
#include "emodule.h"
#include "ewins.h"
#include "ewin-ops.h"
#include "list.h"
#include "windowmatch.h"
typedef struct _windowmatch WindowMatch;
struct _windowmatch {
dlist_t list;
char *name;
/* Match criteria */
char match;
@ -68,7 +69,7 @@ struct _windowmatch {
static int WindowMatchEobjOpsParse(EObj * eo, const char *ops);
static Ecore_List *wm_list = NULL;
static LIST_HEAD(wm_list);
static const char *const MatchType[] = {
NULL, "Title", "Name", "Class", "Size", "Width", "Height", "Prop", NULL
@ -103,9 +104,7 @@ WindowMatchCreate(const char *name)
if (!b)
return NULL;
if (!wm_list)
wm_list = ecore_list_new();
ecore_list_prepend(wm_list, b);
LIST_PREPEND(WindowMatch, &wm_list, b);
b->name = Estrdup(name);
b->width_max = 99999;
@ -120,7 +119,7 @@ WindowMatchDestroy(WindowMatch * wm)
if (!wm)
return;
ecore_list_node_remove(wm_list, wm);
LIST_REMOVE(WindowMatch, &wm_list, wm);
Efree(wm->name);
Efree(wm->value);
@ -406,7 +405,8 @@ WindowMatchDecode(const char *line)
}
else
{
ecore_list_append(wm_list, ecore_list_node_remove(wm_list, wm));
LIST_APPEND(WindowMatch, &wm_list,
LIST_REMOVE(WindowMatch, &wm_list, wm));
}
}
@ -593,7 +593,7 @@ WindowMatchType(const EWin * ewin, int type)
wmtd.type = type;
wmtd.ewin = ewin;
return (WindowMatch *) ecore_list_find(wm_list, WindowMatchTypeMatch, &wmtd);
return LIST_FIND(WindowMatch, &wm_list, WindowMatchTypeMatch, &wmtd);
}
Border *
@ -891,7 +891,9 @@ _WindowMatchEwinFunc(void *_wm, void *_ew)
void
WindowMatchEwinOps(EWin * ew)
{
ecore_list_for_each(wm_list, _WindowMatchEwinFunc, ew);
WindowMatch *wm;
LIST_FOR_EACH(WindowMatch, &wm_list, wm) _WindowMatchEwinFunc(wm, ew);
}
#if USE_COMPOSITE
@ -911,7 +913,9 @@ _WindowMatchEobjFunc(void *_wm, void *_eo)
void
WindowMatchEobjOps(EObj * eo)
{
ecore_list_for_each(wm_list, _WindowMatchEobjFunc, eo);
WindowMatch *wm;
LIST_FOR_EACH(WindowMatch, &wm_list, wm) _WindowMatchEobjFunc(wm, eo);
}
#endif
@ -963,7 +967,7 @@ WindowMatchIpc(const char *params)
{
WindowMatch *wm;
ECORE_LIST_FOR_EACH(wm_list, wm)
LIST_FOR_EACH(WindowMatch, &wm_list, wm)
IpcPrintf("%s\n", WindowMatchEncode(wm, buf, sizeof(buf)));
}
}