Subversion Repositories Kolibri OS

Rev

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

Rev 9455 Rev 9461
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];
-
 
37
char temp_filename[4096];
36
char cur_skin_path[4096];
Line 38... Line -...
38
int files_mas[400];
-
 
39
 
-
 
40
_ini ini = { "/sys/settings/system.ini" };
-
 
41
 
-
 
42
int cur;
-
 
43
 
-
 
44
proc_info Form;
-
 
45
block skp;
-
 
46
 
-
 
47
enum {SKINS, WALLPAPERS, SCREENSAVERS};
37
int files_mas[400];
48
 
38
 
Line 49... Line 39...
49
_tabs tabs = { -sizeof(t_skins)-sizeof(t_wallpapers)-sizeof(t_screensaver)-3*8+WIN_W
39
_tabs tabs = { -sizeof(t_skins)-sizeof(t_wallpapers)-sizeof(t_screensaver)-3*8+WIN_W
Line 50... Line -...
50
	 - TAB_PADDING / 2, LP, NULL, BASE_TAB_BUTTON_ID };
-
 
51
 
-
 
52
checkbox update_docky = { T_UPDATE_DOCK, false };
-
 
53
 
40
	 - TAB_PADDING / 2, LP, NULL, BASE_TAB_BUTTON_ID };
54
char default_dir[] = "/rd/1";
41
 
Line -... Line 42...
-
 
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
 
-
 
47
struct SCREENSAVER_SETTINGS {
55
od_filter filter2 = { 8, "TXT\0\0" };
48
	int timeout;
56
 
49
	char program[60];
57
checkbox optionbox_stretch = { T_CHECKBOX_STRETCH, true };
50
	char available[200];
58
checkbox optionbox_tiled = { T_CHECKBOX_TILED, false };
51
} ss_settings;
59
 
52
 
Line 60... Line 53...
60
//===================================================//
53
//===================================================//
61
//                                                   //
54
//                                                   //
62
//                       CODE                        //
55
//                       CODE                        //
63
//                                                   //
56
//                                                   //
64
//===================================================//
57
//===================================================//
65
 
58
 
66
void main()
59
void main()
67
{   
60
{   
Line 80... Line 73...
80
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
73
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
81
	loop() switch(WaitEvent()) 
74
	loop() switch(WaitEvent()) 
82
	{
75
	{
83
	  	case evMouse:
76
	  	case evMouse:
84
			SelectList_ProcessMouse();
77
			SelectList_ProcessMouse();
85
 
-
 
86
			if (tabs.active_tab == SKINS) {
-
 
87
				edit_box_mouse stdcall (#edit_cmm);
-
 
88
				edit_box_mouse stdcall (#edit_st);
-
 
89
			}
-
 
90
 
-
 
91
	  		if (mouse.key&MOUSE_RIGHT) && (mouse.up) 
-
 
92
	  		&&(select_list.MouseOver(mouse.x, mouse.y)) {
-
 
93
	  			select_list.ProcessMouse(mouse.x, mouse.y);
-
 
94
				SelectList_Draw();
-
 
95
				EventSetNewCurrent();
-
 
96
	  			open_lmenu(mouse.x, mouse.y, MENU_TOP_RIGHT, NULL, MENU_LIST);
-
 
97
	  		}
-
 
98
	  		break;
78
	  		break;
Line 99... Line 79...
99
 
79
 
100
		case evButton:
80
		case evButton:
101
			id=GetButtonID();
81
			id=GetButtonID();
Line 121... Line 101...
121
				DrawWindowContent();
101
				DrawWindowContent();
122
				break;
102
				break;
123
			}
103
			}
Line 124... Line 104...
124
 
104
 
125
			if (! edit_cmm.flags & ed_focus) && (! edit_st.flags & ed_focus)
105
			if (! edit_cmm.flags & ed_focus) && (! edit_st.flags & ed_focus)
126
			for (id=select_list.cur_y+1; id
106
			for (i=select_list.cur_y+1; i
127
			{
107
			{
128
				strcpy(#temp_filename, io.dir.position(files_mas[id]));
108
				id = ESBYTE[io.dir.position(files_mas[i])];
129
				if (temp_filename[0]==key_ascii) || (temp_filename[0]==key_ascii-32)
109
				if (id==ESBYTE[EAX]) || (id==key_ascii-32)
130
				{
110
				{
131
					select_list.cur_y = id - 1;
111
					select_list.cur_y = i - 1;
132
					select_list.KeyDown();
112
					select_list.KeyDown();
133
					EventApply();
113
					EventApply();
134
					break;
114
					break;
135
				}
115
				}
Line 136... Line 116...
136
			}
116
			}
137
 
117
 
138
			if (tabs.active_tab == SKINS) {
118
			if (tabs.active_tab == TAB_SKINS) {
139
				EAX = key_ascii << 8;
119
				EAX = key_editbox;
140
				edit_box_key stdcall (#edit_cmm);
120
				edit_box_key stdcall (#edit_cmm);
141
				edit_box_key stdcall (#edit_st);				
121
				edit_box_key stdcall (#edit_st);				
Line 142... Line 122...
142
			}
122
			}
143
			break;
123
			break;
144
		 
-
 
145
		 case evReDraw:		
124
		 
146
			draw_window();
125
		 case evReDraw:		
Line 147... Line 126...
147
	 		EventHandleMenuClick();
126
			draw_window();
148
   }
127
   }
149
}
128
}
150
 
129
 
151
void draw_window()
-
 
152
{
-
 
153
	sc.get();
130
void draw_window()
154
	DefineAndDrawWindow(screen.width-600/2,80,WIN_W+9,WIN_H+skin_height,0x34,sc.work,WINDOW_HEADER,0);
131
{
Line 155... Line 132...
155
	GetProcessInfo(#Form, SelfInfo);
132
	sc.get();
156
	IF (Form.status_window&ROLLED_UP) return;
133
	DefineAndDrawWindow(screen.width-WIN_W-9/2,80,WIN_W+9,WIN_H+4+skin_height,0x34,sc.work,WINDOW_HEADER,0);
157
	DrawWindowContent();
-
 
158
}
-
 
159
 
134
	DrawWindowContent();
Line 160... Line -...
160
void DrawWindowContent()
-
 
161
{
135
}
162
	int id;
136
 
163
 
137
void DrawWindowContent()
164
	sc.get();	
138
{
Line 165... Line 139...
165
 
139
	sc.get();	
166
	//tabs.w = Form.cwidth-LP-LP;
140
 
167
	tabs.draw();
141
	tabs.draw();
168
	draw_icon_16w(tabs.x + TAB_PADDING, LP+5, 17);
142
	draw_icon_16w(tabs.x + TAB_PADDING, LP+5, 17);
169
	draw_icon_16w(sizeof(t_skins)-1*8 + TAB_PADDING + TAB_PADDING + tabs.x, LP+5, 6);
143
	draw_icon_16w(sizeof(t_skins)-1*8 + TAB_PADDING + TAB_PADDING + tabs.x, LP+5, 6);
170
	draw_icon_16w(sizeof(t_wallpapers)+sizeof(t_skins)-2*8 + TAB_PADDING + TAB_PADDING + TAB_PADDING + tabs.x, LP+5, 61);
144
	draw_icon_16w(sizeof(t_wallpapers)+sizeof(t_skins)-2*8 + TAB_PADDING + TAB_PADDING + TAB_PADDING + tabs.x, LP+5, 61);
171
 
145
 
172
	id = select_list.cur_y;
146
	$push select_list.cur_y
Line 173... Line -...
173
	SelectList_Init(
-
 
174
		LP + TAB_PADDING,
-
 
175
		PANEL_H, 
-
 
176
		LIST_W, 
-
 
177
		Form.cheight-LP - TAB_PADDING - PANEL_H
-
 
178
		);
-
 
179
	select_list.cur_y = id;
147
	SelectList_Init(
Line 180... Line 148...
180
 
148
		LP + TAB_PADDING,
181
	skp.set_size(
149
		PANEL_H, 
Line 182... Line 150...
182
		LP + TAB_PADDING + LIST_W + TAB_PADDING + 30,
150
		LIST_W, 
183
		PANEL_H,
151
		WIN_H - LP - TAB_PADDING - PANEL_H
184
		226,
152
		);
185
		230 //select_list.h - 50 - 50
153
	$pop select_list.cur_y
186
	);
154
 
187
	DrawBar(skp.x, skp.y, skp.w, WIN_H, sc.work);
155
	DrawBar(RIGHTx, PANEL_H, RIGHTw, WIN_H-PANEL_H-LP, sc.work);
188
 
156
 
189
	SelectList_Draw();
157
	SelectList_Draw();
190
	SelectList_DrawBorder();
158
	SelectList_DrawBorder();
191
 
159
 
192
	if (tabs.active_tab == SKINS)
160
	if (tabs.active_tab == TAB_SKINS)
193
	{
161
	{
194
		DrawFrame(skp.x, PANEL_H+5, skp.w, skp.h, " Components Preview ");
162
		DrawFrame(RIGHTx, PANEL_H+5, RIGHTw, RIGHTh, T_UI_PREVIEW);
195
		DrawUiElementsPreview(skp.x+20, PANEL_H+5, skp.h);
163
		DrawUiElementsPreview(RIGHTx+20, PANEL_H+5, RIGHTh);
196
		if (CheckProcessExists("@DOCKY")) update_docky.draw(skp.x, PANEL_H+250);
164
		if (CheckProcessExists("@DOCKY")) update_docky.draw(RIGHTx, PANEL_H+250);
197
	}
165
	}
198
	if (tabs.active_tab == WALLPAPERS)
166
	if (tabs.active_tab == TAB_WALLPAPERS)
199
	{
167
	{
Line 200... Line 168...
200
		DrawFrame(skp.x, PANEL_H+5, 180, 80, T_PICTURE_MODE);
168
		DrawFrame(RIGHTx, PANEL_H+5, 180, 80, T_PICTURE_MODE);
201
		optionbox_stretch.draw(skp.x+14, PANEL_H+25);
169
		optionbox_stretch.draw(RIGHTx+14, PANEL_H+25);
202
		optionbox_tiled.draw(skp.x+14, PANEL_H+52);
170
		optionbox_tiled.draw(RIGHTx+14, PANEL_H+52);
203
		DrawStandartCaptButton(skp.x, PANEL_H+100, BTN_SELECT_WALLP_FOLDER, T_SELECT_FOLDER);
171
		DrawStandartCaptButton(RIGHTx, PANEL_H+100, BTN_SELECT_WALLP_FOLDER, T_SELECT_FOLDER);
Line 204... Line 172...
204
	}
172
	}
205
	if (tabs.active_tab == SCREENSAVERS)
173
	if (tabs.active_tab == TAB_SCREENSAVERS)
206
	{
174
	{
-
 
175
		DrawStandartCaptButton(RIGHTx, PANEL_H, BTN_TEST_SCREENSAVER, "Test");
207
		DrawStandartCaptButton(skp.x, PANEL_H, BTN_TEST_SCREENSAVER, "Test");
176
	}
208
	}
177
}
209
}
178
 
210
 
179
bool strreqi(dword _left, _right)
211
bool strreqi(dword _left, _right)
180
{
212
{
181
	return strcmp(_left+strrchr(_left,'.'), _right);
213
	return strcmpi(_left+strrchr(_left,'.')-1, _right);
182
}
214
}
183
 
215
 
184
void Open_Dir()
216
void Open_Dir()
185
{
217
{
186
	int j;
218
	int j;
187
	char temp_filename[4096];
219
	select_list.count = 0;
188
	select_list.count = 0;
220
	if(io.dir.buffer)free(io.dir.buffer);
189
	if(io.dir.buffer)free(io.dir.buffer);
-
 
190
	io.dir.load(#folder_path,DIR_ONLYREAL);
221
	io.dir.load(#folder_path,DIR_ONLYREAL);
191
	for (j=0; j
222
	for (j=0; j
192
	{
223
	{
193
		strcpy(#temp_filename, io.dir.position(j));
224
		strcpy(#temp_filename, io.dir.position(j));
-
 
225
		strlwr(#temp_filename);
194
		strlwr(#temp_filename);
226
		if (tabs.active_tab==SKINS) {
195
		if (tabs.active_tab==TAB_SKINS) {
227
			if (strreqi(#temp_filename,".skn")!=0) continue;
196
			if (strreqi(#temp_filename,"skn")!=0) continue;
228
		}
197
		}
Line 254... Line 223...
254
	Sort_by_Name(isn, b);
223
	Sort_by_Name(isn, b);
255
}
224
}
Line 256... Line 225...
256
 
225
 
257
void SelectList_DrawLine(dword i)
226
void SelectList_DrawLine(dword i)
-
 
227
{
-
 
228
	int draw_y = i*SELECT_LIST_ITEMH+PANEL_H;
258
{
229
	int i_abs = select_list.first + i;
259
	int yyy;
230
	char filename[4096];
260
 
-
 
261
	cur = select_list.first + i;
231
 
262
	strcpy(#temp_filename, io.dir.position(files_mas[cur]));
232
	strcpy(#filename, io.dir.position(files_mas[i_abs]));
263
	temp_filename[strlen(#temp_filename)-4] = 0;
233
	EAX = math.min(strrchr(#filename,'.')-1, LIST_W - 24 / 8);
Line 264... Line 234...
264
	yyy = i*select_list.item_h+select_list.y;
234
	filename[EAX] = '\0';
265
	
235
	
266
	if (select_list.cur_y-select_list.first==i)
236
	if (select_list.cur_y == i_abs)
267
	{
237
	{
268
		DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, sc.button);
238
		DrawBar(select_list.x, draw_y, LIST_W, SELECT_LIST_ITEMH, sc.button);
269
		WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,sc.button_text, #temp_filename);
239
		WriteText(select_list.x+12,draw_y+select_list.text_y,select_list.font_type,sc.button_text, #filename);
270
	}
240
	}
271
	else
241
	else
272
	{
242
	{
273
		DrawBar(select_list.x,yyy,select_list.w, select_list.item_h, 0xFFFfff);
243
		DrawBar(select_list.x,draw_y,LIST_W, SELECT_LIST_ITEMH, 0xFFFfff);
274
		WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,0, #temp_filename);
244
		WriteText(select_list.x+12,draw_y+select_list.text_y,select_list.font_type,0, #filename);
Line 275... Line 245...
275
	}
245
	}
276
}
246
}
Line 282... Line 252...
282
 
252
 
283
void ActivateTab(int _id)
253
void ActivateTab(int _id)
284
{
254
{
285
	select_list.ClearList();
255
	select_list.ClearList();
286
	Open_Dir();
256
	Open_Dir();
287
	if (!select_list.count) notify("'No files were found' -E");
257
	if (!select_list.count) notify(T_NO_FILES);
288
	select_list.cur_y = _id;
258
	select_list.cur_y = _id;
289
	if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; 
259
	if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; 
290
	select_list.CheckDoesValuesOkey();	
260
	select_list.CheckDoesValuesOkey();	
291
	if (select_list.w) DrawWindowContent();
261
	if (LIST_W) DrawWindowContent();
Line 292... Line 262...
292
}
262
}
293
 
263
 
294
dword GetRealKolibriosPath()
264
dword GetRealKolibriosPath()
Line 323... Line 293...
323
	ActivateTab(active_wallpaper);
293
	ActivateTab(active_wallpaper);
324
}
294
}
Line 325... Line 295...
325
 
295
 
326
void EventTabScreensaverClick()
296
void EventTabScreensaverClick()
-
 
297
{
327
{
298
	ini.section = "screensaver";
-
 
299
	ss_settings.timeout = ini.GetInt("timeout", 10);
-
 
300
	ini.GetString("title", #ss_settings.program, sizeof(ss_settings.program), 0);
328
	//strcpy(#folder_path, #wallp_folder_path);
301
	ini.GetString("available", #ss_settings.available, sizeof(ss_settings.available), 0);
329
	ActivateTab(active_screensaver);
302
	ActivateTab(active_screensaver);
Line 330... Line 303...
330
}
303
}
331
 
304
 
Line 336... Line 309...
336
	EventApply();
309
	EventApply();
337
}
310
}
Line 338... Line 311...
338
 
311
 
339
void EventSetNewCurrent()
312
void EventSetNewCurrent()
340
{
-
 
341
	cur = select_list.cur_y;
313
{
342
	miniprintf(#cur_file_path,"%s/",#folder_path);
314
	miniprintf(#cur_file_path,"%s/",#folder_path);
343
	strcat(#cur_file_path, io.dir.position(files_mas[cur]));
315
	strcat(#cur_file_path, io.dir.position(files_mas[calc(select_list.cur_y)]));
Line 344... Line 316...
344
}
316
}
345
 
317
 
346
void EventSelectWallpFolder()
318
void EventSelectWallpFolder()
Line 365... Line 337...
365
 
337
 
366
void EventApply()
338
void EventApply()
367
{
339
{
368
	char kivpath[4096+10];
340
	char kivpath[4096+10];
369
	EventSetNewCurrent();
341
	EventSetNewCurrent();
370
	if (tabs.active_tab==SKINS)
342
	if (tabs.active_tab==TAB_SKINS)
371
	{
-
 
372
		cur = select_list.cur_y;
343
	{
373
		SetSystemSkin(#cur_file_path);
344
		SetSystemSkin(#cur_file_path);
374
		SelectList_Draw();
345
		SelectList_Draw();
375
		strcpy(#cur_skin_path, #cur_file_path);
346
		strcpy(#cur_skin_path, #cur_file_path);
376
		EventUpdateDocky();
347
		EventUpdateDocky();
377
	} 
348
	} 
378
	if (tabs.active_tab==WALLPAPERS)
349
	if (tabs.active_tab==TAB_WALLPAPERS)
379
	{
350
	{
380
		SelectList_Draw();
351
		SelectList_Draw();
381
		if (optionbox_stretch.checked) miniprintf(#kivpath, "\\S__%s", #cur_file_path);
352
		if (optionbox_stretch.checked) miniprintf(#kivpath, "\\S__%s", #cur_file_path);
382
		if (optionbox_tiled.checked) miniprintf(#kivpath, "\\T__%s", #cur_file_path);
353
		if (optionbox_tiled.checked) miniprintf(#kivpath, "\\T__%s", #cur_file_path);
Line 388... Line 359...
388
{
359
{
389
	if (!update_docky.checked) return;
360
	if (!update_docky.checked) return;
390
	KillProcessByName("@docky", MULTIPLE);
361
	KillProcessByName("@docky", MULTIPLE);
391
	RunProgram("/sys/@docky",NULL);
362
	RunProgram("/sys/@docky",NULL);
392
	pause(50);
363
	pause(50);
393
	ActivateWindow(GetProcessSlot(Form.ID));
364
	ActivateWindow_Self();
394
}
365
}
Line 395... Line 366...
395
 
366
 
396
void EventOpenFile()
367
void EventOpenFile()
397
{
368
{
398
	if (tabs.active_tab==SKINS) RunProgram("/sys/skincfg", #cur_file_path);
369
	if (tabs.active_tab==TAB_SKINS) RunProgram("/sys/skincfg", #cur_file_path);
399
	if (tabs.active_tab==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path);
370
	if (tabs.active_tab==TAB_WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path);
Line 400... Line 371...
400
}
371
}
401
 
372
 
402
void EventExit()
373
void EventExit()
Line 406... Line 377...
406
		ini.SetString("skin", #cur_skin_path, strlen(#cur_skin_path));
377
		ini.SetString("skin", #cur_skin_path, strlen(#cur_skin_path));
407
	}
378
	}
408
	ExitProcess();
379
	ExitProcess();
409
}
380
}
Line 410... Line -...
410
 
-
 
411
void EventHandleMenuClick()
-
 
412
{
-
 
413
	switch (get_menu_click()) 
-
 
414
	{
-
 
415
		case 1: 
-
 
416
			EventOpenFile(); 
-
 
417
			break;
-
 
418
		case 2: 
-
 
419
			EventDeleteFile();
-
 
420
			break;
-
 
421
	};
-
 
422
}
-
 
423
 
381