source: titan/titan/dir.h @ 15338

Last change on this file since 15338 was 15115, checked in by nit, 12 years ago

[titan] optimize

File size: 4.9 KB
Line 
1#ifndef DIR_H
2#define DIR_H
3
4void readlabelext(struct skin* label, char* filename, char* ext)
5{
6        char *tmpstr = NULL, *tmpstr1 = NULL;
7
8        tmpstr = changefilenameext(filename, ext);
9        tmpstr1 = readfiletomem(tmpstr, 0);
10        if(tmpstr1 == NULL && ostrcmp(ext, ".epg") == 0)
11        {
12                free(tmpstr); tmpstr = NULL;
13                tmpstr = changefilenameext(filename, ".eit");
14                tmpstr1 = readeittomem(tmpstr);
15        }
16       
17        changetext(label, tmpstr1);
18
19        free(tmpstr); tmpstr = NULL;
20        free(tmpstr1); tmpstr1 = NULL;
21}
22
23//flag 1: add selected dir to path
24//flag 2: add selected dir to path and use dirrcret for dirs
25char* screendir(char* path, char* mask, char* selection, int *dirrcret, char* ext, char* b1, int rc1, char* b2, int rc2, char* b3, int rc3, char* b4, int rc4, int width, int prozwidth, int height, int prozheight, int flag)
26{
27        int rcret = 0;
28        struct skin* dir = NULL;
29
30        if(ext != NULL)
31                dir = getscreen("dirlabel");
32        else
33                dir = getscreen("dir");
34
35        struct skin* filelistpath = getscreennode(dir, "filelistpath");
36        struct skin* filelist = getscreennode(dir, "filelist");
37        struct skin* label = getscreennode(dir, "label");
38        struct skin *button = NULL;
39        char *ret = NULL;
40        char *tmppath = NULL;
41
42        if(path == NULL || strlen(path) == 0 || !isdir(path))
43                tmppath = ostrcat("/", "", 0, 0);
44        else
45                tmppath = ostrcat(path, "", 0, 0);
46
47        filelist->aktline = 0;
48        filelist->aktpage = 0;
49        changemask(filelist, mask);
50        changeinput(filelist, tmppath);
51        changetext(filelistpath, filelist->input);
52        dir->width = width;
53        dir->prozwidth = prozwidth;
54        dir->height = height;
55        dir->prozheight = prozheight;
56
57        free(tmppath);
58        delmarkedscreennodes(dir, FILELISTDELMARK);
59        createfilelist(dir, filelist, 0);
60        setlistboxselection(filelist, selection);
61
62        if(ext != NULL)
63        {
64                ret = createpath(filelist->input, selection);
65                readlabelext(label, ret, ext);
66                free(ret); ret = NULL;
67        }
68
69        button = getscreennode(dir, "b1");
70        if(b1 != NULL)
71                changetext(button, _(b1));
72        else
73                changetext(button, _("---"));
74
75        button = getscreennode(dir, "b2");
76        if(b2 != NULL)
77                changetext(button, _(b2));
78        else
79                changetext(button, _("---"));
80
81        button = getscreennode(dir,  "b3");
82        if(b3 != NULL)
83                changetext(button, _(b3));
84        else
85                changetext(button, _("---"));
86
87        button = getscreennode(dir, "b4");
88        if(b4 != NULL)
89                changetext(button, _(b4));
90        else
91                changetext(button, _("---"));
92
93        drawscreen(dir, 0);
94        addscreenrc(dir, filelist);
95
96        while(1)
97        {
98                if(ext != NULL) status.screencalc = 2;
99                rcret = waitrc(dir, 0, 0);
100                if(ext != NULL) status.screencalc = 0;
101
102                if(rcret == getrcconfigint("rcexit", NULL))
103                {
104                        free(ret); ret = NULL;
105                        if(dirrcret != NULL) *dirrcret = 5;
106                        break;
107                }
108
109                if(rcret == getrcconfigint("rcup", NULL) || rcret == getrcconfigint("rcdown", NULL) || rcret == getrcconfigint("rcright", NULL) || rcret == getrcconfigint("rcleft", NULL))
110                {
111                        if(ext != NULL && filelist->select != NULL && filelist->select->input != NULL) //dir
112                        {
113                                changetext(label, NULL);
114                                drawscreen(dir, 0);
115                        }
116                        else if(filelist->select != NULL && filelist->select->input == NULL) //file
117                        {
118
119                                ret = createpath(filelistpath->text, filelist->select->text);
120                                if(ext != NULL)
121                                {
122                                        readlabelext(label, ret, ext);
123                                        drawscreen(dir, 0);
124                                }
125                                free(ret); ret = NULL;
126                        }
127                        continue;
128                }
129
130                if(rcret == getrcconfigint("rcok", NULL) || (b1 != NULL && rcret == getrcconfigint("rcred", NULL)) || (b3 != NULL && rcret == getrcconfigint("rcyellow", NULL)) || (b4 != NULL && rcret == getrcconfigint("rcblue", NULL)))
131                {
132                        if(filelist->select != NULL && filelist->select->input != NULL) //dir
133                        {
134                                if(dirrcret != NULL && flag == 2)
135                                {
136                                        if(b1 != NULL && rcret == getrcconfigint("rcred", NULL))
137                                        {
138                                                *dirrcret = 1;
139                                                break;
140                                        }
141                                }
142                                if(ext != NULL)
143                                        drawscreen(dir, 0);
144                                continue;
145                        }
146                        else if(filelist->select != NULL && filelist->select->input == NULL) //file
147                        {
148                                ret = createpath(filelistpath->text, filelist->select->text);
149                                if(dirrcret != NULL)
150                                {
151                                        if(b1 != NULL && rcret == getrcconfigint("rcred", NULL))
152                                                *dirrcret = 1;
153                                        else if(b3 != NULL && rcret == getrcconfigint("rcyellow", NULL))
154                                                *dirrcret = 3;
155                                        else if(b4 != NULL && rcret == getrcconfigint("rcblue", NULL))
156                                                *dirrcret = 4;
157                                }
158                                break;
159                        }
160                        else if(ext != NULL)
161                                drawscreen(dir, 0);
162                }
163
164                if(rcret == getrcconfigint("rcgreen", NULL))
165                {
166                        if(filelistpath != NULL)
167                        {
168                                if(filelist->mask == NULL || strlen(filelist->mask) == 0)
169                                {
170                                        if(flag == 1 || flag == 2)
171                                                ret = createpath(filelistpath->text, filelist->select->text);
172                                        else
173                                                ret = createpath(filelistpath->text, "");
174                                        if(dirrcret != NULL) *dirrcret = 2;
175                                        break;
176                                }
177                                else if(filelist->select != NULL && filelist->select->input == NULL)
178                                {
179                                        ret = createpath(filelistpath->text, filelist->select->text);
180                                        if(dirrcret != NULL) *dirrcret = 2;
181                                        break;
182                                }
183                        }
184                }
185        }
186
187        delmarkedscreennodes(dir, FILELISTDELMARK);
188        delownerrc(dir);
189        clearscreen(dir);
190        return ret;
191}
192
193#endif
Note: See TracBrowser for help on using the repository browser.