Rev 4072 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4042 | leency | 1 | //Leency 2013 |
2 | |||
4049 | leency | 3 | llist app_list; |
4057 | leency | 4 | struct app_list_string { char item[1024]; char ext[5]; }; |
4049 | leency | 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 | free(buff); |
||
15 | if (!GetFile(#buff, #fsize, abspath("Eolite.ini"))) |
||
16 | { |
||
17 | notify("Eolite.ini not found. Don't know any programm."); |
||
18 | return -1; |
||
19 | } |
||
20 | |||
21 | for (tj=0; tj |
||
22 | { |
||
23 | bukva = ESBYTE[buff+tj]; |
||
24 | switch (bukva) |
||
25 | { |
||
26 | case ';': InfType=COMMENT; break; |
||
27 | case '[': InfType=SECTION; section=NULL; break; |
||
28 | case ']': InfType=PARAM; break; |
||
29 | case '=': InfType=OPTION; break; |
||
30 | case 0x0a: |
||
31 | case 0x0d: |
||
4057 | leency | 32 | if (!strcmp(#section,"Associations")) && (option) && (InfType!=COMMENT) |
4049 | leency | 33 | { |
34 | for (ti=0; ti |
||
35 | { |
||
4057 | leency | 36 | if (strcmp(#app_paths[ti].item, #option)==0) goto _OUT; |
4049 | leency | 37 | } |
4057 | leency | 38 | if (kolibrios_drive==false) && (strstr(#option,"kolibrios/")!=0) goto _OUT; |
4049 | leency | 39 | strcpy(#app_paths[app_list.count].item, #option); |
4057 | leency | 40 | if (strlen(#parametr)<=5) && (parametr[0]) strcpy(#app_paths[app_list.count].ext, #parametr); |
41 | else strcpy(#app_paths[app_list.count].ext, "kex"); |
||
4049 | leency | 42 | app_list.count++; |
43 | } |
||
44 | _OUT: |
||
4057 | leency | 45 | InfType=PARAM; |
4049 | leency | 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 | |||
57 | |||
4042 | leency | 58 | void OpenWith() |
59 | { |
||
4049 | leency | 60 | #define WIN_W 290 |
61 | #define OPEN_LIST_VISIBLE_N 12 |
||
62 | #define OPEN_LIST_LINE_H 20 |
||
63 | #define PANEL_H 40 |
||
4057 | leency | 64 | #define PADDING 8 |
4049 | leency | 65 | int WIN_H; |
4042 | leency | 66 | mouse mm; |
4049 | leency | 67 | word key, slot; |
4042 | leency | 68 | proc_info MenuForm; |
69 | |||
70 | app_list.ClearList(); |
||
4049 | leency | 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); |
72 | if (!app_list.count) if (GetListOfPrograms()==-1) return; |
||
4042 | leency | 73 | SetEventMask(100111b); |
74 | goto _APP_LIST_DRAW; |
||
75 | |||
76 | loop() switch(WaitEvent()) |
||
77 | { |
||
78 | case evMouse: |
||
79 | slot = GetProcessSlot(MenuForm.ID); |
||
80 | if (slot != GetActiveProcess()) ExitProcess(); |
||
81 | mm.get(); |
||
4049 | leency | 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.x |
||
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(); |
||
95 | } |
||
4057 | leency | 96 | if (mm.lkm) |
97 | { |
||
98 | RunProgram(#app_paths[app_list.current].item, #file_path); |
||
99 | ExitProcess(); |
||
100 | } |
||
4049 | leency | 101 | } |
102 | |||
4042 | leency | 103 | break; |
104 | |||
105 | case evKey: |
||
106 | key = GetKey(); |
||
107 | if (key==27) ExitProcess(); |
||
4057 | leency | 108 | if (key==13) { RunProgram(#app_paths[app_list.current].item, #file_path); ExitProcess(); } |
4072 | leency | 109 | if (app_list.ProcessKey(key)) DrawAppList(); |
4042 | leency | 110 | break; |
111 | |||
112 | case evReDraw: _APP_LIST_DRAW: |
||
4049 | leency | 113 | WIN_H = app_list.h+PANEL_H+PADDING+2; |
114 | DefineAndDrawWindow(files.w-WIN_W/2+files.x+Form.left+6, |
||
115 | files.h-WIN_H/2+files.y+Form.top+GetSkinHeight(),WIN_W+1,WIN_H,0x01, 0, 0, 0x01fffFFF); |
||
4042 | leency | 116 | GetProcessInfo(#MenuForm, SelfInfo); |
4076 | leency | 117 | DrawPopup(0,0,MenuForm.width-2,MenuForm.height-2,0, sc.work, sc.work_graph); |
118 | DrawRectangle(app_list.x-1, app_list.y-2, app_list.w+1, app_list.h+2, sc.work_graph); |
||
4042 | leency | 119 | |
4076 | leency | 120 | Put_icon(#file_name+_strrchr(#file_name,'.'), 10, 13, sc.work, 0); |
121 | WriteText(35,10, 0x80, sc.work_text, T_SELECT_APP_TO_OPEN_WITH); |
||
122 | WriteText(35,23, 0x80, sc.work_text, #file_name); |
||
4049 | leency | 123 | |
124 | DrawAppList(); |
||
4042 | leency | 125 | } |
4049 | leency | 126 | } |
127 | |||
128 | void DrawAppList() |
||
129 | { |
||
4057 | leency | 130 | #define SCROLL_WIDTH 5 |
131 | llist tiny_scroll; |
||
4049 | leency | 132 | dword index, col_bg; |
133 | for (index = 0; (index |
||
134 | { |
||
135 | if (index+app_list.first==app_list.current) col_bg = col_selec; else col_bg = 0xFFFfff; |
||
136 | DrawBar(app_list.x, index*app_list.line_h+app_list.y, app_list.w, app_list.line_h, col_bg); |
||
4057 | leency | 137 | Put_icon(#app_paths[index+app_list.first].ext, app_list.x+4, index*app_list.line_h+app_list.y+2, col_bg, 6); |
138 | WriteText(app_list.x+25, index*app_list.line_h+app_list.y+7, 0x80, 0, #app_paths[index+app_list.first].item); |
||
4049 | leency | 139 | } |
4057 | leency | 140 | tiny_scroll.x = app_list.x+app_list.w-SCROLL_WIDTH-1; |
4063 | leency | 141 | tiny_scroll.h = app_list.h * app_list.visible / app_list.count; |
142 | tiny_scroll.y = app_list.h * app_list.first / app_list.count + app_list.y; |
||
143 | debugi(tiny_scroll.y + tiny_scroll.h - app_list.y - app_list.h); |
||
144 | if (tiny_scroll.y + tiny_scroll.h - app_list.y - app_list.h >= 0) tiny_scroll.y = app_list.y + app_list.h - tiny_scroll.h-1; |
||
4057 | leency | 145 | DrawBar(tiny_scroll.x, tiny_scroll.y, SCROLL_WIDTH, tiny_scroll.h, 0x555555); //scroll |
4042 | leency | 146 | } |