Subversion Repositories Kolibri OS

Rev

Rev 9516 | Rev 9530 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9516 Rev 9524
1
//11.03.12 - start!
1
//11.03.12 - start!
2
//TODO: select current value at startap
-
 
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"
7
#include "../lib/io.h"
6
#include "../lib/io.h"
8
#include "../lib/list_box.h"
7
#include "../lib/list_box.h"
9
#include "../lib/gui.h"
8
#include "../lib/gui.h"
10
 
9
 
11
#include "../lib/obj/box_lib.h"
10
#include "../lib/obj/box_lib.h"
12
#include "../lib/obj/proc_lib.h"
11
#include "../lib/obj/proc_lib.h"
13
#include "../lib/obj/libini.h"
12
#include "../lib/obj/libini.h"
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"
17
#include "../lib/patterns/restart_process.h"
16
#include "../lib/patterns/restart_process.h"
-
 
17
 
-
 
18
dword fmas;
18
 
19
 
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
//                                                   //
24
//                       DATA                        //
25
//                       DATA                        //
25
//                                                   //
26
//                                                   //
26
//===================================================//
27
//===================================================//
27
 
28
 
28
int active_skin, active_wallpaper, active_screensaver;
29
int active_skin=-1, active_wallpaper=-1, active_screensaver=-1;
29
 
30
 
30
checkbox update_docky = { T_UPDATE_DOCK, false };
31
checkbox update_docky = { T_UPDATE_DOCK, false };
31
 
32
 
32
checkbox optionbox_stretch = { T_CHECKBOX_STRETCH, false };
33
checkbox optionbox_stretch = { T_CHECKBOX_STRETCH, false };
33
checkbox optionbox_tiled = { T_CHECKBOX_TILED, false };
34
checkbox optionbox_tiled = { T_CHECKBOX_TILED, false };
34
checkbox optionbox_auto = { T_CHECKBOX_AUTO, true };
35
checkbox optionbox_auto = { T_CHECKBOX_AUTO, true };
35
 
36
 
36
char ss_available[200];
37
char ss_available[200];
37
 
38
 
38
collection list;
39
collection list;
-
 
40
 
39
 
41
 
40
//===================================================//
42
//===================================================//
41
//                                                   //
43
//                                                   //
42
//                       CODE                        //
44
//                       CODE                        //
43
//                                                   //
45
//                                                   //
44
//===================================================//
46
//===================================================//
45
 
47
 
46
void main()
48
void main()
47
{   
49
{   
48
	int id, i;
50
	int id, i;
49
	load_dll(boxlib, #box_lib_init,0);
51
	load_dll(boxlib, #box_lib_init,0);
50
	load_dll(libini, #lib_init,1);
52
	load_dll(libini, #lib_init,1);
51
	load_dll(Proc_lib, #OpenDialog_init,0);
53
	load_dll(Proc_lib, #OpenDialog_init,0);
52
	OpenDialog_init stdcall (#o_dialog);
54
	OpenDialog_init stdcall (#o_dialog);
53
 
55
 
54
	GetIniSettings();
56
	GetIniSettings();
55
 
57
 
56
	tabs.add(#t_skins, #EventTabSkinsClick);	
58
	tabs.add(#t_skins, #EventTabSkinsClick);	
57
	tabs.add(#t_wallpapers, #EventTabWallpappersClick);
59
	tabs.add(#t_wallpapers, #EventTabWallpappersClick);
58
	tabs.add(#t_screensaver, #EventTabScreensaverClick);
60
	tabs.add(#t_screensaver, #EventTabScreensaverClick);
59
	tabs.draw_active_tab();
61
	tabs.draw_active_tab();
60
 
62
 
61
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
63
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
62
	loop() switch(WaitEvent()) 
64
	loop() switch(WaitEvent()) 
63
	{
65
	{
64
	  	case evMouse:
66
	  	case evMouse:
65
			SelectList_ProcessMouse();
67
			SelectList_ProcessMouse();
66
			if (tabs.active_tab == TAB_SCREENSAVERS) {
68
			if (tabs.active_tab == TAB_SCREENSAVERS) {
67
				scrollbar_h_mouse stdcall (#ss_timeout);
69
				scrollbar_h_mouse stdcall (#ss_timeout);
68
				if (ss_timeout.redraw) {
70
				if (ss_timeout.redraw) {
69
					draw_timeout();
71
					draw_timeout();
70
					ss_timeout.redraw = false; //reset flag
72
					ss_timeout.redraw = false; //reset flag
71
				}
73
				}
72
			}
74
			}
73
	  		break;
75
	  		break;
74
 
76
 
75
		case evButton:
77
		case evButton:
76
			id=GetButtonID();
78
			id=GetButtonID();
77
			if (id==1) EventExit();
79
			if (id==1) EventExit();
78
			tabs.click(id);
80
			tabs.click(id);
79
			if (tabs.active_tab == TAB_SKINS) {
81
			if (tabs.active_tab == TAB_SKINS) {
80
				checkbox1.click(id);
82
				checkbox1.click(id);
81
				spinbox1.click(id);
83
				spinbox1.click(id);
82
				if (update_docky.click(id)) EventUpdateDocky();
84
				if (update_docky.click(id)) EventUpdateDocky();
83
			}
85
			}
84
			if (tabs.active_tab == TAB_WALLPAPERS) {
86
			if (tabs.active_tab == TAB_WALLPAPERS) {
85
				if (id==BTN_SELECT_WALLP_FOLDER) EventSelectWallpFolder();
87
				if (id==BTN_SELECT_WALLP_FOLDER) EventSelectWallpFolder();
86
				if (optionbox_stretch.click(id)) EventSetWallpMode(1,0,0);
88
				if (optionbox_stretch.click(id)) EventSetWallpMode(1,0,0);
87
				if (optionbox_tiled.click(id)) EventSetWallpMode(0,1,0);
89
				if (optionbox_tiled.click(id)) EventSetWallpMode(0,1,0);
88
				if (optionbox_auto.click(id)) EventSetWallpMode(0,0,1);
90
				if (optionbox_auto.click(id)) EventSetWallpMode(0,0,1);
89
			}
91
			}
90
			if (tabs.active_tab == TAB_SCREENSAVERS) {
92
			if (tabs.active_tab == TAB_SCREENSAVERS) {
91
				if (id==BTN_TEST_SCREENSAVER) EventOpenFile();
93
				if (id==BTN_TEST_SCREENSAVER) EventOpenFile();
92
				if (id==BTN_SET_SCREENSAVER) EventSetSs();
94
				if (id==BTN_SET_SCREENSAVER) EventSetSs();
93
			}
95
			}
94
			break;
96
			break;
95
	  
97
	  
96
		case evKey:
98
		case evKey:
97
			GetKeys(); 
99
			GetKeys(); 
98
			if (select_list.ProcessKey(key_scancode)) { EventApply(); break; }
100
			if (select_list.ProcessKey(key_scancode)) { EventApply(); break; }
99
			if (key_scancode==SCAN_CODE_ENTER) { EventOpenFile(); break; }
101
			if (key_scancode==SCAN_CODE_ENTER) { EventOpenFile(); break; }
100
			if (key_scancode==SCAN_CODE_DEL) { EventDeleteFile(); break; }
102
			if (key_scancode==SCAN_CODE_DEL) { EventDeleteFile(); break; }
101
			if (key_scancode==SCAN_CODE_TAB) {
103
			if (key_scancode==SCAN_CODE_TAB) {
102
				id = tabs.active_tab+1; 
104
				id = tabs.active_tab+1; 
103
				if(id==3)id=0;
105
				if(id==3)id=0;
104
				tabs.click(id + tabs.base_id);
106
				tabs.click(id + tabs.base_id);
105
				break;
107
				break;
106
			}
108
			}
107
			for (i=select_list.cur_y+1; i
109
			for (i=select_list.cur_y+1; i
108
			{
110
			{
109
				id = list.get(i) + strrchr(list.get(i), '/');
111
				id = list.get(i) + strrchr(list.get(i), '/');
110
				if (ESBYTE[id]==key_ascii) || (ESBYTE[id]==key_ascii-32)
112
				if (ESBYTE[id]==key_ascii) || (ESBYTE[id]==key_ascii-32)
111
				{
113
				{
112
					select_list.cur_y = i - 1;
114
					select_list.cur_y = i - 1;
113
					select_list.KeyDown();
115
					select_list.KeyDown();
114
					EventApply();
116
					EventApply();
115
					break;
117
					break;
116
				}
118
				}
117
			}
119
			}
118
			break;
120
			break;
119
		 
121
		 
120
		 case evReDraw:		
122
		 case evReDraw:		
121
			draw_window();
123
			draw_window();
122
   }
124
   }
123
}
125
}
124
 
126
 
125
void draw_window()
127
void draw_window()
126
{
128
{
127
	sc.get();
129
	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);
130
	DefineAndDrawWindow(screen.width-WIN_W-9/2,80,WIN_W+9,WIN_H+4+skin_height,0x34,sc.work,WINDOW_HEADER,0);
129
 
131
 
130
	tabs.draw();
132
	tabs.draw();
131
	draw_icon_16w(tabs.x + TAB_P, LP+5, 17);
133
	draw_icon_16w(tabs.x + TAB_P, LP+5, 17);
132
	draw_icon_16w(sizeof(t_skins)-1*8 + TAB_P + TAB_P + tabs.x, LP+5, 6);
134
	draw_icon_16w(sizeof(t_skins)-1*8 + TAB_P + TAB_P + tabs.x, LP+5, 6);
133
	draw_icon_16w(sizeof(t_wallpapers)+sizeof(t_skins)-2*8 + TAB_P + TAB_P + TAB_P + tabs.x, LP+5, 61);
135
	draw_icon_16w(sizeof(t_wallpapers)+sizeof(t_skins)-2*8 + TAB_P + TAB_P + TAB_P + tabs.x, LP+5, 61);
134
 
136
 
135
	$push select_list.cur_y
137
	$push select_list.cur_y
136
	SelectList_Init(
138
	SelectList_Init(
137
		LP,
139
		LP,
138
		PANEL_H, 
140
		PANEL_H, 
139
		LIST_W, 
141
		LIST_W, 
140
		WIN_H - LP - PANEL_H
142
		WIN_H - LP - PANEL_H
141
		);
143
		);
142
	$pop select_list.cur_y
144
	$pop select_list.cur_y
143
 
145
 
144
	DrawBar(RIGHTx, PANEL_H, RIGHTw, WIN_H-PANEL_H-LP, sc.work);
146
	DrawBar(RIGHTx, PANEL_H, RIGHTw, WIN_H-PANEL_H-LP, sc.work);
145
 
147
 
146
	SelectList_Draw();
148
	SelectList_Draw();
147
	SelectList_DrawBorder();
149
	SelectList_DrawBorder();
148
 
150
 
149
	if (tabs.active_tab == TAB_SKINS)
151
	if (tabs.active_tab == TAB_SKINS)
150
	{
152
	{
151
		DrawFrame(RIGHTx, PANEL_H+5, RIGHTw, RIGHTh, T_UI_PREVIEW);
153
		DrawFrame(RIGHTx, PANEL_H+5, RIGHTw, RIGHTh, T_UI_PREVIEW);
152
		DrawUiElementsPreview(RIGHTx+20, PANEL_H+5, RIGHTh);
154
		DrawUiElementsPreview(RIGHTx+20, PANEL_H+5, RIGHTh);
153
		if (CheckProcessExists("@DOCKY")) update_docky.draw(RIGHTx, PANEL_H+250);
155
		if (CheckProcessExists("@DOCKY")) update_docky.draw(RIGHTx, PANEL_H+250);
154
	}
156
	}
155
	if (tabs.active_tab == TAB_WALLPAPERS)
157
	if (tabs.active_tab == TAB_WALLPAPERS)
156
	{
158
	{
157
		DrawFrame(RIGHTx, PANEL_H+5, 180, 105, T_PICTURE_MODE);
159
		DrawFrame(RIGHTx, PANEL_H+5, 180, 105, T_PICTURE_MODE);
158
		optionbox_stretch.draw(RIGHTx+14, PANEL_H+25);
160
		optionbox_stretch.draw(RIGHTx+14, PANEL_H+25);
159
		optionbox_tiled.draw(RIGHTx+14, PANEL_H+52);
161
		optionbox_tiled.draw(RIGHTx+14, PANEL_H+52);
160
		optionbox_auto.draw(RIGHTx+14, PANEL_H+79);
162
		optionbox_auto.draw(RIGHTx+14, PANEL_H+79);
161
		DrawStandartCaptButton(RIGHTx, PANEL_H+130, BTN_SELECT_WALLP_FOLDER, T_SELECT_FOLDER);
163
		DrawStandartCaptButton(RIGHTx, PANEL_H+130, BTN_SELECT_WALLP_FOLDER, T_SELECT_FOLDER);
162
	}
164
	}
163
	if (tabs.active_tab == TAB_SCREENSAVERS)
165
	if (tabs.active_tab == TAB_SCREENSAVERS)
164
	{
166
	{
165
		draw_timeout();
167
		draw_timeout();
166
		ss_timeout.line_col = sc.work_graph;
168
		ss_timeout.line_col = sc.work_graph;
167
		ss_timeout.frnt_col = sc.work;
169
		ss_timeout.frnt_col = sc.work;
168
		scrollbar_h_draw stdcall (#ss_timeout);
170
		scrollbar_h_draw stdcall (#ss_timeout);
169
		DrawRectangle(RIGHTx, RIGHTy+25, RIGHTw-20, 15, sc.work_graph);
171
		DrawRectangle(RIGHTx, RIGHTy+25, RIGHTw-20, 15, sc.work_graph);
170
		ESI = DrawStandartCaptButton(RIGHTx, PANEL_H + 65, BTN_TEST_SCREENSAVER, T_SS_PREVIEW);
172
		ESI = DrawStandartCaptButton(RIGHTx, PANEL_H + 65, BTN_TEST_SCREENSAVER, T_SS_PREVIEW);
171
		DrawStandartCaptButton(RIGHTx+ESI, PANEL_H + 65, BTN_SET_SCREENSAVER, T_SS_SET);
173
		DrawStandartCaptButton(RIGHTx+ESI, PANEL_H + 65, BTN_SET_SCREENSAVER, T_SS_SET);
172
	}
174
	}
173
}
175
}
174
 
176
 
175
void draw_timeout()
177
void draw_timeout()
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
}
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
	}
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;
190
	char fname[4096];
196
	dword ext;
191
	select_list.ClearList();
197
	select_list.ClearList();
-
 
198
 
192
	if(io.dir.buffer)free(io.dir.buffer);
199
	if (io.dir.buffer) free(io.dir.buffer);
193
	io.dir.load(#folder_path,DIR_ONLYREAL);
200
	io.dir.load(#folder_path,DIR_ONLYREAL);
-
 
201
 
-
 
202
	if (fmas) free(fmas);
-
 
203
	fmas = malloc(io.dir.count * 4);
194
 
204
 
195
	for (j=0; j
205
	for (j=0; j
196
	{
206
	{
197
		strcpy(#fname, io.dir.position(j));
207
		strncpy(#param, io.dir.position(j), PATHLEN);
-
 
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
		}
212
		}
202
		if (tabs.active_tab==TAB_WALLPAPERS) {
213
		if (tabs.active_tab==TAB_WALLPAPERS) {
203
			if (strreqi(#fname,"png")!=0)
-
 
204
			&& (strreqi(#fname,"jpg")!=0) 
214
			if (!streq(ext,"png")) && (!streq(ext,"jpg")) 
205
			&& (strreqi(#fname,"jpeg")!=0)
-
 
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;
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
224
	//save current item for tab change
216
	//add default item
225
	//add default item
217
	switch(tabs.active_tab) {
226
	if(tabs.active_tab == TAB_SKINS) 
218
		CASE TAB_SKINS: 
227
	{
219
				select_list.cur_y = active_skin;
-
 
220
				select_list.count++;
228
		select_list.count++;
221
				list.add(#default_skin);
229
		list.add(#default_skin);
-
 
230
		add_filesnames_into_the_list();
-
 
231
		if (active_skin==-1) && (ESBYTE[#previous_skin]) 
-
 
232
		{
-
 
233
			for (j=0; j
-
 
234
				if (streq(list.get(j), #previous_skin)) {
-
 
235
					active_skin = j;
222
				BREAK;
236
					break;
223
		CASE TAB_WALLPAPERS: 
237
				}
-
 
238
			}
-
 
239
		}
224
				select_list.cur_y = active_wallpaper; 
240
		select_list.cur_y = active_skin;
-
 
241
	} else { 
225
				select_list.count++;
242
		select_list.count++;
226
				list.add(#default_wallp);
243
		list.add(#default_wallp);
227
				BREAK;
-
 
228
		CASE TAB_SCREENSAVERS: 
244
		add_filesnames_into_the_list();
229
				select_list.cur_y = active_screensaver;
245
		if (active_wallpaper==-1) && (ESBYTE[#previous_wallp]=='\\') 
230
	}
246
		{
231
 
-
 
232
	for (j=0; j
247
			for (j=0; j
233
		miniprintf(#param,"%s/",#folder_path);
248
				if (streq(list.get(j), #previous_wallp+4)) {
234
		strcat(#param, io.dir.position(files_mas[j]));
249
					active_wallpaper = j;
235
		list.add(#param);
250
					break;
-
 
251
				}
-
 
252
			}
-
 
253
		}
-
 
254
		select_list.cur_y = active_wallpaper; 
236
	}
255
	}
237
 
256
 
238
	if (!select_list.count) notify(T_NO_FILES);
257
	if (!select_list.count) notify(T_NO_FILES);
-
 
258
	if (select_list.cur_y>SL_VISIBLE) {
239
	if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; 
259
		select_list.first = -SL_VISIBLE/2 + select_list.cur_y; 
-
 
260
	}
240
	select_list.CheckDoesValuesOkey();	
261
	select_list.CheckDoesValuesOkey();	
241
	if (LIST_W) draw_window();
262
	if (LIST_W) draw_window();
242
}
263
}
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
		}
-
 
254
	}
-
 
255
	Sort_by_Name(a, isn-2);
-
 
256
	Sort_by_Name(isn, b);
-
 
257
}
-
 
258
 
264
 
259
void SelectList_DrawLine(dword i)
265
void SelectList_DrawLine(dword i)
260
{
266
{
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;
264
	dword bg_color = 0x000000;
270
	dword bg_color = 0x000000;
265
	char filename_buf[4096];
271
	char filename_buf[PATHLEN];
266
	char* filename = #filename_buf;
272
	char* filename = #filename_buf;
267
 
273
 
268
	strcpy(filename, list.get(i_abs));
274
	strcpy(filename, list.get(i_abs));
269
	if (EAX = strrchr(filename,'/')) filename += EAX;
275
	if (EAX = strrchr(filename,'/')) filename += EAX;
270
	if (ESBYTE[filename]=='T') && (ESBYTE[filename+1]=='_') filename+=2;
276
	if (ESBYTE[filename]=='T') && (ESBYTE[filename+1]=='_') filename+=2;
271
	EAX = math.min(strrchr(filename,'.')-1, LIST_W - 24 / 8);
277
	EAX = math.min(strrchr(filename,'.')-1, LIST_W - 24 / 8);
272
	if(EAX) ESBYTE[filename+EAX] = '\0';
278
	if(EAX) ESBYTE[filename+EAX] = '\0';
273
 
279
 
274
	//save current item for tab change
280
	//save current item for tab change
275
	switch(tabs.active_tab) {
281
	switch(tabs.active_tab) {
276
		CASE TAB_SKINS: 
282
		CASE TAB_SKINS: 
277
				active_skin = select_list.cur_y;
283
				active_skin = select_list.cur_y;
278
				if (!i_abs) filename = T_DEFAULT;
284
				if (!i_abs) filename = T_DEFAULT;
279
				BREAK;
285
				BREAK;
280
		CASE TAB_WALLPAPERS: 
286
		CASE TAB_WALLPAPERS: 
281
				active_wallpaper = select_list.cur_y; 
287
				active_wallpaper = select_list.cur_y; 
282
				if (!i_abs) filename = T_DEFAULT;
288
				if (!i_abs) filename = T_DEFAULT;
283
				BREAK;
289
				BREAK;
284
		CASE TAB_SCREENSAVERS: 
290
		CASE TAB_SCREENSAVERS: 
285
				active_screensaver = select_list.cur_y;
291
				active_screensaver = select_list.cur_y;
286
				if (!i_abs) filename = T_NO_SS;
292
				if (!i_abs) filename = T_NO_SS;
287
	}
293
	}
288
	
294
	
289
	if (select_list.cur_y == i_abs) {
295
	if (select_list.cur_y == i_abs) {
290
		text_color = sc.button;
296
		text_color = sc.button;
291
		bg_color = sc.button_text;
297
		bg_color = sc.button_text;
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
}
296
 
-
 
297
void SelectList_LineChanged() 
-
 
298
{
-
 
299
	EventApply();
-
 
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));
-
 
308
	return #real_kolibrios_path;
302
 
309
}
303
 
310
 
304
 
311
void GetIniSettings()
305
void GetIniSettings()
312
{
306
{
313
	ini.section = "screensaver";
-
 
314
	ss_timeout.position = ini.GetInt("timeout", 10) - 1;
-
 
315
	ini.GetString("available", #ss_available, sizeof(ss_available), 0);
-
 
316
	ini.section = "style";
307
	ini.section = "style";
317
	ini.GetString("default_skin", #default_skin, PATHLEN, 0);
308
	ini.GetString("default_skin", #default_skin, PATHLEN, 0);
318
	ini.GetString("default_wallp", #default_wallp, 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";
-
 
314
	ss_timeout.position = ini.GetInt("timeout", 10) - 1;
-
 
315
	ini.GetString("available", #ss_available, sizeof(ss_available), 0);
-
 
316
	ini.GetString("program", #previous_ss, PATHLEN, 0);
319
}
317
}
320
 
318
 
321
//===================================================//
319
//===================================================//
322
//                                                   //
320
//                                                   //
323
//                     EVENTS                        //
321
//                     EVENTS                        //
324
//                                                   //
322
//                                                   //
325
//===================================================//
323
//===================================================//
326
 
324
 
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) {
336
		strcpy(#folder_path, #opendir_path);
334
		strcpy(#folder_path, #opendir_path);
337
	} else {
335
	} else {
338
		miniprintf(#folder_path, "%s/res/wallpapers", GetRealKolibriosPath());
336
		miniprintf(#folder_path, "%s/res/wallpapers", get_real_kolibrios_path());
339
	}
337
	}
340
	Open_Dir();
338
	Open_Dir();
341
}
339
}
342
 
340
 
343
void EventTabScreensaverClick()
341
void EventTabScreensaverClick()
344
{
342
{
345
	dword j;
343
	dword j;
346
	char ssmas[sizeof(ss_available)];
344
	char ssmas[sizeof(ss_available)];
347
	list.drop();
345
	list.drop();
348
	select_list.ClearList();
346
	select_list.ClearList();
349
 
347
 
350
	select_list.count++;
348
	select_list.count++;
351
	list.add("");
349
	list.add("");
352
 
350
 
353
	strcpy(#ssmas, #ss_available);
351
	strcpy(#ssmas, #ss_available);
354
	do {
352
	do {
355
		j = strrchr(#ssmas, '|');
353
		j = strrchr(#ssmas, '|');
356
		miniprintf(#param, "/sys/%s", #ssmas + j);
354
		miniprintf(#param, "/sys/%s", #ssmas + j);
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);
-
 
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();
363
}
368
}
364
 
369
 
365
void EventDeleteFile()
370
void EventDeleteFile()
366
{
371
{
367
	if (select_list.cur_y) DeleteFile(#cur_file_path); //no not delete default
372
	if (select_list.cur_y) DeleteFile(#cur_file_path); //no not delete default
368
	Open_Dir();
373
	Open_Dir();
369
	EventApply();
374
	EventApply();
370
}
375
}
371
 
376
 
372
void EventSelectWallpFolder()
377
void EventSelectWallpFolder()
373
{
378
{
374
	o_dialog.type = 2; //select folder
379
	o_dialog.type = 2; //select folder
375
	OpenDialog_start stdcall (#o_dialog);
380
	OpenDialog_start stdcall (#o_dialog);
376
	if (o_dialog.status) EventTabWallpappersClick();
381
	if (o_dialog.status) EventTabWallpappersClick();
377
}
382
}
378
 
383
 
379
void EventSetWallpMode(dword _stretch, _titled, _auto)
384
void EventSetWallpMode(dword _stretch, _titled, _auto)
380
{
385
{
381
	optionbox_stretch.checked = _stretch;
386
	optionbox_stretch.checked = _stretch;
382
	optionbox_tiled.checked = _titled;
387
	optionbox_tiled.checked = _titled;
383
	optionbox_auto.checked = _auto;
388
	optionbox_auto.checked = _auto;
384
	optionbox_tiled.redraw();
389
	optionbox_tiled.redraw();
385
	optionbox_stretch.redraw();
390
	optionbox_stretch.redraw();
386
	optionbox_auto.redraw();
391
	optionbox_auto.redraw();
387
	EventApply();
392
	EventApply();
388
}
393
}
389
 
394
 
390
void EventApply()
395
void EventApply()
391
{
396
{
392
	char kivparam[4096+10];
397
	char kivparam[4096+10];
393
	dword file_name = list.get(select_list.cur_y);
398
	dword file_name = list.get(select_list.cur_y);
394
	strcpy(#cur_file_path, list.get(select_list.cur_y));
399
	strcpy(#cur_file_path, list.get(select_list.cur_y));
395
	if (tabs.active_tab==TAB_SKINS)
400
	if (tabs.active_tab==TAB_SKINS)
396
	{
401
	{
397
		SetSystemSkin(#cur_file_path);
402
		SetSystemSkin(#cur_file_path);
398
		SelectList_Draw();
403
		SelectList_Draw();
399
		strcpy(#cur_skin_path, #cur_file_path);
404
		strcpy(#cur_skin_path, #cur_file_path);
400
		EventUpdateDocky();
405
		EventUpdateDocky();
401
	} 
406
	} 
402
	if (tabs.active_tab==TAB_WALLPAPERS)
407
	if (tabs.active_tab==TAB_WALLPAPERS)
403
	{
408
	{
404
		SelectList_Draw();
409
		SelectList_Draw();
405
		miniprintf(#kivparam, "\\S__%s", #cur_file_path);
410
		miniprintf(#kivparam, "\\S__%s", #cur_file_path);
406
		if (optionbox_tiled.checked) || (!select_list.cur_y) kivparam[1]='T';
411
		if (optionbox_tiled.checked) || (!select_list.cur_y) kivparam[1]='T';
407
		if (optionbox_auto.checked) {
412
		if (optionbox_auto.checked) {
408
			file_name += strrchr(file_name, '/');
413
			file_name += strrchr(file_name, '/');
409
			if (ESBYTE[file_name] == 'T') && (ESBYTE[file_name+1] == '_') {
414
			if (ESBYTE[file_name] == 'T') && (ESBYTE[file_name+1] == '_') {
410
				kivparam[1]='T';
415
				kivparam[1]='T';
411
			}
416
			}
412
		}
417
		}
413
		RunProgram("/sys/media/kiv", #kivparam);
418
		RunProgram("/sys/media/kiv", #kivparam);
414
	}
419
	}
415
	if (tabs.active_tab==TAB_SCREENSAVERS)
420
	if (tabs.active_tab==TAB_SCREENSAVERS)
416
	{
421
	{
417
		SelectList_Draw();
422
		SelectList_Draw();
418
	}
423
	}
419
}
424
}
420
 
425
 
421
void EventUpdateDocky()
426
void EventUpdateDocky()
422
{
427
{
423
	if (update_docky.checked) {
428
	if (update_docky.checked) {
424
		RestartProcessByName("/sys/@docky", MULTIPLE);
429
		RestartProcessByName("/sys/@docky", MULTIPLE);
425
		pause(50);
430
		pause(50);
426
		ActivateWindow_Self();		
431
		ActivateWindow_Self();		
427
	}
432
	}
428
}
433
}
429
 
434
 
430
void EventOpenFile()
435
void EventOpenFile()
431
{
436
{
432
	switch (tabs.active_tab) {
437
	switch (tabs.active_tab) {
433
		case TAB_SKINS: RunProgram("/sys/skincfg", #cur_file_path); break;
438
		case TAB_SKINS: RunProgram("/sys/skincfg", #cur_file_path); break;
434
		case TAB_WALLPAPERS: RunProgram("/sys/media/kiv", #cur_file_path); break;
439
		case TAB_WALLPAPERS: RunProgram("/sys/media/kiv", #cur_file_path); break;
435
		case TAB_SCREENSAVERS: if(select_list.cur_y) RunProgram(list.get(select_list.cur_y), "@ss");
440
		case TAB_SCREENSAVERS: if(select_list.cur_y) RunProgram(list.get(select_list.cur_y), "@ss");
436
	}
441
	}
437
}
442
}
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();
446
}
451
}
447
 
452
 
448
void EventSetSs()
453
void EventSetSs()
449
{
454
{
450
	dword cur_ss = list.get(select_list.cur_y);
455
	dword cur_ss = list.get(select_list.cur_y);
451
	ini.section = "screensaver";
456
	ini.section = "screensaver";
452
	ini.SetString("program", cur_ss, strlen(cur_ss));
457
	ini.SetString("program", cur_ss, strlen(cur_ss));
453
	ini.SetInt("timeout", ss_timeout.position+1);
458
	ini.SetInt("timeout", ss_timeout.position+1);
454
	RestartProcessByName("/sys/@ss", MULTIPLE);
459
	RestartProcessByName("/sys/@ss", MULTIPLE);
455
}
460
}
456
 
461
 
457
stop:
462
stop:
458
 
463
 
459
char folder_path[PATHLEN];
464
char folder_path[PATHLEN];
-
 
465
 
460
char cur_file_path[PATHLEN];
466
char cur_file_path[PATHLEN];
461
char cur_skin_path[PATHLEN];
467
char cur_skin_path[PATHLEN];
-
 
468
 
462
char default_skin[PATHLEN];
469
char default_skin[PATHLEN];
463
char default_wallp[PATHLEN];
470
char default_wallp[PATHLEN];
464
471
 
-
 
472
char previous_skin[PATHLEN];
-
 
473
char previous_wallp[PATHLEN];
-
 
474
char previous_ss[PATHLEN];
-
 
475
465
476