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

Daniel Burrows dburrows@costa.debian.org
Tue, 07 Jun 2005 15:22:51 +0000


Author: dburrows
Date: Tue Jun  7 15:22:46 2005
New Revision: 3363

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/download_list.cc
   branches/aptitude-0.3/aptitude/src/download_list.h
Log:
Adjust the download list code 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 15:22:46 2005
@@ -1,3 +1,9 @@
+2005-06-07  Daniel Burrows  <dburrows@debian.org>
+
+	* src/download_list.cc:
+
+	Adjust the download list code for styles.
+
 2005-06-06  Daniel Burrows  <dburrows@debian.org>
 
 	* src/download_item.cc:

Modified: branches/aptitude-0.3/aptitude/src/download_list.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/download_list.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/download_list.cc	Tue Jun  7 15:22:46 2005
@@ -58,8 +58,6 @@
 
   fragment *fragment=wrapbox(sequence_fragment(fragments));
 
-  fragment->set_attr(get_color("DefaultWidgetBackground")|A_REVERSE);
-
   vscreen_widget *rval;
   if(already_cancelled || !cancel_slot)
     rval=vs_dialog_ok(fragment, arg(sigc::ptr_fun(vscreen_exitmain)));
@@ -69,7 +67,7 @@
 			 arg(sigc::bind(sigc::ptr_fun(download_summary_nasty_hack),
 					*cancel_slot)),
 			 _("Cancel"),
-			 get_color("DefaultWidgetBackground")|A_REVERSE);
+			 style_attrs_flip(A_REVERSE));
 
   rval->connect_key("PrevPage",
 		    &global_bindings,
@@ -123,21 +121,26 @@
 
 // all that CRITICAL_ENTER/CRITICAL_EXIT stuff is left out until I'm sure I
 // really need it.
-void download_list::paint()
+void download_list::paint(const style &st)
 {
   int y=0;
   unsigned int where=start;
   int width,height;
+  const style progress_style=st+get_style("DownloadProgress");
+  const int st_attrs=st.get_attrs();
+  const int progress_attrs=progress_style.get_attrs();
   getmaxyx(height, width);
 
   // Display the completed items
   while(y<height-1 && where<msgs.size())
     {
-      std::string disp(msgs[where].first,
-		       min<string::size_type>(startx, msgs[where].first.size()));
+      const style msg_style=st+msgs[where].second;
+      const int msg_attrs=msg_style.get_attrs();
+      const string disp(msgs[where].first,
+			min<string::size_type>(startx, msgs[where].first.size()));
 
       show_string_as_progbar(0, y, disp,
-			     msgs[where].second, msgs[where].second,
+			     msg_attrs, msg_attrs,
 			     width, width);
 
       y++;
@@ -162,7 +165,7 @@
 		  min<string::size_type>(startx, workers[where].msg.size()));
 
       show_string_as_progbar(0, y, disp,
-			     get_color("DownloadProgress"), get_bg(),
+			     progress_attrs, st_attrs,
 			     width1, width);
 
       y++;
@@ -189,7 +192,7 @@
       if(barsize>width)
 	barsize=width;
 
-      attrset(get_color("ScreenStatusColor"));
+      apply_style(get_style("Status"));
       if(CurrentCPS>0)
 	snprintf(progress_string, 50, _(" [ %i%% ] (%sB/s, %s remaining)"), int(double((100.0*(CurrentBytes+CurrentItems)))/(TotalBytes+TotalItems)), SizeToStr(CurrentCPS).c_str(), TimeToStr(ETA).c_str());
       else if(CurrentBytes>0 || CurrentItems>0)
@@ -204,8 +207,8 @@
   show_string_as_progbar(0,
 			 height-1,
 			 output,
-			 get_color("Progress"),
-			 get_color("ScreenStatusColor"),
+			 progress_attrs,
+			 get_style("Status").get_attrs(),
 			 barsize,
 			 width);
 }
@@ -263,10 +266,8 @@
 			    _("Please insert the disc labeled \"%s\" into the drive \"%s\""),
 			    media.c_str(), drive.c_str()));
 
-  f->set_attr(get_color("MediaChange"));
-
   vscreen_widget *w=vs_dialog_ok(f, arg(sigc::ptr_fun(vscreen_exitmain)),
-				 get_color("MediaChange"));
+				 get_style("MediaChange"));
   w->show_all();
   popup_widget(w);
 
@@ -280,8 +281,8 @@
 {
   if(display_messages)
     {
-      msgs.push_back(pair<string, int>(itmdesc.Description+" "+_("[Hit]"),
-					    get_color("DownloadHit")));
+      msgs.push_back(msg(itmdesc.Description+" "+_("[Hit]"),
+			 get_style("DownloadHit")));
 
       sync_top();
 
@@ -300,8 +301,8 @@
 {
   if(display_messages)
     {
-      msgs.push_back(pair<string, int>(itmdesc.Description+" "+_("[Downloaded]"),
-				       get_color("DownloadProgress")));
+      msgs.push_back(msg(itmdesc.Description+" "+_("[Downloaded]"),
+			 get_style("DownloadProgress")));
 
       sync_top();
 
@@ -320,16 +321,16 @@
 
       // ???
       if(itmdesc.Owner->Status==pkgAcquire::Item::StatDone)
-	msgs.push_back(pair<string, int>(itmdesc.Description+" "+_("[IGNORED]"),
-					      get_color("DownloadHit")));
+	msgs.push_back(msg(itmdesc.Description+" "+_("[IGNORED]"),
+			   get_style("DownloadHit")));
       else
 	{
 	  failed=true;
 
-	  msgs.push_back(pair<string, int>(itmdesc.Description+" "+_("[ERROR]"),
-						get_color("Error")));
-	  msgs.push_back(pair<string, int>(" "+itmdesc.Owner->ErrorText,
-						get_color("Error")));
+	  msgs.push_back(msg(itmdesc.Description+" "+_("[ERROR]"),
+			     get_style("Error")));
+	  msgs.push_back(msg(" "+itmdesc.Owner->ErrorText,
+			     get_style("Error")));
 	}
 
       sync_top();

Modified: branches/aptitude-0.3/aptitude/src/download_list.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/download_list.h	(original)
+++ branches/aptitude-0.3/aptitude/src/download_list.h	Tue Jun  7 15:22:46 2005
@@ -29,8 +29,10 @@
       :msg(_msg), current(_current), total(_total) {}
   };
 
+  typedef std::pair<std::string, style> msg;
+
   // Contains strings paired with attributes.
-  typedef std::vector<std::pair<std::string, int> > msglist;
+  typedef std::vector<msg> msglist;
 
   // Contains strings paired with the current and total sizes associated
   // with that worker (updated in Pulse)
@@ -81,7 +83,7 @@
 
   void layout_me();
 protected:
-  void paint();
+  void paint(const style &st);
   bool handle_char(chtype ch);
 public:
   download_list(slot0arg _abortslot=NULL,