Rev 7960 | Rev 8261 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4078 | leency | 1 | //11.03.12 - start! |
7594 | leency | 2 | //ver 2.3 |
4078 | leency | 3 | |
4085 | leency | 4 | #ifndef AUTOBUILD |
5 | ?include "lang.h--" |
||
6 | #endif |
||
7 | |||
7660 | leency | 8 | #define MEMSIZE 200*1024 |
7909 | leency | 9 | #include "../lib/mem.h" |
10 | #include "../lib/strings.h" |
||
11 | #include "../lib/io.h" |
||
12 | #include "../lib/list_box.h" |
||
13 | #include "../lib/obj/libimg.h" |
||
14 | #include "../lib/gui.h" |
||
7353 | leency | 15 | |
7909 | leency | 16 | #include "../lib/obj/box_lib.h" |
17 | #include "../lib/obj/proc_lib.h" |
||
18 | #include "../lib/obj/libini.h" |
||
7353 | leency | 19 | |
7909 | leency | 20 | #include "../lib/patterns/select_list.h" |
21 | #include "../lib/patterns/simple_open_dialog.h" |
||
4078 | leency | 22 | |
7614 | leency | 23 | #include "ui_elements_preview.h" |
24 | |||
6212 | leency | 25 | //===================================================// |
26 | // // |
||
27 | // DATA // |
||
28 | // // |
||
29 | //===================================================// |
||
30 | |||
4085 | leency | 31 | #ifdef LANG_RUS |
6212 | leency | 32 | ?define WINDOW_HEADER "Настройки оформления" |
7909 | leency | 33 | ?define T_SKINS " Стиль окон" |
34 | ?define T_WALLPAPERS " Обои" |
||
7353 | leency | 35 | ?define T_SELECT_FOLDER "Выбрать папку" |
7778 | leency | 36 | ?define MENU_LIST "Открыть файл |Enter\nУдалить файл |Del" |
7611 | leency | 37 | ?define T_PICTURE_MODE " Положение картинки " |
38 | ?define T_CHECKBOX_STRETCH "Растянуть" |
||
39 | ?define T_CHECKBOX_TILED "Замостить" |
||
7612 | leency | 40 | ?define T_UPDATE_DOCK "Обновлять Dock-панель" |
4085 | leency | 41 | #else |
42 | ?define WINDOW_HEADER "Appearance" |
||
7909 | leency | 43 | ?define T_SKINS " Skins" |
44 | ?define T_WALLPAPERS " Wallpapers" |
||
7611 | leency | 45 | ?define T_SELECT_FOLDER "Select folder" |
7778 | leency | 46 | ?define MENU_LIST "Open file |Enter\nDelete file |Del" |
7611 | leency | 47 | ?define T_PICTURE_MODE " Picture Mode " |
48 | ?define T_CHECKBOX_STRETCH "Stretch" |
||
49 | ?define T_CHECKBOX_TILED "Tiled" |
||
7612 | leency | 50 | ?define T_UPDATE_DOCK "Update Dock" |
4085 | leency | 51 | #endif |
4078 | leency | 52 | |
6212 | leency | 53 | #define PANEL_H 40 |
7225 | leency | 54 | #define LP 10 //LIST_PADDING |
7594 | leency | 55 | char skins_folder_path[4096]; |
56 | char wallp_folder_path[4096]; |
||
4078 | leency | 57 | |
6264 | leency | 58 | signed int active_skin=-1, active_wallpaper=-1; |
7353 | leency | 59 | enum { |
7909 | leency | 60 | BASE_TAB_BUTTON_ID=2, |
61 | BTN_SELECT_WALLP_FOLDER=10 }; |
||
4078 | leency | 62 | |
63 | char folder_path[4096]; |
||
64 | char cur_file_path[4096]; |
||
7551 | leency | 65 | char cur_skin_path[4096]; |
4078 | leency | 66 | char temp_filename[4096]; |
6096 | leency | 67 | int files_mas[400]; |
4078 | leency | 68 | |
69 | int cur; |
||
70 | |||
71 | proc_info Form; |
||
7244 | leency | 72 | block skp; |
4078 | leency | 73 | |
7909 | leency | 74 | enum {SKINS, WALLPAPERS}; |
7225 | leency | 75 | |
7909 | leency | 76 | _tabs tabs = { LP, LP, NULL, BASE_TAB_BUTTON_ID }; |
77 | |||
7612 | leency | 78 | checkbox update_docky = { T_UPDATE_DOCK, false }; |
7244 | leency | 79 | |
7353 | leency | 80 | char default_dir[] = "/rd/1"; |
81 | od_filter filter2 = { 8, "TXT\0\0" }; |
||
82 | |||
7611 | leency | 83 | checkbox optionbox_stretch = { T_CHECKBOX_STRETCH, true }; |
84 | checkbox optionbox_tiled = { T_CHECKBOX_TILED, false }; |
||
85 | |||
6212 | leency | 86 | //===================================================// |
87 | // // |
||
88 | // CODE // |
||
89 | // // |
||
90 | //===================================================// |
||
5548 | leency | 91 | |
7594 | leency | 92 | void GetRealFolderPathes() |
93 | { |
||
94 | char real_skin_path[4096]; |
||
95 | SetCurDir("/kolibrios"); |
||
96 | GetCurDir(#real_skin_path, sizeof(real_skin_path)); |
||
97 | sprintf(#skins_folder_path, "%s/res/skins", #real_skin_path); |
||
98 | sprintf(#wallp_folder_path, "%s/res/wallpapers", #real_skin_path); |
||
99 | } |
||
100 | |||
4078 | leency | 101 | void main() |
102 | { |
||
7909 | leency | 103 | int id; |
4078 | leency | 104 | |
7594 | leency | 105 | GetRealFolderPathes(); |
106 | |||
5626 | leency | 107 | load_dll(boxlib, #box_lib_init,0); |
7533 | leency | 108 | load_dll(libini, #lib_init,1); |
7909 | leency | 109 | load_dll(libio, #libio_init,1); |
110 | load_dll(libimg, #libimg_init,1); |
||
7353 | leency | 111 | load_dll(Proc_lib, #OpenDialog_init,0); |
112 | o_dialog.type = 2; //select folder |
||
113 | OpenDialog_init stdcall (#o_dialog); |
||
114 | |||
7909 | leency | 115 | tabs.add(T_SKINS, #EventTabSkinsClick); |
116 | tabs.add(T_WALLPAPERS, #EventTabWallpappersClick); |
||
117 | tabs.draw_active_tab(); |
||
7353 | leency | 118 | |
7551 | leency | 119 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
6096 | leency | 120 | loop() switch(WaitEvent()) |
4078 | leency | 121 | { |
122 | case evMouse: |
||
6653 | leency | 123 | SelectList_ProcessMouse(); |
4410 | leency | 124 | |
7353 | leency | 125 | if (tabs.active_tab == SKINS) { |
126 | edit_box_mouse stdcall (#edit_cmm); |
||
127 | edit_box_mouse stdcall (#edit_st); |
||
128 | } |
||
129 | |||
7778 | leency | 130 | if (mouse.key&MOUSE_RIGHT) && (mouse.up) |
131 | &&(select_list.MouseOver(mouse.x, mouse.y)) { |
||
6651 | leency | 132 | select_list.ProcessMouse(mouse.x, mouse.y); |
6653 | leency | 133 | SelectList_Draw(); |
7353 | leency | 134 | EventSetNewCurrent(); |
8020 | leency | 135 | open_lmenu(mouse.x, mouse.y, MENU_TOP_RIGHT, NULL, MENU_LIST); |
6212 | leency | 136 | } |
4078 | leency | 137 | break; |
138 | |||
139 | case evButton: |
||
140 | id=GetButtonID(); |
||
7551 | leency | 141 | if (id==1) EventExit(); |
7353 | leency | 142 | if (id==BTN_SELECT_WALLP_FOLDER) EventSelectWallpFolder(); |
7909 | leency | 143 | tabs.click(id); |
7244 | leency | 144 | checkbox1.click(id); |
7252 | leency | 145 | spinbox1.click(id); |
7612 | leency | 146 | if (update_docky.click(id)) EventUpdateDocky(); |
7611 | leency | 147 | if (!optionbox_stretch.checked) && (optionbox_stretch.click(id)) EventSetWallpMode_Stretch(); |
148 | if (!optionbox_tiled.checked) && (optionbox_tiled.click(id)) EventSetWallpMode_Tiled(); |
||
4078 | leency | 149 | break; |
150 | |||
151 | case evKey: |
||
5706 | leency | 152 | GetKeys(); |
6651 | leency | 153 | if (select_list.ProcessKey(key_scancode)) EventApply(); |
6212 | leency | 154 | if (key_scancode==SCAN_CODE_ENTER) EventOpenFile(); |
7909 | leency | 155 | if (key_scancode==SCAN_CODE_TAB) tabs.click(tabs.active_tab ^ 1); |
6212 | leency | 156 | if (key_scancode==SCAN_CODE_DEL) EventDeleteFile(); |
7349 | leency | 157 | |
7506 | leency | 158 | if (! edit_cmm.flags & ed_focus) && (! edit_st.flags & ed_focus) |
6651 | leency | 159 | for (id=select_list.cur_y+1; id |
4078 | leency | 160 | { |
6212 | leency | 161 | strcpy(#temp_filename, io.dir.position(files_mas[id])); |
162 | if (temp_filename[0]==key_ascii) || (temp_filename[0]==key_ascii-32) |
||
163 | { |
||
6651 | leency | 164 | select_list.cur_y = id - 1; |
165 | select_list.KeyDown(); |
||
6212 | leency | 166 | EventApply(); |
167 | break; |
||
168 | } |
||
4078 | leency | 169 | } |
7349 | leency | 170 | |
7353 | leency | 171 | if (tabs.active_tab == SKINS) { |
172 | EAX = key_ascii << 8; |
||
173 | edit_box_key stdcall (#edit_cmm); |
||
174 | edit_box_key stdcall (#edit_st); |
||
175 | } |
||
4078 | leency | 176 | break; |
177 | |||
7353 | leency | 178 | case evReDraw: |
179 | draw_window(); |
||
7778 | leency | 180 | EventHandleMenuClick(); |
4078 | leency | 181 | } |
182 | } |
||
183 | |||
7353 | leency | 184 | void draw_window() |
185 | { |
||
7909 | leency | 186 | sc.get(); |
7806 | leency | 187 | DefineAndDrawWindow(screen.width-600/2,80,630,504+skin_height,0x34,sc.work,WINDOW_HEADER,0); |
7353 | leency | 188 | GetProcessInfo(#Form, SelfInfo); |
189 | IF (Form.status_window>=2) return; |
||
190 | DrawWindowContent(); |
||
191 | } |
||
7244 | leency | 192 | |
6212 | leency | 193 | void DrawWindowContent() |
194 | { |
||
195 | int id; |
||
7353 | leency | 196 | int list_w; |
7225 | leency | 197 | |
7806 | leency | 198 | sc.get(); |
7612 | leency | 199 | |
7611 | leency | 200 | if (tabs.active_tab == SKINS) list_w=250; else list_w=350; |
7353 | leency | 201 | |
7225 | leency | 202 | tabs.w = Form.cwidth-LP-LP; |
7909 | leency | 203 | tabs.draw(); |
204 | DrawIcon16(tabs.x + TAB_PADDING, 15, sc.work, 17); |
||
205 | DrawIcon16(strlen(T_SKINS)*8 + tabs.x + TAB_PADDING + TAB_PADDING, 15, sc.work, 6); |
||
7225 | leency | 206 | |
6651 | leency | 207 | id = select_list.cur_y; |
6653 | leency | 208 | SelectList_Init( |
7225 | leency | 209 | tabs.x+TAB_PADDING, |
210 | tabs.y+TAB_HEIGHT+TAB_PADDING, |
||
7353 | leency | 211 | list_w, |
7909 | leency | 212 | Form.cheight-LP-LP - TAB_PADDING - TAB_PADDING - TAB_HEIGHT, |
6653 | leency | 213 | false |
214 | ); |
||
6651 | leency | 215 | select_list.cur_y = id; |
7244 | leency | 216 | |
217 | skp.set_size( |
||
7252 | leency | 218 | select_list.x + select_list.w + TAB_PADDING + scroll1.size_x + 20, |
7612 | leency | 219 | select_list.y + 30 + 50, |
7353 | leency | 220 | list_w, |
7612 | leency | 221 | 230 //select_list.h - 50 - 50 |
7244 | leency | 222 | ); |
223 | |||
6653 | leency | 224 | SelectList_Draw(); |
6662 | leency | 225 | SelectList_DrawBorder(); |
7806 | leency | 226 | //DrawWideRectangle(0, 0, Form.cwidth, Form.cheight, LP, sc.work); |
7244 | leency | 227 | |
228 | if (tabs.active_tab == SKINS) |
||
229 | { |
||
7612 | leency | 230 | update_docky.draw(skp.x, select_list.y+15); |
7244 | leency | 231 | DrawFrame(skp.x, skp.y, skp.w, skp.h, " Components Preview "); |
7614 | leency | 232 | DrawUiElementsPreview(skp.x+20, skp.y, skp.h); |
7244 | leency | 233 | } |
7353 | leency | 234 | if (tabs.active_tab == WALLPAPERS) |
235 | { |
||
7611 | leency | 236 | skp.x -= TAB_PADDING + 3; |
237 | DrawStandartCaptButton(skp.x, select_list.y, BTN_SELECT_WALLP_FOLDER, T_SELECT_FOLDER); |
||
238 | DrawFrame(skp.x, select_list.y+50, 180, 80, T_PICTURE_MODE); |
||
239 | optionbox_stretch.draw(skp.x+14, select_list.y+70); |
||
240 | optionbox_tiled.draw(skp.x+14, select_list.y+97); |
||
7353 | leency | 241 | } |
6212 | leency | 242 | } |
243 | |||
4410 | leency | 244 | |
6212 | leency | 245 | void Open_Dir() |
4078 | leency | 246 | { |
6212 | leency | 247 | int j; |
6651 | leency | 248 | select_list.count = 0; |
6212 | leency | 249 | if(io.dir.buffer)free(io.dir.buffer); |
250 | io.dir.load(#folder_path,DIR_ONLYREAL); |
||
251 | for (j=0; j |
||
4410 | leency | 252 | { |
6212 | leency | 253 | strcpy(#temp_filename, io.dir.position(j)); |
254 | strlwr(#temp_filename); |
||
7353 | leency | 255 | if (tabs.active_tab==SKINS) { |
256 | if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue; |
||
257 | } |
||
258 | if (tabs.active_tab==WALLPAPERS) { |
||
259 | if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".png")!=0) |
||
260 | && (strcmpi(#temp_filename+strlen(#temp_filename)-4,".jpg")!=0) |
||
261 | && (strcmpi(#temp_filename+strlen(#temp_filename)-5,".jpeg")!=0) |
||
262 | && (strcmpi(#temp_filename+strlen(#temp_filename)-4,".gif")!=0) continue; |
||
263 | } |
||
6651 | leency | 264 | cur = select_list.count; |
6212 | leency | 265 | files_mas[cur]=j; |
6651 | leency | 266 | if (!strcmpi("default.skn",#temp_filename)) files_mas[0]> |
267 | select_list.count++; |
||
4410 | leency | 268 | } |
6212 | leency | 269 | } |
270 | |||
6653 | leency | 271 | void SelectList_DrawLine(dword i) |
6212 | leency | 272 | { |
6651 | leency | 273 | int yyy, list_last; |
6212 | leency | 274 | |
6651 | leency | 275 | cur = select_list.first + i; |
276 | strcpy(#temp_filename, io.dir.position(files_mas[cur])); |
||
277 | temp_filename[strlen(#temp_filename)-4] = 0; |
||
278 | yyy = i*select_list.item_h+select_list.y; |
||
279 | |||
280 | if (select_list.cur_y-select_list.first==i) |
||
4410 | leency | 281 | { |
7806 | leency | 282 | DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, sc.button); |
283 | WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,sc.button_text, #temp_filename); |
||
4410 | leency | 284 | } |
6651 | leency | 285 | else |
286 | { |
||
287 | DrawBar(select_list.x,yyy,select_list.w, select_list.item_h, 0xFFFfff); |
||
288 | WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,0, #temp_filename); |
||
289 | } |
||
4078 | leency | 290 | } |
291 | |||
6653 | leency | 292 | void SelectList_LineChanged() |
293 | { |
||
294 | EventApply(); |
||
295 | } |
||
296 | |||
7960 | leency | 297 | void ActivateTab(int _id) |
298 | { |
||
299 | select_list.ClearList(); |
||
300 | Open_Dir(); |
||
301 | if (!select_list.count) notify("'No files were found' -E"); |
||
302 | select_list.cur_y = _id; |
||
303 | if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; |
||
304 | select_list.CheckDoesValuesOkey(); |
||
305 | if (select_list.w) draw_window(); |
||
306 | } |
||
307 | |||
6212 | leency | 308 | //===================================================// |
309 | // // |
||
310 | // EVENTS // |
||
311 | // // |
||
312 | //===================================================// |
||
4078 | leency | 313 | |
7909 | leency | 314 | void EventTabSkinsClick() |
4085 | leency | 315 | { |
7909 | leency | 316 | active_wallpaper = select_list.cur_y; |
317 | strcpy(#folder_path, #skins_folder_path); |
||
7960 | leency | 318 | ActivateTab(active_skin); |
6212 | leency | 319 | } |
4078 | leency | 320 | |
7909 | leency | 321 | void EventTabWallpappersClick() |
322 | { |
||
323 | active_skin = select_list.cur_y; |
||
324 | strcpy(#folder_path, #wallp_folder_path); |
||
7960 | leency | 325 | ActivateTab(active_wallpaper); |
7909 | leency | 326 | } |
327 | |||
6212 | leency | 328 | void EventDeleteFile() |
329 | { |
||
330 | io.del(#cur_file_path); |
||
331 | Open_Dir(); |
||
332 | EventApply(); |
||
333 | } |
||
4078 | leency | 334 | |
7353 | leency | 335 | void EventSetNewCurrent() |
336 | { |
||
337 | cur = select_list.cur_y; |
||
338 | sprintf(#cur_file_path,"%s/%s",#folder_path,io.dir.position(files_mas[cur])); |
||
339 | } |
||
340 | |||
341 | void EventSelectWallpFolder() |
||
342 | { |
||
343 | OpenDialog_start stdcall (#o_dialog); |
||
344 | if (o_dialog.status) { |
||
345 | strcpy(#wallp_folder_path, #opendir_path); |
||
7909 | leency | 346 | EventTabWallpappersClick(); |
7353 | leency | 347 | } |
348 | } |
||
349 | |||
7611 | leency | 350 | void EventSetWallpMode_Stretch() |
351 | { |
||
352 | optionbox_tiled.checked = false; |
||
353 | optionbox_tiled.redraw(); |
||
354 | EventApply(); |
||
355 | } |
||
356 | |||
357 | void EventSetWallpMode_Tiled() |
||
358 | { |
||
359 | optionbox_stretch.checked = false; |
||
360 | optionbox_stretch.redraw(); |
||
361 | EventApply(); |
||
362 | } |
||
363 | |||
7612 | leency | 364 | #include "..\lib\patterns\restart_process.h" |
6212 | leency | 365 | void EventApply() |
366 | { |
||
7353 | leency | 367 | char kivpath[4096+10]; |
368 | EventSetNewCurrent(); |
||
6264 | leency | 369 | if (tabs.active_tab==SKINS) |
6212 | leency | 370 | { |
6651 | leency | 371 | cur = select_list.cur_y; |
6212 | leency | 372 | SetSystemSkin(#cur_file_path); |
7612 | leency | 373 | SelectList_Draw(); |
7551 | leency | 374 | strcpy(#cur_skin_path, #cur_file_path); |
7612 | leency | 375 | EventUpdateDocky(); |
6212 | leency | 376 | } |
6264 | leency | 377 | if (tabs.active_tab==WALLPAPERS) |
6212 | leency | 378 | { |
7551 | leency | 379 | SelectList_Draw(); |
7611 | leency | 380 | if (optionbox_stretch.checked) strcpy(#kivpath, "\\S__"); |
381 | if (optionbox_tiled.checked) strcpy(#kivpath, "\\T__"); |
||
7353 | leency | 382 | strcat(#kivpath, #cur_file_path); |
383 | RunProgram("/sys/media/kiv", #kivpath); |
||
6212 | leency | 384 | } |
385 | } |
||
4085 | leency | 386 | |
7612 | leency | 387 | void EventUpdateDocky() |
388 | { |
||
389 | if (!update_docky.checked) return; |
||
390 | KillProcessByName("@docky", MULTIPLE); |
||
391 | RunProgram("/sys/@docky",NULL); |
||
392 | pause(50); |
||
393 | ActivateWindow(GetProcessSlot(Form.ID)); |
||
394 | } |
||
395 | |||
6212 | leency | 396 | void EventOpenFile() |
397 | { |
||
6264 | leency | 398 | if (tabs.active_tab==SKINS) RunProgram("/sys/skincfg", #cur_file_path); |
399 | if (tabs.active_tab==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path); |
||
4085 | leency | 400 | } |
401 | |||
7870 | leency | 402 | _ini ini = { "/sys/settings/system.ini", "style" }; |
7551 | leency | 403 | void EventExit() |
404 | { |
||
7613 | leency | 405 | if (cur_skin_path) ini.SetString("skin", #cur_skin_path, strlen(#cur_skin_path)); |
7551 | leency | 406 | ExitProcess(); |
407 | } |
||
408 | |||
7778 | leency | 409 | void EventHandleMenuClick() |
410 | { |
||
411 | switch (get_menu_click()) |
||
412 | { |
||
413 | case 1: |
||
414 | EventOpenFile(); |
||
415 | break; |
||
416 | case 2: |
||
417 | EventDeleteFile(); |
||
418 | break; |
||
419 | }; |
||
420 | } |
||
421 | |||
4078 | leency | 422 | stop: |