1 /*
2  * Copyright 2003, 2004 Martin Fuchs
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18 
19 
20  //
21  // Explorer clone
22  //
23  // dialogs/searchprogram.h
24  //
25  // Explorer dialogs
26  //
27  // Martin Fuchs, 02.10.2003
28  //
29 
30 
31 typedef void (*COLLECT_CALLBACK)(Entry* entry, void* param);
32 typedef stack<ShellDirectory*> ShellDirectoryStack;
33 
34  /// Thread for collecting start menu entries
35 struct CollectProgramsThread : public Thread
36 {
37 	CollectProgramsThread(COLLECT_CALLBACK callback, HWND hwnd, void* para)
38 	 :	_cache_valid(false),
39 		_callback(callback),
40 		_hwnd(hwnd),
41 		_para(para)
42 	{
43 	}
44 
45 	~CollectProgramsThread()
46 	{
47 		free_dirs();
48 	}
49 
50 	int		Run();
51 	void	free_dirs();
52 
53 	bool	_cache_valid;
54 
55 protected:
56 	COLLECT_CALLBACK _callback;
57 	HWND	_hwnd;
58 	void*	_para;
59 	ShellDirectoryStack _dirs;
60 
61 	void	collect_programs(const ShellPath& path);
62 };
63 
64 
65  /// entry for the list in "find program" dialogs
66 struct FPDEntry
67 {
68 	Entry*	_entry;
69 	int		_idxIcon;
70 	String	_menu_path;
71 	String	_path;
72 };
73 
74 typedef list<FPDEntry> FPDCache;
75 
76 
77  /// Dialog to work with the complete list of start menu entries
78 struct FindProgramDlg : public ResizeController<Dialog>
79 {
80 	typedef ResizeController<Dialog> super;
81 
82 	FindProgramDlg(HWND hwnd);
83 	~FindProgramDlg();
84 
85 protected:
86 	HWND	_list_ctrl;
87 	HACCEL	_haccel;
88 	String	_lwr_filter;
89 
90 	CollectProgramsThread _thread;
91 	FPDCache _cache;
92 
93 	String	_common_programs, _user_programs;
94 
95 	ListSort _sort;
96 
97 	virtual LRESULT WndProc(UINT, WPARAM, LPARAM);
98 	virtual int	Command(int id, int code);
99 	virtual int	Notify(int id, NMHDR* pnmh);
100 
101 	void	Refresh(bool delete_cache=false);
102 	void	add_entry(const FPDEntry& cache_entry);
103 	void	LaunchSelected();
104 	void	CheckEntries();
105 
106 	static void collect_programs_callback(Entry* entry, void* param);
107 	static int CALLBACK CompareFunc(LPARAM lparam1, LPARAM lparam2, LPARAM lparamSort);
108 };
109