This is the mail archive of the cygwin-patches@cygwin.com 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]

Updated Robert Collins dependency/category patch against current CVS


I felt bad about changing code around Robert's patch, so I regenerated
it against the current CVS sources, if anyone wants to try it.

cgf
Index: choose.cc
===================================================================
RCS file: /cvs/uberbaum/winsup/cinstall/choose.cc,v
retrieving revision 2.30
diff -p -r2.30 choose.cc
*** choose.cc	2001/06/15 04:23:01	2.30
--- choose.cc	2001/06/15 04:26:47
*************** headers[] = {
*** 81,94 ****
  #define NEW_COL 1
    { "Src?", 4, 0, 0 },
  #define SRC_COL 2
    { "Package", 7, 0, 0 },
! #define PACKAGE_COL 3
    { 0, 0, 0, 0 }
  };
  #define NUM_COLUMNS (sizeof (headers) / (sizeof (headers[0])) - 1)
  
  int *package_indexes, nindexes;
  
  static bool
  isinstalled (Package *pkg, int trust)
  {
--- 81,100 ----
  #define NEW_COL 1
    { "Src?", 4, 0, 0 },
  #define SRC_COL 2
+   { "Category", 8, 0, 0 },
+ #define CATEGORY_COL 3
    { "Package", 7, 0, 0 },
! #define PACKAGE_COL 4
    { 0, 0, 0, 0 }
  };
  #define NUM_COLUMNS (sizeof (headers) / (sizeof (headers[0])) - 1)
  
  int *package_indexes, nindexes;
  
+ static int add_required(Package *pkg);
+ static void set_full_list (HWND h, int isfull);
+ 
+ 
  static bool
  isinstalled (Package *pkg, int trust)
  {
*************** set_action (Package *pkg, bool preinc)
*** 165,170 ****
--- 171,257 ----
        }
  }
  
+ static int
+ add_required (Package *pkg)
+ {
+   Dependency *dp;
+   Package *required;
+   int c;
+   int changed = 0;
+   dp = pkg->required;
+   switch (pkg->action)
+     {
+     case ACTION_UNINSTALL:
+     case ACTION_ERROR:
+     case ACTION_UNKNOWN:
+     case ACTION_SRC_ONLY:
+     case ACTION_SKIP:
+       return 0;
+     default:
+       break;
+     }
+   while (dp)
+     {
+       if ((required = getpkgbyname(dp->package)) == NULL)
+         {
+           dp=dp->next;
+           continue;
+         }
+       switch (required->action)
+         {
+ 	case ACTION_PREV:
+ 	case ACTION_CURR:
+ 	case ACTION_TEST:
+ 	case ACTION_LAST:
+ 	case ACTION_SAME_CURR:
+ 	case ACTION_SAME_TEST:
+ 	case ACTION_SAME_PREV:
+ 	case ACTION_REDO:
+ 	case ACTION_SAME_LAST:
+ 	  /* we are installing a user selected version */
+ 	  break;
+ 	
+ 	case ACTION_UNINSTALL:
+ 	  /* it's already installed - leave it */
+ 	  required->action = ACTION_SKIP;
+ 	  break;
+ 	case ACTION_ERROR:
+ 	case ACTION_UNKNOWN:
+ 	case ACTION_SRC_ONLY:
+ 	case ACTION_SKIP:
+ 	  /* the current install will fail */
+ 	  required->action = ACTION_PREV; /* this find prev, then curr, then test. */
+ 	  set_action(required, 0);	  /* we need a find_best that gets installed, */
+ 	  changed++;			  /* then current, then prev, then test */
+ 	  /* we should insert the package in alphabetical order */
+ 	  if (package_indexes) 
+ 	    {
+ 	      int n=0;
+ 	      while (n < nindexes)
+ 	        {
+ 		  if (package_indexes[n] > required-package)
+ 		    {
+ 		      memmove (&package_indexes[n + 1], &package_indexes[n], (nindexes - n) * sizeof (package_indexes[n]));
+ 		      package_indexes[n] = required - package;
+ 		      nindexes++;
+ 		      n=nindexes;	
+ 		    }
+ 		  else if (package_indexes[n] == required-package)
+ 		    n=nindexes;
+ 		  n++;
+ 		}
+ 	    }
+ //	  package_indexes[nindexes++] = required - package;
+ 	  break;
+ 	default:
+ 	  log (0, "should never get here %d\n", required->action);
+ 	}
+       changed += add_required (required);
+       dp=dp->next;
+     }
+   return changed;
+ }
+ 
  /* Return an appropriate caption given the current action. */
  const char *
  choose_caption (Package *pkg)
*************** paint (HWND hwnd)
*** 258,263 ****
--- 345,353 ----
        BitBlt (hdc, x + headers[SRC_COL].x, by, 11, 11,
  	      bitmap_dc, 0, 0, SRCCOPY);
  
+       if (package[i].category)
+        TextOut (hdc, x + headers[CATEGORY_COL].x, r, package[i].category, strlen (package[i].category));
+ 
        if (package[i].sdesc)
  	s = package[i].sdesc;
        else
*************** list_hscroll (HWND hwnd, HWND hctl, UINT
*** 350,356 ****
  static LRESULT CALLBACK
  list_click (HWND hwnd, BOOL dblclk, int x, int y, UINT hitCode)
  {
!   int r;
  
    if (nindexes == 0)
      return 0;
--- 440,446 ----
  static LRESULT CALLBACK
  list_click (HWND hwnd, BOOL dblclk, int x, int y, UINT hitCode)
  {
!   int r,refresh;
  
    if (nindexes == 0)
      return 0;
*************** list_click (HWND hwnd, BOOL dblclk, int 
*** 370,384 ****
    if (x >= headers[NEW_COL].x - (HMARGIN / 2) && x <= headers[NEW_COL + 1].x - HMARGIN/2)
      set_action (pkg, 1);
  
    if (x >= headers[SRC_COL].x - HMARGIN/2 && x <= headers[SRC_COL + 1].x - HMARGIN/2)
      pkg->srcpicked ^= 1;
  
!   RECT rect;
!   rect.left = headers[NEW_COL].x - scroll_ulc_x;
!   rect.right = headers[SRC_COL + 1].x - scroll_ulc_x;
!   rect.top = header_height + r * row_height - scroll_ulc_y;
!   rect.bottom = rect.top + row_height;
!   InvalidateRect (hwnd, &rect, TRUE);
  }
  
  static LRESULT CALLBACK
--- 460,497 ----
    if (x >= headers[NEW_COL].x - (HMARGIN / 2) && x <= headers[NEW_COL + 1].x - HMARGIN/2)
      set_action (pkg, 1);
  
+   /* Add any packages that are needed by this package */
+   refresh = add_required(pkg);
+ 
    if (x >= headers[SRC_COL].x - HMARGIN/2 && x <= headers[SRC_COL + 1].x - HMARGIN/2)
      pkg->srcpicked ^= 1;
  
!   if (refresh)
!     {
!       RECT r;
!       GetClientRect (lv, &r);
!       SCROLLINFO si;
!       memset (&si, 0, sizeof (si));
!       si.cbSize = sizeof (si);
!       si.fMask = SIF_RANGE;
!       si.nMin = 0;
! 
!       si.nMax = nindexes * row_height;
!       SetScrollInfo (lv, SB_VERT, &si, FALSE);
! 
!       InvalidateRect (lv, &r, TRUE);
! 
! //      scroll_ulc_x = scroll_ulc_y = 0;
!     }
!   else
!     {
!       RECT rect;
!       rect.left = headers[NEW_COL].x - scroll_ulc_x;
!       rect.right = headers[SRC_COL + 1].x - scroll_ulc_x;
!       rect.top = header_height + r * row_height - scroll_ulc_y;
!       rect.bottom = rect.top + row_height;
!       InvalidateRect (hwnd, &rect, TRUE);
!     }
  }
  
  static LRESULT CALLBACK
*************** default_trust (HWND h, trusts trust)
*** 481,486 ****
--- 594,601 ----
    for (Package *pkg = package; pkg->name; pkg++)
      {
        pkg->action = (actions) trust;
+       if (pkg->category && strcasecmp(pkg->category, "Required"))
+ 	pkg->action = ACTION_SKIP;
        set_action (pkg, 0);
      }
    RECT r;
*************** create_listview (HWND dlg, RECT *r)
*** 574,579 ****
--- 689,695 ----
  	}
        for (Info *inf = pkg->infoscan; inf < pkg->infoend; inf++)
  	note_width (dc, inf->version, NEW_COL_SIZE_SLOP, NEW_COL);
+       note_width (dc, pkg->category, 0, CATEGORY_COL);
        note_width (dc, pkg->name, 0, PACKAGE_COL);
        note_width (dc, pkg->sdesc, 0, PACKAGE_COL);
      }
*************** create_listview (HWND dlg, RECT *r)
*** 583,592 ****
    headers[CURRENT_COL].x = HMARGIN/2;
    headers[NEW_COL].x = headers[CURRENT_COL].x + headers[CURRENT_COL].width + NEW_COL_SIZE_SLOP + HMARGIN;
    headers[SRC_COL].x = headers[NEW_COL].x + headers[NEW_COL].width + HMARGIN;
!   headers[PACKAGE_COL].x = headers[SRC_COL].x + headers[SRC_COL].width + HMARGIN;
  
    default_trust (lv, TRUST_CURR);
    set_full_list (lv, full_list);
    static int ta[] = { IDC_CHOOSE_CURR, 0 };
    rbset (dlg, ta, IDC_CHOOSE_CURR);
  
--- 699,711 ----
    headers[CURRENT_COL].x = HMARGIN/2;
    headers[NEW_COL].x = headers[CURRENT_COL].x + headers[CURRENT_COL].width + NEW_COL_SIZE_SLOP + HMARGIN;
    headers[SRC_COL].x = headers[NEW_COL].x + headers[NEW_COL].width + HMARGIN;
!   headers[CATEGORY_COL].x = headers[SRC_COL].x + headers[SRC_COL].width + HMARGIN;
!   headers[PACKAGE_COL].x = headers[CATEGORY_COL].x + headers[CATEGORY_COL].width + HMARGIN;
  
    default_trust (lv, TRUST_CURR);
    set_full_list (lv, full_list);
+   for (Package *foo = package; foo->name; foo++)
+     add_required(foo);
    static int ta[] = { IDC_CHOOSE_CURR, 0 };
    rbset (dlg, ta, IDC_CHOOSE_CURR);
  
*************** dialog_cmd (HWND h, int id, HWND hwndctl
*** 600,613 ****
--- 719,738 ----
      {
      case IDC_CHOOSE_PREV:
        default_trust (lv, TRUST_PREV);
+       for (Package *foo = package; foo->name; foo++)
+         add_required(foo);
        set_full_list (lv, full_list);
        break;
      case IDC_CHOOSE_CURR:
        default_trust (lv, TRUST_CURR);
+       for (Package *foo = package; foo->name; foo++)
+         add_required(foo);
        set_full_list (lv, full_list);
        break;
      case IDC_CHOOSE_EXP:
        default_trust (lv, TRUST_TEST);
+       for (Package *foo = package; foo->name; foo++)
+         add_required(foo);
        set_full_list (lv, full_list);
        break;
      case IDC_CHOOSE_FULLPART:
*************** do_choose (HINSTANCE h)
*** 958,966 ****
  			       : "unknown");
        const char *excluded = (pkg->exclude ? "yes" : "no");
  
!       log (LOG_BABBLE, "[%s] action=%s trust=%s installed=%s excluded=%s src?=%s",
  	   pkg->name, action, trust, installed,
! 	   excluded, pkg->srcpicked ? "yes" : "no");
        for (int t = 1; t < NTRUST; t++)
  	{
  	  if (pkg->info[t].install)
--- 1083,1092 ----
  			       : "unknown");
        const char *excluded = (pkg->exclude ? "yes" : "no");
  
!       log (LOG_BABBLE, "[%s] action=%s trust=%s installed=%s excluded=%s src?=%s"
! 	   "category=%s",
  	   pkg->name, action, trust, installed,
! 	   excluded, pkg->srcpicked ? "yes" : "no", pkg->category);
        for (int t = 1; t < NTRUST; t++)
  	{
  	  if (pkg->info[t].install)

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