This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: Setup.exe - search for package


Dave Korn wrote:
> Dave Korn wrote:
>> Andrew Punch wrote:
>>> Hi,
>>> 
>>> I have attached a patch for searching packages in the package selection
>>>  screen. The patch is against version 2.573.2.3 - I couldn't get the
>>> CVS head to build due to a libtool version problem.
>> Thanks for contributing this.  I'm currently up-porting it to CVS HEAD
>> and giving it some testing.  

>  I think the search box needs a label attached and a tool-tip, and IMO I
> think it might look nicer if it was left-aligned away from the view
> controls; what do you (and everyone else) think?  

  So, I've up-ported to HEAD, adjusted coding style to match its surroundings,
slightly restructured a couple of bits, and added a label and tool-tip and
left-aligned it.  The result is attached for whoever else would like to test it.

  One consequence of doing this is that it draws attention to the fact we need
to implement minimum window size dimensions for the chooser page; it's bad
enough that you can shrink it down far enough that controls slide off the
left-hand edge, but it looks even uglier when the right-aligned controls start
to slide over the left-aligned ones.  If that sounds like the right thing to
do, I'll roll a patch.

> Secondly, every time you
> change the search-box contents in the category view, it collapses all
> expanded categories; I'd like to avoid that if we can, but haven't yet
> looked to see how.

  I decided not to go any further into this one for now, because it's only the
same behaviour that all the other buttons display when using the category
view.  Maybe we'll fix it later, maybe it will prove less tractable, but it's
another patch for another day.

  Revised changelog follows.  What do you think, everyone: 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: 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	1 Apr 2009 15:28:07 -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: 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	1 Apr 2009 15:28:07 -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
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	1 Apr 2009 15:28:07 -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: 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	1 Apr 2009 15:28:07 -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: 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	1 Apr 2009 15:28:07 -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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]