From b33671f3ab0a5826e3fcf8e603467c28b7415c49 Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Fri, 17 Oct 2003 22:56:25 +0000 Subject: [PATCH] activate find-progra-dialog filter svn path=/trunk/; revision=6352 --- reactos/subsys/system/explorer/buildno.h | 8 +-- .../system/explorer/dialogs/searchprogram.cpp | 56 ++++++++++++++---- .../system/explorer/dialogs/searchprogram.h | 2 + reactos/subsys/system/explorer/explorer.dsp | 4 ++ .../subsys/system/explorer/explorer_intres.h | 3 +- .../subsys/system/explorer/explorer_intres.rc | 8 +-- .../subsys/system/explorer/res/appicon.ico | Bin 0 -> 318 bytes .../subsys/system/explorer/shell/shellfs.cpp | 39 +++++++++++- .../subsys/system/explorer/utility/utility.h | 15 ++++- 9 files changed, 108 insertions(+), 27 deletions(-) create mode 100644 reactos/subsys/system/explorer/res/appicon.ico diff --git a/reactos/subsys/system/explorer/buildno.h b/reactos/subsys/system/explorer/buildno.h index 8f768dfe6c2..f7cc327aa00 100644 --- a/reactos/subsys/system/explorer/buildno.h +++ b/reactos/subsys/system/explorer/buildno.h @@ -1,10 +1,10 @@ /* Do not edit - Machine generated */ #ifndef _INC_REACTOS_BUILDNO #define _INC_REACTOS_BUILDNO -#define KERNEL_VERSION_BUILD 1 -#define KERNEL_VERSION_BUILD_STR "1" -#define KERNEL_RELEASE_RC "0.1.4.1\0" -#define KERNEL_RELEASE_STR "0.1.4.1" +#define KERNEL_VERSION_BUILD 4 +#define KERNEL_VERSION_BUILD_STR "4" +#define KERNEL_RELEASE_RC "0.1.4.4\0" +#define KERNEL_RELEASE_STR "0.1.4.4" #define KERNEL_VERSION_RC "0.1.4\0" #define KERNEL_VERSION_STR "0.1.4" #endif diff --git a/reactos/subsys/system/explorer/dialogs/searchprogram.cpp b/reactos/subsys/system/explorer/dialogs/searchprogram.cpp index 887a1031537..1c941c4b62e 100644 --- a/reactos/subsys/system/explorer/dialogs/searchprogram.cpp +++ b/reactos/subsys/system/explorer/dialogs/searchprogram.cpp @@ -73,6 +73,8 @@ void CollectProgramsThread::collect_programs(const ShellPath& path) if (_alive) _callback(dir._folder, shell_entry, _para); } + + dir.free_subentries(); } @@ -94,6 +96,7 @@ FindProgramTopicDlg::FindProgramTopicDlg(HWND hwnd) _haccel = LoadAccelerators(g_Globals._hInstance, MAKEINTRESOURCE(IDA_SEARCH_PROGRAM)); ListView_SetImageList(_list_ctrl, _himl, LVSIL_SMALL); + _idxNoIcon = ImageList_AddIcon(_himl, SmallIcon(IDI_APPICON)); LV_COLUMN column = {LVCF_FMT|LVCF_WIDTH|LVCF_TEXT, LVCFMT_LEFT, 250}; @@ -119,6 +122,12 @@ void FindProgramTopicDlg::Refresh() { WaitCursor wait; + _thread.Stop(); + + TCHAR buffer[1024]; + GetWindowText(GetDlgItem(_hwnd, IDC_TOPIC), buffer, 1024); + _filter = buffer; + ListView_DeleteAllItems(_list_ctrl); _thread.Start(); @@ -140,32 +149,49 @@ void FindProgramTopicDlg::collect_programs_callback(ShellFolder& folder, const S hr = pShellLink->GetPath(path, MAX_PATH-1, (WIN32_FIND_DATA*)&wfd, SLGP_UNCPRIORITY); if (SUCCEEDED(hr)) { + FindProgramTopicDlg* pThis = (FindProgramTopicDlg*) param; + String lwr_path = path; String lwr_name = entry->_display_name; + String filter = pThis->_filter; #ifndef __WINE__ //TODO _tcslwr((LPTSTR)lwr_path.c_str()); _tcslwr((LPTSTR)lwr_name.c_str()); + _tcslwr((LPTSTR)filter.c_str()); #endif - if (_tcsstr(lwr_path, _T(".exe")) && //@@ filter on ".exe" suffix - !_tcsstr(lwr_name, _T("uninstal")) && !_tcsstr(lwr_name, _T("deinstal"))) { //@@ filter out deinstallation links - FindProgramTopicDlg* pThis = (FindProgramTopicDlg*) param; - + //if (_tcsstr(lwr_path, _T(".exe"))) //@@ filter on ".exe" suffix + //if (!_tcsstr(lwr_name, _T("uninstal")) && !_tcsstr(lwr_name, _T("deinstal"))) //@@ filter out deinstallation links + if (_tcsstr(lwr_path, filter) || _tcsstr(lwr_name, filter)) { LV_ITEM item = {LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM, INT_MAX}; item.pszText = entry->_display_name; - item.iImage = ImageList_AddIcon(pThis->_himl, entry->_hIcon); + + if (entry->_hIcon != (HICON)-1) + item.iImage = ImageList_AddIcon(pThis->_himl, entry->_hIcon); + else + item.iImage = pThis->_idxNoIcon; + item.lParam = 0; //@@ //TODO: store info in ShellPathWithFolder + Lock lock(pThis->_thread._crit_sect); + + // resolve deadlocks while executing Thread::Stop() + if (!pThis->_thread.is_alive()) + return; + item.iItem = ListView_InsertItem(pThis->_list_ctrl, &item); item.mask = LVIF_TEXT; item.iSubItem = 1; item.pszText = path; + if (!pThis->_thread.is_alive()) + return; + ListView_SetItem(pThis->_list_ctrl, &item); } } @@ -187,14 +213,20 @@ LRESULT FindProgramTopicDlg::WndProc(UINT message, WPARAM wparam, LPARAM lparam) int FindProgramTopicDlg::Command(int id, int code) { - switch(id) { - case ID_REFRESH: - Refresh(); - break; + if (code == BN_CLICKED) + switch(id) { + case ID_REFRESH: + Refresh(); + break; - default: - return super::Command(id, code); - } + default: + return super::Command(id, code); + } + else if (code == EN_CHANGE) + switch(id) { + case IDC_TOPIC: + Refresh(); + } return TRUE; } diff --git a/reactos/subsys/system/explorer/dialogs/searchprogram.h b/reactos/subsys/system/explorer/dialogs/searchprogram.h index d2d1efbfd5c..f049e5b7376 100644 --- a/reactos/subsys/system/explorer/dialogs/searchprogram.h +++ b/reactos/subsys/system/explorer/dialogs/searchprogram.h @@ -72,6 +72,8 @@ protected: HWND _list_ctrl; HACCEL _haccel; HIMAGELIST _himl; + int _idxNoIcon; // Ersatzicon für Links ohne Symbole + String _filter; CollectProgramsThread _thread; diff --git a/reactos/subsys/system/explorer/explorer.dsp b/reactos/subsys/system/explorer/explorer.dsp index dfc6e9f976a..d00403e5765 100644 --- a/reactos/subsys/system/explorer/explorer.dsp +++ b/reactos/subsys/system/explorer/explorer.dsp @@ -561,6 +561,10 @@ SOURCE=.\dialogs\searchprogram.h # End Group # Begin Source File +SOURCE=.\res\appicon.ico +# End Source File +# Begin Source File + SOURCE=.\buildno.h # End Source File # Begin Source File diff --git a/reactos/subsys/system/explorer/explorer_intres.h b/reactos/subsys/system/explorer/explorer_intres.h index 14a1b2da883..629234b165a 100644 --- a/reactos/subsys/system/explorer/explorer_intres.h +++ b/reactos/subsys/system/explorer/explorer_intres.h @@ -47,6 +47,7 @@ #define IDB_LOGOV 129 #define IDB_LOGOV256 130 #define IDA_SEARCH_PROGRAM 133 +#define IDI_APPICON 134 #define ID_VIEW_NAME 401 #define ID_VIEW_ALL_ATTRIBUTES 402 #define ID_VIEW_SELECTED_ATTRIBUTES 403 @@ -81,7 +82,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 134 +#define _APS_NEXT_RESOURCE_VALUE 135 #define _APS_NEXT_COMMAND_VALUE 40002 #define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_SYMED_VALUE 101 diff --git a/reactos/subsys/system/explorer/explorer_intres.rc b/reactos/subsys/system/explorer/explorer_intres.rc index e06813eb7ab..82aa1cf556e 100644 --- a/reactos/subsys/system/explorer/explorer_intres.rc +++ b/reactos/subsys/system/explorer/explorer_intres.rc @@ -8,7 +8,6 @@ // Generated from the TEXTINCLUDE 2 resource. // #include -#include ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -146,8 +145,8 @@ IDB_LOGOV256 BITMAP DISCARDABLE "res/logov256.bmp" IDA_EXPLORER ACCELERATORS DISCARDABLE BEGIN - 88, ID_FILE_EXIT, VIRTKEY, ALT, NOINVERT - 83, ID_VIEW_FULLSCREEN, VIRTKEY, SHIFT, CONTROL, + "X", ID_FILE_EXIT, VIRTKEY, ALT, NOINVERT + "S", ID_VIEW_FULLSCREEN, VIRTKEY, SHIFT, CONTROL, NOINVERT END @@ -345,6 +344,7 @@ IDI_STARTMENU ICON DISCARDABLE "res/startmenu.ico" IDI_LOGOFF ICON DISCARDABLE "res/logoff.ico" IDI_ARROW ICON DISCARDABLE "res/arrow.ico" IDI_ARROW_SELECTED ICON DISCARDABLE "res/arrowsel.ico" +IDI_APPICON ICON DISCARDABLE "res/appicon.ico" ///////////////////////////////////////////////////////////////////////////// // @@ -565,7 +565,7 @@ STYLE WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME EXSTYLE WS_EX_APPWINDOW CAPTION "Search Program in Startmenu" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN EDITTEXT IDC_TOPIC,7,7,130,14,ES_AUTOHSCROLL CONTROL "List1",IDC_MAILS_FOUND,"SysListView32",LVS_REPORT | diff --git a/reactos/subsys/system/explorer/res/appicon.ico b/reactos/subsys/system/explorer/res/appicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..233a137918717bb4dbbad25bddad4dd981ee318c GIT binary patch literal 318 zcmbVIu?>JQ409!7II*23QX3UWj8Y1OH374nRA(U* zCMw{eZ(;xwX5FYP;qG(|S|nOiMKaWq44fVL2-M6W@!zjN&0C;8_wM7l;ab6YurK5v H_5Fbxqtj>R literal 0 HcmV?d00001 diff --git a/reactos/subsys/system/explorer/shell/shellfs.cpp b/reactos/subsys/system/explorer/shell/shellfs.cpp index 86daf93d300..f003f5460ed 100644 --- a/reactos/subsys/system/explorer/shell/shellfs.cpp +++ b/reactos/subsys/system/explorer/shell/shellfs.cpp @@ -196,6 +196,27 @@ static HICON extract_icon(IShellFolder* folder, LPCITEMIDLIST pidl) DestroyIcon(hIconLarge); } + if (!hIcon) { + SHFILEINFO sfi; + + if (SHGetFileInfo(path, 0, &sfi, sizeof(sfi), SHGFI_ICON|SHGFI_SMALLICON)) + hIcon = sfi.hIcon; + } +/* + if (!hIcon) { + LPBYTE b = (LPBYTE) alloca(0x10000); + SHFILEINFO sfi; + + FILE* file = fopen(path, "rb"); + if (file) { + int l = fread(b, 1, 0x10000, file); + fclose(file); + + if (l) + hIcon = CreateIconFromResourceEx(b, l, TRUE, 0x00030000, 16, 16, LR_DEFAULTCOLOR); + } + } +*/ return hIcon; } } @@ -294,10 +315,22 @@ void ShellDirectory::read_directory() // get display icons for files and virtual objects if (!(entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || !(attribs & SFGAO_FILESYSTEM)) { - entry->_hIcon = extract_icon(_folder, pidls[n]); + entry->_hIcon = extract_icon(_folder, pidls[n]/*, (ShellEntry*)entry*/); - if (!entry->_hIcon) - entry->_hIcon = (HICON)-1; // don't try again later + if (!entry->_hIcon) { + if (!entry->_hIcon) { + ShellPath pidl_abs = static_cast(entry)->create_absolute_pidl(); + LPCITEMIDLIST pidl = pidl_abs; + + SHFILEINFO sfi; + + if (SHGetFileInfo((LPCTSTR)pidl, 0, &sfi, sizeof(sfi), SHGFI_PIDL|SHGFI_ICON|SHGFI_SMALLICON)) + entry->_hIcon = sfi.hIcon; + } + + if (!entry->_hIcon) + entry->_hIcon = (HICON)-1; // don't try again later + } } entry->_down = NULL; diff --git a/reactos/subsys/system/explorer/utility/utility.h b/reactos/subsys/system/explorer/utility/utility.h index 0f5fb459e90..c1438651104 100644 --- a/reactos/subsys/system/explorer/utility/utility.h +++ b/reactos/subsys/system/explorer/utility/utility.h @@ -191,14 +191,23 @@ struct Thread void Stop() { - _alive = false; + if (_alive) { + { + Lock lock(_crit_sect); + _alive = false; + } - // wait for finishing - WaitForSingleObject(_hThread, INFINITE); + // wait for finishing + WaitForSingleObject(_hThread, INFINITE); + } } virtual int Run() = 0; + bool is_alive() const {return _alive;} + + CritSect _crit_sect; + protected: static DWORD WINAPI ThreadProc(void* para);