This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
[PATCH] Setup.exe package search/filter (PING cgf)
- From: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- To: cygwin-apps <cygwin-apps at cygwin dot com>
- Date: Fri, 24 Apr 2009 20:30:36 +0100
- Subject: [PATCH] Setup.exe package search/filter (PING cgf)
Prompted by Marcio (thanks!), I went back to the setup.exe filter search patch.
The one outstanding issue, you may remember, was the need to set a minimum
size for the setup dialog, to prevent horrible ugliness when the controls
overdrew each other or went outside the client area.
On investigation, it turns out that we already had a serviceable
minimum-size mechanism, which was disabled in r2.10 of propsheet.cc when cgf
was adding the auto-maximization of the chooser page. The ChangeLog comment
doesn't refer to this, so PING cgf: was this an inadvertent change? I tried
reverting it and it doesn't appear to be necessary for the auto-maximization
to function correctly, nor could I see anything wrong with using the initial
layout size as a minimum.
So here's an updated and retested 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-03-27 Andrew Punch <andrew@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.
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 18:53:29 -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 18:53:29 -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 18:53:29 -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 18:53:29 -0000
@@ -183,6 +183,9 @@ static LRESULT CALLBACK PropSheetWndProc
{
RECTWrapper clientRect;
GetClientRect (hwnd, &clientRect);
+
+ log (LOG_PLAIN) << "WM_SIZE " << clientRect.left << "," << clientRect.top
+ << " - " << clientRect.width () << "x" << clientRect.height () << endLog;
/*
When the window is minimized, the client rect is reduced to
@@ -201,6 +204,10 @@ static LRESULT CALLBACK PropSheetWndProc
clientRect.width () - psd.lastClientRect.width ();
const int dY =
clientRect.height () - psd.lastClientRect.height ();
+
+ log (LOG_PLAIN) << "Not min, client rect valid, dX " << dX
+ << " x dY " << dY << endLog;
+
ControlAdjuster::AdjustControls (hwnd, PropSheetControlsInfo,
dX, dY);
@@ -219,6 +226,7 @@ static LRESULT CALLBACK PropSheetWndProc
else
{
psd.clientRectValid = true;
+ log (LOG_PLAIN) << "Client rect set valid" << endLog;
}
/*
Store away the current size and use it as the minmal window size.
@@ -226,7 +234,9 @@ static LRESULT CALLBACK PropSheetWndProc
if (!psd.hasMinRect)
{
GetWindowRect (hwnd, &psd.minRect);
- // psd.hasMinRect = true;
+ psd.hasMinRect = true;
+ log (LOG_PLAIN) << "minRect: " << psd.minRect.left << "," << psd.minRect.top
+ << " - " << psd.minRect.width () << "x" << psd.minRect.height () << endLog;
}
psd.lastClientRect = clientRect;
@@ -240,6 +250,8 @@ static LRESULT CALLBACK PropSheetWndProc
LPMINMAXINFO mmi = (LPMINMAXINFO)lParam;
mmi->ptMinTrackSize.x = psd.minRect.width ();
mmi->ptMinTrackSize.y = psd.minRect.height ();
+ log (LOG_PLAIN) << "set minRect: " << psd.minRect.width () <<
+ "x" << psd.minRect.height () << endLog;
}
}
break;
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 18:53:29 -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 18:53:29 -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