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]

Patch: Setup.exe - search for package


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.

The features of the patch are as follows:
* In the "Select Packages" screen I added a new edit box - the search edit box. The search edit box is to the left of the Keep/Prev/Curr/Exp and View elements
* As soon as the text in the search edit box changes - the list of packages is filtered
* If the package name contains the text in the search edit box - the package is displayed
* If the View is in "Category" mode - only categories containing matching packages will be displayed, when a category is expanded only matching packages are shown


Any suggestions are welcome.

-Andrew
Common subdirectories: setup-2.573.2.3/.deps and setup-new/.deps
diff -u --exclude '*config.*' --exclude '*Makefile' setup-2.573.2.3/PickView.cc setup-new/PickView.cc
--- setup-2.573.2.3/PickView.cc	2006-05-24 23:01:34.000000000 +1000
+++ setup-new/PickView.cc	2009-03-31 23:02:41.078125000 +1100
@@ -172,7 +172,7 @@
         {
           packagemeta & pkg = **i;
 
-          if ( // "Full" : everything
+          if (( // "Full" : everything
               (view_mode == PickView::views::PackageFull)
 
               // "Partial" : packages that are being added/removed/upgraded
@@ -189,9 +189,14 @@
 
               // "Not installed"
               || (view_mode == PickView::views::PackageSkips &&
-                  (!pkg.desired && !pkg.installed)))
-            
-            insert_pkg (pkg);
+                  (!pkg.desired && !pkg.installed))
+				  )
+				  // Filter by package name
+				  && (packageFilterString.empty() || pkg.name.find(packageFilterString) != std::string::npos)
+				  )
+            {
+				 insert_pkg (pkg);
+			}
         }
     }
 
@@ -283,20 +288,20 @@
     }
   else
     {
-      for (set <std::string, casecompare_lt_op>::const_iterator x
+	  for (set <std::string, casecompare_lt_op>::const_iterator x
 	   = pkg.categories.begin (); x != pkg.categories.end (); ++x)
-        {
+		{
 	  // Special case - yuck
 	  if (casecompare(*x, "All") == 0)
-	    continue;
+		continue;
 
 	  packagedb db;
 	  PickCategoryLine & catline = 
-	    *new PickCategoryLine (*this, *db.categories.find (*x), 1);
+		*new PickCategoryLine (*this, *db.categories.find (*x), 1);
 	  PickLine & line = *new PickPackageLine(*this, pkg);
 	  catline.insert (line);
 	  contents.insert (catline);
-        }
+		}
     }
 }
 
@@ -308,13 +313,23 @@
       (!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&
@@ -501,7 +516,7 @@
 
 PickView::PickView (Category &cat) : deftrust (TRUST_UNKNOWN),
 contents (*this, cat, 0, false, true), showObsolete (false), 
-hasClientRect (false)
+packageFilterString(), hasClientRect (false)
 {
 }
 
diff -u --exclude '*config.*' --exclude '*Makefile' setup-2.573.2.3/PickView.h setup-new/PickView.h
--- setup-2.573.2.3/PickView.h	2006-05-24 23:01:34.000000000 +1000
+++ setup-new/PickView.h	2009-03-31 21:14:00.375000000 +1100
@@ -19,6 +19,7 @@
 #include "win32.h"
 #include "window.h"
 #include "RECTWrapper.h"
+#include <string>
 
 #define HMARGIN         10
 #define ROW_MARGIN      5
@@ -82,6 +83,13 @@
   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 @@
   HWND listheader;
   views view_mode;
   bool showObsolete;
+  std::string packageFilterString;
 
   // Stuff needed to handle resizing
   bool hasClientRect;
Common subdirectories: setup-2.573.2.3/cfgaux and setup-new/cfgaux
diff -u --exclude '*config.*' --exclude '*Makefile' setup-2.573.2.3/choose.cc setup-new/choose.cc
--- setup-2.573.2.3/choose.cc	2006-04-16 22:30:07.000000000 +1000
+++ setup-new/choose.cc	2009-03-31 21:14:00.375000000 +1100
@@ -65,6 +65,7 @@
   Sizing information.
  */
 static ControlAdjuster::ControlInfo ChooserControlsInfo[] = {
+  {IDC_CHOOSE_SEARCH_EDIT, 	CP_RIGHT,   CP_TOP},
   {IDC_CHOOSE_KEEP, 		CP_RIGHT,   CP_TOP},
   {IDC_CHOOSE_PREV, 		CP_RIGHT,   CP_TOP},
   {IDC_CHOOSE_CURR, 		CP_RIGHT,   CP_TOP},
@@ -252,7 +253,15 @@
 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;
@@ -291,8 +300,9 @@
     case IDC_CHOOSE_HIDE:
       chooser->setObsolete (!IsButtonChecked (id));
       break;
+	  
+
     default:
-      // Wasn't recognized or handled.
       return false;
     }
 
Common subdirectories: setup-2.573.2.3/csu_util and setup-new/csu_util
Only in setup-new: cygwin-package-search.diff
Common subdirectories: setup-2.573.2.3/libgcrypt and setup-new/libgcrypt
Common subdirectories: setup-2.573.2.3/libgetopt++ and setup-new/libgetopt++
Common subdirectories: setup-2.573.2.3/libgpg-error and setup-new/libgpg-error
Common subdirectories: setup-2.573.2.3/libmd5-rfc and setup-new/libmd5-rfc
diff -u --exclude '*config.*' --exclude '*Makefile' setup-2.573.2.3/res.rc setup-new/res.rc
--- setup-2.573.2.3/res.rc	2008-06-19 09:26:20.000000000 +1000
+++ setup-new/res.rc	2009-03-31 21:14:00.390625000 +1100
@@ -316,7 +316,8 @@
 CAPTION "Cygwin Setup - Select Packages"
 FONT 8, "MS Shell Dlg"
 BEGIN
-    CONTROL         "&Keep",IDC_CHOOSE_KEEP,"Button",BS_AUTORADIOBUTTON | 
+    EDITTEXT		IDC_CHOOSE_SEARCH_EDIT, 7, 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 , 
                     134,30,27,14
diff -u --exclude '*config.*' --exclude '*Makefile' setup-2.573.2.3/resource.h setup-new/resource.h
--- setup-2.573.2.3/resource.h	2008-06-19 09:26:20.000000000 +1000
+++ setup-new/resource.h	2009-03-31 21:14:00.390625000 +1100
@@ -161,3 +161,5 @@
 #define IDC_STATUS_HEADER                 582
 #define IDC_STATUS                        583
 #define IDC_STATIC_HEADER                 584
+#define IDC_CHOOSE_SEARCH_EDIT			  585
+
Common subdirectories: setup-2.573.2.3/tests and setup-new/tests
2009-03-27 Andrew Punch <andrew@magneticbooks.com.au>

This patch adds package search functionality to cygwin setup. The functionality I propose is as follows:
* In the "Select Packages" screen I added a new edit box - the search edit box. The search edit box is to the left of the Keep/Prev/Curr/Exp and View elements
* As soon as the text in the search edit box changes - the list of packages is filtered
* If the package name contains the text in the search edit box - the package is displayed
* If the View is in "Category" mode - only categories containing matching packages will be displayed, when a category is expanded only matching packages are shown


* PickView.h (PickView::SetPackageFilter): Added definition of function SetPackageFilter to class PickView
* PickView.h (PickView::packageFilterString): Added variable packageFilterString to class PickView
* PickView.h: Added #include <string>, as std::string is used for packageFilterString variable
* PickView.cc (PickView::setViewMode): If packageFilterString is not empty - check whether packageFilterString matches the package name 
* PickView.cc (PickView::insert_category): If packageFilterString is not empty - check whether packageFilterString matches the package name
* PickView.cc (PickView::PickView): Initialise packageFilterString to be a blank string
* res.rc: Added IDC_CHOOSE_SEARCH_EDIT
* resource.h: Added IDC_CHOOSE_SEARCH_EDIT
* choose.cc (ChooserControlsInfo): Added IDC_CHOOSE_SEARCH_EDIT control to auto-resize list
* choose.cc (ChooserPage::OnMessageCmd): Added handling of EN_CHANGE code event from IDC_CHOOSE_SEARCH_EDIT

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]