Subversion Repositories Kolibri OS

Rev

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

Rev 4043 Rev 4049
Line 1... Line 1...
1
//Leency 2013
1
//Leency 2013
Line -... Line 2...
-
 
2
 
-
 
3
llist app_list;
-
 
4
struct app_list_string { char item[1024]; char icon; };
-
 
5
app_list_string app_paths[100];
-
 
6
 
-
 
7
int GetListOfPrograms()
-
 
8
{
-
 
9
	byte section[32], parametr[32], option[256], InfType=0;
-
 
10
	char bukva[2];
-
 
11
	int tj, ti;
-
 
12
	static dword buff, fsize;
-
 
13
 
-
 
14
	debug("GetListOfPrograms()");
-
 
15
 
-
 
16
	free(buff);
-
 
17
	if (!GetFile(#buff, #fsize, abspath("Eolite.ini")))
-
 
18
	{
-
 
19
		notify("Eolite.ini not found. Don't know any programm.");
-
 
20
		return -1;
-
 
21
	}
-
 
22
 
-
 
23
	for (tj=0; tj
-
 
24
	{   
-
 
25
		bukva = ESBYTE[buff+tj];
-
 
26
		switch (bukva)
-
 
27
		{
-
 
28
			case ';': InfType=COMMENT; break;				
-
 
29
			case '[': InfType=SECTION; section=NULL; break;
-
 
30
			case ']': InfType=PARAM; break;
-
 
31
			case '=': InfType=OPTION; break;
-
 
32
			case 0x0a:
-
 
33
			case 0x0d:
-
 
34
				InfType=PARAM;				
-
 
35
				if (!strcmp(#section,"Associations")) && (option)
-
 
36
				{
-
 
37
					for (ti=0; ti
-
 
38
					{
-
 
39
						if (strcmp(#app_paths[ti].item, #option)==0) GOTO _OUT;
-
 
40
					}
-
 
41
					// for (i=0; ext[i]!=0; i+=2;) if (!strcmp(extension, ext[i])) { icon_n = ext[i+1]; break;	}
-
 
42
					strcpy(#app_paths[app_list.count].item, #option);
-
 
43
					app_list.count++;
-
 
44
				}
-
 
45
				_OUT:
-
 
46
				parametr=option=NULL;
-
 
47
				break;
-
 
48
			default:
-
 
49
				IF (InfType==SECTION) chrcat(#section, bukva);
-
 
50
				IF (InfType==PARAM) chrcat(#parametr, bukva);
-
 
51
				IF (InfType==OPTION) chrcat(#option, bukva);
-
 
52
		}
-
 
53
	}
-
 
54
}
-
 
55
 
-
 
56
 
2
 
57
 
3
void OpenWith()
58
void OpenWith()
-
 
59
{
-
 
60
	#define WIN_W 290
4
{
61
	#define OPEN_LIST_VISIBLE_N 12
5
	?define OPEN_LIST_W 300
62
	#define OPEN_LIST_LINE_H 20
-
 
63
	#define PANEL_H 40
-
 
64
	#define PADDING 8;
6
	?define OPEN_LIST_H 300
65
	int WIN_H;
7
	mouse mm;
66
	mouse mm;
8
	word key, slot, index, start_y;
-
 
9
	llist app_list;
67
	word key, slot;
10
	proc_info MenuForm;
-
 
Line 11... Line 68...
11
	int texty, newi;
68
	proc_info MenuForm;
12
 
69
 
-
 
70
	app_list.ClearList();
13
	app_list.ClearList();
71
	app_list.SetSizes(PADDING,PANEL_H+1,WIN_W-PADDING-PADDING,OPEN_LIST_VISIBLE_N*OPEN_LIST_LINE_H,150,OPEN_LIST_LINE_H);
14
	app_list.SetSizes(files.w-OPEN_LIST_W/2+files.x+Form.left+4,files.h-OPEN_LIST_H/2+files.y+Form.top+GetSkinHeight(),OPEN_LIST_W,OPEN_LIST_H,150,18);
72
	if (!app_list.count) if (GetListOfPrograms()==-1) return;
Line 15... Line 73...
15
	SetEventMask(100111b);
73
	SetEventMask(100111b);
16
	goto _APP_LIST_DRAW;
74
	goto _APP_LIST_DRAW;
17
 
75
 
18
	loop() switch(WaitEvent())
76
	loop() switch(WaitEvent())
19
	{
77
	{
20
		case evMouse:
78
		case evMouse:
21
				slot = GetProcessSlot(MenuForm.ID);
79
				slot = GetProcessSlot(MenuForm.ID);
-
 
80
				if (slot != GetActiveProcess()) ExitProcess();
-
 
81
				mm.get();
-
 
82
				//if (mm.lkm) ExitProcess();
-
 
83
				if (mm.vert)
-
 
84
				{
-
 
85
					app_list.MouseScroll(mm.vert);
-
 
86
					DrawAppList();
-
 
87
				}
-
 
88
				if (mm.x>app_list.x) && (mm.xapp_list.y) && (mm.y
-
 
89
				{
-
 
90
					app_list.current_temp = mm.y - app_list.y / app_list.line_h + app_list.first;
-
 
91
					if (app_list.current_temp != app_list.current)
-
 
92
					{
-
 
93
						app_list.current = app_list.current_temp;
-
 
94
						DrawAppList();
22
				if (slot != GetActiveProcess()) ExitProcess();
95
					}
Line 23... Line 96...
23
				mm.get();
96
				}
24
				if (mm.lkm) ExitProcess();
97
 
25
				break;
98
				break;
26
				
99
				
Line -... Line 100...
-
 
100
		case evKey:
-
 
101
				key = GetKey();
-
 
102
				if (key==27) ExitProcess();
-
 
103
				break;
-
 
104
 
27
		case evKey:
105
		case evButton:
-
 
106
				RunProgram(#app_paths[GetButtonID()-10].item, #file_path);
-
 
107
				ExitProcess();
28
				key = GetKey();
108
				break;
29
				if (key==27) ExitProcess();
109
				
30
				break;
110
		case evReDraw: _APP_LIST_DRAW:
31
				
-
 
32
		case evReDraw: _APP_LIST_DRAW:
-
 
33
				DefineAndDrawWindow(app_list.x, app_list.y,app_list.w+3,app_list.h+6,0x01, 0, 0, 0x01fffFFF);
111
				WIN_H = app_list.h+PANEL_H+PADDING+2;
Line -... Line 112...
-
 
112
				DefineAndDrawWindow(files.w-WIN_W/2+files.x+Form.left+6, 
-
 
113
				files.h-WIN_H/2+files.y+Form.top+GetSkinHeight(),WIN_W+1,WIN_H,0x01, 0, 0, 0x01fffFFF);
34
				GetProcessInfo(#MenuForm, SelfInfo);
114
				GetProcessInfo(#MenuForm, SelfInfo);
-
 
115
				DrawPopup(0,0,MenuForm.width-2,MenuForm.height-2,0, col_work, col_border);
35
				DrawPopup(0,0,app_list.w,app_list.h,0, col_work,col_border);
116
				DrawRectangle(app_list.x-1, app_list.y-2, app_list.w+1, app_list.h+2, col_border);
-
 
117
 
-
 
118
				Put_icon(#file_name+_strrchr(#file_name,'.'), 10, 13, col_work);
-
 
119
				WriteText(35,10, 0x80, 0, T_SELECT_APP_TO_OPEN_WITH);
-
 
120
				WriteText(35,23, 0x80, 0, #file_name);
-
 
121
 
-
 
122
				DrawAppList();
-
 
123
	}
-
 
124
}
-
 
125
 
-
 
126
void DrawAppList()
-
 
127
{
-
 
128
	dword index, col_bg;
-
 
129
	for (index = 0; (index
36
				WriteText(10,10, 0x80, 0, "Select application to open file"w);
130
	{
37
				WriteText(10,23, 0x80, 0, #file_name);
131
		DefineButton(app_list.x, index*app_list.line_h+app_list.y, app_list.w, app_list.line_h-1, index+app_list.first+10+BT_HIDE+BT_NOFRAME, 0);
38
				WriteTextB(app_list.w/2-25,app_list.h/2, 0x90, 0, "S O O N");
132
		if (index+app_list.first==app_list.current) col_bg = col_selec; else col_bg = 0xFFFfff;