Subversion Repositories Kolibri OS

Rev

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

Rev 9461 Rev 9465
Line 1... Line 1...
1
//11.03.12 - start!
1
//11.03.12 - start!
2
//ver 2.31
2
//ver 2.31
Line 3... Line 3...
3
 
3
 
4
#define MEMSIZE 200*1024
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"
7
#include "../lib/io.h"
7
#include "../lib/io.h"
8
#include "../lib/list_box.h"
8
#include "../lib/list_box.h"
Line 32... Line 32...
32
	BTN_TEST_SCREENSAVER };
32
	BTN_TEST_SCREENSAVER };
Line 33... Line 33...
33
 
33
 
34
char folder_path[4096];
34
char folder_path[4096];
35
char cur_file_path[4096];
35
char cur_file_path[4096];
36
char cur_skin_path[4096];
36
char cur_skin_path[4096];
-
 
37
char ss_available[200];
-
 
38
 
Line 37... Line 39...
37
int files_mas[400];
39
int screensaver_timeout;
38
 
40
 
Line 39... Line 41...
39
_tabs tabs = { -sizeof(t_skins)-sizeof(t_wallpapers)-sizeof(t_screensaver)-3*8+WIN_W
41
_tabs tabs = { -sizeof(t_skins)-sizeof(t_wallpapers)-sizeof(t_screensaver)-3*8+WIN_W
Line 40... Line 42...
40
	 - TAB_PADDING / 2, LP, NULL, BASE_TAB_BUTTON_ID };
42
	 - TAB_PADDING / 2, LP, NULL, BASE_TAB_BUTTON_ID };
41
 
43
 
-
 
44
checkbox update_docky = { T_UPDATE_DOCK, false };
Line 42... Line -...
42
checkbox update_docky = { T_UPDATE_DOCK, false };
-
 
43
 
-
 
44
checkbox optionbox_stretch = { T_CHECKBOX_STRETCH, true };
-
 
45
checkbox optionbox_tiled = { T_CHECKBOX_TILED, false };
-
 
46
 
45
 
Line 47... Line 46...
47
struct SCREENSAVER_SETTINGS {
46
checkbox optionbox_stretch = { T_CHECKBOX_STRETCH, false };
48
	int timeout;
47
checkbox optionbox_tiled = { T_CHECKBOX_TILED, false };
49
	char program[60];
48
checkbox optionbox_auto = { T_CHECKBOX_AUTO, true };
50
	char available[200];
49
 
Line 68... Line 67...
68
	tabs.add(#t_skins, #EventTabSkinsClick);	
67
	tabs.add(#t_skins, #EventTabSkinsClick);	
69
	tabs.add(#t_wallpapers, #EventTabWallpappersClick);
68
	tabs.add(#t_wallpapers, #EventTabWallpappersClick);
70
	tabs.add(#t_screensaver, #EventTabScreensaverClick);
69
	tabs.add(#t_screensaver, #EventTabScreensaverClick);
71
	tabs.draw_active_tab();
70
	tabs.draw_active_tab();
Line -... Line 71...
-
 
71
 
-
 
72
	GetScreensaverIniSettings();
72
 
73
 
73
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
74
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
74
	loop() switch(WaitEvent()) 
75
	loop() switch(WaitEvent()) 
75
	{
76
	{
76
	  	case evMouse:
77
	  	case evMouse:
77
			SelectList_ProcessMouse();
78
			SelectList_ProcessMouse();
Line 78... Line 79...
78
	  		break;
79
	  		break;
79
 
80
 
80
		case evButton:
81
		case evButton:
81
			id=GetButtonID();
-
 
82
			if (id==1) EventExit();
82
			id=GetButtonID();
-
 
83
			if (id==1) EventExit();
83
			if (id==BTN_SELECT_WALLP_FOLDER) EventSelectWallpFolder();
84
			tabs.click(id);
84
			tabs.click(id);
85
			if (tabs.active_tab == TAB_SKINS) {
85
			checkbox1.click(id);
86
				checkbox1.click(id);
-
 
87
				spinbox1.click(id);
-
 
88
				if (update_docky.click(id)) EventUpdateDocky();
-
 
89
			}
86
			spinbox1.click(id);
90
			if (tabs.active_tab == TAB_WALLPAPERS) {
87
			if (update_docky.click(id)) EventUpdateDocky();
91
				if (id==BTN_SELECT_WALLP_FOLDER) EventSelectWallpFolder();
-
 
92
				if (optionbox_stretch.click(id)) EventSetWallpMode(1,0,0);
-
 
93
				if (optionbox_tiled.click(id)) EventSetWallpMode(0,1,0);
-
 
94
				if (optionbox_auto.click(id)) EventSetWallpMode(0,0,1);
-
 
95
			}
-
 
96
			if (tabs.active_tab == TAB_SCREENSAVERS) {
88
			if (!optionbox_stretch.checked) && (optionbox_stretch.click(id)) EventSetWallpMode_Stretch();
97
				if (id==BTN_TEST_SCREENSAVER) EventOpenFile();
Line 89... Line 98...
89
			if (!optionbox_tiled.checked) && (optionbox_tiled.click(id)) EventSetWallpMode_Tiled();
98
			}
90
			break;
99
			break;
91
	  
100
	  
Line 96... Line 105...
96
			if (key_scancode==SCAN_CODE_DEL) EventDeleteFile();
105
			if (key_scancode==SCAN_CODE_DEL) EventDeleteFile();
97
			if (key_scancode==SCAN_CODE_TAB) {
106
			if (key_scancode==SCAN_CODE_TAB) {
98
				id = tabs.active_tab+1; 
107
				id = tabs.active_tab+1; 
99
				if(id==3)id=0;
108
				if(id==3)id=0;
100
				tabs.click(id + tabs.base_id);
109
				tabs.click(id + tabs.base_id);
101
				DrawWindowContent();
-
 
102
				break;
110
				break;
103
			}
111
			}
Line 104... Line 112...
104
 
112
 
105
			if (! edit_cmm.flags & ed_focus) && (! edit_st.flags & ed_focus)
113
			if (! edit_cmm.flags & ed_focus) && (! edit_st.flags & ed_focus)
106
			for (i=select_list.cur_y+1; i
114
			for (i=select_list.cur_y+1; i
107
			{
115
			{
108
				id = ESBYTE[io.dir.position(files_mas[i])];
116
				id = ESBYTE[list.get(i)];
109
				if (id==ESBYTE[EAX]) || (id==key_ascii-32)
117
				if (id==ESBYTE[EAX]) || (id==key_ascii-32)
110
				{
118
				{
111
					select_list.cur_y = i - 1;
119
					select_list.cur_y = i - 1;
112
					select_list.KeyDown();
120
					select_list.KeyDown();
Line 163... Line 171...
163
		DrawUiElementsPreview(RIGHTx+20, PANEL_H+5, RIGHTh);
171
		DrawUiElementsPreview(RIGHTx+20, PANEL_H+5, RIGHTh);
164
		if (CheckProcessExists("@DOCKY")) update_docky.draw(RIGHTx, PANEL_H+250);
172
		if (CheckProcessExists("@DOCKY")) update_docky.draw(RIGHTx, PANEL_H+250);
165
	}
173
	}
166
	if (tabs.active_tab == TAB_WALLPAPERS)
174
	if (tabs.active_tab == TAB_WALLPAPERS)
167
	{
175
	{
168
		DrawFrame(RIGHTx, PANEL_H+5, 180, 80, T_PICTURE_MODE);
176
		DrawFrame(RIGHTx, PANEL_H+5, 180, 105, T_PICTURE_MODE);
169
		optionbox_stretch.draw(RIGHTx+14, PANEL_H+25);
177
		optionbox_stretch.draw(RIGHTx+14, PANEL_H+25);
170
		optionbox_tiled.draw(RIGHTx+14, PANEL_H+52);
178
		optionbox_tiled.draw(RIGHTx+14, PANEL_H+52);
-
 
179
		optionbox_auto.draw(RIGHTx+14, PANEL_H+79);
171
		DrawStandartCaptButton(RIGHTx, PANEL_H+100, BTN_SELECT_WALLP_FOLDER, T_SELECT_FOLDER);
180
		DrawStandartCaptButton(RIGHTx, PANEL_H+130, BTN_SELECT_WALLP_FOLDER, T_SELECT_FOLDER);
172
	}
181
	}
173
	if (tabs.active_tab == TAB_SCREENSAVERS)
182
	if (tabs.active_tab == TAB_SCREENSAVERS)
174
	{
183
	{
175
		DrawStandartCaptButton(RIGHTx, PANEL_H, BTN_TEST_SCREENSAVER, "Test");
184
		DrawStandartCaptButton(RIGHTx, PANEL_H, BTN_TEST_SCREENSAVER, T_SCREENSAVER_PREVIEW);
176
	}
185
	}
177
}
186
}
Line 178... Line 187...
178
 
187
 
179
bool strreqi(dword _left, _right)
188
bool strreqi(dword _left, _right)
180
{
189
{
181
	return strcmp(_left+strrchr(_left,'.'), _right);
190
	return strcmp(_left+strrchr(_left,'.'), _right);
Line -... Line 191...
-
 
191
}
182
}
192
 
183
 
193
dword files_mas[400];
184
void Open_Dir()
194
void Open_Dir()
185
{
195
{
186
	int j;
196
	int j;
187
	char temp_filename[4096];
197
	char fname[4096];
188
	select_list.count = 0;
198
	select_list.ClearList();
189
	if(io.dir.buffer)free(io.dir.buffer);
199
	if(io.dir.buffer)free(io.dir.buffer);
190
	io.dir.load(#folder_path,DIR_ONLYREAL);
200
	io.dir.load(#folder_path,DIR_ONLYREAL);
191
	for (j=0; j
201
	for (j=0; j
192
	{
202
	{
193
		strcpy(#temp_filename, io.dir.position(j));
203
		strcpy(#fname, io.dir.position(j));
194
		strlwr(#temp_filename);
204
		strlwr(#fname);
195
		if (tabs.active_tab==TAB_SKINS) {
205
		if (tabs.active_tab==TAB_SKINS) {
196
			if (strreqi(#temp_filename,"skn")!=0) continue;
206
			if (strreqi(#fname,"skn")!=0) continue;
197
		}
207
		}
198
		if (tabs.active_tab==TAB_WALLPAPERS) {
208
		if (tabs.active_tab==TAB_WALLPAPERS) {
199
			if (strreqi(#temp_filename,"png")!=0)
209
			if (strreqi(#fname,"png")!=0)
200
			&& (strreqi(#temp_filename,"jpg")!=0) 
210
			&& (strreqi(#fname,"jpg")!=0) 
201
			&& (strreqi(#temp_filename,"jpeg")!=0)
211
			&& (strreqi(#fname,"jpeg")!=0)
202
			&& (strreqi(#temp_filename,"bmp")!=0)
212
			&& (strreqi(#fname,"bmp")!=0)
203
			&& (strreqi(#temp_filename,"gif")!=0) continue;
213
			&& (strreqi(#fname,"gif")!=0) continue;
204
		}
214
		}
205
		files_mas[calc(select_list.count)]=j;
215
		ESDWORD[select_list.count*4 + #files_mas] = j;
206
		select_list.count++;
216
		select_list.count++;
-
 
217
	}
-
 
218
	Sort_by_Name(0, select_list.count-1);
-
 
219
	list.drop();
-
 
220
	for (j=0; j
-
 
221
		list.add(io.dir.position(files_mas[j]));
-
 
222
	}
-
 
223
	if (!select_list.count) notify(T_NO_FILES);
-
 
224
	//save current item for tab change
-
 
225
	switch(tabs.active_tab) {
-
 
226
		CASE TAB_SKINS: select_list.cur_y = active_skin; BREAK;
-
 
227
		CASE TAB_WALLPAPERS: select_list.cur_y = active_wallpaper; BREAK;
-
 
228
		CASE TAB_SCREENSAVERS: select_list.cur_y = active_screensaver;
-
 
229
	}
-
 
230
	if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; 
207
	}
231
	select_list.CheckDoesValuesOkey();	
Line 208... Line 232...
208
	Sort_by_Name(0, select_list.count-1);
232
	if (LIST_W) draw_window();
209
}
233
}
210
 
234
 
Line 225... Line 249...
225
 
249
 
226
void SelectList_DrawLine(dword i)
250
void SelectList_DrawLine(dword i)
227
{
251
{
228
	int draw_y = i*SELECT_LIST_ITEMH+PANEL_H;
252
	int draw_y = i*SELECT_LIST_ITEMH+PANEL_H;
229
	int i_abs = select_list.first + i;
253
	int i_abs = select_list.first + i;
-
 
254
	char filename_buf[4096];
Line 230... Line 255...
230
	char filename[4096];
255
	char* filename = #filename_buf;
231
 
256
 
232
	strcpy(#filename, io.dir.position(files_mas[i_abs]));
257
	strcpy(filename, list.get(i_abs));
-
 
258
	EAX = math.min(strrchr(filename,'.')-1, LIST_W - 24 / 8);
-
 
259
	filename_buf[EAX] = '\0';
-
 
260
	if (EAX = strrchr(filename,'/')) filename += EAX;
-
 
261
 
-
 
262
	//save current item for tab change
-
 
263
	switch(tabs.active_tab) {
-
 
264
		CASE TAB_SKINS: active_skin = select_list.cur_y; BREAK;
-
 
265
		CASE TAB_WALLPAPERS: active_wallpaper = select_list.cur_y; BREAK;
Line 233... Line 266...
233
	EAX = math.min(strrchr(#filename,'.')-1, LIST_W - 24 / 8);
266
		CASE TAB_SCREENSAVERS: active_screensaver = select_list.cur_y;
234
	filename[EAX] = '\0';
267
	}
235
	
268
	
236
	if (select_list.cur_y == i_abs)
269
	if (select_list.cur_y == i_abs)
237
	{
270
	{
238
		DrawBar(select_list.x, draw_y, LIST_W, SELECT_LIST_ITEMH, sc.button);
271
		DrawBar(select_list.x, draw_y, LIST_W, SELECT_LIST_ITEMH, sc.button);
239
		WriteText(select_list.x+12,draw_y+select_list.text_y,select_list.font_type,sc.button_text, #filename);
272
		WriteText(select_list.x+12,draw_y+select_list.text_y,select_list.font_type,sc.button_text, filename);
240
	}
273
	}
241
	else
274
	else
242
	{
275
	{
243
		DrawBar(select_list.x,draw_y,LIST_W, SELECT_LIST_ITEMH, 0xFFFfff);
276
		DrawBar(select_list.x,draw_y,LIST_W, SELECT_LIST_ITEMH, 0xFFFfff);
Line 244... Line 277...
244
		WriteText(select_list.x+12,draw_y+select_list.text_y,select_list.font_type,0, #filename);
277
		WriteText(select_list.x+12,draw_y+select_list.text_y,select_list.font_type,0, filename);
245
	}
278
	}
246
}
279
}
247
 
280
 
Line 248... Line -...
248
void SelectList_LineChanged() 
-
 
249
{
-
 
250
	EventApply();
-
 
251
}
-
 
252
 
-
 
253
void ActivateTab(int _id)
-
 
254
{
-
 
255
	select_list.ClearList();
-
 
256
	Open_Dir();
-
 
257
	if (!select_list.count) notify(T_NO_FILES);
-
 
258
	select_list.cur_y = _id;
-
 
259
	if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; 
281
void SelectList_LineChanged() 
260
	select_list.CheckDoesValuesOkey();	
282
{
261
	if (LIST_W) DrawWindowContent();
283
	EventApply();
262
}
284
}
263
 
285
 
264
dword GetRealKolibriosPath()
286
dword GetRealKolibriosPath()
265
{
287
{
Line -... Line 288...
-
 
288
	char real_kolibrios_path[4096];
-
 
289
	SetCurDir("/kolibrios");
-
 
290
	GetCurDir(#real_kolibrios_path, sizeof(real_kolibrios_path));
-
 
291
	return #real_kolibrios_path;
-
 
292
}
-
 
293
 
-
 
294
void GetScreensaverIniSettings()
266
	char real_kolibrios_path[4096];
295
{
267
	SetCurDir("/kolibrios");
296
	ini.section = "screensaver";
268
	GetCurDir(#real_kolibrios_path, sizeof(real_kolibrios_path));
297
	screensaver_timeout = ini.GetInt("timeout", 10);
269
	return #real_kolibrios_path;
298
	ini.GetString("available", #ss_available, sizeof(ss_available), 0);
270
}
299
}
Line 271... Line 300...
271
 
300
 
272
//===================================================//
301
//===================================================//
273
//                                                   //
-
 
274
//                     EVENTS                        //
302
//                                                   //
275
//                                                   //
303
//                     EVENTS                        //
276
//===================================================//
304
//                                                   //
Line 277... Line 305...
277
 
305
//===================================================//
278
void EventTabSkinsClick()
306
 
279
{
-
 
280
	active_wallpaper = select_list.cur_y;
307
void EventTabSkinsClick()
281
	miniprintf(#folder_path, "%s/res/skins", GetRealKolibriosPath());
308
{
282
	ActivateTab(active_skin);
309
	miniprintf(#folder_path, "%s/res/skins", GetRealKolibriosPath());
283
}
310
	Open_Dir();
284
 
311
}
285
void EventTabWallpappersClick()
312
 
286
{
313
void EventTabWallpappersClick()
Line 287... Line 314...
287
	active_skin = select_list.cur_y;
314
{
288
	if (opendir_path) {
315
	if (opendir_path) {
-
 
316
		strcpy(#folder_path, #opendir_path);
289
		strcpy(#folder_path, #opendir_path);
317
	} else {
-
 
318
		miniprintf(#folder_path, "%s/res/wallpapers", GetRealKolibriosPath());
290
	} else {
319
	}
-
 
320
	Open_Dir();
291
		miniprintf(#folder_path, "%s/res/wallpapers", GetRealKolibriosPath());
321
}
-
 
322
 
-
 
323
void EventTabScreensaverClick()
292
	}
324
{
-
 
325
	dword j;
-
 
326
	char ssmas[sizeof(ss_available)];
-
 
327
	list.drop();
-
 
328
	select_list.ClearList();
-
 
329
 
293
	ActivateTab(active_wallpaper);
330
	strcpy(#ssmas, #ss_available);
294
}
331
	do {
Line 295... Line 332...
295
 
332
		j = strrchr(#ss_available, '|');
296
void EventTabScreensaverClick()
333
		miniprintf(#param, "/sys/%s", #ss_available + j);
297
{
334
		list.add(#param);
298
	ini.section = "screensaver";
335
		ESBYTE[#ss_available + j - 1] = '\0';
299
	ss_settings.timeout = ini.GetInt("timeout", 10);
336
		select_list.count++;
300
	ini.GetString("title", #ss_settings.program, sizeof(ss_settings.program), 0);
337
	} while (j);
Line 301... Line -...
301
	ini.GetString("available", #ss_settings.available, sizeof(ss_settings.available), 0);
-
 
302
	ActivateTab(active_screensaver);
-
 
303
}
-
 
304
 
-
 
305
void EventDeleteFile()
-
 
306
{
-
 
307
	io.del(#cur_file_path);
338
 
308
	Open_Dir();
339
	if (LIST_W) draw_window();
309
	EventApply();
340
}
310
}
341
 
311
 
342
void EventDeleteFile()
Line 312... Line 343...
312
void EventSetNewCurrent()
343
{
313
{
344
	DeleteFile(#cur_file_path);
-
 
345
	Open_Dir();
314
	miniprintf(#cur_file_path,"%s/",#folder_path);
346
	EventApply();
-
 
347
}
315
	strcat(#cur_file_path, io.dir.position(files_mas[calc(select_list.cur_y)]));
348
 
316
}
-
 
317
 
-
 
318
void EventSelectWallpFolder()
-
 
319
{
-
 
320
	OpenDialog_start stdcall (#o_dialog);
-
 
321
	if (o_dialog.status) EventTabWallpappersClick();
-
 
322
}
349
void EventSelectWallpFolder()
-
 
350
{
323
 
351
	OpenDialog_start stdcall (#o_dialog);
324
void EventSetWallpMode_Stretch()
352
	if (o_dialog.status) EventTabWallpappersClick();
Line 325... Line 353...
325
{
353
}
326
	optionbox_tiled.checked = false;
354
 
327
	optionbox_tiled.redraw();
355
void EventSetWallpMode(dword _stretch, _titled, _auto)
328
	EventApply();
356
{
-
 
357
	optionbox_stretch.checked = _stretch;
-
 
358
	optionbox_tiled.checked = _titled;
329
}
359
	optionbox_auto.checked = _auto;
330
 
360
	optionbox_tiled.redraw();
331
void EventSetWallpMode_Tiled()
361
	optionbox_stretch.redraw();
332
{
362
	optionbox_auto.redraw();
333
	optionbox_stretch.checked = false;
363
	EventApply();
334
	optionbox_stretch.redraw();
364
}
335
	EventApply();
365
 
336
}
366
void EventApply()
337
 
367
{
338
void EventApply()
368
	char kivparam[4096+10];
339
{
369
	dword file_name = list.get(select_list.cur_y);
340
	char kivpath[4096+10];
370
	miniprintf(#cur_file_path,"%s/",#folder_path);
-
 
371
	strcat(#cur_file_path, list.get(select_list.cur_y));
-
 
372
	if (tabs.active_tab==TAB_SKINS)
-
 
373
	{
-
 
374
		SetSystemSkin(#cur_file_path);
-
 
375
		SelectList_Draw();
341
	EventSetNewCurrent();
376
		strcpy(#cur_skin_path, #cur_file_path);
-
 
377
		EventUpdateDocky();
-
 
378
	} 
-
 
379
	if (tabs.active_tab==TAB_WALLPAPERS)
-
 
380
	{
342
	if (tabs.active_tab==TAB_SKINS)
381
		SelectList_Draw();
343
	{
382
		miniprintf(#kivparam, "\\S__%s", #cur_file_path);
Line 344... Line 383...
344
		SetSystemSkin(#cur_file_path);
383
		if (optionbox_tiled.checked) kivparam[1]='T';
345
		SelectList_Draw();
384
		if (optionbox_auto.checked) {
Line 366... Line 405...
366
 
405
 
367
void EventOpenFile()
406
void EventOpenFile()
368
{
407
{
369
	if (tabs.active_tab==TAB_SKINS) RunProgram("/sys/skincfg", #cur_file_path);
408
	if (tabs.active_tab==TAB_SKINS) RunProgram("/sys/skincfg", #cur_file_path);
-
 
409
	if (tabs.active_tab==TAB_WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path);
370
	if (tabs.active_tab==TAB_WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path);
410
	if (tabs.active_tab==TAB_SCREENSAVERS) RunProgram(list.get(select_list.cur_y), "@ss");
Line 371... Line 411...
371
}
411
}
372
 
412
 
373
void EventExit()
413
void EventExit()