Rev 9640 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9640 | Rev 9643 | ||
---|---|---|---|
1 | //11.03.12 - start! |
1 | //11.03.12 - start! |
2 | 2 | ||
3 | #define MEMSIZE 1024*70 |
3 | #define MEMSIZE 1024*70 |
4 | #include "../lib/mem.h" |
4 | #include "../lib/mem.h" |
5 | #include "../lib/strings.h" |
5 | #include "../lib/strings.h" |
6 | #include "../lib/io.h" |
6 | #include "../lib/io.h" |
7 | #include "../lib/list_box.h" |
7 | #include "../lib/list_box.h" |
8 | #include "../lib/gui.h" |
8 | #include "../lib/gui.h" |
9 | 9 | ||
10 | #include "../lib/obj/box_lib.h" |
10 | #include "../lib/obj/box_lib.h" |
11 | #include "../lib/obj/proc_lib.h" |
11 | #include "../lib/obj/proc_lib.h" |
12 | #include "../lib/obj/libini.h" |
12 | #include "../lib/obj/libini.h" |
13 | 13 | ||
14 | #include "../lib/patterns/select_list.h" |
14 | #include "../lib/patterns/select_list.h" |
15 | #include "../lib/patterns/simple_open_dialog.h" |
15 | #include "../lib/patterns/simple_open_dialog.h" |
16 | #include "../lib/patterns/restart_process.h" |
16 | #include "../lib/patterns/restart_process.h" |
17 | 17 | ||
18 | dword fmas; |
18 | dword fmas; |
19 | 19 | ||
20 | #include "ui_elements_preview.h" |
20 | #include "ui_elements_preview.h" |
21 | #include "const.h" |
21 | #include "const.h" |
22 | 22 | ||
23 | //===================================================// |
23 | //===================================================// |
24 | // // |
24 | // // |
25 | // DATA // |
25 | // DATA // |
26 | // // |
26 | // // |
27 | //===================================================// |
27 | //===================================================// |
28 | 28 | ||
29 | int active_skin=-1, active_wallpaper=-1, active_screensaver=-1; |
29 | int active_skin=-1, active_wallpaper=-1, active_screensaver=-1; |
30 | 30 | ||
31 | checkbox optionbox_stretch = { T_CHECKBOX_STRETCH, false }; |
31 | checkbox optionbox_stretch = { T_CHECKBOX_STRETCH, false }; |
32 | checkbox optionbox_tiled = { T_CHECKBOX_TILED, false }; |
32 | checkbox optionbox_tiled = { T_CHECKBOX_TILED, false }; |
33 | checkbox optionbox_auto = { T_CHECKBOX_AUTO, true }; |
33 | checkbox optionbox_auto = { T_CHECKBOX_AUTO, true }; |
34 | 34 | ||
35 | char ss_available[200]; |
35 | char ss_available[200]; |
36 | 36 | ||
37 | collection list; |
37 | collection list; |
38 | 38 | ||
39 | 39 | ||
40 | //===================================================// |
40 | //===================================================// |
41 | // // |
41 | // // |
42 | // CODE // |
42 | // CODE // |
43 | // // |
43 | // // |
44 | //===================================================// |
44 | //===================================================// |
45 | 45 | ||
46 | void main() |
46 | void main() |
47 | { |
47 | { |
48 | int id, i; |
48 | int id, i; |
49 | load_dll(boxlib, #box_lib_init,0); |
49 | load_dll(boxlib, #box_lib_init,0); |
50 | load_dll(libini, #lib_init,1); |
50 | load_dll(libini, #lib_init,1); |
51 | load_dll(Proc_lib, #OpenDialog_init,0); |
51 | load_dll(Proc_lib, #OpenDialog_init,0); |
52 | OpenDialog_init stdcall (#o_dialog); |
52 | OpenDialog_init stdcall (#o_dialog); |
53 | 53 | ||
54 | GetIniSettings(); |
54 | GetIniSettings(); |
55 | 55 | ||
56 | tabs.add(#t_skins, #EventTabSkinsClick); |
56 | tabs.add(#t_skins, #EventTabSkinsClick); |
57 | tabs.add(#t_wallpapers, #EventTabWallpappersClick); |
57 | tabs.add(#t_wallpapers, #EventTabWallpappersClick); |
58 | tabs.add(#t_screensaver, #EventTabScreensaverClick); |
58 | tabs.add(#t_screensaver, #EventTabScreensaverClick); |
59 | tabs.draw_active_tab(); |
59 | tabs.draw_active_tab(); |
60 | 60 | ||
61 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
61 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
62 | loop() switch(WaitEvent()) |
62 | loop() switch(WaitEvent()) |
63 | { |
63 | { |
64 | case evMouse: |
64 | case evMouse: |
65 | SelectList_ProcessMouse(); |
65 | SelectList_ProcessMouse(); |
66 | if (tabs.active_tab == TAB_SCREENSAVERS) { |
66 | if (tabs.active_tab == TAB_SCREENSAVERS) { |
67 | scrollbar_h_mouse stdcall (#ss_timeout); |
67 | scrollbar_h_mouse stdcall (#ss_timeout); |
68 | if (ss_timeout.redraw) { |
68 | if (ss_timeout.redraw) { |
69 | draw_timeout(); |
69 | draw_timeout(); |
70 | ss_timeout.redraw = false; //reset flag |
70 | ss_timeout.redraw = false; //reset flag |
71 | } |
71 | } |
72 | } |
72 | } |
73 | break; |
73 | break; |
74 | 74 | ||
75 | case evButton: |
75 | case evButton: |
76 | id=GetButtonID(); |
76 | id=GetButtonID(); |
77 | if (id==1) EventExit(); |
77 | if (id==1) EventExit(); |
78 | tabs.click(id); |
78 | tabs.click(id); |
79 | if (tabs.active_tab == TAB_SKINS) { |
79 | if (tabs.active_tab == TAB_SKINS) { |
80 | checkbox1.click(id); |
80 | checkbox1.click(id); |
81 | spinbox1.click(id); |
81 | spinbox1.click(id); |
82 | } |
82 | } |
83 | if (tabs.active_tab == TAB_WALLPAPERS) { |
83 | if (tabs.active_tab == TAB_WALLPAPERS) { |
84 | if (id==BTN_SELECT_WALLP_FOLDER) EventSelectWallpFolder(); |
84 | if (id==BTN_SELECT_WALLP_FOLDER) EventSelectWallpFolder(); |
85 | if (optionbox_stretch.click(id)) EventSetWallpMode(1,0,0); |
85 | if (optionbox_stretch.click(id)) EventSetWallpMode(1,0,0); |
86 | if (optionbox_tiled.click(id)) EventSetWallpMode(0,1,0); |
86 | if (optionbox_tiled.click(id)) EventSetWallpMode(0,1,0); |
87 | if (optionbox_auto.click(id)) EventSetWallpMode(0,0,1); |
87 | if (optionbox_auto.click(id)) EventSetWallpMode(0,0,1); |
88 | } |
88 | } |
89 | if (tabs.active_tab == TAB_SCREENSAVERS) { |
89 | if (tabs.active_tab == TAB_SCREENSAVERS) { |
90 | if (id==BTN_TEST_SCREENSAVER) EventOpenFile(); |
90 | if (id==BTN_TEST_SCREENSAVER) EventOpenFile(); |
91 | if (id==BTN_SET_SCREENSAVER) EventSetSs(); |
91 | if (id==BTN_SET_SCREENSAVER) EventSetSs(); |
92 | } |
92 | } |
93 | break; |
93 | break; |
94 | 94 | ||
95 | case evKey: |
95 | case evKey: |
96 | GetKeys(); |
96 | GetKeys(); |
97 | if (select_list.ProcessKey(key_scancode)) { EventApply(); break; } |
97 | if (select_list.ProcessKey(key_scancode)) { EventApply(); break; } |
98 | if (key_scancode==SCAN_CODE_ENTER) { EventOpenFile(); break; } |
98 | if (key_scancode==SCAN_CODE_ENTER) { EventOpenFile(); break; } |
99 | if (key_scancode==SCAN_CODE_DEL) { EventDeleteFile(); break; } |
99 | if (key_scancode==SCAN_CODE_DEL) { EventDeleteFile(); break; } |
100 | if (key_scancode==SCAN_CODE_TAB) { |
100 | if (key_scancode==SCAN_CODE_TAB) { |
101 | id = tabs.active_tab+1; |
101 | id = tabs.active_tab+1; |
102 | if(id==3)id=0; |
102 | if(id==3)id=0; |
103 | tabs.click(id + tabs.base_id); |
103 | tabs.click(id + tabs.base_id); |
104 | break; |
104 | break; |
105 | } |
105 | } |
106 | for (i=select_list.cur_y+1; i |
106 | for (i=select_list.cur_y+1; i |
107 | { |
107 | { |
108 | id = list.get(i) + strrchr(list.get(i), '/'); |
108 | id = list.get(i) + strrchr(list.get(i), '/'); |
109 | if (ESBYTE[id]==key_ascii) || (ESBYTE[id]==key_ascii-32) |
109 | if (ESBYTE[id]==key_ascii) || (ESBYTE[id]==key_ascii-32) |
110 | { |
110 | { |
111 | select_list.cur_y = i - 1; |
111 | select_list.cur_y = i - 1; |
112 | select_list.KeyDown(); |
112 | select_list.KeyDown(); |
113 | EventApply(); |
113 | EventApply(); |
114 | break; |
114 | break; |
115 | } |
115 | } |
116 | } |
116 | } |
117 | break; |
117 | break; |
118 | 118 | ||
119 | case evReDraw: |
119 | case evReDraw: |
120 | draw_window(); |
120 | draw_window(); |
121 | } |
121 | } |
122 | } |
122 | } |
123 | 123 | ||
124 | void draw_window() |
124 | void draw_window() |
125 | { |
125 | { |
126 | sc.get(); |
126 | sc.get(); |
127 | DefineAndDrawWindow(screen.w-WIN_W-9/2,80,WIN_W+9,WIN_H+4+skin_h,0x74,sc.work,WINDOW_HEADER,0); |
127 | DefineAndDrawWindow(screen.w-WIN_W-9/2,80,WIN_W+9,WIN_H+4+skin_h,0x74,sc.work,WINDOW_HEADER,0); |
128 | 128 | ||
129 | DrawBar(0, 0, WIN_W, PANEL_H-2, sc.work); //top |
129 | DrawBar(0, 0, WIN_W, PANEL_H-2, sc.work); //top |
130 | DrawBar(0, PANEL_H-2, LP-2, WIN_H-PANEL_H-LP+4, EDX); //left |
130 | DrawBar(0, PANEL_H-2, LP-2, WIN_H-PANEL_H-LP+4, EDX); //left |
131 | DrawBar(LIST_W+LP+20, PANEL_H-2, WIN_W-LIST_W-26, WIN_H-PANEL_H-LP+4, EDX); //right |
131 | DrawBar(LIST_W+LP+20, PANEL_H-2, WIN_W-LIST_W-26, WIN_H-PANEL_H-LP+4, EDX); //right |
132 | DrawBar(0, WIN_H-LP+2, WIN_W, LP-2, EDX); //bottom |
132 | DrawBar(0, WIN_H-LP+2, WIN_W, LP-2, EDX); //bottom |
133 | 133 | ||
134 | tabs.draw(); |
134 | tabs.draw(); |
135 | draw_icon_16w(tabs.x + TAB_P, LP+5, 17); |
135 | draw_icon_16w(tabs.x + TAB_P, LP+5, 17); |
136 | draw_icon_16w(sizeof(t_skins)-1*8 + TAB_P + TAB_P + tabs.x, LP+5, 6); |
136 | draw_icon_16w(sizeof(t_skins)-1*8 + TAB_P + TAB_P + tabs.x, LP+5, 6); |
137 | draw_icon_16w(sizeof(t_wallpapers)+sizeof(t_skins)-2*8 + TAB_P + TAB_P + TAB_P + tabs.x, LP+5, 61); |
137 | draw_icon_16w(sizeof(t_wallpapers)+sizeof(t_skins)-2*8 + TAB_P + TAB_P + TAB_P + tabs.x, LP+5, 61); |
138 | 138 | ||
139 | if (tabs.active_tab == TAB_SKINS) |
139 | if (tabs.active_tab == TAB_SKINS) |
140 | { |
140 | { |
141 | DrawFrame(RIGHTx, PANEL_H+5, RIGHTw, RIGHTh, T_UI_PREVIEW); |
141 | DrawFrame(RIGHTx, PANEL_H+5, RIGHTw, RIGHTh, T_UI_PREVIEW); |
142 | DrawUiElementsPreview(RIGHTx+20, PANEL_H+5, RIGHTh); |
142 | DrawUiElementsPreview(RIGHTx+20, PANEL_H+5, RIGHTh); |
143 | } |
143 | } |
144 | if (tabs.active_tab == TAB_WALLPAPERS) |
144 | if (tabs.active_tab == TAB_WALLPAPERS) |
145 | { |
145 | { |
146 | DrawFrame(RIGHTx, PANEL_H+5, 180, 105, T_PICTURE_MODE); |
146 | DrawFrame(RIGHTx, PANEL_H+5, 180, 105, T_PICTURE_MODE); |
147 | optionbox_stretch.draw(RIGHTx+14, PANEL_H+25); |
147 | optionbox_stretch.draw(RIGHTx+14, PANEL_H+25); |
148 | optionbox_tiled.draw(RIGHTx+14, PANEL_H+52); |
148 | optionbox_tiled.draw(RIGHTx+14, PANEL_H+52); |
149 | optionbox_auto.draw(RIGHTx+14, PANEL_H+79); |
149 | optionbox_auto.draw(RIGHTx+14, PANEL_H+79); |
150 | DrawStandartCaptButton(RIGHTx, PANEL_H+130, BTN_SELECT_WALLP_FOLDER, T_SELECT_FOLDER); |
150 | DrawStandartCaptButton(RIGHTx, PANEL_H+130, BTN_SELECT_WALLP_FOLDER, T_SELECT_FOLDER); |
151 | } |
151 | } |
152 | if (tabs.active_tab == TAB_SCREENSAVERS) |
152 | if (tabs.active_tab == TAB_SCREENSAVERS) |
153 | { |
153 | { |
154 | draw_timeout(); |
154 | draw_timeout(); |
155 | ss_timeout.line_col = sc.line; |
155 | ss_timeout.line_col = sc.line; |
156 | ss_timeout.frnt_col = sc.work; |
156 | ss_timeout.frnt_col = sc.work; |
157 | scrollbar_h_draw stdcall (#ss_timeout); |
157 | scrollbar_h_draw stdcall (#ss_timeout); |
158 | DrawRectangle(RIGHTx, RIGHTy+25, RIGHTw-20, 15, sc.line); |
158 | DrawRectangle(RIGHTx, RIGHTy+25, RIGHTw-20, 15, sc.line); |
159 | ESI = DrawStandartCaptButton(RIGHTx, PANEL_H + 65, BTN_TEST_SCREENSAVER, T_SS_PREVIEW); |
159 | ESI = DrawStandartCaptButton(RIGHTx, PANEL_H + 65, BTN_TEST_SCREENSAVER, T_SS_PREVIEW); |
160 | DrawStandartCaptButton(RIGHTx+ESI, PANEL_H + 65, BTN_SET_SCREENSAVER, T_SS_SET); |
160 | DrawStandartCaptButton(RIGHTx+ESI, PANEL_H + 65, BTN_SET_SCREENSAVER, T_SS_SET); |
161 | } |
161 | } |
162 | 162 | ||
163 | $push select_list.cur_y |
163 | $push select_list.cur_y |
164 | SelectList_Init( |
164 | SelectList_Init( |
165 | LP, |
165 | LP, |
166 | PANEL_H, |
166 | PANEL_H, |
167 | LIST_W, |
167 | LIST_W, |
168 | WIN_H - LP - PANEL_H |
168 | WIN_H - LP - PANEL_H |
169 | ); |
169 | ); |
170 | $pop select_list.cur_y |
170 | $pop select_list.cur_y |
171 | 171 | ||
172 | SelectList_Draw(); |
172 | SelectList_Draw(); |
173 | SelectList_DrawBorder(); |
173 | SelectList_DrawBorder(); |
174 | } |
174 | } |
175 | 175 | ||
176 | void draw_timeout() |
176 | void draw_timeout() |
177 | { |
177 | { |
178 | miniprintf(#param, T_SS_TIMEOUT, ss_timeout.position+1); |
178 | miniprintf(#param, T_SS_TIMEOUT, ss_timeout.position+1); |
179 | WriteTextWithBg(RIGHTx, PANEL_H, 0xD0, sc.work_text, #param, sc.work); |
179 | WriteTextWithBg(RIGHTx, PANEL_H, 0xD0, sc.work_text, #param, sc.work); |
180 | } |
180 | } |
181 | 181 | ||
182 | void add_filesnames_into_the_list() |
182 | void add_filesnames_into_the_list() |
183 | { |
183 | { |
184 | int j; |
184 | int j; |
185 | for (j=0; j |
185 | for (j=0; j |
186 | miniprintf(#param,"%s/",#folder_path); |
186 | miniprintf(#param,"%s/",#folder_path); |
187 | strcat(#param, io.dir.position(ESDWORD[j*4+fmas])); |
187 | strcat(#param, io.dir.position(ESDWORD[j*4+fmas])); |
188 | list.add(#param); |
188 | list.add(#param); |
189 | } |
189 | } |
190 | } |
190 | } |
191 | 191 | ||
192 | void Open_Dir() |
192 | void Open_Dir() |
193 | { |
193 | { |
194 | int j; |
194 | int j; |
195 | dword ext; |
195 | dword ext; |
196 | select_list.ClearList(); |
196 | select_list.ClearList(); |
197 | 197 | ||
198 | if (io.dir.buffer) free(io.dir.buffer); |
198 | if (io.dir.buffer) free(io.dir.buffer); |
199 | io.dir.load(#folder_path,DIR_ONLYREAL); |
199 | io.dir.load(#folder_path,DIR_ONLYREAL); |
200 | 200 | ||
201 | if (fmas) free(fmas); |
201 | if (fmas) free(fmas); |
202 | fmas = malloc(io.dir.count * 4); |
202 | fmas = malloc(io.dir.count * 4); |
203 | 203 | ||
204 | for (j=0; j |
204 | for (j=0; j |
205 | { |
205 | { |
206 | strncpy(#param, io.dir.position(j), PATHLEN); |
206 | strncpy(#param, io.dir.position(j), PATHLEN); |
207 | strlwr(#param); |
207 | strlwr(#param); |
208 | ext = #param + strrchr(#param,'.'); |
208 | ext = #param + strrchr(#param,'.'); |
209 | if (tabs.active_tab==TAB_SKINS) { |
209 | if (tabs.active_tab==TAB_SKINS) { |
210 | if (!streq(ext,"skn")) continue; |
210 | if (!streq(ext,"skn")) continue; |
211 | } |
211 | } |
212 | if (tabs.active_tab==TAB_WALLPAPERS) { |
212 | if (tabs.active_tab==TAB_WALLPAPERS) { |
213 | if (!streq(ext,"png")) && (!streq(ext,"jpg")) |
213 | if (!streq(ext,"png")) && (!streq(ext,"jpg")) |
214 | && (!streq(ext,"jpeg")) && (!streq(ext,"bmp")) |
214 | && (!streq(ext,"jpeg")) && (!streq(ext,"bmp")) |
215 | && (!streq(ext,"gif")) continue; |
215 | && (!streq(ext,"gif")) continue; |
216 | } |
216 | } |
217 | ESDWORD[select_list.count*4 + fmas] = j; |
217 | ESDWORD[select_list.count*4 + fmas] = j; |
218 | select_list.count++; |
218 | select_list.count++; |
219 | } |
219 | } |
220 | sort_by_name(0, select_list.count-1); |
220 | sort_by_name(0, select_list.count-1); |
221 | 221 | ||
222 | list.drop(); |
222 | list.drop(); |
223 | //save current item for tab change |
223 | //save current item for tab change |
224 | //add default item |
224 | //add default item |
225 | if(tabs.active_tab == TAB_SKINS) |
225 | if(tabs.active_tab == TAB_SKINS) |
226 | { |
226 | { |
227 | select_list.count++; |
227 | select_list.count++; |
228 | list.add(#default_skin); |
228 | list.add(#default_skin); |
229 | add_filesnames_into_the_list(); |
229 | add_filesnames_into_the_list(); |
230 | if (active_skin==-1) && (ESBYTE[#previous_skin]) |
230 | if (active_skin==-1) && (ESBYTE[#previous_skin]) |
231 | { |
231 | { |
232 | for (j=0; j |
232 | for (j=0; j |
233 | if (streq(list.get(j), #previous_skin)) { |
233 | if (streq(list.get(j), #previous_skin)) { |
234 | active_skin = j; |
234 | active_skin = j; |
235 | break; |
235 | break; |
236 | } |
236 | } |
237 | } |
237 | } |
238 | } |
238 | } |
239 | select_list.cur_y = active_skin; |
239 | select_list.cur_y = active_skin; |
240 | } else { |
240 | } else { |
241 | select_list.count++; |
241 | select_list.count++; |
242 | list.add(#default_wallp); |
242 | list.add(#default_wallp); |
243 | add_filesnames_into_the_list(); |
243 | add_filesnames_into_the_list(); |
244 | if (active_wallpaper==-1) && (ESBYTE[#previous_wallp]=='\\') |
244 | if (active_wallpaper==-1) && (ESBYTE[#previous_wallp]=='\\') |
245 | { |
245 | { |
246 | for (j=0; j |
246 | for (j=0; j |
247 | if (streq(list.get(j), #previous_wallp+4)) { |
247 | if (streq(list.get(j), #previous_wallp+4)) { |
248 | active_wallpaper = j; |
248 | active_wallpaper = j; |
249 | break; |
249 | break; |
250 | } |
250 | } |
251 | } |
251 | } |
252 | } |
252 | } |
253 | select_list.cur_y = active_wallpaper; |
253 | select_list.cur_y = active_wallpaper; |
254 | } |
254 | } |
255 | 255 | ||
256 | if (!select_list.count) notify(T_NO_FILES); |
256 | if (!select_list.count) notify(T_NO_FILES); |
257 | if (select_list.cur_y>SL_VISIBLE) { |
257 | if (select_list.cur_y>SL_VISIBLE) { |
258 | select_list.first = -SL_VISIBLE/2 + select_list.cur_y; |
258 | select_list.first = -SL_VISIBLE/2 + select_list.cur_y; |
259 | } |
259 | } |
260 | select_list.CheckDoesValuesOkey(); |
260 | select_list.CheckDoesValuesOkey(); |
261 | if (LIST_W) draw_window(); |
261 | if (LIST_W) draw_window(); |
262 | } |
262 | } |
263 | 263 | ||
264 | void SelectList_DrawLine(dword i) |
264 | void SelectList_DrawLine(dword i) |
265 | { |
265 | { |
266 | int draw_y = i*SELECT_LIST_ITEMH+PANEL_H; |
266 | int draw_y = i*SELECT_LIST_ITEMH+PANEL_H; |
267 | int i_abs = select_list.first + i; |
267 | int i_abs = select_list.first + i; |
268 | dword text_color = 0xFFFfff; |
268 | dword text_color = 0xFFFfff; |
269 | dword bg_color = 0x000000; |
269 | dword bg_color = 0x000000; |
270 | char filename_buf[PATHLEN]; |
270 | char filename_buf[PATHLEN]; |
271 | char* filename = #filename_buf; |
271 | char* filename = #filename_buf; |
272 | 272 | ||
273 | strcpy(filename, list.get(i_abs)); |
273 | strcpy(filename, list.get(i_abs)); |
274 | if (EAX = strrchr(filename,'/')) filename += EAX; |
274 | if (EAX = strrchr(filename,'/')) filename += EAX; |
275 | if (ESBYTE[filename]=='T') && (ESBYTE[filename+1]=='_') filename+=2; |
275 | if (ESBYTE[filename]=='T') && (ESBYTE[filename+1]=='_') filename+=2; |
276 | EAX = math.min(strrchr(filename,'.')-1, LIST_W - 24 / 8); |
276 | EAX = math.min(strrchr(filename,'.')-1, LIST_W - 24 / 8); |
277 | if(EAX) ESBYTE[filename+EAX] = '\0'; |
277 | if(EAX) ESBYTE[filename+EAX] = '\0'; |
278 | 278 | ||
279 | //save current item for tab change |
279 | //save current item for tab change |
280 | switch(tabs.active_tab) { |
280 | switch(tabs.active_tab) { |
281 | CASE TAB_SKINS: |
281 | CASE TAB_SKINS: |
282 | active_skin = select_list.cur_y; |
282 | active_skin = select_list.cur_y; |
283 | if (!i_abs) filename = T_DEFAULT; |
283 | if (!i_abs) filename = T_DEFAULT; |
284 | BREAK; |
284 | BREAK; |
285 | CASE TAB_WALLPAPERS: |
285 | CASE TAB_WALLPAPERS: |
286 | active_wallpaper = select_list.cur_y; |
286 | active_wallpaper = select_list.cur_y; |
287 | if (!i_abs) filename = T_DEFAULT; |
287 | if (!i_abs) filename = T_DEFAULT; |
288 | BREAK; |
288 | BREAK; |
289 | CASE TAB_SCREENSAVERS: |
289 | CASE TAB_SCREENSAVERS: |
290 | active_screensaver = select_list.cur_y; |
290 | active_screensaver = select_list.cur_y; |
291 | if (!i_abs) filename = T_NO_SS; |
291 | if (!i_abs) filename = T_NO_SS; |
292 | } |
292 | } |
293 | 293 | ||
294 | if (select_list.cur_y == i_abs) { |
294 | if (select_list.cur_y == i_abs) { |
295 | text_color = sc.button; |
295 | text_color = sc.button; |
296 | bg_color = sc.button_text; |
296 | bg_color = sc.button_text; |
297 | } |
297 | } |
298 | DrawBar(select_list.x, draw_y, LIST_W, SELECT_LIST_ITEMH, text_color); |
298 | DrawBar(select_list.x, draw_y, LIST_W, SELECT_LIST_ITEMH, text_color); |
299 | WriteText(select_list.x+12,draw_y+select_list.text_y,select_list.font_type,bg_color, filename); |
299 | WriteText(select_list.x+12,draw_y+select_list.text_y,select_list.font_type,bg_color, filename); |
300 | } |
300 | } |
301 | 301 | ||
302 | 302 | ||
303 | 303 | ||
304 | void GetIniSettings() |
304 | void GetIniSettings() |
305 | { |
305 | { |
306 | ini.section = "style"; |
306 | ini.section = "style"; |
307 | ini.GetString("default_skin", #default_skin, PATHLEN, 0); |
307 | ini.GetString("default_skin", #default_skin, PATHLEN, 0); |
308 | ini.GetString("default_wallp", #default_wallp, PATHLEN, 0); |
308 | ini.GetString("default_wallp", #default_wallp, PATHLEN, 0); |
309 | ini.GetString("skin", #previous_skin, PATHLEN, 0); |
309 | ini.GetString("skin", #previous_skin, PATHLEN, 0); |
310 | ini.GetString("bg_param", #previous_wallp, PATHLEN, 0); |
310 | ini.GetString("bg_param", #previous_wallp, PATHLEN, 0); |
311 | 311 | ||
312 | ini.section = "screensaver"; |
312 | ini.section = "screensaver"; |
313 | ss_timeout.position = ini.GetInt("timeout", 10) - 1; |
313 | ss_timeout.position = ini.GetInt("timeout", 10) - 1; |
314 | ini.GetString("available", #ss_available, sizeof(ss_available), 0); |
314 | ini.GetString("available", #ss_available, sizeof(ss_available), 0); |
315 | ini.GetString("program", #previous_ss, PATHLEN, 0); |
315 | ini.GetString("program", #previous_ss, PATHLEN, 0); |
316 | } |
316 | } |
317 | 317 | ||
318 | //===================================================// |
318 | //===================================================// |
319 | // // |
319 | // // |
320 | // EVENTS // |
320 | // EVENTS // |
321 | // // |
321 | // // |
322 | //===================================================// |
322 | //===================================================// |
323 | 323 | ||
324 | void EventTabSkinsClick() |
324 | void EventTabSkinsClick() |
325 | { |
325 | { |
326 | miniprintf(#folder_path, "%s/res/skins", get_real_kolibrios_path()); |
326 | miniprintf(#folder_path, "%s/res/skins", get_real_kolibrios_path()); |
327 | Open_Dir(); |
327 | Open_Dir(); |
328 | } |
328 | } |
329 | 329 | ||
330 | void EventTabWallpappersClick() |
330 | void EventTabWallpappersClick() |
331 | { |
331 | { |
332 | if (opendir_path) { |
332 | if (opendir_path) { |
333 | strcpy(#folder_path, #opendir_path); |
333 | strcpy(#folder_path, #opendir_path); |
334 | } else { |
334 | } else { |
335 | miniprintf(#folder_path, "%s/res/wallpapers", get_real_kolibrios_path()); |
335 | miniprintf(#folder_path, "%s/res/wallpapers", get_real_kolibrios_path()); |
336 | } |
336 | } |
337 | Open_Dir(); |
337 | Open_Dir(); |
338 | } |
338 | } |
339 | 339 | ||
340 | void EventTabScreensaverClick() |
340 | void EventTabScreensaverClick() |
341 | { |
341 | { |
342 | dword j; |
342 | dword j; |
343 | char ssmas[sizeof(ss_available)]; |
343 | char ssmas[sizeof(ss_available)]; |
344 | list.drop(); |
344 | list.drop(); |
345 | select_list.ClearList(); |
345 | select_list.ClearList(); |
346 | 346 | ||
347 | select_list.count++; |
347 | select_list.count++; |
348 | list.add(""); |
348 | list.add(""); |
349 | 349 | ||
350 | strcpy(#ssmas, #ss_available); |
350 | strcpy(#ssmas, #ss_available); |
351 | do { |
351 | do { |
352 | j = strrchr(#ssmas, '|'); |
352 | j = strrchr(#ssmas, '|'); |
353 | if (ssmas[j]=='/') { |
353 | if (ssmas[j]=='/') { |
354 | strcpy(#param, #ssmas + j); |
354 | strcpy(#param, #ssmas + j); |
355 | } else { |
355 | } else { |
356 | miniprintf(#param, "/sys/%s", #ssmas + j); |
356 | miniprintf(#param, "/sys/%s", #ssmas + j); |
357 | } |
357 | } |
358 | list.add(#param); |
358 | list.add(#param); |
359 | ESBYTE[#ssmas + j - 1] = '\0'; |
359 | ESBYTE[#ssmas + j - 1] = '\0'; |
360 | select_list.count++; |
360 | select_list.count++; |
361 | } while (j); |
361 | } while (j); |
362 | 362 | ||
363 | if (active_screensaver == -1) && (ESBYTE[#previous_ss]) { |
363 | if (active_screensaver == -1) && (ESBYTE[#previous_ss]) { |
364 | for (j=0; j |
364 | for (j=0; j |
365 | if (strstr(list.get(j), #previous_ss)) active_screensaver = j; |
365 | if (strstr(list.get(j), #previous_ss)) active_screensaver = j; |
366 | } |
366 | } |
367 | } |
367 | } |
368 | select_list.cur_y = active_screensaver; |
368 | select_list.cur_y = active_screensaver; |
369 | 369 | ||
370 | if (LIST_W) draw_window(); |
370 | if (LIST_W) draw_window(); |
371 | } |
371 | } |
372 | 372 | ||
373 | void EventDeleteFile() |
373 | void EventDeleteFile() |
374 | { |
374 | { |
375 | if (select_list.cur_y) DeleteFile(list.get(select_list.cur_y)); //no not delete default |
375 | if (select_list.cur_y) DeleteFile(list.get(select_list.cur_y)); //no not delete default |
376 | Open_Dir(); |
376 | Open_Dir(); |
377 | EventApply(); |
377 | EventApply(); |
378 | } |
378 | } |
379 | 379 | ||
380 | void EventSelectWallpFolder() |
380 | void EventSelectWallpFolder() |
381 | { |
381 | { |
382 | o_dialog.type = 2; //select folder |
382 | o_dialog.type = 2; //select folder |
383 | OpenDialog_start stdcall (#o_dialog); |
383 | OpenDialog_start stdcall (#o_dialog); |
384 | if (o_dialog.status) EventTabWallpappersClick(); |
384 | if (o_dialog.status) EventTabWallpappersClick(); |
385 | } |
385 | } |
386 | 386 | ||
387 | void EventSetWallpMode(dword _stretch, _titled, _auto) |
387 | void EventSetWallpMode(dword _stretch, _titled, _auto) |
388 | { |
388 | { |
389 | optionbox_stretch.checked = _stretch; |
389 | optionbox_stretch.checked = _stretch; |
390 | optionbox_tiled.checked = _titled; |
390 | optionbox_tiled.checked = _titled; |
391 | optionbox_auto.checked = _auto; |
391 | optionbox_auto.checked = _auto; |
392 | optionbox_tiled.redraw(); |
392 | optionbox_tiled.redraw(); |
393 | optionbox_stretch.redraw(); |
393 | optionbox_stretch.redraw(); |
394 | optionbox_auto.redraw(); |
394 | optionbox_auto.redraw(); |
395 | EventApply(); |
395 | EventApply(); |
396 | } |
396 | } |
397 | 397 | ||
398 | void EventApply() |
398 | void EventApply() |
399 | { |
399 | { |
400 | char kivparam[4096+10]; |
400 | char kivparam[4096+10]; |
401 | dword file_name = list.get(select_list.cur_y); |
401 | dword file_name = list.get(select_list.cur_y); |
402 | if (tabs.active_tab==TAB_SKINS) |
402 | if (tabs.active_tab==TAB_SKINS) |
403 | { |
403 | { |
404 | strcpy(#cur_skin_path, list.get(select_list.cur_y)); |
404 | strcpy(#cur_skin_path, list.get(select_list.cur_y)); |
405 | SetSystemSkin(#cur_skin_path); |
405 | SetSystemSkin(#cur_skin_path); |
406 | MoveSize(OLD, OLD, OLD, WIN_H+4+GetSkinHeight()); |
406 | MoveSize(OLD, OLD, OLD, WIN_H+4+GetSkinHeight()); |
407 | } |
407 | } |
408 | if (tabs.active_tab==TAB_WALLPAPERS) |
408 | if (tabs.active_tab==TAB_WALLPAPERS) |
409 | { |
409 | { |
410 | SelectList_Draw(); |
410 | SelectList_Draw(); |
411 | miniprintf(#kivparam, "\\S__%s", list.get(select_list.cur_y)); |
411 | miniprintf(#kivparam, "\\S__%s", list.get(select_list.cur_y)); |
412 | if (optionbox_tiled.checked) || (!select_list.cur_y) kivparam[1]='T'; |
412 | if (optionbox_tiled.checked) || (!select_list.cur_y) kivparam[1]='T'; |
413 | if (optionbox_auto.checked) { |
413 | if (optionbox_auto.checked) { |
414 | file_name += strrchr(file_name, '/'); |
414 | file_name += strrchr(file_name, '/'); |
415 | if (ESBYTE[file_name] == 'T') && (ESBYTE[file_name+1] == '_') { |
415 | if (ESBYTE[file_name] == 'T') && (ESBYTE[file_name+1] == '_') { |
416 | kivparam[1]='T'; |
416 | kivparam[1]='T'; |
417 | } |
417 | } |
418 | } |
418 | } |
419 | RunProgram("/sys/media/kiv", #kivparam); |
419 | RunProgram("/sys/media/kiv", #kivparam); |
420 | } |
420 | } |
421 | if (tabs.active_tab==TAB_SCREENSAVERS) |
421 | if (tabs.active_tab==TAB_SCREENSAVERS) |
422 | { |
422 | { |
423 | SelectList_Draw(); |
423 | SelectList_Draw(); |
424 | } |
424 | } |
425 | } |
425 | } |
426 | 426 | ||
427 | void EventOpenFile() |
427 | void EventOpenFile() |
428 | { |
428 | { |
429 | switch (tabs.active_tab) { |
429 | switch (tabs.active_tab) { |
- | 430 | case TAB_SKINS: |
|
430 | case TAB_SKINS: RunProgram("/sys/skincfg", list.get(select_list.cur_y)); break; |
431 | RunProgram("/sys/skincfg", list.get(select_list.cur_y)); |
- | 432 | break; |
|
- | 433 | case TAB_WALLPAPERS: |
|
431 | case TAB_WALLPAPERS: RunProgram("/sys/media/kiv", list.get(select_list.cur_y)); break; |
434 | RunProgram("/sys/media/kiv", list.get(select_list.cur_y)); |
- | 435 | break; |
|
- | 436 | case TAB_SCREENSAVERS: |
|
- | 437 | if(select_list.cur_y) { |
|
- | 438 | KillProcessByName("@ss", MULTIPLE); |
|
432 | case TAB_SCREENSAVERS: if(select_list.cur_y) RunProgram(list.get(select_list.cur_y), "@ss"); |
439 | RunProgram(list.get(select_list.cur_y), "@ss"); |
- | 440 | } |
|
433 | } |
441 | } |
434 | } |
442 | } |
435 | 443 | ||
436 | void EventExit() |
444 | void EventExit() |
437 | { |
445 | { |
438 | if (get_real_kolibrios_path()) && (ESBYTE[#cur_skin_path]) { |
446 | if (get_real_kolibrios_path()) && (ESBYTE[#cur_skin_path]) { |
439 | ini.section = "style"; |
447 | ini.section = "style"; |
440 | ini.SetString("skin", #cur_skin_path, strlen(#cur_skin_path)); |
448 | ini.SetString("skin", #cur_skin_path, strlen(#cur_skin_path)); |
441 | } |
449 | } |
442 | ExitProcess(); |
450 | ExitProcess(); |
443 | } |
451 | } |
444 | 452 | ||
445 | void EventSetSs() |
453 | void EventSetSs() |
446 | { |
454 | { |
447 | dword cur_ss = list.get(select_list.cur_y); |
455 | dword cur_ss = list.get(select_list.cur_y); |
448 | ini.section = "screensaver"; |
456 | ini.section = "screensaver"; |
449 | ini.SetString("program", cur_ss, strlen(cur_ss)); |
457 | ini.SetString("program", cur_ss, strlen(cur_ss)); |
450 | ini.SetInt("timeout", ss_timeout.position+1); |
458 | ini.SetInt("timeout", ss_timeout.position+1); |
451 | RestartProcessByName("/sys/@ss", MULTIPLE); |
459 | RestartProcessByName("/sys/@ss", MULTIPLE); |
452 | } |
460 | } |
453 | 461 | ||
454 | stop: |
462 | stop: |
455 | 463 | ||
456 | char folder_path[PATHLEN]; |
464 | char folder_path[PATHLEN]; |
457 | char cur_skin_path[PATHLEN]; |
465 | char cur_skin_path[PATHLEN]; |
458 | 466 | ||
459 | char default_skin[PATHLEN]; |
467 | char default_skin[PATHLEN]; |
460 | char default_wallp[PATHLEN]; |
468 | char default_wallp[PATHLEN]; |
461 | 469 | ||
462 | char previous_skin[PATHLEN]; |
470 | char previous_skin[PATHLEN]; |
463 | char previous_wallp[PATHLEN]; |
471 | char previous_wallp[PATHLEN]; |
464 | char previous_ss[PATHLEN]; |
472 | char previous_ss[PATHLEN]; |