From: <enl...@li...> - 2006-02-18 08:30:22
|
Enlightenment CVS committal Author : kwo Project : e16 Module : e Dir : e16/e/src Modified Files: E.h Makefile.am aclass.c aclass.h actions.c arrange.c backgrounds.c backgrounds.h borders.c borders.h buttons.c buttons.h comms.c conf.h config.c cursors.c desktops.c dialog.c dialog.h dock.c ewin-ops.c ewins.c finders.c focus.c fonts.c fx.c groups.c groups.h iclass.c iclass.h iconify.c ipc.c main.c menus-misc.c menus.c menus.h mod-trans.c pager.c session.c settings.c slideout.c snaps.c sound.c startup.c tclass.c tooltips.c tooltips.h windowmatch.c Added Files: e16-ecore_list.c e16-ecore_list.h Removed Files: lists.c Log Message: Move lists to Ecore_List. =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v retrieving revision 1.532 retrieving revision 1.533 diff -u -3 -r1.532 -r1.533 --- E.h 12 Feb 2006 19:14:14 -0000 1.532 +++ E.h 18 Feb 2006 08:30:03 -0000 1.533 @@ -178,38 +178,6 @@ #define SPANS_COMMON(x1, w1, x2, w2) \ (!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1))))) -#define LIST_FINDBY_NAME 0 -#define LIST_FINDBY_ID 1 -#define LIST_FINDBY_BOTH 2 -#define LIST_FINDBY_NONE 3 -#define LIST_FINDBY_POINTER 4 - -#define LIST_TYPE_ANY 0 -#define LIST_TYPE_CLIENT 1 -#define LIST_TYPE_BORDER 3 -#define LIST_TYPE_ICLASS 4 -#define LIST_TYPE_ACLASS 5 -#define LIST_TYPE_ACLASS_GLOBAL 7 -#define LIST_TYPE_TCLASS 9 -#define LIST_TYPE_BACKGROUND 10 -#define LIST_TYPE_BUTTON 11 -#define LIST_TYPE_SCLASS 12 -#define LIST_TYPE_WINDOWMATCH 13 -#define LIST_TYPE_COLORMODIFIER 14 -#define LIST_TYPE_SLIDEOUT 16 -#define LIST_TYPE_TOOLTIP 18 -#define LIST_TYPE_MENU 21 -#define LIST_TYPE_MENU_STYLE 22 -#define LIST_TYPE_ECURSOR 23 -#define LIST_TYPE_SNAPSHOT 24 -#define LIST_TYPE_DIALOG 25 -#define LIST_TYPE_FONT 26 -#define LIST_TYPE_PAGER 27 -#define LIST_TYPE_ICONBOX 28 -#define LIST_TYPE_GROUP 32 - -#define LIST_TYPE_COUNT 33 - #define STATE_NORMAL 0 #define STATE_HILITED 1 #define STATE_CLICKED 2 @@ -647,7 +615,7 @@ void CommsBroadcastToSlaveWMs(const char *s); /* config.c */ -int ConfigSkipIfExists(FILE * fs, const char *name, int type); +void SkipTillEnd(FILE * ConfigFile); char *GetLine(char *s, int size, FILE * f); void ConfigAlertLoad(const char *txt); char *FindFile(const char *file, const char *themepath, @@ -674,6 +642,7 @@ #define ECSR_ACT_RESIZE 5 #define ECSR_COUNT 6 +ECursor *ECursorFind(const char *name); void ECursorApply(ECursor * ec, Window win); void ECursorIncRefcount(ECursor * ec); void ECursorDecRefcount(ECursor * ec); @@ -844,23 +813,6 @@ const char *EstrInt2Enc(const char *str, int want_utf8); void EstrInt2EncFree(const char *str, int want_utf8); -/* lists.c */ -void ListsInit(int num); -void *FindItem(const void *name, int id, int find_by, int type); -void AddItem(const void *item, const char *name, int id, - int type); -void AddItemEnd(const void *item, const char *name, int id, - int type); -void *RemoveItem(const void *name, int id, int find_by, int type); -void *RemoveItemByPtr(const void *item, int type); -void **ListItemType(int *num, int type); -char **ListItems(int *num, int type); -void **ListItemTypeID(int *num, int type, int id); -void **ListItemTypeName(int *num, int type, const char *name); -void MoveItemToListTop(const void *item, int type); -void MoveItemToListBottom(const void *item, int type); -void ListChangeItemID(int type, void *ptr, int id); - /* main.c */ void EExit(int exitcode); const char *EDirRoot(void); =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/Makefile.am,v retrieving revision 1.63 retrieving revision 1.64 diff -u -3 -r1.63 -r1.64 --- Makefile.am 22 Dec 2005 18:43:14 -0000 1.63 +++ Makefile.am 18 Feb 2006 08:30:03 -0000 1.64 @@ -38,6 +38,8 @@ dialog.h \ dock.c \ draw.c \ + e16-ecore_list.c \ + e16-ecore_list.h \ econfig.c \ econfig.h \ ecore-e16.c \ @@ -75,7 +77,6 @@ icons.h \ ipc.c \ lang.c \ - lists.c \ main.c \ memory.c \ menus.c \ =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/aclass.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -3 -r1.25 -r1.26 --- aclass.c 7 Jan 2006 07:20:57 -0000 1.25 +++ aclass.c 18 Feb 2006 08:30:03 -0000 1.26 @@ -24,6 +24,7 @@ #include "E.h" #include "aclass.h" #include "conf.h" +#include "e16-ecore_list.h" #include "emodule.h" #include "ewins.h" @@ -60,6 +61,9 @@ static void UnGrabActionKey(Action * aa); static void GrabActionKey(Action * aa); +static Ecore_List *aclass_list = NULL; +static Ecore_List *aclass_list_global = NULL; + static char mode_action_destroy = 0; static void @@ -171,8 +175,19 @@ ac->list = NULL; ac->tooltipstring = NULL; ac->ref_count = 0; - AddItem(ac, ac->name, 0, (global)? - LIST_TYPE_ACLASS_GLOBAL : LIST_TYPE_ACLASS); + + if (global) + { + if (!aclass_list_global) + aclass_list_global = ecore_list_new(); + ecore_list_prepend(aclass_list_global, ac); + } + else + { + if (!aclass_list) + aclass_list = ecore_list_new(); + ecore_list_prepend(aclass_list, ac); + } return ac; } @@ -191,8 +206,8 @@ ac->ref_count); return; } - while (RemoveItemByPtr(ac, LIST_TYPE_ACLASS)) - ; + + ecore_list_remove_node(aclass_list, ac); for (i = 0; i < ac->num; i++) ActionDestroy(ac->list[i]); @@ -206,6 +221,24 @@ mode_action_destroy = 1; } +static int +_ActionclassMatchName(const void *data, const void *match) +{ + return strcmp(((const ActionClass *)data)->name, match); +} + +ActionClass * +ActionclassGlobalFind(const char *name) +{ + return ecore_list_find(aclass_list_global, _ActionclassMatchName, name); +} + +ActionClass * +ActionclassFind(const char *name) +{ + return ecore_list_find(aclass_list, _ActionclassMatchName, name); +} + int AclassConfigLoad(FILE * fs) { @@ -285,10 +318,10 @@ case CONFIG_CLASSNAME: case ACLASS_NAME: - ac = RemoveItem(s2, 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS); + ac = ecore_list_remove_node(aclass_list, ActionclassFind(s2)); if (!ac) - ac = RemoveItem(s2, 0, LIST_FINDBY_NAME, - LIST_TYPE_ACLASS_GLOBAL); + ac = ecore_list_remove_node(aclass_list_global, + ActionclassGlobalFind(s2)); if (ac) { if (!strcmp(s2, "KEYBINDINGS")) @@ -299,10 +332,10 @@ break; case CONFIG_TYPE: case ACLASS_TYPE: - if (atoi(s2) == LIST_TYPE_ACLASS) + if (atoi(s2) == ACLASS_TYPE_ACLASS) break; - RemoveItem(ac->name, 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS); - AddItem(ac, ac->name, 0, LIST_TYPE_ACLASS_GLOBAL); + ecore_list_remove_node(aclass_list, ActionclassFind(s2)); + ecore_list_prepend(aclass_list_global, ac); global = 1; break; @@ -642,10 +675,10 @@ if (!strcmp(prm1, "Aclass")) { - ac = RemoveItem(prm2, 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS); + ac = ecore_list_remove_node(aclass_list, ActionclassFind(prm2)); if (!ac) - ac = RemoveItem(prm2, 0, LIST_FINDBY_NAME, - LIST_TYPE_ACLASS_GLOBAL); + ac = ecore_list_remove_node(aclass_list_global, + ActionclassGlobalFind(prm2)); if (ac) ActionclassDestroy(ac); @@ -729,7 +762,7 @@ if (!Mode.keybinds_changed) return; - ac = FindItem("KEYBINDINGS", 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS_GLOBAL); + ac = ActionclassGlobalFind("KEYBINDINGS"); if (!ac || ac->num <= 0) return; @@ -991,18 +1024,13 @@ int ActionclassesGlobalEvent(XEvent * ev) { - ActionClass **lst; - int i, num, match; - - lst = (ActionClass **) ListItemType(&num, LIST_TYPE_ACLASS_GLOBAL); - if (!lst) - return 0; + ActionClass *ac; + int match; match = 0; - for (i = 0; i < num; i++) - match |= ActionclassEvent(lst[i], ev, GetFocusEwin()); - - Efree(lst); + for (ecore_list_goto_first(aclass_list_global); + (ac = ecore_list_next(aclass_list_global)) != NULL;) + match |= ActionclassEvent(ac, ev, GetFocusEwin()); return match; } @@ -1051,7 +1079,8 @@ { const char *p; char cmd[128], prm[4096]; - int i, len, num; + int i, len; + ActionClass *ac; cmd[0] = prm[0] = '\0'; p = params; @@ -1067,11 +1096,9 @@ } else if (!strncmp(cmd, "kb", 2)) { - ActionClass *ac; Action *aa; - ac = FindItem("KEYBINDINGS", 0, LIST_FINDBY_NAME, - LIST_TYPE_ACLASS_GLOBAL); + ac = ActionclassGlobalFind("KEYBINDINGS"); if (!ac || ac->num <= 0) return; @@ -1087,13 +1114,10 @@ } else if (!strncmp(cmd, "list", 2)) { - ActionClass **lst; - - lst = (ActionClass **) ListItemType(&num, LIST_TYPE_ACLASS); - for (i = 0; i < num; i++) - IpcPrintf("%s\n", ActionclassGetName(lst[i])); - if (lst) - Efree(lst); + IpcPrintf("Global:\n"); + ECORE_LIST_FOR_EACH(aclass_list_global, ac) IpcPrintf("%s\n", ac->name); + IpcPrintf("Normal:\n"); + ECORE_LIST_FOR_EACH(aclass_list, ac) IpcPrintf("%s\n", ac->name); } else if (!strncmp(cmd, "load", 2)) { @@ -1110,7 +1134,7 @@ Action *aa; int i, mod; - ac = FindItem("KEYBINDINGS", 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS_GLOBAL); + ac = ActionclassGlobalFind("KEYBINDINGS"); if (!ac) return; @@ -1186,8 +1210,8 @@ Mode.keybinds_changed = 1; - ac = (ActionClass *) RemoveItem("KEYBINDINGS", 0, LIST_FINDBY_NAME, - LIST_TYPE_ACLASS_GLOBAL); + ac = ecore_list_remove_node(aclass_list_global, + ActionclassGlobalFind("KEYBINDINGS")); if (ac) ActionclassDestroy(ac); @@ -1312,7 +1336,7 @@ Action *aa; unsigned int mod, button, mask; - ac = FindItem("BUTTONBINDINGS", 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS); + ac = ActionclassFind("BUTTONBINDINGS"); if (!ac) return; @@ -1364,7 +1388,7 @@ Action *aa; unsigned int mod, button; - ac = FindItem("BUTTONBINDINGS", 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS); + ac = ActionclassFind("BUTTONBINDINGS"); if (!ac) return; =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/aclass.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- aclass.h 7 Jan 2006 07:20:57 -0000 1.2 +++ aclass.h 18 Feb 2006 08:30:03 -0000 1.3 @@ -40,6 +40,8 @@ void ActionclassAddAction(ActionClass * ac, Action * aa); void ActionclassSetTooltipString(ActionClass * ac, const char *tts); +ActionClass *ActionclassFind(const char *name); +ActionClass *ActionclassGlobalFind(const char *name); void ActionclassIncRefcount(ActionClass * ac); void ActionclassDecRefcount(ActionClass * ac); const char *ActionclassGetName(ActionClass * ac); =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/actions.c,v retrieving revision 1.196 retrieving revision 1.197 diff -u -3 -r1.196 -r1.197 --- actions.c 7 Jan 2006 07:20:57 -0000 1.196 +++ actions.c 18 Feb 2006 08:30:03 -0000 1.197 @@ -281,7 +281,7 @@ DItem *table, *di; char buf[1024]; - d = FindItem("ABOUT_ENLIGHTENMENT", 0, LIST_FINDBY_NAME, LIST_TYPE_DIALOG); + d = DialogFind("ABOUT_ENLIGHTENMENT"); if (d) { ShowDialog(d); =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/arrange.c,v retrieving revision 1.86 retrieving revision 1.87 diff -u -3 -r1.86 -r1.87 --- arrange.c 7 Jan 2006 07:20:57 -0000 1.86 +++ arrange.c 18 Feb 2006 08:30:03 -0000 1.87 @@ -887,7 +887,8 @@ fixed[j].p = EoGetLayer(e); j++; } - blst = (Button **) ListItemType(&num, LIST_TYPE_BUTTON); + + blst = ButtonsGetList(&num); if (blst) { fixed = Erealloc(fixed, sizeof(RectBox) * (num + j)); @@ -1052,7 +1053,7 @@ } } - blst = (Button **) ListItemType(&num, LIST_TYPE_BUTTON); + blst = ButtonsGetList(&num); if (blst) { fixed = Erealloc(fixed, sizeof(RectBox) * (num + k)); =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/backgrounds.c,v retrieving revision 1.58 retrieving revision 1.59 diff -u -3 -r1.58 -r1.59 --- backgrounds.c 11 Feb 2006 17:05:08 -0000 1.58 +++ backgrounds.c 18 Feb 2006 08:30:03 -0000 1.59 @@ -26,6 +26,7 @@ #include "backgrounds.h" #include "desktops.h" #include "dialog.h" +#include "e16-ecore_list.h" #include "emodule.h" #include "iclass.h" #include "tclass.h" @@ -58,6 +59,8 @@ unsigned int use_count; /* pmap */ }; +static Ecore_List *bg_list = NULL; + char * BackgroundGetUniqueString(const Background * bg) { @@ -257,7 +260,8 @@ return -1; } - RemoveItemByPtr(bg, LIST_TYPE_BACKGROUND); + ecore_list_remove_node(bg_list, bg); + BackgroundFilesRemove(bg); BackgroundPixmapFree(bg); @@ -310,6 +314,10 @@ if (!bg) return NULL; + if (!bg_list) + bg_list = ecore_list_new(); + ecore_list_prepend(bg_list, bg); + bg->name = Estrdup(name); ESetColor(&(bg->bg_solid), 160, 160, 160); @@ -332,15 +340,31 @@ bg->top.xperc = txperc; bg->top.yperc = typerc; - AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND); - return bg; } +static int +_BackgroundMatchName(const void *data, const void *match) +{ + return strcmp(((const Background *)data)->name, match); +} + +Background * +BackgroundFind(const char *name) +{ + return ecore_list_find(bg_list, _BackgroundMatchName, name); +} + +Background * +BackgroundCheck(Background * bg) +{ + return ecore_list_goto(bg_list, bg); +} + void BackgroundDestroyByName(const char *name) { - BackgroundDestroy(FindItem(name, 0, LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND)); + BackgroundDestroy(BackgroundFind(name)); } static void @@ -862,7 +886,7 @@ int maxw = 48, maxh = 48; int justx = 512, justy = 512; - bg = FindItem(bgid, 0, LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND); + bg = BackgroundFind(bgid); if (thumb) { @@ -1113,14 +1137,28 @@ void BackgroundsInvalidate(int refresh) { - int i, num; - Background **lst; + Background *bg; - lst = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND); - for (i = 0; i < num; i++) - BackgroundInvalidate(lst[i], refresh); - if (lst) - Efree(lst); + ECORE_LIST_FOR_EACH(bg_list, bg) BackgroundInvalidate(bg, refresh); +} + +Background * +BackgroundGetRandom(void) +{ + Background *bg; + int num; + unsigned int rnd; + + num = ecore_list_nodes(bg_list); + for (;;) + { + rnd = rand(); + bg = ecore_list_goto_index(bg_list, rnd % num); + if (num <= 1 || !BackgroundIsNone(bg)) + break; + } + + return bg; } /* @@ -1230,7 +1268,7 @@ case CONFIG_CLASSNAME: case BG_NAME: - bg = FindItem(s2, 0, LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND); + bg = BackgroundFind(s2); if (bg) { ignore = 1; @@ -1349,12 +1387,11 @@ { char s[FILEPATH_LEN_MAX], st[FILEPATH_LEN_MAX]; FILE *fs; - int i, num; - Background **bglist; + Background *bg; unsigned int j; - int r, g, b; + int i, num, r, g, b; - bglist = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND); + num = ecore_list_nodes(bg_list); if (num <= 0) return; @@ -1365,55 +1402,56 @@ for (i = num - 1; i >= 0; i--) { + bg = ecore_list_goto_index(bg_list, i); + if (!bg) + continue; + fprintf(fs, "5 999\n"); - fprintf(fs, "100 %s\n", bglist[i]->name); - EGetColor(&(bglist[i]->bg_solid), &r, &g, &b); + fprintf(fs, "100 %s\n", bg->name); + EGetColor(&(bg->bg_solid), &r, &g, &b); fprintf(fs, "560 %d %d %d\n", r, g, b); - if ((bglist[i]->bg.file) && (!bglist[i]->bg.real_file)) - bglist[i]->bg.real_file = ThemeFileFind(bglist[i]->bg.file, 0); + if ((bg->bg.file) && (!bg->bg.real_file)) + bg->bg.real_file = ThemeFileFind(bg->bg.file, 0); - if ((bglist[i]->top.file) && (!bglist[i]->top.real_file)) - bglist[i]->top.real_file = ThemeFileFind(bglist[i]->top.file, 0); + if ((bg->top.file) && (!bg->top.real_file)) + bg->top.real_file = ThemeFileFind(bg->top.file, 0); - if ((bglist[i]->bg.file) && (bglist[i]->bg.real_file)) + if ((bg->bg.file) && (bg->bg.real_file)) { fprintf(fs, "561 %s %d %d %d %d %d %d\n", - bglist[i]->bg.real_file, bglist[i]->bg_tile, - bglist[i]->bg.keep_aspect, bglist[i]->bg.xjust, - bglist[i]->bg.yjust, bglist[i]->bg.xperc, - bglist[i]->bg.yperc); + bg->bg.real_file, bg->bg_tile, + bg->bg.keep_aspect, bg->bg.xjust, + bg->bg.yjust, bg->bg.xperc, bg->bg.yperc); } - else if (bglist[i]->bg.file) + else if (bg->bg.file) { fprintf(fs, "561 %s %d %d %d %d %d %d\n", - bglist[i]->bg.file, bglist[i]->bg_tile, - bglist[i]->bg.keep_aspect, bglist[i]->bg.xjust, - bglist[i]->bg.yjust, bglist[i]->bg.xperc, - bglist[i]->bg.yperc); + bg->bg.file, bg->bg_tile, + bg->bg.keep_aspect, bg->bg.xjust, + bg->bg.yjust, bg->bg.xperc, bg->bg.yperc); } - if ((bglist[i]->top.file) && (bglist[i]->top.real_file)) + if ((bg->top.file) && (bg->top.real_file)) { fprintf(fs, "562 %s %d %d %d %d %d\n", - bglist[i]->top.real_file, - bglist[i]->top.keep_aspect, bglist[i]->top.xjust, - bglist[i]->top.yjust, bglist[i]->top.xperc, - bglist[i]->top.yperc); + bg->top.real_file, + bg->top.keep_aspect, bg->top.xjust, + bg->top.yjust, bg->top.xperc, bg->top.yperc); } - else if (bglist[i]->top.file) + else if (bg->top.file) { fprintf(fs, "562 %s %d %d %d %d %d\n", - bglist[i]->top.file, bglist[i]->top.keep_aspect, - bglist[i]->top.xjust, bglist[i]->top.yjust, - bglist[i]->top.xperc, bglist[i]->top.yperc); + bg->top.file, bg->top.keep_aspect, + bg->top.xjust, bg->top.yjust, bg->top.xperc, + bg->top.yperc); } #if ENABLE_COLOR_MODIFIERS - if (bglist[i]->cmclass) + if (bg->cmclass) { - fprintf(fs, "370 %s\n", bglist[i]->cmclass->name); + fprintf(fs, "370 %s\n", bg->cmclass->name); } #endif @@ -1421,9 +1459,9 @@ { Desk *dsk = DeskGet(j); - if (BackgroundIsNone(bglist[i]) && !DeskBackgroundGet(dsk)) + if (BackgroundIsNone(bg) && !DeskBackgroundGet(dsk)) fprintf(fs, "564 %d\n", j); - if (DeskBackgroundGet(dsk) == bglist[i]) + if (DeskBackgroundGet(dsk) == bg) fprintf(fs, "564 %d\n", j); } @@ -1434,8 +1472,6 @@ Esnprintf(s, sizeof(s), "%s.backgrounds", EGetSavePrefix()); E_mv(st, s); - - Efree(bglist); } /* @@ -1445,13 +1481,10 @@ static void BackgroundsAccounting(void) { - time_t now; - int i, num; unsigned int j; - Background **lst, *bg; Desk *dsk; - - now = time(NULL); + Background *bg; + time_t now; for (j = 0; j < DesksGetNumber(); j++) { @@ -1460,22 +1493,18 @@ BackgroundTouch(DeskBackgroundGet(dsk)); } - lst = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND); - for (i = 0; i < num; i++) - { - bg = lst[i]; - - /* Skip if no pixmap or not timed out */ - if ((bg->pmap == None) || - ((now - BackgroundGetTimestamp(bg)) <= Conf.backgrounds.timeout)) - continue; - - if (bg->ref_count) - DesksBackgroundFree(bg, 0); - BackgroundPixmapFree(bg); - } - if (lst) - Efree(lst); + now = time(NULL); + ECORE_LIST_FOR_EACH(bg_list, bg) + { + /* Skip if no pixmap or not timed out */ + if ((bg->pmap == None) || + ((now - BackgroundGetTimestamp(bg)) <= Conf.backgrounds.timeout)) + continue; + + if (bg->ref_count) + DesksBackgroundFree(bg, 0); + BackgroundPixmapFree(bg); + } } static void @@ -1740,48 +1769,39 @@ static void CB_ConfigureDelBG(Dialog * d __UNUSED__, int val, void *data __UNUSED__) { - Background **bglist, *bg; + Background *bg; int i, num; int slider, lower, upper; - bglist = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND); - if (!bglist || num <= 1) - goto done; + num = ecore_list_nodes(bg_list); + if (num <= 1) + return; - DialogItemSliderGetBounds(bg_sel_slider, &lower, &upper); - slider = DialogItemSliderGetVal(bg_sel_slider); - upper -= 4; - DialogItemSliderSetBounds(bg_sel_slider, lower, upper); - if (slider > upper) - DialogItemSliderSetVal(bg_sel_slider, upper); + bg = ecore_list_goto(bg_list, tmp_bg); + if (!bg) + return; - bg = NULL; - for (i = 0; i < num; i++) - { - if (bglist[i] == tmp_bg) - { - if (i < (num - 1)) - bg = bglist[i + 1]; - else - bg = bglist[i - 1]; - break; - } - } + i = ecore_list_index(bg_list); + bg = ecore_list_goto_index(bg_list, (i < num - 1) ? i + 1 : i - 1); DeskBackgroundSet(DesksGetCurrent(), bg); + if (val == 0) BackgroundDestroy(tmp_bg); else BackgroundDelete(tmp_bg); tmp_bg = NULL; + DialogItemSliderGetBounds(bg_sel_slider, &lower, &upper); + slider = DialogItemSliderGetVal(bg_sel_slider); + upper -= 4; + DialogItemSliderSetBounds(bg_sel_slider, lower, upper); + if (slider > upper) + DialogItemSliderSetVal(bg_sel_slider, upper); + BgDialogSetNewCurrent(bg); autosave(); - - done: - if (bglist) - Efree(bglist); } /* Move current background to first position in list */ @@ -1789,28 +1809,24 @@ CB_ConfigureFrontBG(Dialog * d __UNUSED__, int val __UNUSED__, void *data __UNUSED__) { - MoveItemToListTop(tmp_bg, LIST_TYPE_BACKGROUND); + ecore_list_prepend(bg_list, ecore_list_remove_node(bg_list, tmp_bg)); BG_RedrawView(); autosave(); } -static int tmp_bg_selected = -1; - /* Draw the scrolling background image window */ static void BG_RedrawView(void) { - int num, i; - Background **bglist; - int w, h; + Background *bg; + int x, w, h, num; Window win; - int x; Pixmap pmap; GC gc; ImageClass *ic_button; - bglist = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND); - if (!bglist) + num = ecore_list_nodes(bg_list); + if (num <= 0) return; win = DialogItemAreaGetWindow(bg_sel); @@ -1827,51 +1843,50 @@ x = -(num * (64 + 8) - w) * tmp_bg_sel_sliderval / (4 * num); - for (i = 0; i < num; i++) - { - if (((x + 64 + 8) >= 0) && (x < w)) - { - Imlib_Image *im; - - if (ic_button) - ImageclassApplySimple(ic_button, win, pmap, - (i == tmp_bg_selected) ? - STATE_CLICKED : STATE_NORMAL, - x, 0, 64 + 8, 48 + 8); - - if (BackgroundIsNone(bglist[i])) - { - TextClass *tc; - - tc = TextclassFind("DIALOG", 1); - if (tc) - { - int tw, th; - - TextSize(tc, 0, 0, STATE_NORMAL, - _("No\nBackground"), &tw, &th, 17); - TextDraw(tc, pmap, 0, 0, STATE_NORMAL, - _("No\nBackground"), x + 4, - 4 + ((48 - th) / 2), 64, 48, 17, 512); - } - } - else - { - im = BackgroundCacheMini(bglist[i], 1, 0); - if (im) - { - imlib_context_set_image(im); - imlib_context_set_drawable(pmap); - imlib_render_image_on_drawable_at_size(x + 4, 4, 64, 48); - imlib_free_image(); - } - } - } - x += (64 + 8); - } + ECORE_LIST_FOR_EACH(bg_list, bg) + { + if (((x + 64 + 8) >= 0) && (x < w)) + { + Imlib_Image *im; + + if (ic_button) + ImageclassApplySimple(ic_button, win, pmap, + (bg == tmp_bg) ? + STATE_CLICKED : STATE_NORMAL, + x, 0, 64 + 8, 48 + 8); + + if (BackgroundIsNone(bg)) + { + TextClass *tc; + + tc = TextclassFind("DIALOG", 1); + if (tc) + { + int tw, th; + + TextSize(tc, 0, 0, STATE_NORMAL, + _("No\nBackground"), &tw, &th, 17); + TextDraw(tc, pmap, 0, 0, STATE_NORMAL, + _("No\nBackground"), x + 4, + 4 + ((48 - th) / 2), 64, 48, 17, 512); + } + } + else + { + im = BackgroundCacheMini(bg, 1, 0); + if (im) + { + imlib_context_set_image(im); + imlib_context_set_drawable(pmap); + imlib_render_image_on_drawable_at_size(x + 4, 4, 64, 48); + imlib_free_image(); + } + } + } + x += (64 + 8); + } EFreeGC(gc); EFreePixmap(pmap); - Efree(bglist); EClearWindow(win); } @@ -1906,7 +1921,7 @@ CB_BGAreaEvent(int val __UNUSED__, void *data) { int x, num, w, h; - Background **bglist; + Background *bg; XEvent *ev = (XEvent *) data; DialogItemAreaGetSize(bg_sel, &w, &h); @@ -1914,20 +1929,15 @@ switch (ev->type) { case ButtonPress: - bglist = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND); - if (!bglist) - break; - + num = ecore_list_nodes(bg_list); x = (num * (64 + 8) - w) * tmp_bg_sel_sliderval / (4 * num) + ev->xbutton.x; - tmp_bg_selected = x / (64 + 8); - if ((tmp_bg_selected >= 0) && (tmp_bg_selected < num)) - { - BgDialogSetNewCurrent(bglist[tmp_bg_selected]); - DeskBackgroundSet(DesksGetCurrent(), tmp_bg); - autosave(); - } - Efree(bglist); + bg = ecore_list_goto_index(bg_list, x / (64 + 8)); + if (!bg || bg == DeskBackgroundGet(DesksGetCurrent())) + break; + BgDialogSetNewCurrent(bg); + DeskBackgroundSet(DesksGetCurrent(), bg); + autosave(); break; } } @@ -1950,70 +1960,43 @@ static void BGSettingsGoTo(Background * bg) { - Background **bglist; int i, num; - if (!FindItem("CONFIGURE_BG", 0, LIST_FINDBY_NAME, LIST_TYPE_DIALOG)) + if (!DialogFind("CONFIGURE_BG")) return; - bglist = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND); - if (!bglist) + bg = ecore_list_goto(bg_list, bg); + if (!bg) return; - for (i = 0; i < num; i++) - { - if (bglist[i] == bg) - { - DialogItemSliderSetVal(bg_sel_slider, 4 * i); - DialogDrawItems(bg_sel_dialog, bg_sel_slider, 0, 0, 99999, 99999); - DialogItemCallCallback(NULL, bg_sel_slider); - tmp_bg_selected = i; - BgDialogSetNewCurrent(bglist[tmp_bg_selected]); - tmp_bg_selected = -1; - break; - } - } - Efree(bglist); + i = ecore_list_index(bg_list); + num = ecore_list_nodes(bg_list); + i = ((4 * num + 20) * i) / num - 8; + if (i < 0) + i = 0; + else if (i > 4 * num) + i = 4 * num; + DialogItemSliderSetVal(bg_sel_slider, i); + DialogDrawItems(bg_sel_dialog, bg_sel_slider, 0, 0, 99999, 99999); + DialogItemCallCallback(NULL, bg_sel_slider); + BgDialogSetNewCurrent(bg); } static void -CB_BGPrev(Dialog * d __UNUSED__, int val __UNUSED__, void *data __UNUSED__) +CB_BGNext(Dialog * d __UNUSED__, int val, void *data __UNUSED__) { - Background **bglist; - int i, num; + Background *bg; - bglist = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND); - for (i = 0; i < num; i++) - { - if ((bglist[i] == tmp_bg) && (i > 0)) - { - BGSettingsGoTo(bglist[i - 1]); - DeskBackgroundSet(DesksGetCurrent(), bglist[i - 1]); - break; - } - } - if (bglist) - Efree(bglist); -} + bg = ecore_list_goto(bg_list, tmp_bg); + if (!bg) + return; -static void -CB_BGNext(Dialog * d __UNUSED__, int val __UNUSED__, void *data __UNUSED__) -{ - Background **bglist; - int i, num; + bg = ecore_list_goto_index(bg_list, ecore_list_index(bg_list) + val); + if (!bg) + return; - bglist = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND); - for (i = 0; i < num; i++) - { - if ((bglist[i] == tmp_bg) && (i < (num - 1))) - { - BGSettingsGoTo(bglist[i + 1]); - DeskBackgroundSet(DesksGetCurrent(), bglist[i + 1]); - break; - } - } - if (bglist) - Efree(bglist); + BGSettingsGoTo(bg); + DeskBackgroundSet(DesksGetCurrent(), bg); } static int @@ -2044,22 +2027,17 @@ Background **bglist; int i, num; - bglist = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND); + bglist = (Background **) ecore_list_items_get(bg_list, &num); if (!bglist) return; /* remove them all from the list */ for (i = 0; i < num; i++) - RemoveItemByPtr(bglist[i], LIST_TYPE_BACKGROUND); + ecore_list_remove_node(bg_list, bglist[i]); Quicksort((void **)bglist, 0, num - 1, (int (*)(void *d1, void *d2))BG_SortFileCompare); for (i = 0; i < num; i++) - { - Background *bg; - - bg = bglist[i]; - AddItem(bg, BackgroundGetName(bg), 0, LIST_TYPE_BACKGROUND); - } + ecore_list_prepend(bg_list, bglist[i]); Efree(bglist); BGSettingsGoTo(tmp_bg); @@ -2074,13 +2052,13 @@ Background **bglist; int i, num; - bglist = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND); + bglist = (Background **) ecore_list_items_get(bg_list, &num); if (!bglist) return; /* remove them all from the list */ for (i = 0; i < num; i++) - RemoveItemByPtr(bglist[i], LIST_TYPE_BACKGROUND); + ecore_list_remove_node(bg_list, bglist[i]); for (i = 0; i < num; i++) { Background *bg; @@ -2088,7 +2066,7 @@ bg = bglist[i]; if ((bg) && (bg->bg_tile) && (bg->bg.xperc == 0) && (bg->bg.yperc == 0)) { - AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND); + ecore_list_prepend(bg_list, bg); bglist[i] = NULL; } } @@ -2099,7 +2077,7 @@ bg = bglist[i]; if (bg) { - AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND); + ecore_list_prepend(bg_list, bg); bglist[i] = NULL; } } @@ -2117,21 +2095,17 @@ Background **bglist; int i, num; - bglist = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND); - if (bglist) - { - /* remove them all from the list */ - for (i = 0; i < num; i++) - RemoveItemByPtr(bglist[i], LIST_TYPE_BACKGROUND); - for (i = 0; i < num; i++) - { - Background *bg; + bglist = (Background **) ecore_list_items_get(bg_list, &num); + if (!bglist) + return; + + /* remove them all from the list */ + for (i = 0; i < num; i++) + ecore_list_remove_node(bg_list, bglist[i]); + for (i = 0; i < num; i++) + ecore_list_prepend(bg_list, bglist[i]); + Efree(bglist); - bg = bglist[i]; - AddItem(bg, BackgroundGetName(bg), 0, LIST_TYPE_BACKGROUND); - } - Efree(bglist); - } autosave(); } @@ -2144,7 +2118,7 @@ int num; char s[1024]; - d = FindItem("CONFIGURE_BG", 0, LIST_FINDBY_NAME, LIST_TYPE_DIALOG); + d = DialogFind("CONFIGURE_BG"); if (d) { SoundPlay("SOUND_SETTINGS_ACTIVE"); @@ -2355,16 +2329,16 @@ di = DialogAddItem(table2, DITEM_BUTTON); DialogItemSetFill(di, 0, 0); DialogItemSetText(di, "<-"); - DialogItemSetCallback(di, CB_BGPrev, 0, NULL); - DialogBindKey(d, "Left", CB_BGPrev, 0); - DialogBindKey(d, "BackSpace", CB_BGPrev, 0); + DialogItemSetCallback(di, CB_BGNext, -1, NULL); + DialogBindKey(d, "Left", CB_BGNext, -1); + DialogBindKey(d, "BackSpace", CB_BGNext, -1); di = DialogAddItem(table2, DITEM_BUTTON); DialogItemSetFill(di, 0, 0); DialogItemSetText(di, "->"); - DialogItemSetCallback(di, CB_BGNext, 0, NULL); - DialogBindKey(d, "Right", CB_BGNext, 0); - DialogBindKey(d, "space", CB_BGNext, 0); + DialogItemSetCallback(di, CB_BGNext, 1, NULL); + DialogBindKey(d, "Right", CB_BGNext, 1); + DialogBindKey(d, "space", CB_BGNext, 1); di = DialogAddItem(table, DITEM_BUTTON); DialogItemSetFill(di, 0, 0); @@ -2394,14 +2368,7 @@ DialogItemAreaSetSize(di, 160, 56); DialogItemAreaSetEventFunc(di, CB_BGAreaEvent); - num = 0; - { - Background **bglist; - - bglist = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND); - if (bglist) - Efree(bglist); - } + num = ecore_list_nodes(bg_list); di = bg_sel_slider = DialogAddItem(table, DITEM_SLIDER); DialogItemSetColSpan(di, 3); DialogItemSliderSetBounds(di, 0, num * 4); @@ -2420,7 +2387,6 @@ ShowDialog(d); CB_DesktopMiniDisplayRedraw(NULL, 1, area); - BG_RedrawView(); BGSettingsGoTo(tmp_bg); } @@ -2440,7 +2406,7 @@ if (!p) return; - bg = FindItem(name, 0, LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND); + bg = BackgroundFind(name); if (!bg) { bg = BackgroundCreate(name, NULL, NULL, 0, 0, 0, @@ -2552,7 +2518,7 @@ topf, &tkeep_aspect, &txjust, &tyjust, &txperc, &typerc); ESetColor(&xclr, r, g, b); - bg = FindItem(name, 0, LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND); + bg = BackgroundFind(name); if (bg) { BackgroundModify(bg, &xclr, bgf, tile, keep_aspect, xjust, @@ -2599,7 +2565,7 @@ { Window win; - bg = FindItem(prm, 0, LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND); + bg = BackgroundFind(prm); if (bg) { win = None; @@ -2618,19 +2584,11 @@ } else if (!strncmp(cmd, "list", 2)) { - Background **lst; - - lst = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND); - for (i = 0; i < num; i++) - { - IpcPrintf("%s\n", BackgroundGetName(lst[i])); - } - if (lst) - Efree(lst); + ECORE_LIST_FOR_EACH(bg_list, bg) IpcPrintf("%s\n", bg->name); } else if (!strncmp(cmd, "load", 2)) { - bg = FindItem(prm, 0, LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND); + bg = BackgroundFind(prm); if (bg) { IpcPrintf("Background already defined\n"); @@ -2646,7 +2604,7 @@ } else if (!strncmp(cmd, "show", 2)) { - bg = FindItem(prm, 0, LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND); + bg = BackgroundFind(prm); if (bg) { @@ -2661,7 +2619,7 @@ if (!strcmp(prm, "-")) bg = NULL; else - bg = FindItem(prm, 0, LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND); + bg = BackgroundFind(prm); num = DesksGetCurrentNum(); sscanf(p, "%d %n", &num, &len); @@ -2670,7 +2628,7 @@ } else if (!strncmp(cmd, "xget", 2)) { - bg = FindItem(prm, 0, LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND); + bg = BackgroundFind(prm); if (bg) { @@ -2700,7 +2658,7 @@ word(params, 1, param1); - bg = FindItem(param1, 0, LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND); + bg = BackgroundFind(param1); if (!bg) return; @@ -2729,7 +2687,7 @@ return; sscanf(params, "%1000s %1000s", buf, buf2); - bg = FindItem(buf, 0, LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND); + bg = BackgroundFind(buf); cm = FindItem(buf2, 0, LIST_FINDBY_NAME, LIST_TYPE_COLORMODIFIER); if ((bg) && (bg->cmclass != cm)) { @@ -2758,7 +2716,7 @@ return; sscanf(params, "%1000s", param1); - bg = FindItem(param1, 0, LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND); + bg = BackgroundFind(param1); Esnprintf(buf, sizeof(buf), "(null)"); if ((bg) && (bg->cmclass)) Esnprintf(buf, sizeof(buf), "%s", bg->cmclass->name); =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/backgrounds.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- backgrounds.h 7 Jan 2006 07:20:57 -0000 1.6 +++ backgrounds.h 18 Feb 2006 08:30:03 -0000 1.7 @@ -27,6 +27,9 @@ typedef struct _background Background; /* backgrounds.c */ +Background *BackgroundFind(const char *name); +Background *BackgroundCheck(Background * bg); +Background *BackgroundGetRandom(void); char *BackgroundGetUniqueString(const Background * bg); void BackgroundPixmapSet(Background * bg, Pixmap pmap); void BackgroundPixmapUnset(Background * bg, Pixmap pmap); =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/borders.c,v retrieving revision 1.283 retrieving revision 1.284 diff -u -3 -r1.283 -r1.284 --- borders.c 29 Jan 2006 14:03:37 -0000 1.283 +++ borders.c 18 Feb 2006 08:30:03 -0000 1.284 @@ -24,6 +24,7 @@ #include "E.h" #include "aclass.h" #include "borders.h" +#include "e16-ecore_list.h" #include "ewins.h" #include "hints.h" #include "iclass.h" @@ -38,6 +39,8 @@ #define EWIN_BORDER_TITLE_EVENT_MASK \ (EWIN_BORDER_PART_EVENT_MASK) +static Ecore_List *border_list = NULL; + static void BorderDestroy(Border * b); static void BorderWinpartHandleEvents(XEvent * ev, void *prm); static void BorderFrameHandleEvents(XEvent * ev, void *prm); @@ -424,7 +427,7 @@ if (ewin->inh_wm.b.border) { - b = FindItem("BORDERLESS", 0, LIST_FINDBY_NAME, LIST_TYPE_BORDER); + b = BorderFind("BORDERLESS"); goto done; } @@ -436,16 +439,16 @@ b = NULL; if (ewin->props.no_border) - b = FindItem("BORDERLESS", 0, LIST_FINDBY_NAME, LIST_TYPE_BORDER); + b = BorderFind("BORDERLESS"); if (!b) b = WindowMatchEwinBorder(ewin); if (!b) - b = FindItem("DEFAULT", 0, LIST_FINDBY_NAME, LIST_TYPE_BORDER); + b = BorderFind("DEFAULT"); if (!b) - b = FindItem("__FALLBACK_BORDER", 0, LIST_FINDBY_NAME, LIST_TYPE_BORDER); + b = BorderFind("__FALLBACK_BORDER"); done: ewin->normal_border = ewin->border = b; @@ -608,11 +611,7 @@ void EwinSetBorderByName(EWin * ewin, const char *name) { - Border *b; - - b = FindItem(name, 0, LIST_FINDBY_NAME, LIST_TYPE_BORDER); - - EwinSetBorder(ewin, b, 0); + EwinSetBorder(ewin, BorderFind(name), 0); } static Border * @@ -624,6 +623,10 @@ if (!b) return NULL; + if (!border_list) + border_list = ecore_list_new(); + ecore_list_prepend(border_list, b); + b->name = Estrdup(name); b->group_border_name = NULL; b->shadedir = 2; @@ -645,8 +648,7 @@ return; } - while (RemoveItemByPtr(b, LIST_TYPE_BORDER)) - ; + ecore_list_remove_node(border_list, b); for (i = 0; i < b->num_winparts; i++) { @@ -671,6 +673,18 @@ ActionclassDecRefcount(b->aclass); } +static int +_BorderMatchName(const void *data, const void *match) +{ + return strcmp(((const Border *)data)->name, match); +} + +Border * +BorderFind(const char *name) +{ + return ecore_list_find(border_list, _BorderMatchName, name); +} + static void BorderWinpartAdd(Border * b, ImageClass * iclass, ActionClass * aclass, TextClass * tclass, ECursor * ec, char ontop, int flags, @@ -1086,14 +1100,14 @@ break; case CONFIG_ACTIONCLASS: case BORDERPART_ACLASS: - aclass = FindItem(s2, 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS); + aclass = ActionclassFind(s2); break; case CONFIG_TEXT: case BORDERPART_TEXTCLASS: tclass = TextclassFind(s2, 1); break; case CONFIG_CURSOR: - ec = FindItem(s2, 0, LIST_FINDBY_NAME, LIST_TYPE_ECURSOR); + ec = ECursorFind(s2); break; case BORDERPART_ONTOP: ontop = atoi(s2); @@ -1170,7 +1184,6 @@ char s[FILEPATH_LEN_MAX]; char s2[FILEPATH_LEN_MAX]; int i1; - char added = 0; int fields; while (GetLine(s, sizeof(s), fs)) @@ -1207,17 +1220,16 @@ switch (i1) { case CONFIG_CLOSE: - if (!added) - AddItem(b, b->name, 0, LIST_TYPE_BORDER); goto done; case BORDER_INIT: - AddItem(b, b->name, 0, LIST_TYPE_BORDER); - added = 1; break; case CONFIG_CLASSNAME: case BORDER_NAME: - if (ConfigSkipIfExists(fs, s2, LIST_TYPE_BORDER)) - goto done; + if (BorderFind(s2)) + { + SkipTillEnd(fs); + goto done; + } b = BorderCreate(s2); break; case BORDER_GROUP_NAME: @@ -1242,8 +1254,7 @@ b->changes_shape = atoi(s2); break; case CONFIG_ACTIONCLASS: - b->aclass = - FindItem(s2, 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS); + b->aclass = ActionclassFind(s2); break; default: break; @@ -1262,7 +1273,7 @@ Border *b; ImageClass *ic; - ic = FindItem("__BLACK", 0, LIST_FINDBY_NAME, LIST_TYPE_ICLASS); + ic = ImageclassFind("__BLACK", 1); b = BorderCreate("__FILLER"); b->throwaway = 1; @@ -1295,6 +1306,18 @@ } void +BordersForeach(void (*func) (Border * b, void *data), void *data) +{ + ecore_list_for_each(border_list, (Ecore_For_Each) func, data); +} + +Border ** +BordersGetList(int *pnum) +{ + return (Border **) ecore_list_items_get(border_list, pnum); +} + +void BordersSetupFallback(void) { /* @@ -1307,12 +1330,11 @@ ImageClass *ic; ActionClass *ac; - ac = FindItem("__FALLBACK_ACTION", 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS); - ic = FindItem("__FALLBACK_ICLASS", 0, LIST_FINDBY_NAME, LIST_TYPE_ICLASS); + ac = ActionclassFind("__FALLBACK_ACTION"); + ic = ImageclassFind("__FALLBACK_ICLASS", 0); /* create a fallback border in case no border is found */ b = BorderCreate("__FALLBACK_BORDER"); - AddItem(b, b->name, 0, LIST_TYPE_BORDER); b->border.left = 8; b->border.right = 8; =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/borders.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- borders.h 7 Jan 2006 07:20:57 -0000 1.2 +++ borders.h 18 Feb 2006 08:30:03 -0000 1.3 @@ -87,6 +87,7 @@ EWinBit; /* borders.c */ +Border *BorderFind(const char *name); void BorderIncRefcount(const Border * b); void BorderDecRefcount(const Border * b); const char *BorderGetName(const Border * b); @@ -104,6 +105,9 @@ int BorderWinpartIndex(EWin * ewin, Window win); Border *BorderCreateFiller(int left, int right, int top, int bottom); +void BordersForeach(void (*func) (Border * b, void *data), + void *data); +Border **BordersGetList(int *pnum); void BordersSetupFallback(void); #endif /* _BORDERS_H_ */ =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/buttons.c,v retrieving revision 1.81 retrieving revision 1.82 diff -u -3 -r1.81 -r1.82 --- buttons.c 7 Jan 2006 07:20:57 -0000 1.81 +++ buttons.c 18 Feb 2006 08:30:03 -0000 1.82 @@ -25,6 +25,7 @@ #include "aclass.h" #include "buttons.h" #include "desktops.h" +#include "e16-ecore_list.h" #include "emodule.h" #include "iclass.h" #include "tclass.h" @@ -56,6 +57,7 @@ ActionClass *aclass; TextClass *tclass; char *label; + int id; int flags; char internal; char default_show; @@ -69,6 +71,8 @@ unsigned int ref_count; }; +static Ecore_List *button_list = NULL; + static struct { Button *button; @@ -121,6 +125,11 @@ b = Ecalloc(1, sizeof(Button)); + if (!button_list) + button_list = ecore_list_new(); + ecore_list_append(button_list, b); + + b->id = id; b->label = Estrdup(label); b->iclass = iclass; @@ -166,8 +175,6 @@ ESelectInput(EoGetWin(b), BUTTON_EVENT_MASK); EventCallbackRegister(EoGetWin(b), 0, ButtonHandleEvents, b); - AddItemEnd(b, EoGetName(b), id, LIST_TYPE_BUTTON); - return b; } @@ -183,8 +190,7 @@ return; } - while (RemoveItemByPtr(b, LIST_TYPE_BUTTON)) - ; + ecore_list_remove_node(button_list, b); EoFini(b); @@ -203,6 +209,18 @@ Efree(b); } +static int +_ButtonMatchName(const void *data, const void *match) +{ + return strcmp(((const Button *)data)->o.name, match); +} + +Button * +ButtonFind(const char *name) +{ + return ecore_list_find(button_list, _ButtonMatchName, name); +} + static void ButtonCalc(Button * b) { @@ -456,23 +474,40 @@ autosave(); } +Button ** +ButtonsGetList(int *pnum) +{ + return (Button **) ecore_list_items_get(button_list, pnum); +} + void -ButtonsMoveStickyToDesk(Desk * dsk) +ButtonsForeach(int id, Desk * dsk, void (*func) (Button * b)) { - Button **lst, *btn; - int i, num; + Button *b; - lst = (Button **) ListItemType(&num, LIST_TYPE_BUTTON); - for (i = 0; i < num; i++) + for (ecore_list_goto_first(button_list); + (b = ecore_list_next(button_list)) != NULL;) { - btn = lst[i]; - if (!EoIsSticky(btn) || ButtonIsInternal(btn)) + if (id >= 0 && id != b->id) continue; - - ButtonMoveToDesktop(btn, dsk); + if (dsk && dsk != EoGetDesk(b)) + continue; + func(b); } - if (lst) - Efree(lst); +} + +void +ButtonsMoveStickyToDesk(Desk * dsk) +{ + Button *b; + + ECORE_LIST_FOR_EACH(button_list, b) + { + if (!EoIsSticky(b) || ButtonIsInternal(b)) + continue; + + ButtonMoveToDesktop(b, dsk); + } } /* @@ -511,8 +546,7 @@ { ActionClass *ac; - ac = FindItem("ACTION_BUTTON_DRAG", 0, LIST_FINDBY_NAME, - LIST_TYPE_ACLASS); + ac = ActionclassFind("ACTION_BUTTON_DRAG"); if (ac && !Mode_buttons.action_inhibit) ActionclassEvent(ac, ev, NULL); } @@ -617,7 +651,7 @@ Button *b = data; /* Validate button */ - if (!FindItem(b, 0, LIST_FINDBY_POINTER, LIST_TYPE_BUTTON)) + if (!ecore_list_goto(button_list, b)) return NULL; return b->aclass; @@ -767,11 +801,11 @@ case BUTTON_NAME: _EFREE(name); name = Estrdup(s2); - pbt = FindItem(name, 0, LIST_FINDBY_NAME, LIST_TYPE_BUTTON); + pbt = ButtonFind(name); break; case CONFIG_ACTIONCLASS: case BUTTON_ACLASS: - ac = FindItem(s2, 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS); + ac = ActionclassFind(s2); if (pbt) pbt->aclass = ac; break; @@ -915,7 +949,7 @@ Button **blst; int flags; - blst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, 0); + blst = ButtonsGetList(&num); if (!blst) return; @@ -926,7 +960,7 @@ for (i = 0; i < num; i++) { - if (blst[i]->internal) + if (blst[i]->id != 0 || blst[i]->internal) continue; fprintf(fs, "4 999\n"); @@ -1008,21 +1042,47 @@ } } +typedef struct +{ + int id; + int match; + const char *regex; +} button_match_data; + +static void +_ButtonHideShow(void *data, void *prm) +{ + Button *b = data; + button_match_data *bmd = prm; + int match; + + if (bmd->id >= 0 && bmd->id != b->id) + return; + + if (bmd->regex) + { + match = matchregexp(bmd->regex, EoGetName(b)); + if ((match && !bmd->match) || (!match && bmd->match)) + return; + if (!strcmp(EoGetName(b), "_DESKTOP_DESKRAY_DRAG_CONTROL")) /* FIXME - ??? */ + return; + } + + ButtonToggle(b); +} + static void doHideShowButton(const char *params) { - Button **lst, *b; + Button *b; char s[1024]; const char *ss; - int num, i; + button_match_data bmd = { -1, 1, NULL }; if (!params) { - lst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, 0); - for (i = 0; i < num; i++) - ButtonToggle(lst[i]); - if (lst) - Efree(lst); + bmd.id = 0; + ecore_list_for_each(button_list, _ButtonHideShow, &bmd); goto done; } @@ -1030,7 +1090,7 @@ if (!strcmp(s, "button")) { sscanf(params, "%*s %1000s", s); - b = FindItem(s, 0, LIST_FINDBY_NAME, LIST_TYPE_BUTTON); + b = ButtonFind(s); if (b) ButtonToggle(b); } @@ -1040,18 +1100,8 @@ if (!ss) return; - lst = (Button **) ListItemType(&num, LIST_TYPE_BUTTON); - for (i = 0; i < num; i++) - { - if (matchregexp(ss, EoGetName(lst[i]))) - { - if (strcmp(EoGetName(lst[i]), - "_DESKTOP_DESKRAY_DRAG_CONTROL")) - ButtonToggle(lst[i]); - } - } - if (lst) - Efree(lst); + bmd.regex = ss; + ecore_list_for_each(button_list, _ButtonHideShow, &bmd); } else if (!strcmp(s, "all_buttons_except")) { @@ -1059,29 +1109,14 @@ if (!ss) return; - lst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, 0); - for (i = 0; i < num; i++) - { - if (!matchregexp(ss, EoGetName(lst[i]))) - { - if (strcmp(EoGetName(lst[i]), - "_DESKTOP_DESKRAY_DRAG_CONTROL")) - ButtonToggle(lst[i]); - } - } - if (lst) - Efree(lst); + bmd.id = 0; + bmd.match = 0; + bmd.regex = ss; + ecore_list_for_each(button_list, _ButtonHideShow, &bmd); } else if (!strcmp(s, "all")) { - lst = (Button **) ListItemType(&num, LIST_TYPE_BUTTON); - for (i = 0; i < num; i++) - { - if (strcmp(EoGetName(lst[i]), "_DESKTOP_DESKRAY_DRAG_CONTROL")) - ButtonToggle(lst[i]); - } - if (lst) - Efree(lst); + ecore_list_for_each(button_list, _ButtonHideShow, &bmd); } done: @@ -1093,7 +1128,8 @@ { const char *p; char cmd[128], prm[4096]; - int i, len, num; + int len; + Button *b; cmd[0] = prm[0] = '\0'; p = params; @@ -1109,21 +1145,11 @@ } else if (!strncmp(cmd, "list", 2)) { - Button **lst, *b; - IpcPrintf("Win d s l x y w h name\n"); - lst = (Button **) ListItemType(&num, LIST_TYPE_BUTTON); - for (i = 0; i < num; i++) - { - b = lst[i]; - IpcPrintf("%#lx %2d %2d %2d %5d+%5d %5dx%5d %s\n", - EoGetWin(b), EoGetDeskNum(b), EoIsSticky(b), - EoGetLayer(b), EoGetX(b), EoGetY(b), EoGetW(b), - EoGetH(b), EoGetName(lst[i])); - } - if (lst) - Efree(lst); - + ECORE_LIST_FOR_EACH(button_list, b) + IpcPrintf("%#lx %2d %2d %2d %5d+%5d %5dx%5d %s\n", + EoGetWin(b), EoGetDeskNum(b), EoIsSticky(b), EoGetLayer(b), + EoGetX(b), EoGetY(b), EoGetW(b), EoGetH(b), EoGetName(b)); } else if (!strncmp(cmd, "move", 2)) { =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/buttons.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- buttons.h 7 Jan 2006 07:20:57 -0000 1.7 +++ buttons.h 18 Feb 2006 08:30:04 -0000 1.8 @@ -46,6 +46,7 @@ int xsr, int xsa, int ysr, int ysa, char simg, int desk, char sticky); void ButtonDestroy(Button * b); +Button *ButtonFind(const char *name); void ButtonShow(Button * b); void ButtonHide(Button * b); void ButtonMoveToCoord(Button * b, int x, int y); @@ -61,6 +62,9 @@ int ButtonEmbedWindow(Button * ButtonToUse, Window WindowToEmbed); +Button **ButtonsGetList(int *pnum); +void ButtonsForeach(int id, struct _desk *dsk, + void (*func) (Button * b)); void ButtonsMoveStickyToDesk(struct _desk *d); int ButtonsConfigLoad(FILE * fs); =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/comms.c,v retrieving revision 1.73 retrieving revision 1.74 diff -u -3 -r1.73 -r1.74 --- comms.c 7 Jan 2006 07:20:57 -0000 1.73 +++ comms.c 18 Feb 2006 08:30:04 -0000 1.74 @@ -22,6 +22,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "E.h" +#include "e16-ecore_list.h" #include "ecore-e16.h" #include "xwin.h" @@ -36,6 +37,8 @@ char replied; }; +static Ecore_List *client_list = NULL; + static Window comms_win = 0; static Atom XA_ENLIGHTENMENT_COMMS = 0; @@ -58,24 +61,25 @@ c->win = win; ERegisterWindow(win); EventCallbackRegister(win, 0, ClientHandleEvents, c); - AddItem(c, st, win, LIST_TYPE_CLIENT); XSelectInput(disp, win, StructureNotifyMask | SubstructureNotifyMask); + if (!client_list) + client_list = ecore_list_new(); + ecore_list_prepend(client_list, c); + return c; } static void ClientDestroy(Client * c) { - Window win; - if (!c) return; - win = c->win; - RemoveItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_CLIENT); - EventCallbackUnregister(win, 0, ClientHandleEvents, c); - EUnregisterWindow(win); + ecore_list_remove_node(client_list, c); + + EventCallbackUnregister(c->win, 0, ClientHandleEvents, c); + EUnregisterWindow(c->win); if (c->name) Efree(c->name); if (c->msg) @@ -141,6 +145,12 @@ return 0; } +static int +ClientMatchWindow(const void *data, const void *match) +{ + return ((const Client *)data)->win != (Window) match; +} + static char * ClientCommsGet(Client ** c, XClientMessageEvent * ev) { @@ -162,7 +172,7 @@ for (i = 0; i < 12; i++) s[i] = ev->data.b[i + 8]; sscanf(s2, "%lx", &win); - cl = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_CLIENT); + cl = ecore_list_find(client_list, ClientMatchWindow, (void *)win); if (!cl) { cl = ClientCreate(win); @@ -334,6 +344,7 @@ CommsDoSend(RootWindow(disp, Mode.wm.master_screen), s); } +#if 0 /* Unused */ /* * When we are running in multi-head, connect to the slave wm processes * and broadcast the message @@ -371,3 +382,4 @@ } StrlistFree(l, num); } +#endif =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/conf.h,v retrieving revision 1.40 retrieving revision 1.41 diff -u -3 -r1.40 -r1.41 --- conf.h 7 Jan 2006 07:20:57 -0000 1.40 +++ conf.h 18 Feb 2006 08:30:06 -0000 1.41 @@ -102,6 +102,8 @@ #define ACLASS_EVENT_TRIGGER 428 #define ACLASS_ACTION 429 +#define ACLASS_TYPE_ACLASS 5 + #define BORDERPART_ICLASS 450 #define BORDERPART_ACLASS 451 #define BORDERPART_TEXTCLASS 452 =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/config.c,v retrieving revision 1.144 retrieving revision 1.145 diff -u -3 -r1.144 -r1.145 --- config.c 7 Jan 2006 07:20:57 -0000 1.144 +++ config.c 18 Feb 2006 08:30:06 -0000 1.145 @@ -32,10 +32,7 @@ #include "tclass.h" #include "tooltips.h" -#define SKIP_If_EXISTS(name, type) \ - if (ConfigSkipIfExists(ConfigFile, name, type)) return - -static void +void SkipTillEnd(FILE * ConfigFile) { char s[FILEPATH_LEN_MAX]; @@ -52,17 +49,6 @@ } } -int -ConfigSkipIfExists(FILE * ConfigFile, const char *name, int type) -{ - if (FindItem(name, 0, LIST_FINDBY_NAME, type)) - { - SkipTillEnd(ConfigFile); - return 1; - } - return 0; -} - static int IsWhitespace(const char *s) { =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/cursors.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -3 -r1.30 -r1.31 --- cursors.c 7 Jan 2006 07:20:57 -0000 1.30 +++ cursors.c 18 Feb 2006 08:30:08 -0000 1.31 @@ -24,6 +24,7 @@ #include "E.h" #include "X11/cursorfont.h" #include "conf.h" +#include "e16-ecore_list.h" #include "emodule.h" #include "xwin.h" @@ -38,6 +39,8 @@ #endif }; +static Ecore_List *cursor_list = NULL; + static ECursor * ECursorCreate(const char *name, const char *image, int native_id, XColor * fg, XColor * bg) @@ -97,7 +100,9 @@ ec->inroot = 0; #endif - AddItem(ec, ec->name, 0, LIST_TYPE_ECURSOR); + if (!cursor_list) + cursor_list = ecore_list_new(); + ecore_list_prepend(cursor_list, ec); return ec; } @@ -115,8 +120,7 @@ return; } - while (RemoveItemByPtr(ec, LIST_TYPE_ECURSOR)) - ; + ecore_list_remove_node(cursor_list, ec); if (ec->name) Efree(ec->name); @@ -126,6 +130,18 @@ } static int +_ECursorMatchName(const void *data, const void *match) +{ + return strcmp(((const ECursor *)data)->name, match); +} + +ECursor * +ECursorFind(const char *name) +{ + return ecore_list_find(cursor_list, _ECursorMatchName, name); +} + +static int ECursorConfigLoad(FILE * fs) { int err = 0; @@ -180,8 +196,11 @@ break; case CONFIG_CLASSNAME: - if (ConfigSkipIfExists(fs, s2, LIST_TYPE_ECURSOR)) - goto done; + if (ECursorFind(s2)) + { + SkipTillEnd(fs); + goto done; + } _EFDUP(name, s2); break; case CURS_BG_RGB: @@ -232,7 +251,7 @@ { ECursor *ec; - ec = FindItem(name, 0, LIST_FINDBY_NAME, LIST_TYPE_ECURSOR); + ec = ECursorFind(name); if (!ec) return XCreateFontCursor(disp, fallback); @@ -255,12 +274,6 @@ ec->ref_count--; } -static const char * -ECursorGetName(ECursor * ec) -{ - return (ec) ? ec->name : 0; -} - #if 0 /* Not used */ static int ECursorGetRefcount(ECursor * ec) @@ -318,7 +331,7 @@ { const char *p; char cmd[128], prm[4096]; - int i, len, num; + int len; ECursor *ec; cmd[0] = prm[0] = '\0'; @@ -337,21 +350,11 @@ } else if (!strncmp(cmd, "del", 3)) { - ec = FindItem(prm, 0, LIST_FINDBY_NAME, LIST_TYPE_ECURSOR); - if (ec) - ECursorDestroy(ec); + ECursorDestroy(ECursorFind(prm)); } else if (!strncmp(cmd, "list", 2)) { - ECursor **lst; - - lst = (ECursor **) ListItemType(&num, LIST_TYPE_ECURSOR); - for (i = 0; i < num; i++) - { - IpcPrintf("%s\n", ECursorGetName(lst[i])); - } - if (lst) - Efree(lst); + ECORE_LIST_FOR_EACH(cursor_list, ec) IpcPrintf("%s\n", ec->name); } } =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/desktops.c,v retrieving revision 1.222 retrieving revision 1.223 diff -u -3 -r1.222 -r1.223 --- desktops.c 11 Feb 2006 12:57:33 -0000 1.222 +++ desktops.c 18 Feb 2006 08:30:08 -0000 1.223 @@ -94,7 +94,7 @@ Conf.desks.dragbar_length = VRoot.w; Esnprintf(s, sizeof(s), "DRAGBAR_DESKTOP_%i", dsk->num); - ac = FindItem(s, 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS); + ac = ActionclassFind(s); if (!ac) { ac = ActionclassCreate(s, 0); @@ -136,7 +136,7 @@ } Esnprintf(s, sizeof(s), "RAISEBUTTON_DESKTOP_%i", dsk->num); - ac2 = FindItem(s, 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS); + ac2 = ActionclassFind(s); if (!ac2) { ac2 = ActionclassCreate(s, 0); @@ -150,7 +150,7 @@ } Esnprintf(s, sizeof(s), "LOWERBUTTON_DESKTOP_%i", dsk->num); - ac3 = FindItem(s, 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS); + ac3 = ActionclassFind(s); if (!ac3) { ac3 = ActionclassCreate(s, 0); @@ -329,33 +329,13 @@ static void DeskControlsDestroy(Desk * dsk, int id) { - Button **blst; - int num, i; - - blst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, id); - if (!blst) - return; - - for (i = 0; i < num; i++) - if (EobjGetDesk((EObj *) (blst[i])) == dsk) - ButtonDestroy(blst[i]); - Efree(blst); + ButtonsForeach(id, dsk, ButtonDestroy); } static void DeskControlsShow(Desk * dsk, int id) { - Button **blst; - int num, i; - - blst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, id); - if (!blst) - return; - - for (i = 0; i < nu... [truncated message content] |