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