Subversion Repositories Kolibri OS

Rev

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