Subversion Repositories Kolibri OS

Rev

Rev 9489 | Rev 9524 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9489 Rev 9516
Line 1... Line 1...
1
//11.03.12 - start!
1
//11.03.12 - start!
2
//ver 2.31
2
//TODO: select current value at startap
Line 3... Line 3...
3
 
3
 
4
#define MEMSIZE 1024*70
4
#define MEMSIZE 1024*70
5
#include "../lib/mem.h"
5
#include "../lib/mem.h"
6
#include "../lib/strings.h"
6
#include "../lib/strings.h"
Line 25... Line 25...
25
//                                                   //
25
//                                                   //
26
//===================================================//
26
//===================================================//
Line 27... Line 27...
27
 
27
 
Line 28... Line -...
28
int active_skin, active_wallpaper, active_screensaver;
-
 
29
 
-
 
30
char folder_path[4096];
-
 
31
char cur_file_path[4096];
-
 
32
char cur_skin_path[4096];
-
 
33
char default_skin[4096];
-
 
34
char default_wallp[4096];
-
 
35
char ss_available[200];
-
 
36
 
-
 
37
int screensaver_timeout;
-
 
38
 
-
 
39
_tabs tabs = { -sizeof(t_skins)-sizeof(t_wallpapers)-sizeof(t_screensaver)-3*8+WIN_W
-
 
40
	 - TAB_PADDING / 2, LP, NULL, BASE_TAB_BUTTON_ID };
28
int active_skin, active_wallpaper, active_screensaver;
41
 
-
 
Line 42... Line 29...
42
checkbox update_docky = { T_UPDATE_DOCK, false };
29
 
43
checkbox ss_in_on = { T_UPDATE_DOCK, false };
30
checkbox update_docky = { T_UPDATE_DOCK, false };
44
 
31
 
Line -... Line 32...
-
 
32
checkbox optionbox_stretch = { T_CHECKBOX_STRETCH, false };
-
 
33
checkbox optionbox_tiled = { T_CHECKBOX_TILED, false };
45
checkbox optionbox_stretch = { T_CHECKBOX_STRETCH, false };
34
checkbox optionbox_auto = { T_CHECKBOX_AUTO, true };
Line 46... Line 35...
46
checkbox optionbox_tiled = { T_CHECKBOX_TILED, false };
35
 
47
checkbox optionbox_auto = { T_CHECKBOX_AUTO, true };
36
char ss_available[200];
48
 
37
 
Line 58... Line 47...
58
{   
47
{   
59
	int id, i;
48
	int id, i;
60
	load_dll(boxlib, #box_lib_init,0);
49
	load_dll(boxlib, #box_lib_init,0);
61
	load_dll(libini, #lib_init,1);
50
	load_dll(libini, #lib_init,1);
62
	load_dll(Proc_lib, #OpenDialog_init,0);
51
	load_dll(Proc_lib, #OpenDialog_init,0);
63
	o_dialog.type = 2; //select folder
-
 
64
	OpenDialog_init stdcall (#o_dialog);
52
	OpenDialog_init stdcall (#o_dialog);
Line 65... Line 53...
65
 
53
 
Line 66... Line 54...
66
	GetIniSettings();
54
	GetIniSettings();
Line 73... Line 61...
73
	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);
74
	loop() switch(WaitEvent()) 
62
	loop() switch(WaitEvent()) 
75
	{
63
	{
76
	  	case evMouse:
64
	  	case evMouse:
77
			SelectList_ProcessMouse();
65
			SelectList_ProcessMouse();
-
 
66
			if (tabs.active_tab == TAB_SCREENSAVERS) {
-
 
67
				scrollbar_h_mouse stdcall (#ss_timeout);
-
 
68
				if (ss_timeout.redraw) {
-
 
69
					draw_timeout();
-
 
70
					ss_timeout.redraw = false; //reset flag
-
 
71
				}
-
 
72
			}
78
	  		break;
73
	  		break;
Line 79... Line 74...
79
 
74
 
80
		case evButton:
75
		case evButton:
81
			id=GetButtonID();
76
			id=GetButtonID();
Line 98... Line 93...
98
			}
93
			}
99
			break;
94
			break;
Line 100... Line 95...
100
	  
95
	  
101
		case evKey:
96
		case evKey:
102
			GetKeys(); 
97
			GetKeys(); 
103
			if (select_list.ProcessKey(key_scancode)) EventApply();
98
			if (select_list.ProcessKey(key_scancode)) { EventApply(); break; }
104
			if (key_scancode==SCAN_CODE_ENTER) EventOpenFile();
99
			if (key_scancode==SCAN_CODE_ENTER) { EventOpenFile(); break; }
105
			if (key_scancode==SCAN_CODE_DEL) EventDeleteFile();
100
			if (key_scancode==SCAN_CODE_DEL) { EventDeleteFile(); break; }
106
			if (key_scancode==SCAN_CODE_TAB) {
101
			if (key_scancode==SCAN_CODE_TAB) {
107
				id = tabs.active_tab+1; 
102
				id = tabs.active_tab+1; 
108
				if(id==3)id=0;
103
				if(id==3)id=0;
109
				tabs.click(id + tabs.base_id);
104
				tabs.click(id + tabs.base_id);
110
				break;
105
				break;
111
			}
-
 
112
 
-
 
113
			if (! edit_cmm.flags & ed_focus) && (! edit_st.flags & ed_focus)
106
			}
114
			for (i=select_list.cur_y+1; i
107
			for (i=select_list.cur_y+1; i
115
			{
108
			{
116
				id = list.get(i) + strrchr(list.get(i), '/');
109
				id = list.get(i) + strrchr(list.get(i), '/');
117
				if (ESBYTE[id]==key_ascii) || (ESBYTE[id]==key_ascii-32)
110
				if (ESBYTE[id]==key_ascii) || (ESBYTE[id]==key_ascii-32)
Line 120... Line 113...
120
					select_list.KeyDown();
113
					select_list.KeyDown();
121
					EventApply();
114
					EventApply();
122
					break;
115
					break;
123
				}
116
				}
124
			}
117
			}
125
 
-
 
126
			if (tabs.active_tab == TAB_SKINS) {
-
 
127
				EAX = key_editbox;
-
 
128
				edit_box_key stdcall (#edit_cmm);
-
 
129
				edit_box_key stdcall (#edit_st);				
-
 
130
			}
-
 
131
			break;
118
			break;
Line 132... Line 119...
132
		 
119
		 
133
		 case evReDraw:		
120
		 case evReDraw:		
134
			draw_window();
121
			draw_window();
Line 137... Line 124...
137
 
124
 
138
void draw_window()
125
void draw_window()
139
{
126
{
140
	sc.get();
127
	sc.get();
141
	DefineAndDrawWindow(screen.width-WIN_W-9/2,80,WIN_W+9,WIN_H+4+skin_height,0x34,sc.work,WINDOW_HEADER,0);
-
 
142
	DrawWindowContent();
-
 
143
}
-
 
144
 
-
 
145
void DrawWindowContent()
-
 
146
{
-
 
Line 147... Line 128...
147
	sc.get();	
128
	DefineAndDrawWindow(screen.width-WIN_W-9/2,80,WIN_W+9,WIN_H+4+skin_height,0x34,sc.work,WINDOW_HEADER,0);
148
 
129
 
149
	tabs.draw();
130
	tabs.draw();
150
	draw_icon_16w(tabs.x + TAB_PADDING, LP+5, 17);
131
	draw_icon_16w(tabs.x + TAB_P, LP+5, 17);
Line 151... Line 132...
151
	draw_icon_16w(sizeof(t_skins)-1*8 + TAB_PADDING + TAB_PADDING + tabs.x, LP+5, 6);
132
	draw_icon_16w(sizeof(t_skins)-1*8 + TAB_P + TAB_P + tabs.x, LP+5, 6);
152
	draw_icon_16w(sizeof(t_wallpapers)+sizeof(t_skins)-2*8 + TAB_PADDING + TAB_PADDING + TAB_PADDING + tabs.x, LP+5, 61);
133
	draw_icon_16w(sizeof(t_wallpapers)+sizeof(t_skins)-2*8 + TAB_P + TAB_P + TAB_P + tabs.x, LP+5, 61);
153
 
134
 
154
	$push select_list.cur_y
135
	$push select_list.cur_y
155
	SelectList_Init(
136
	SelectList_Init(
156
		LP + TAB_PADDING,
137
		LP,
157
		PANEL_H, 
138
		PANEL_H, 
158
		LIST_W, 
139
		LIST_W, 
Line 159... Line 140...
159
		WIN_H - LP - TAB_PADDING - PANEL_H
140
		WIN_H - LP - PANEL_H
Line 179... Line 160...
179
		optionbox_auto.draw(RIGHTx+14, PANEL_H+79);
160
		optionbox_auto.draw(RIGHTx+14, PANEL_H+79);
180
		DrawStandartCaptButton(RIGHTx, PANEL_H+130, BTN_SELECT_WALLP_FOLDER, T_SELECT_FOLDER);
161
		DrawStandartCaptButton(RIGHTx, PANEL_H+130, BTN_SELECT_WALLP_FOLDER, T_SELECT_FOLDER);
181
	}
162
	}
182
	if (tabs.active_tab == TAB_SCREENSAVERS)
163
	if (tabs.active_tab == TAB_SCREENSAVERS)
183
	{
164
	{
-
 
165
		draw_timeout();
-
 
166
		ss_timeout.line_col = sc.work_graph;
-
 
167
		ss_timeout.frnt_col = sc.work;
184
		miniprintf(#param, T_SS_TIMEOUT, screensaver_timeout);
168
		scrollbar_h_draw stdcall (#ss_timeout);
185
		WriteTextWithBg(RIGHTx, PANEL_H, 0xD0, sc.work_text, #param, sc.work);
169
		DrawRectangle(RIGHTx, RIGHTy+25, RIGHTw-20, 15, sc.work_graph);
186
		ESI = DrawStandartCaptButton(RIGHTx, PANEL_H + 25, BTN_TEST_SCREENSAVER, T_SS_PREVIEW);
170
		ESI = DrawStandartCaptButton(RIGHTx, PANEL_H + 65, BTN_TEST_SCREENSAVER, T_SS_PREVIEW);
187
		DrawStandartCaptButton(RIGHTx+ESI, PANEL_H + 25, BTN_SET_SCREENSAVER, T_SS_SET);
171
		DrawStandartCaptButton(RIGHTx+ESI, PANEL_H + 65, BTN_SET_SCREENSAVER, T_SS_SET);
188
	}
172
	}
189
}
173
}
Line -... Line 174...
-
 
174
 
-
 
175
void draw_timeout()
-
 
176
{
-
 
177
	miniprintf(#param, T_SS_TIMEOUT, ss_timeout.position+1);
-
 
178
	WriteTextWithBg(RIGHTx, PANEL_H, 0xD0, sc.work_text, #param, sc.work);	
-
 
179
}
190
 
180
 
191
bool strreqi(dword _left, _right)
181
bool strreqi(dword _left, _right)
192
{
182
{
193
	return strcmp(_left+strrchr(_left,'.'), _right);
183
	return strcmp(_left+strrchr(_left,'.'), _right);
Line 268... Line 258...
268
 
258
 
269
void SelectList_DrawLine(dword i)
259
void SelectList_DrawLine(dword i)
270
{
260
{
271
	int draw_y = i*SELECT_LIST_ITEMH+PANEL_H;
261
	int draw_y = i*SELECT_LIST_ITEMH+PANEL_H;
-
 
262
	int i_abs = select_list.first + i;
-
 
263
	dword text_color = 0xFFFfff;
272
	int i_abs = select_list.first + i;
264
	dword bg_color = 0x000000;
273
	char filename_buf[4096];
265
	char filename_buf[4096];
Line 274... Line 266...
274
	char* filename = #filename_buf;
266
	char* filename = #filename_buf;
275
 
267
 
Line 289... Line 281...
289
				active_wallpaper = select_list.cur_y; 
281
				active_wallpaper = select_list.cur_y; 
290
				if (!i_abs) filename = T_DEFAULT;
282
				if (!i_abs) filename = T_DEFAULT;
291
				BREAK;
283
				BREAK;
292
		CASE TAB_SCREENSAVERS: 
284
		CASE TAB_SCREENSAVERS: 
293
				active_screensaver = select_list.cur_y;
285
				active_screensaver = select_list.cur_y;
-
 
286
				if (!i_abs) filename = T_NO_SS;
294
	}
287
	}
Line 295... Line 288...
295
	
288
	
296
	if (select_list.cur_y == i_abs)
-
 
297
	{
289
	if (select_list.cur_y == i_abs) {
298
		DrawBar(select_list.x, draw_y, LIST_W, SELECT_LIST_ITEMH, sc.button);
-
 
299
		WriteText(select_list.x+12,draw_y+select_list.text_y,select_list.font_type,sc.button_text, filename);
-
 
300
	}
-
 
301
	else
-
 
302
	{
290
		text_color = sc.button;
303
		DrawBar(select_list.x,draw_y,LIST_W, SELECT_LIST_ITEMH, 0xFFFfff);
-
 
304
		WriteText(select_list.x+12,draw_y+select_list.text_y,select_list.font_type,0, filename);
291
		bg_color = sc.button_text;
-
 
292
	}
-
 
293
	DrawBar(select_list.x, draw_y, LIST_W, SELECT_LIST_ITEMH, text_color);
305
	}
294
	WriteText(select_list.x+12,draw_y+select_list.text_y,select_list.font_type,bg_color, filename);
Line 306... Line 295...
306
}
295
}
307
 
296
 
308
void SelectList_LineChanged() 
297
void SelectList_LineChanged() 
309
{
298
{
Line 310... Line 299...
310
	EventApply();
299
	EventApply();
311
}
300
}
312
 
301
 
-
 
302
dword GetRealKolibriosPath()
313
dword GetRealKolibriosPath()
303
{
314
{
304
	char real_kolibrios_path[4096];
315
	char real_kolibrios_path[4096];
305
	if (!dir_exists("/kolibrios")) return 0;
316
	SetCurDir("/kolibrios");
306
	SetCurDir("/kolibrios");
Line 317... Line 307...
317
	GetCurDir(#real_kolibrios_path, sizeof(real_kolibrios_path));
307
	GetCurDir(#real_kolibrios_path, sizeof(real_kolibrios_path));
318
	return #real_kolibrios_path;
308
	return #real_kolibrios_path;
319
}
309
}
320
 
310
 
321
void GetIniSettings()
311
void GetIniSettings()
322
{
312
{
323
	ini.section = "screensaver";
313
	ini.section = "screensaver";
324
	screensaver_timeout = ini.GetInt("timeout", 10);
314
	ss_timeout.position = ini.GetInt("timeout", 10) - 1;
325
	ini.GetString("available", #ss_available, sizeof(ss_available), 0);
315
	ini.GetString("available", #ss_available, sizeof(ss_available), 0);
Line 326... Line 316...
326
	ini.section = "style";
316
	ini.section = "style";
327
	ini.GetString("default_skin", #default_skin, sizeof(default_skin), 0);
317
	ini.GetString("default_skin", #default_skin, PATHLEN, 0);
328
	ini.GetString("default_wallp", #default_wallp, sizeof(default_wallp), 0);
318
	ini.GetString("default_wallp", #default_wallp, PATHLEN, 0);
Line 356... Line 346...
356
	char ssmas[sizeof(ss_available)];
346
	char ssmas[sizeof(ss_available)];
357
	list.drop();
347
	list.drop();
358
	select_list.ClearList();
348
	select_list.ClearList();
Line 359... Line 349...
359
 
349
 
360
	select_list.count++;
350
	select_list.count++;
Line 361... Line 351...
361
	list.add(T_NO_SS);
351
	list.add("");
362
 
352
 
363
	strcpy(#ssmas, #ss_available);
353
	strcpy(#ssmas, #ss_available);
364
	do {
354
	do {
Line 379... Line 369...
379
	EventApply();
369
	EventApply();
380
}
370
}
Line 381... Line 371...
381
 
371
 
382
void EventSelectWallpFolder()
372
void EventSelectWallpFolder()
-
 
373
{
383
{
374
	o_dialog.type = 2; //select folder
384
	OpenDialog_start stdcall (#o_dialog);
375
	OpenDialog_start stdcall (#o_dialog);
385
	if (o_dialog.status) EventTabWallpappersClick();
376
	if (o_dialog.status) EventTabWallpappersClick();
Line 386... Line 377...
386
}
377
}
Line 427... Line 418...
427
	}
418
	}
428
}
419
}
Line 429... Line 420...
429
 
420
 
430
void EventUpdateDocky()
421
void EventUpdateDocky()
431
{
422
{
432
	if (!update_docky.checked) return;
-
 
433
	// KillProcessByName("@docky", MULTIPLE);
-
 
434
	// RunProgram("/sys/@docky",NULL);
423
	if (update_docky.checked) {
435
	RestartProcessByName("/sys/@docky", MULTIPLE);
424
		RestartProcessByName("/sys/@docky", MULTIPLE);
436
	pause(50);
425
		pause(50);
437
	ActivateWindow_Self();
426
		ActivateWindow_Self();		
-
 
427
	}
Line 438... Line 428...
438
}
428
}
439
 
429
 
440
void EventOpenFile()
430
void EventOpenFile()
441
{
431
{
Line 446... Line 436...
446
	}
436
	}
447
}
437
}
Line 448... Line 438...
448
 
438
 
449
void EventExit()
439
void EventExit()
450
{
440
{
451
	if (cur_skin_path) {
441
	if (GetRealKolibriosPath()) {
452
		ini.section = "style";
442
		ini.section = "style";
453
		ini.SetString("skin", #cur_skin_path, strlen(#cur_skin_path));
443
		ini.SetString("skin", #cur_skin_path, strlen(#cur_skin_path));
454
	}
444
	}
455
	ExitProcess();
445
	ExitProcess();
Line 458... Line 448...
458
void EventSetSs()
448
void EventSetSs()
459
{
449
{
460
	dword cur_ss = list.get(select_list.cur_y);
450
	dword cur_ss = list.get(select_list.cur_y);
461
	ini.section = "screensaver";
451
	ini.section = "screensaver";
462
	ini.SetString("program", cur_ss, strlen(cur_ss));
452
	ini.SetString("program", cur_ss, strlen(cur_ss));
-
 
453
	ini.SetInt("timeout", ss_timeout.position+1);
463
	RestartProcessByName("/sys/@ss", MULTIPLE);
454
	RestartProcessByName("/sys/@ss", MULTIPLE);
464
}
455
}
Line 465... Line 456...
465
 
456
 
-
 
457
stop:
-
 
458
 
-
 
459
char folder_path[PATHLEN];
-
 
460
char cur_file_path[PATHLEN];
-
 
461
char cur_skin_path[PATHLEN];
-
 
462
char default_skin[PATHLEN];
466
stop:
463
char default_wallp[PATHLEN];