Dave Korn wrote: > So here's an updated and retested
and corrected! > version of the patch done under the assumption that reverting that change > will be acceptable; if not, I can find a different way of doing it. Ok for > head? 2009-04-24 Andrew Punch <and...@xxxxxxxxxxxxx.xxx.xx> * PickView.h: Add #include <string>. (PickView::SetPackageFilter): Add new function. (PickView::packageFilterString): Add new string data member. * PickView.cc (PickView::setViewMode): Use it to filter names. (PickView::insert_category): Likewise. (PickView::PickView): Initialise packageFilterString to blank. * res.rc (IDD_CHOOSE): Add IDC_CHOOSE_SEARCH_EDIT and IDC_CHOOSE_SEARCH_LABEL controls. (IDS_SEARCH_TOOLTIP): Add new string resource. * resource.h (IDS_SEARCH_TOOLTIP): New string resource ID. (IDC_CHOOSE_SEARCH_EDIT): New edit control ID. (IDC_CHOOSE_SEARCH_LABEL): Mew static text control ID. * choose.cc (ChooserControlsInfo[]): Add IDC_CHOOSE_SEARCH_LABEL and IDC_CHOOSE_SEARCH_EDIT controls to auto-resize list. (ChooserPage::OnInit): Add tooltip to search edit box. (ChooserPage::OnMessageCmd): Handle EN_CHANGE event from IDC_CHOOSE_SEARCH_EDIT. 2009-04-24 Dave Korn <dave.korn.cyg...@xxxxx.xxx> * propsheet.cc (PropSheetWndProc): Re-enable hasMinRect. So, is _this_ one OK? cheers, DaveK
Index: PickView.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/PickView.cc,v retrieving revision 2.32 diff -p -u -r2.32 PickView.cc --- PickView.cc 8 Apr 2008 23:50:54 -0000 2.32 +++ PickView.cc 24 Apr 2009 19:21:57 -0000 @@ -191,8 +191,12 @@ PickView::setViewMode (views mode) // "Not installed" || (view_mode == PickView::views::PackageSkips && (!pkg.desired && !pkg.installed))) - - insert_pkg (pkg); + { + // Filter by package name + if (packageFilterString.empty () + || pkg.name.find (packageFilterString) != std::string::npos) + insert_pkg (pkg); + } } } @@ -309,13 +313,23 @@ PickView::insert_category (Category *cat (!showObsolete && isObsolete (cat->first))) return; PickCategoryLine & catline = *new PickCategoryLine (*this, *cat, 1, collapsed); + int packageCount = 0; for (vector <packagemeta *>::iterator i = cat->second.begin (); i != cat->second.end () ; ++i) { - PickLine & line = *new PickPackageLine (*this, **i); - catline.insert (line); + if (packageFilterString.empty () \ + || (*i && (*i)->name.find (packageFilterString) != std::string::npos)) + { + PickLine & line = *new PickPackageLine (*this, **i); + catline.insert (line); + packageCount++; + } } - contents.insert (catline); + + if (packageFilterString.empty () || packageCount) + contents.insert (catline); + else + delete &catline; } PickView::views& @@ -502,7 +516,7 @@ PickView::init_headers (HDC dc) PickView::PickView (Category &cat) : deftrust (TRUST_UNKNOWN), contents (*this, cat, 0, false, true), showObsolete (false), -hasClientRect (false) +packageFilterString (), hasClientRect (false) { } Index: PickView.h =================================================================== RCS file: /cvs/cygwin-apps/setup/PickView.h,v retrieving revision 2.17 diff -p -u -r2.17 PickView.h --- PickView.h 24 May 2006 13:01:34 -0000 2.17 +++ PickView.h 24 Apr 2009 19:21:57 -0000 @@ -16,6 +16,7 @@ #ifndef SETUP_PICKVIEW_H #define SETUP_PICKVIEW_H +#include <string> #include "win32.h" #include "window.h" #include "RECTWrapper.h" @@ -82,6 +83,13 @@ public: int header_height; PickCategoryLine contents; void scroll (HWND hwnd, int which, int *var, int code, int howmany); + + void SetPackageFilter (const std::string &filterString) + { + packageFilterString = filterString; + } + + HWND ListHeader (void) const { return listheader; @@ -135,6 +143,7 @@ private: HWND listheader; views view_mode; bool showObsolete; + std::string packageFilterString; // Stuff needed to handle resizing bool hasClientRect; Index: choose.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/choose.cc,v retrieving revision 2.145 diff -p -u -r2.145 choose.cc --- choose.cc 5 Aug 2008 15:48:55 -0000 2.145 +++ choose.cc 24 Apr 2009 19:21:57 -0000 @@ -67,6 +67,8 @@ extern ThreeBarProgressPage Progress; Sizing information. */ static ControlAdjuster::ControlInfo ChooserControlsInfo[] = { + {IDC_CHOOSE_SEARCH_LABEL, CP_LEFT, CP_TOP}, + {IDC_CHOOSE_SEARCH_EDIT, CP_LEFT, CP_TOP}, {IDC_CHOOSE_KEEP, CP_RIGHT, CP_TOP}, {IDC_CHOOSE_PREV, CP_RIGHT, CP_TOP}, {IDC_CHOOSE_CURR, CP_RIGHT, CP_TOP}, @@ -172,6 +174,7 @@ ChooserPage::OnInit () AddTooltip (IDC_CHOOSE_EXP, IDS_TRUSTEXP_TOOLTIP); AddTooltip (IDC_CHOOSE_VIEW, IDS_VIEWBUTTON_TOOLTIP); AddTooltip (IDC_CHOOSE_HIDE, IDS_HIDEOBS_TOOLTIP); + AddTooltip (IDC_CHOOSE_SEARCH_EDIT, IDS_SEARCH_TOOLTIP); } void @@ -255,7 +258,14 @@ ChooserPage::changeTrust(trusts aTrust) bool ChooserPage::OnMessageCmd (int id, HWND hwndctl, UINT code) { - if (code != BN_CLICKED) + if (code == EN_CHANGE && id == IDC_CHOOSE_SEARCH_EDIT) + { + std::string value (egetString (GetHWND (), IDC_CHOOSE_SEARCH_EDIT)); + chooser->SetPackageFilter (value); + chooser->refresh (); + return true; + } + else if (code != BN_CLICKED && code != EN_CHANGE) { // Not a click notification, we don't care. return false; Index: propsheet.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/propsheet.cc,v retrieving revision 2.12 diff -p -u -r2.12 propsheet.cc --- propsheet.cc 21 Mar 2009 21:15:47 -0000 2.12 +++ propsheet.cc 24 Apr 2009 19:21:57 -0000 @@ -226,7 +226,7 @@ static LRESULT CALLBACK PropSheetWndProc if (!psd.hasMinRect) { GetWindowRect (hwnd, &psd.minRect); - // psd.hasMinRect = true; + psd.hasMinRect = true; } psd.lastClientRect = clientRect; Index: res.rc =================================================================== RCS file: /cvs/cygwin-apps/setup/res.rc,v retrieving revision 2.75 diff -p -u -r2.75 res.rc --- res.rc 22 Jun 2008 02:37:16 -0000 2.75 +++ res.rc 24 Apr 2009 19:21:57 -0000 @@ -316,6 +316,9 @@ STYLE DS_MODALFRAME | DS_3DLOOK | WS_CHI CAPTION "Cygwin Setup - Select Packages" FONT 8, "MS Shell Dlg" BEGIN + RTEXT "&Search",IDC_STATIC,0,30,32,12,SS_CENTERIMAGE, + WS_EX_RIGHT + EDITTEXT IDC_CHOOSE_SEARCH_EDIT, 34, 30, 60, 12 CONTROL "&Keep",IDC_CHOOSE_KEEP,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,99,30,30,14 CONTROL "&Prev",IDC_CHOOSE_PREV,"Button",BS_AUTORADIOBUTTON , @@ -486,4 +489,5 @@ BEGIN "infrastructure packages that are handled automatically." IDS_SIG_INVALID "Mirror Error: Setup.ini signature %s from %s failed to verify.\nPossible corrupt mirror? Setup.ini rejected." IDS_CRYPTO_ERROR "Internal Error: gcrypt library error %d %s" + IDS_SEARCH_TOOLTIP "Search for this string in package names." END Index: resource.h =================================================================== RCS file: /cvs/cygwin-apps/setup/resource.h,v retrieving revision 2.36 diff -p -u -r2.36 resource.h --- resource.h 22 Jun 2008 02:37:16 -0000 2.36 +++ resource.h 24 Apr 2009 19:21:57 -0000 @@ -33,6 +33,7 @@ #define IDS_HIDEOBS_TOOLTIP 130 #define IDS_SIG_INVALID 131 #define IDS_CRYPTO_ERROR 132 +#define IDS_SEARCH_TOOLTIP 133 // Dialogs @@ -161,3 +162,5 @@ #define IDC_STATUS_HEADER 582 #define IDC_STATUS 583 #define IDC_STATIC_HEADER 584 +#define IDC_CHOOSE_SEARCH_EDIT 585 +#define IDC_CHOOSE_SEARCH_LABEL 586