Make sure Locale dirs exsit before copying icons to them.
[cake.git] / rom / workbench / getnextappicon.c
blobe42625c8bd77a2c309e5e8dd0834a6a8bee2e336
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Accesses AppIcon information from workbench.library.
6 Lang: English
7 */
9 #include <exec/types.h>
10 #include <exec/ports.h>
11 #include <utility/tagitem.h>
12 #include <dos/dos.h>
13 #include <graphics/gfx.h>
15 #include <proto/utility.h>
17 #include "workbench_intern.h"
18 #include <workbench/workbench.h>
20 #define DEBUG 0
21 #include <aros/debug.h>
22 /*****************************************************************************
24 NAME */
25 #include <proto/workbench.h>
27 AROS_LH2(struct DiskObject *, GetNextAppIcon,
28 /* SYNOPSIS */
29 AROS_LHA(struct DiskObject *, lastdiskobj, A0),
30 AROS_LHA(char *, text, A1),
32 /* LOCATION */
33 struct WorkbenchBase *, WorkbenchBase, 10, Workbench)
35 /* FUNCTION
37 Accesses AppIcon information from workbench.library. This function
38 is meant for iterations through wblibs´ AppIcon storage as needed
39 to display those.
40 Initialised with a NULL as the first argument, it iterates
41 through all AppIcons stored in workbench.library by returning the
42 pointer to the next AppIcon´s DiskObject structure and copies the
43 name of the given AppIcon to the given array. The function returns
44 a NULL if the end of AppIcon list was reached or if no AppIcons
45 were stored.
47 INPUTS
49 lastdiskobj -- NULL (initial value) or pointer to a DiskObject
50 structure stored in workbench.library
51 text -- char array pointer to store AppIcon´s name in
53 RESULT
55 A pointer to an DiskObject structure -- which should be used within
56 the next function call to access the next AppIcon -- or NULL if no
57 AppIcons were found or end of list was reached.
59 NOTES
61 EXAMPLE
63 struct DiskObject *_nb_dob = NULL;
64 char text[32];
66 while ( _nb_dob = GetNextAppIcon(_nb_dob, &text) )
68 printf("appicon found: %s \n", text);
72 BUGS
74 SEE ALSO
76 AddAppIconA(), RemoveAppIcon(), WorkbenchControlA(), icon.library/DrawIconStateA()
78 INTERNALS
80 ******************************************************************************/
82 AROS_LIBFUNC_INIT
84 /* get wblibs list of appicons */
85 struct List *appiconlist = NULL;
86 appiconlist = &WorkbenchBase->wb_AppIcons;
89 /* return NULL if list empty or argument dob is already from last appicon in list*/
90 if ( !IsListEmpty(appiconlist) )
92 /* return NULL if last entry reached */
93 if (lastdiskobj == ((struct AppIcon *)(appiconlist->lh_TailPred))->ai_DiskObject) return NULL;
95 struct Node *currentnode = appiconlist->lh_Head;
96 currentnode = GetHead(appiconlist);
98 /* iterations through the list */
101 /* check if given DiskObject was found and return it´s successor */
102 if ( ((struct AppIcon*)currentnode)->ai_DiskObject == lastdiskobj)
104 currentnode = GetSucc(currentnode);
106 bug("[getnextappicon] appicon found: %s \n", ((struct AppIcon*)currentnode)->ai_Text );
108 strcpy(text, ((struct AppIcon*)currentnode)->ai_Text );
109 return ((struct AppIcon*)currentnode)->ai_DiskObject;
113 } while ((currentnode = GetSucc(currentnode)));
115 /* return first entry if NULL was given or DiskObject could not be found */
116 strcpy(text, ((struct AppIcon *)(appiconlist->lh_Head))->ai_Text );
117 return ((struct AppIcon *)(appiconlist->lh_Head))->ai_DiskObject;
121 return NULL;
123 AROS_LIBFUNC_EXIT
124 } /* GetNextAppIcon() */