Subversion Repositories Kolibri OS

Rev

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

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