[Aptitude-svn-commit] r3369 - in branches/aptitude-0.3/aptitude: . src

Daniel Burrows dburrows@costa.debian.org
Tue, 07 Jun 2005 17:26:34 +0000


Author: dburrows
Date: Tue Jun  7 17:26:32 2005
New Revision: 3369

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/pkg_item.cc
   branches/aptitude-0.3/aptitude/src/pkg_item.h
Log:
Update pkg_item for styles.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Tue Jun  7 17:26:32 2005
@@ -1,5 +1,11 @@
 2005-06-07  Daniel Burrows  <dburrows@debian.org>
 
+	* src/pkg_item.cc, src/pkg_item.h:
+
+	Extend the signature of pkg_item::paint() to properly override its
+	abstract ancestor, and adjust the code that sets the attributes of
+	a package item to be style-based.
+
 	* src/load_pkgview.cc, src/pkg_view.h:
 
 	Adjust the package view loading code to use styles rather than

Modified: branches/aptitude-0.3/aptitude/src/pkg_item.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/pkg_item.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/pkg_item.cc	Tue Jun  7 17:26:32 2005
@@ -79,8 +79,6 @@
 
   fragment *f=wrapbox(fragf(_("%s is an essential package!%n%nAre you sure you want to remove it?%nType '%s' if you are."), pkg.Name(), _(confirm_str)));
 
-  f->set_attr(get_color("DefaultWidgetBackground") | A_REVERSE);
-
   vscreen_widget *w=vs_dialog_string(f,
 				     "",
 				     arg(sigc::bind(sigc::ptr_fun(try_delete_essential),
@@ -88,7 +86,7 @@
 				     NULL,
 				     NULL,
 				     NULL,
-				     get_color("DefaultWidgetBackground") | A_REVERSE);
+				     style_attrs_flip(A_REVERSE));
 
   w->show_all();
 
@@ -234,12 +232,12 @@
    view_changelog(visible_version());
 }
 
-int pkg_item::get_normal_attr()
+style pkg_item::get_normal_style()
 {
-  return pkg_attr(package, vs_treeitem::get_normal_attr());
+  return vs_treeitem::get_normal_style() + pkg_style(package);
 }
 
-int pkg_item::pkg_attr(pkgCache::PkgIterator package, int normal_attr)
+style pkg_item::pkg_style(pkgCache::PkgIterator package)
 {
   if(package.VersionList().end())
     {
@@ -258,13 +256,13 @@
 	}
 
       if(present_now && present_inst)
-	return A_BOLD|normal_attr;
+	return style_attrs_on(A_BOLD);
       else if(present_now)
-	return get_color("PkgToRemove");
+	return get_style("PkgToRemove");
       else if(present_inst)
-	return get_color("PkgToInstall");
+	return get_style("PkgToInstall");
       else
-	return normal_attr;
+	return style();
     }
   else
     {
@@ -272,25 +270,25 @@
 
       if(!state.InstBroken() &&
 	 (state.NewInstall() || (state.iFlags&pkgDepCache::ReInstall)))
-	return get_color("PkgToInstall");
+	return get_style("PkgToInstall");
       else if(state.Status!=2 && // Not being upgraded
 	      (*apt_cache_file)->get_ext_state(package).selection_state==pkgCache::State::Hold // Flagged for hold
 	      && !state.InstBroken()) // Not currently broken.
-	return get_color("PkgToHold");
+	return get_style("PkgToHold");
       else if(state.Delete())
-	return get_color("PkgToRemove");
+	return get_style("PkgToRemove");
       else if(state.InstBroken())
-	return get_color("PkgBroken");
+	return get_style("PkgBroken");
       else if(state.Upgrade())
-	return get_color("PkgToUpgrade");
+	return get_style("PkgToUpgrade");
       else if(package.CurrentVer().end())
-	return normal_attr;
+	return style();
       else
-	return A_BOLD|normal_attr;
+	return style_attrs_on(A_BOLD);
     }
 }
 
-void pkg_item::paint(vs_tree *win, int y, bool hierarchical)
+void pkg_item::paint(vs_tree *win, int y, bool hierarchical, const style &st)
 {
   int basex=hierarchical?2*get_depth():0;
   int width, height;

Modified: branches/aptitude-0.3/aptitude/src/pkg_item.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/pkg_item.h	(original)
+++ branches/aptitude-0.3/aptitude/src/pkg_item.h	Tue Jun  7 17:26:32 2005
@@ -1,6 +1,6 @@
 // pkg_item.h  -*-c++-*-
 //
-//  Copyright 1999,2000 Daniel Burrows
+//  Copyright 1999-2005 Daniel Burrows
 //
 //  This program is free software; you can redistribute it and/or modify
 //  it under the terms of the GNU General Public License as published by
@@ -51,7 +51,7 @@
 	   const pkgCache::PkgIterator &,
 	   const pkgCache::VerIterator &> *sig);
 
-  virtual void paint(vs_tree *win, int y, bool hierarchical);
+  virtual void paint(vs_tree *win, int y, bool hierarchical, const style &st);
 
   virtual const char *tag() const;
   virtual const char *label() const;
@@ -69,7 +69,7 @@
   virtual void highlighted(vs_tree *win);
   virtual void unhighlighted(vs_tree *win);
 
-  virtual int get_normal_attr();
+  virtual style get_normal_style();
 
   void show_changelog();
   void show_information();
@@ -80,11 +80,10 @@
   bool dispatch_char(chtype ch, vs_tree *owner);
   void dispatch_mouse(short id, int x, mmask_t bstate, vs_tree *owner);
 
-  /** Returns the attributes that would be used to display the given
-   *  package.  normal_attr indicates the "background" attributes that
-   *  should be used.
+  /** Returns the style that would be used to display the given
+   *  package.
    */
-  static int pkg_attr(pkgCache::PkgIterator package, int normal_attr);
+  static style pkg_style(pkgCache::PkgIterator package);
 };
 
 #endif