source: titan/titan/menulist.h @ 10994

Last change on this file since 10994 was 10239, checked in by obi, 13 years ago

next fix multiepg menulist

File size: 4.7 KB
Line 
1#ifndef MENULIST_H
2#define MENULIST_H
3
4// showpng = 0 (no icon)
5// showpng = 1 (smal icon)
6
7char* menulistbox(char* defaultstr, char* str, char* skinname, char* skintitle, char* skinpath, int showpng)
8{
9        debug(1000, "in");
10        char* skinname1 = NULL;
11        char* skinpath1 = NULL;
12        char* tmpskinpath = NULL;
13        int rcret = 0;
14
15        if (str == NULL)
16                return 0;
17
18        if (skinname == NULL){
19                debug(60, "skinname default=menulist");
20                skinname1 = ostrcat(skinname, "menulist", 1, 0);
21        } else {
22                debug(60, "skinname changed=%s", skinname);
23                skinname1 = ostrcat(skinname, "", 0, 0);
24        }
25
26        if (skinpath == NULL){
27                debug(60, "skinpath default=skin/");
28                skinpath1 = ostrcat(skinpath, "skin/", 1, 0);
29        } else {
30                debug(60, "skinpath changed=%s", skinpath);
31                skinpath1 = ostrcat(skinpath, "", 0, 0);
32        }
33
34        struct skin* screen = getscreen(skinname1);
35        struct skin* listbox = getscreennode(screen, "listbox");
36       
37        listbox->aktpage = -1;
38        listbox->aktline = 1;
39
40        if(skintitle != NULL){
41                debug(60, "skintitle changed=%s", skintitle);
42                changetitle(screen, _(skintitle));
43        }
44
45        struct skin* tmp = NULL;
46        char* tmpstr = NULL;
47        char* defaultdir = NULL;
48        char* tmpsplit = NULL;
49        char* tmpck = NULL;
50        char* tmpstr1 = NULL;
51        char* tmpstr4 = NULL;
52        char* tmpstr5 = NULL;
53        char* tmppng = NULL;
54
55        struct splitstr* ret1 = NULL;
56        struct splitstr* ret2 = NULL;
57        struct splitstr* ret3 = NULL;
58        int count = 0;
59        int i = 0;
60        ret1 = strsplit(str, "\n", &count);
61
62        for( i = 0; i < count; i++)
63        {
64                int count2 = 0;
65                tmpsplit = ostrcat(tmpsplit, (&ret1[i])->part, 1, 0);
66                free(ret2); ret2 = NULL;
67                ret2 = strsplit(tmpsplit, "-", &count2);
68
69                tmppng = ostrcat("", (&ret1[i])->part, 0, 0);
70
71                stringreplacechar(tmppng, ' ', '_');
72                stringreplacechar(tmppng, ':', '_');
73                string_tolower(tmppng);
74               
75                tmp = addlistbox(screen, listbox, tmp, 1);
76               
77                if(tmp != NULL)
78                {
79                        changetext(tmp, _((&ret1[i])->part));
80                        changename(tmp, (&ret1[i])->part);
81
82                        tmp->del = 1;
83                        if(showpng == 1)
84                        {
85                                tmp->textposx = 120;
86                                tmp->height = 50;
87//                              tmp->fontsize = 30;
88                                tmp->valign = convertxmlentry("middle", 0);
89                                tmp->hspace = 5;
90                                debug(60, "showpng changed=%d", showpng);
91                        }
92                        else
93                        {
94                                debug(60, "showpng default=%d", showpng);
95                        }
96
97                        if(ostrcmp((&ret1[i])->part, "\t") == 0)
98                                tmp->deaktivcol = convertcol("deaktivcol");
99                        else
100                        {
101                                if(showpng == 1)
102                                {
103                                        if(string_find("%pluginpath%",skinpath1)){
104                                                struct splitstr* ret6 = NULL;
105                                                int count6 = 0;
106                                                char* tmpstr6 = NULL;
107                                                tmpstr6 = ostrcat("", skinpath1, 0, 0);
108                                                ret6 = strsplit(tmpstr6, "%", &count6);
109
110                                                defaultdir = ostrcat(getconfig("skinpath", NULL), "/skin/", 0, 0);
111                                                defaultdir = ostrcat(defaultdir, tmppng, 1, 0);
112                                                defaultdir = ostrcat(defaultdir, ".png", 1, 0);
113                                                debug(60, "defaultdir1 %s", defaultdir);
114                                                if(!file_exist(defaultdir))
115                                                {
116                                                        defaultdir = ostrcat(getconfig("pluginpath", NULL), (&ret6[1])->part, 0, 0);
117                                                        defaultdir = ostrcat(defaultdir, tmppng, 1, 0);
118                                                        defaultdir = ostrcat(defaultdir, ".png", 1, 0);
119                                                }
120
121                                                free(ret6), ret6 = NULL;
122                                                debug(60, "defaultdir2 %s", defaultdir);
123                                        }
124                                        else
125                                        {
126                                                defaultdir = ostrcat(getconfig("skinpath", NULL), "/", 0, 0);
127                                                defaultdir = ostrcat(defaultdir, skinpath1, 1, 0);
128                                                defaultdir = ostrcat(defaultdir, tmppng, 1, 0);
129                                                defaultdir = ostrcat(defaultdir, ".png", 1, 0);
130                                                debug(60, "defaultdir3 %s", defaultdir);
131                                        }
132
133                                        debug(60, "defaultdir4 %s", defaultdir);
134                                        if(file_exist(defaultdir))
135                                        {
136                                                tmpskinpath = ostrcat("", defaultdir, 0, 0);
137                                                changepic(tmp, tmpskinpath);
138                                                free(tmpskinpath); tmpskinpath = NULL;
139                                        }
140                                        else
141                                        {
142                                                tmpskinpath = ostrcat(skinpath1, "default.png", 0, 0);
143                                                changepic(tmp, tmpskinpath);
144                                                free(tmpskinpath); tmpskinpath = NULL;
145                                        }
146                                        free(defaultdir); defaultdir = NULL;
147                                }
148                        }
149                        if(defaultstr != NULL)
150                        {
151                                setlistboxselection(listbox, defaultstr);
152                        //      if(ostrcmp(defaultstr, (&ret1[i])->part) == 0)
153                        //              listbox->aktline = i + 1;
154                        }
155                }
156                free(tmppng); tmppng = NULL;
157        }
158
159        free(ret1); ret1 = NULL;
160        free(ret2); ret2 = NULL;
161        free(ret3); ret3 = NULL;
162        free(tmpck); tmpck = NULL;
163        free(tmpsplit); tmpsplit = NULL;
164        free(tmpstr1); tmpstr1 = NULL;
165        free(tmpstr4); tmpstr4 = NULL;
166        free(tmpstr5); tmpstr5 = NULL;
167
168        listbox->aktpage = -1;
169
170        drawscreen(screen,0);
171        addscreenrc(screen, listbox);
172
173        while (1)
174        {
175                rcret = waitrc(screen, 0, 0);
176
177                if(rcret==getrcconfigint("rcexit",NULL)) break;
178                if(listbox->select != NULL && rcret==getrcconfigint("rcok",NULL))
179                {
180                        tmpstr = ostrcat(tmpstr, listbox->select->name, 1, 0);
181                        break;
182                }
183        }
184
185        free(skinname1); skinname1 = NULL;
186        free(skinpath1); skinpath1 = NULL;
187        delownerrc(screen);
188        delmarkedscreennodes(screen, 1);
189        clearscreen(screen);
190        debug(1000, "out");
191        return tmpstr;
192}
193
194#endif
Note: See TracBrowser for help on using the repository browser.