Subversion Repositories Kolibri OS

Rev

Rev 8946 | Rev 9444 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5472 leency 1
#define MEMSIZE 0x23E80
2
#include "..\lib\kolibri.h"
3
#include "..\lib\strings.h"
4
#include "..\lib\mem.h"
7219 leency 5
#include "..\lib\fs.h"
5472 leency 6
#include "..\lib\dll.h"
5499 leency 7
#include "..\lib\gui.h"
5472 leency 8
 
5499 leency 9
#include "..\lib\obj\libini.h"
10
#include "..\lib\obj\box_lib.h"
5472 leency 11
 
5548 leency 12
#include "..\lib\patterns\restart_process.h"
5472 leency 13
 
5504 punk_joker 14
#ifdef LANG_RUS
5506 punk_joker 15
	?define WINDOW_TITLE "Настройки панели задач и Дока"
7636 leency 16
    ?define TASK_FRAME_T "   Панель задач "
17
	?define DOCK_FRAME_T "   Док "
5504 punk_joker 18
	?define MIN_LEFT_BUTTON "Кнопка скрытия слева"
19
	?define MIN_RIGHT_BUTTON "Кнопка скрытия справа"
20
	?define SOFTEN_UP   "Сглаживание сверху"
21
	?define SOFTEN_DOWN "Сглаживание снизу"
22
	?define CLOCK    "Часы"
23
	?define CPU_USAGE "Загрузка ЦП"
24
	?define CHANGE_LANG "Язык ввода"
25
	?define MENU_BUTTON "Кнопка меню"
26
	?define PANEL_HEIGHT "Высота панели"
27
	?define SOFTEN_HEIGHT "Высота сглаживания"
28
	?define BUTTON_OFFSET "Поле вокруг кнопок"
29
	?define FSIZE "Режим панели"
30
	?define ASHOW "Не скрывать"
31
	?define CHANGE_POS "Нажмите на изображение для смены позиции"
32
#else
5506 punk_joker 33
	?define WINDOW_TITLE "Taskbar and Docky configuration"
7636 leency 34
    ?define TASK_FRAME_T "   Taskbar "
35
	?define DOCK_FRAME_T "   Docky "
5504 punk_joker 36
	?define MIN_LEFT_BUTTON "Min Left Button"
37
	?define MIN_RIGHT_BUTTON "Min Right Button"
38
	?define SOFTEN_UP   "Soften Up"
39
	?define SOFTEN_DOWN "Soften Down"
40
	?define CLOCK    "Clock"
41
	?define CPU_USAGE "Cpu Usage"
5507 punk_joker 42
	?define CHANGE_LANG "Change Language"
5504 punk_joker 43
	?define MENU_BUTTON "Menu Button"
44
	?define PANEL_HEIGHT "Panel Height"
45
	?define SOFTEN_HEIGHT "Soften Height"
46
	?define BUTTON_OFFSET "Button Offset"
47
	?define FSIZE "Full width"
48
	?define ASHOW "Always show"
49
	?define CHANGE_POS "Click on image to change position"
50
#endif
51
 
5472 leency 52
char taskbar_ini_path[] = "/sys/settings/taskbar.ini";
7051 leency 53
_ini taskbar_flags_ini = { #taskbar_ini_path, "Flags" };
54
_ini taskbar_vars_ini = { #taskbar_ini_path, "Variables" };
5472 leency 55
 
7051 leency 56
_ini docky_ini = { "/sys/settings/docky.ini", "@" };
57
 
7995 leency 58
unsigned char panels_img_data[] = FROM "bars.raw";
7458 leency 59
#define PIMG_W 37
60
#define PIMG_H 27 //27*5
5472 leency 61
 
62
proc_info Form;
63
 
7244 leency 64
enum { BTN_TB_ATTACHEMENT=100, BTN_DOCKY_ATTACHEMENT=200 };
65
enum { TASKBAR, DOCKY };
5472 leency 66
 
7243 leency 67
more_less_box tbPanelHeight  = { NULL, 6, 99, PANEL_HEIGHT };
68
more_less_box tbSoftenHeight = { NULL, 0, 99, SOFTEN_HEIGHT };
69
more_less_box tbButtonOffset = { NULL, 0, 99, BUTTON_OFFSET };
5472 leency 70
 
7636 leency 71
checkbox taskbar_on = 0;
72
checkbox docky_on = 0;
73
 
7244 leency 74
int tbAttachment;
75
checkbox tbSoftenUp = { SOFTEN_UP };
76
checkbox tbClock = { CLOCK };
77
checkbox tbSoftenDown = { SOFTEN_DOWN };
78
checkbox tbCpuUsage = { CPU_USAGE };
79
checkbox tbMinLeftButton = { MIN_LEFT_BUTTON };
80
checkbox tbChangeLang = { CHANGE_LANG };
81
checkbox tbMinRightButton = { MIN_RIGHT_BUTTON };
82
checkbox tbMenuButton = { MENU_BUTTON };
83
checkbox dkFsize = { FSIZE };
84
checkbox dkAshow = { ASHOW };
85
 
86
int dkLocation;
87
checkbox tbRunApplButton;
88
checkbox tbClnDeskButton;
89
 
90
 
5472 leency 91
void main()
92
{
7984 leency 93
	dword id;
5472 leency 94
 
5630 leency 95
	load_dll(libini, #lib_init,1);
5626 leency 96
	load_dll(boxlib, #box_lib_init,0);
5472 leency 97
 
98
	LoadCfg();
99
 
7984 leency 100
	loop() switch(@WaitEvent())
5472 leency 101
	{
102
		case evButton:
7984 leency 103
				id = @GetButtonID();
104
				if (1==id) @ExitProcess();
7244 leency 105
 
7636 leency 106
				if (taskbar_on.checked) EventTaskbarProcessButton(id);
107
				if (docky_on.checked) EventDockyProcessButton(id);
7244 leency 108
 
7636 leency 109
				if (taskbar_on.click(id)) {
110
					IF (taskbar_on.checked == true) RunProgram("/sys/@taskbar", 0);
111
					ELSE KillProcessByName("@TASKBAR", SINGLE);
112
					DrawWindowContent();
7244 leency 113
				}
7636 leency 114
				if (docky_on.click(id)) {
115
					IF (docky_on.checked == true) RunProgram("/sys/@docky", 0);
116
					ELSE KillProcessByName("@DOCKY", SINGLE);
117
					DrawWindowContent();
7244 leency 118
				}
5472 leency 119
				break;
120
 
121
		case evKey:
7984 leency 122
				if (@GetKeyScancode() == SCAN_CODE_ESC) ExitProcess();
5472 leency 123
				break;
124
 
125
		case evReDraw:
7806 leency 126
				sc.get();
127
				DefineAndDrawWindow(130, 150, 465, 398 + skin_height, 0x34, sc.work, WINDOW_TITLE, 0);
5472 leency 128
				GetProcessInfo(#Form, SelfInfo);
8946 leency 129
				if (Form.status_window&ROLLED_UP) break;
7244 leency 130
				DrawWindowContent();
5472 leency 131
	}
132
}
133
 
7458 leency 134
void DrawPanelsImage(dword y, n)
135
{
136
	_PutImage(22, y, PIMG_W, PIMG_H, n * PIMG_W * PIMG_H * 3 + #panels_img_data);
137
}
138
 
7984 leency 139
void SetDisabledMode()
140
{
141
	EAX = taskbar_on.checked ^ 1;
142
	tbSoftenUp.disabled =
143
	tbSoftenDown.disabled =
144
	tbMinLeftButton.disabled =
145
	tbMinRightButton.disabled =
146
	tbRunApplButton.disabled =
147
	tbClnDeskButton.disabled =
148
	tbClock.disabled =
149
	tbCpuUsage.disabled =
150
	tbChangeLang.disabled =
151
	tbMenuButton.disabled =
152
	tbPanelHeight.disabled =
153
	tbSoftenHeight.disabled =
154
	tbButtonOffset.disabled =
155
	tbButtonOffset.disabled = EAX;
156
	//
157
	dkFsize.disabled =
158
	dkAshow.disabled = docky_on.checked ^ 1;
159
}
160
 
7244 leency 161
void DrawWindowContent()
5472 leency 162
{
7227 leency 163
	#define PD 10
164
	dword frame_y;
6197 leency 165
	word win_center_x = Form.cwidth / 2 + 20;
166
	incn y;
5472 leency 167
 
7984 leency 168
	SetDisabledMode();
169
 
7244 leency 170
	frame_y = 15;
171
	y.n = frame_y;
7458 leency 172
	DefineButton(22, y.inc(18), PIMG_W-1, PIMG_H-1, 100 + BT_HIDE, 0);
173
	DrawPanelsImage(y.n, tbAttachment);
7806 leency 174
	WriteTextWithBg(68, y.inc(7), 0xD0, sc.work_text, CHANGE_POS, sc.work);
7244 leency 175
	tbSoftenUp.draw(22, y.inc(35));
176
	tbClock.draw(win_center_x, y.n);
177
	tbSoftenDown.draw(22, y.inc(24));
178
	tbCpuUsage.draw(win_center_x, y.n);
179
	tbMinLeftButton.draw(22, y.inc(24));
180
	tbChangeLang.draw(win_center_x, y.n);
181
	tbMinRightButton.draw(22, y.inc(24));
182
	tbMenuButton.draw(win_center_x, y.n);
183
	tbPanelHeight.draw(22, y.inc(28));
184
	tbSoftenHeight.draw(22, y.inc(32));
185
	tbButtonOffset.draw(22, y.inc(32));
186
	DrawFrame(PD, frame_y, Form.cwidth-PD-PD, y.inc(32)-frame_y, TASK_FRAME_T);
7636 leency 187
	taskbar_on.draw(22, frame_y-7);
7244 leency 188
	//DOCKY
189
	frame_y = calc(y.inc(20));
7458 leency 190
	DefineButton(22, y.inc(18), PIMG_W-1, PIMG_H-1, 200 + BT_HIDE, 0);
7532 leency 191
	DrawPanelsImage(y.n, dkLocation+1);
7806 leency 192
	WriteTextWithBg(68, y.inc(7), 0xD0, sc.work_text, CHANGE_POS, sc.work);
7244 leency 193
	dkFsize.draw(22, y.inc(35));
194
	dkAshow.draw(win_center_x, y.n);
195
	DrawFrame(PD, frame_y, Form.cwidth-PD-PD, Form.cheight-frame_y-PD, DOCK_FRAME_T);
7636 leency 196
	docky_on.draw(22, frame_y-7);
5472 leency 197
}
198
 
199
void LoadCfg()
200
{
7244 leency 201
	tbAttachment = taskbar_flags_ini.GetInt("Attachment", 1);
202
	tbSoftenUp.checked       = taskbar_flags_ini.GetInt("SoftenUp", 1);
203
	tbSoftenDown.checked     = taskbar_flags_ini.GetInt("SoftenDown", 1);
204
	tbMinLeftButton.checked  = taskbar_flags_ini.GetInt("MinLeftButton", 1);
205
	tbMinRightButton.checked = taskbar_flags_ini.GetInt("MinRightButton", 1);
206
	tbClock.checked          = taskbar_flags_ini.GetInt("Clock", 1);
207
	tbCpuUsage.checked       = taskbar_flags_ini.GetInt("CpuUsage", 1);
208
	tbChangeLang.checked     = taskbar_flags_ini.GetInt("ChangeLang", 1);
209
	tbMenuButton.checked     = taskbar_flags_ini.GetInt("MenuButton", 1);
7243 leency 210
	tbPanelHeight.value  = taskbar_vars_ini.GetInt("PanelHeight", 28);
211
	tbSoftenHeight.value = taskbar_vars_ini.GetInt("SoftenHeight", 4);
212
	tbButtonOffset.value = taskbar_vars_ini.GetInt("ButtonTopOffset", 3);
213
	tbButtonOffset.value = taskbar_vars_ini.GetInt("ButtonBotOffset", 3);
5472 leency 214
 
7051 leency 215
	dkLocation = docky_ini.GetInt("location", 0);
7244 leency 216
	dkFsize.checked = docky_ini.GetInt("fsize", 0);
7636 leency 217
	dkAshow.checked = docky_ini.GetInt("ashow", 0);
218
 
219
	taskbar_on.checked = CheckProcessExists("@TASKBAR");
220
	docky_on.checked = CheckProcessExists("@DOCKY");
5472 leency 221
}
222
 
7244 leency 223
void SaveSettingsAndRestartProcess(byte panel_type)
5472 leency 224
{
5477 leency 225
	if (panel_type==TASKBAR) {
7051 leency 226
		taskbar_flags_ini.SetInt("Attachment", tbAttachment);
7244 leency 227
		taskbar_flags_ini.SetInt("SoftenUp", tbSoftenUp.checked);
228
		taskbar_flags_ini.SetInt("SoftenDown", tbSoftenDown.checked);
229
		taskbar_flags_ini.SetInt("MinLeftButton", tbMinLeftButton.checked);
230
		taskbar_flags_ini.SetInt("MinRightButton", tbMinRightButton.checked);
231
		taskbar_flags_ini.SetInt("RunApplButton", tbRunApplButton.checked);
232
		taskbar_flags_ini.SetInt("ClnDeskButton", tbClnDeskButton.checked);
233
		taskbar_flags_ini.SetInt("Clock", tbClock.checked);
234
		taskbar_flags_ini.SetInt("CpuUsage", tbCpuUsage.checked);
235
		taskbar_flags_ini.SetInt("ChangeLang", tbChangeLang.checked);
236
		taskbar_flags_ini.SetInt("MenuButton", tbMenuButton.checked);
7243 leency 237
		taskbar_vars_ini.SetInt("PanelHeight", tbPanelHeight.value);
238
		taskbar_vars_ini.SetInt("SoftenHeight", tbSoftenHeight.value);
239
		taskbar_vars_ini.SetInt("ButtonTopOffset", tbButtonOffset.value);
240
		taskbar_vars_ini.SetInt("ButtonBottOffset", tbButtonOffset.value);
5477 leency 241
	}
242
	if (panel_type==DOCKY) {
7051 leency 243
		docky_ini.SetInt("location", dkLocation);
7244 leency 244
		docky_ini.SetInt("fsize", dkFsize.checked);
245
		docky_ini.SetInt("ashow", dkAshow.checked);
5477 leency 246
	}
7244 leency 247
	RestartProcess(panel_type);
5472 leency 248
}
249
 
5477 leency 250
void RestartProcess(byte panel_type)
5472 leency 251
{
5548 leency 252
	dword proc_name1;
253
	if (panel_type == TASKBAR)
5472 leency 254
	{
7654 leency 255
		RestartProcessByName("/sys/@taskbar", SINGLE);
5548 leency 256
		pause(50);
5472 leency 257
	}
5548 leency 258
	else
259
	{
7654 leency 260
		RestartProcessByName("/sys/@docky", SINGLE);
5548 leency 261
		pause(120);
262
	}
5472 leency 263
	GetProcessInfo(#Form, SelfInfo);
5477 leency 264
	ActivateWindow(GetProcessSlot(Form.ID));
5472 leency 265
}
266
 
7636 leency 267
void EventTaskbarProcessButton(dword id)
268
{
269
	if (BTN_TB_ATTACHEMENT == id) {
270
		tbAttachment ^= 1;
271
		DrawWindowContent();
272
		SaveSettingsAndRestartProcess(TASKBAR);
273
	}
274
	if (tbSoftenUp.click(id))      || (tbSoftenDown.click(id))
275
	|| (tbMinLeftButton.click(id)) || (tbMinRightButton.click(id))
276
	|| (tbRunApplButton.click(id)) || (tbClnDeskButton.click(id)) {
277
		SaveSettingsAndRestartProcess(TASKBAR);
278
	}
279
	if (tbClock.click(id))       || (tbCpuUsage.click(id))
280
	|| (tbChangeLang.click(id))  || (tbMenuButton.click(id))
281
	|| (tbPanelHeight.click(id)) || (tbSoftenHeight.click(id))
282
	|| (tbButtonOffset.click(id)) {
283
		SaveSettingsAndRestartProcess(TASKBAR);
284
	}
285
}
5477 leency 286
 
7636 leency 287
void EventDockyProcessButton(dword id)
288
{
289
	if (BTN_DOCKY_ATTACHEMENT == id) {
290
		dkLocation++;
7928 leency 291
		if (dkLocation>4) dkLocation=1;
7636 leency 292
		DrawWindowContent();
293
		SaveSettingsAndRestartProcess(DOCKY);
294
	}
295
	if (dkFsize.click(id)) || (dkAshow.click(id)) {
296
		SaveSettingsAndRestartProcess(DOCKY);
297
	}
298
}
5477 leency 299
 
7636 leency 300
 
5472 leency 301
stop: