Subversion Repositories Kolibri OS

Rev

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

Rev 9516 Rev 9524
Line 1... Line 1...
1
//11.03.12 - start!
1
//11.03.12 - start!
2
//TODO: select current value at startap
-
 
Line 3... Line 2...
3
 
2
 
4
#define MEMSIZE 1024*70
3
#define MEMSIZE 1024*70
5
#include "../lib/mem.h"
4
#include "../lib/mem.h"
6
#include "../lib/strings.h"
5
#include "../lib/strings.h"
Line 14... Line 13...
14
 
13
 
15
#include "../lib/patterns/select_list.h"
14
#include "../lib/patterns/select_list.h"
16
#include "../lib/patterns/simple_open_dialog.h"
15
#include "../lib/patterns/simple_open_dialog.h"
Line -... Line 16...
-
 
16
#include "../lib/patterns/restart_process.h"
-
 
17
 
17
#include "../lib/patterns/restart_process.h"
18
dword fmas;
18
 
19
 
Line 19... Line 20...
19
#include "ui_elements_preview.h"
20
#include "ui_elements_preview.h"
20
#include "const.h"
21
#include "const.h"
21
 
22
 
22
//===================================================//
23
//===================================================//
23
//                                                   //
24
//                                                   //
Line 24... Line 25...
24
//                       DATA                        //
25
//                       DATA                        //
Line 25... Line 26...
25
//                                                   //
26
//                                                   //
Line 26... Line 27...
26
//===================================================//
27
//===================================================//
27
 
28
 
Line 35... Line 36...
35
 
36
 
Line 36... Line 37...
36
char ss_available[200];
37
char ss_available[200];
Line -... Line 38...
-
 
38
 
37
 
39
collection list;
38
collection list;
40
 
39
 
41
 
40
//===================================================//
42
//===================================================//
41
//                                                   //
43
//                                                   //
Line 176... Line 178...
176
{
178
{
177
	miniprintf(#param, T_SS_TIMEOUT, ss_timeout.position+1);
179
	miniprintf(#param, T_SS_TIMEOUT, ss_timeout.position+1);
178
	WriteTextWithBg(RIGHTx, PANEL_H, 0xD0, sc.work_text, #param, sc.work);	
180
	WriteTextWithBg(RIGHTx, PANEL_H, 0xD0, sc.work_text, #param, sc.work);	
179
}
181
}
Line 180... Line 182...
180
 
182
 
181
bool strreqi(dword _left, _right)
183
void add_filesnames_into_the_list()
-
 
184
{
-
 
185
	int j;
182
{
186
	for (j=0; j
-
 
187
		miniprintf(#param,"%s/",#folder_path);
-
 
188
		strcat(#param, io.dir.position(ESDWORD[j*4+fmas]));
-
 
189
		list.add(#param);
183
	return strcmp(_left+strrchr(_left,'.'), _right);
190
	}
Line 184... Line -...
184
}
-
 
185
 
191
}
186
dword files_mas[400];
192
 
187
void Open_Dir()
193
void Open_Dir()
188
{
194
{
189
	int j;
195
	int j;
-
 
196
	dword ext;
190
	char fname[4096];
197
	select_list.ClearList();
191
	select_list.ClearList();
198
 
Line -... Line 199...
-
 
199
	if (io.dir.buffer) free(io.dir.buffer);
-
 
200
	io.dir.load(#folder_path,DIR_ONLYREAL);
-
 
201
 
192
	if(io.dir.buffer)free(io.dir.buffer);
202
	if (fmas) free(fmas);
193
	io.dir.load(#folder_path,DIR_ONLYREAL);
203
	fmas = malloc(io.dir.count * 4);
194
 
204
 
195
	for (j=0; j
205
	for (j=0; j
-
 
206
	{
196
	{
207
		strncpy(#param, io.dir.position(j), PATHLEN);
197
		strcpy(#fname, io.dir.position(j));
208
		strlwr(#param);
198
		strlwr(#fname);
209
		ext = #param + strrchr(#param,'.');
199
		if (tabs.active_tab==TAB_SKINS) {
210
		if (tabs.active_tab==TAB_SKINS) {
200
			if (strreqi(#fname,"skn")!=0) continue;
211
			if (!streq(ext,"skn")) continue;
201
		}
-
 
202
		if (tabs.active_tab==TAB_WALLPAPERS) {
212
		}
203
			if (strreqi(#fname,"png")!=0)
-
 
204
			&& (strreqi(#fname,"jpg")!=0) 
213
		if (tabs.active_tab==TAB_WALLPAPERS) {
205
			&& (strreqi(#fname,"jpeg")!=0)
214
			if (!streq(ext,"png")) && (!streq(ext,"jpg")) 
206
			&& (strreqi(#fname,"bmp")!=0)
215
			&& (!streq(ext,"jpeg")) && (!streq(ext,"bmp"))
207
			&& (strreqi(#fname,"gif")!=0) continue;
216
			&& (!streq(ext,"gif")) continue;
208
		}
217
		}
209
		ESDWORD[select_list.count*4 + #files_mas] = j;
218
		ESDWORD[select_list.count*4 + fmas] = j;
Line 210... Line 219...
210
		select_list.count++;
219
		select_list.count++;
211
	}
220
	}
212
	Sort_by_Name(0, select_list.count-1);
221
	sort_by_name(0, select_list.count-1);
213
 
222
 
214
	list.drop();
223
	list.drop();
215
	//save current item for tab change
-
 
216
	//add default item
224
	//save current item for tab change
217
	switch(tabs.active_tab) {
225
	//add default item
-
 
226
	if(tabs.active_tab == TAB_SKINS) 
-
 
227
	{
-
 
228
		select_list.count++;
-
 
229
		list.add(#default_skin);
-
 
230
		add_filesnames_into_the_list();
-
 
231
		if (active_skin==-1) && (ESBYTE[#previous_skin]) 
218
		CASE TAB_SKINS: 
232
		{
219
				select_list.cur_y = active_skin;
233
			for (j=0; j
-
 
234
				if (streq(list.get(j), #previous_skin)) {
-
 
235
					active_skin = j;
220
				select_list.count++;
236
					break;
-
 
237
				}
221
				list.add(#default_skin);
238
			}
222
				BREAK;
239
		}
223
		CASE TAB_WALLPAPERS: 
-
 
224
				select_list.cur_y = active_wallpaper; 
240
		select_list.cur_y = active_skin;
225
				select_list.count++;
241
	} else { 
226
				list.add(#default_wallp);
242
		select_list.count++;
227
				BREAK;
-
 
228
		CASE TAB_SCREENSAVERS: 
243
		list.add(#default_wallp);
229
				select_list.cur_y = active_screensaver;
244
		add_filesnames_into_the_list();
230
	}
245
		if (active_wallpaper==-1) && (ESBYTE[#previous_wallp]=='\\') 
231
 
246
		{
-
 
247
			for (j=0; j
-
 
248
				if (streq(list.get(j), #previous_wallp+4)) {
-
 
249
					active_wallpaper = j;
-
 
250
					break;
232
	for (j=0; j
251
				}
Line 233... Line 252...
233
		miniprintf(#param,"%s/",#folder_path);
252
			}
-
 
253
		}
234
		strcat(#param, io.dir.position(files_mas[j]));
254
		select_list.cur_y = active_wallpaper; 
-
 
255
	}
235
		list.add(#param);
256
 
236
	}
257
	if (!select_list.count) notify(T_NO_FILES);
237
 
258
	if (select_list.cur_y>SL_VISIBLE) {
Line 238... Line -...
238
	if (!select_list.count) notify(T_NO_FILES);
-
 
239
	if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; 
-
 
240
	select_list.CheckDoesValuesOkey();	
-
 
241
	if (LIST_W) draw_window();
-
 
242
}
-
 
243
 
-
 
244
void Sort_by_Name(int a, b) // for the first call: a = 0, b = sizeof(mas) - 1
-
 
245
{                                        
-
 
246
	int j;
-
 
247
	int isn = a;
-
 
248
	if (a >= b) return;
-
 
249
	for (j = a; j <= b; j++) {
-
 
250
		if (strcmpi(io.dir.position(files_mas[j]), io.dir.position(files_mas[b]))<=0) { 
-
 
251
			files_mas[isn] >< files_mas[j]; 
-
 
252
			isn++;
-
 
253
		}
259
		select_list.first = -SL_VISIBLE/2 + select_list.cur_y; 
254
	}
260
	}
255
	Sort_by_Name(a, isn-2);
261
	select_list.CheckDoesValuesOkey();	
256
	Sort_by_Name(isn, b);
262
	if (LIST_W) draw_window();
257
}
263
}
258
 
264
 
259
void SelectList_DrawLine(dword i)
265
void SelectList_DrawLine(dword i)
260
{
266
{
Line 261... Line 267...
261
	int draw_y = i*SELECT_LIST_ITEMH+PANEL_H;
267
	int draw_y = i*SELECT_LIST_ITEMH+PANEL_H;
262
	int i_abs = select_list.first + i;
268
	int i_abs = select_list.first + i;
263
	dword text_color = 0xFFFfff;
269
	dword text_color = 0xFFFfff;
Line 292... Line 298...
292
	}
298
	}
293
	DrawBar(select_list.x, draw_y, LIST_W, SELECT_LIST_ITEMH, text_color);
299
	DrawBar(select_list.x, draw_y, LIST_W, SELECT_LIST_ITEMH, text_color);
294
	WriteText(select_list.x+12,draw_y+select_list.text_y,select_list.font_type,bg_color, filename);
300
	WriteText(select_list.x+12,draw_y+select_list.text_y,select_list.font_type,bg_color, filename);
295
}
301
}
Line 296... Line -...
296
 
-
 
297
void SelectList_LineChanged() 
-
 
298
{
-
 
299
	EventApply();
-
 
Line 300... Line -...
300
}
-
 
301
 
-
 
302
dword GetRealKolibriosPath()
-
 
303
{
-
 
304
	char real_kolibrios_path[4096];
-
 
305
	if (!dir_exists("/kolibrios")) return 0;
-
 
306
	SetCurDir("/kolibrios");
-
 
307
	GetCurDir(#real_kolibrios_path, sizeof(real_kolibrios_path));
-
 
Line 308... Line 302...
308
	return #real_kolibrios_path;
302
 
309
}
303
 
310
 
-
 
311
void GetIniSettings()
-
 
312
{
-
 
313
	ini.section = "screensaver";
304
 
314
	ss_timeout.position = ini.GetInt("timeout", 10) - 1;
305
void GetIniSettings()
315
	ini.GetString("available", #ss_available, sizeof(ss_available), 0);
306
{
-
 
307
	ini.section = "style";
-
 
308
	ini.GetString("default_skin", #default_skin, PATHLEN, 0);
-
 
309
	ini.GetString("default_wallp", #default_wallp, PATHLEN, 0);
-
 
310
	ini.GetString("skin", #previous_skin, PATHLEN, 0);
-
 
311
	ini.GetString("bg_param", #previous_wallp, PATHLEN, 0);
-
 
312
 
-
 
313
	ini.section = "screensaver";
316
	ini.section = "style";
314
	ss_timeout.position = ini.GetInt("timeout", 10) - 1;
Line 317... Line 315...
317
	ini.GetString("default_skin", #default_skin, PATHLEN, 0);
315
	ini.GetString("available", #ss_available, sizeof(ss_available), 0);
318
	ini.GetString("default_wallp", #default_wallp, PATHLEN, 0);
316
	ini.GetString("program", #previous_ss, PATHLEN, 0);
319
}
317
}
320
 
318
 
321
//===================================================//
319
//===================================================//
Line 322... Line 320...
322
//                                                   //
320
//                                                   //
323
//                     EVENTS                        //
321
//                     EVENTS                        //
324
//                                                   //
322
//                                                   //
325
//===================================================//
323
//===================================================//
326
 
324
 
Line 327... Line 325...
327
void EventTabSkinsClick()
325
void EventTabSkinsClick()
328
{
326
{
329
	miniprintf(#folder_path, "%s/res/skins", GetRealKolibriosPath());
327
	miniprintf(#folder_path, "%s/res/skins", get_real_kolibrios_path());
330
	Open_Dir();
328
	Open_Dir();
331
}
329
}
332
 
330
 
333
void EventTabWallpappersClick()
331
void EventTabWallpappersClick()
334
{
332
{
335
	if (opendir_path) {
333
	if (opendir_path) {
Line 336... Line 334...
336
		strcpy(#folder_path, #opendir_path);
334
		strcpy(#folder_path, #opendir_path);
Line 357... Line 355...
357
		list.add(#param);
355
		list.add(#param);
358
		ESBYTE[#ssmas + j - 1] = '\0';
356
		ESBYTE[#ssmas + j - 1] = '\0';
359
		select_list.count++;
357
		select_list.count++;
360
	} while (j);
358
	} while (j);
Line -... Line 359...
-
 
359
 
-
 
360
	if (active_screensaver == -1) && (ESBYTE[#previous_ss]) {
-
 
361
		for (j=0; j
-
 
362
			if (strstr(list.get(j), #previous_ss)) active_screensaver = j;
-
 
363
		}
-
 
364
	}
-
 
365
	select_list.cur_y = active_screensaver;
361
 
366
 
362
	if (LIST_W) draw_window();
367
	if (LIST_W) draw_window();
Line 363... Line 368...
363
}
368
}
364
 
369
 
Line 436... Line 441...
436
	}
441
	}
437
}
442
}
Line 438... Line 443...
438
 
443
 
439
void EventExit()
444
void EventExit()
440
{
445
{
441
	if (GetRealKolibriosPath()) {
446
	if (get_real_kolibrios_path()) && (ESBYTE[#cur_skin_path]) {
442
		ini.section = "style";
447
		ini.section = "style";
443
		ini.SetString("skin", #cur_skin_path, strlen(#cur_skin_path));
448
		ini.SetString("skin", #cur_skin_path, strlen(#cur_skin_path));
444
	}
449
	}
445
	ExitProcess();
450
	ExitProcess();
Line 455... Line 460...
455
}
460
}
Line 456... Line 461...
456
 
461
 
Line 457... Line 462...
457
stop:
462
stop:
-
 
463
 
458
 
464
char folder_path[PATHLEN];
459
char folder_path[PATHLEN];
465
 
-
 
466
char cur_file_path[PATHLEN];
460
char cur_file_path[PATHLEN];
467
char cur_skin_path[PATHLEN];
461
char cur_skin_path[PATHLEN];
468
 
462
char default_skin[PATHLEN];
469
char default_skin[PATHLEN];
-
 
470
char default_wallp[PATHLEN];
-
 
471
 
-
 
472
char previous_skin[PATHLEN];
-
 
473
char previous_wallp[PATHLEN];
463
char default_wallp[PATHLEN];
474
char previous_ss[PATHLEN];