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

Daniel Burrows dburrows at costa.debian.org
Mon Sep 19 23:52:51 UTC 2005


Author: dburrows
Date: Mon Sep 19 23:52:48 2005
New Revision: 4117

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/broken_indicator.cc
   branches/aptitude-0.3/aptitude/src/generic/resolver_manager.cc
Log:
Use columns to display the spinner flush-right and to display it
even when a real solution is being examined.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Mon Sep 19 23:52:48 2005
@@ -1,5 +1,10 @@
 2005-09-19  Daniel Burrows  <dburrows at debian.org>
 
+	* src/broken_indicator.cc:
+
+	  Use columns to display the spinner flush-right and to display it
+	  even when the user selects a finished solution again.
+
 	* src/vscreen/fragment.cc, src/vscreen/fragment.h, src/vscreen/testvscreen.cc:
 
 	  Add a simple column-generating class.  It has a caveat regarding

Modified: branches/aptitude-0.3/aptitude/src/broken_indicator.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/broken_indicator.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/broken_indicator.cc	Mon Sep 19 23:52:48 2005
@@ -59,7 +59,12 @@
   /** Records whether we had generated all solutions at the time of
    *  the last update.
    */
-  bool last_complete;
+  bool last_complete : 1;
+
+  /** Records whether the background thread was active at the time of
+   *  the last update.
+   */
+  bool last_background_active : 1;
 
   /** Tracks the phase of the visual "spinner". */
   int spin_count;
@@ -115,7 +120,7 @@
   {
     if(resman->background_thread_active())
       {
-	++spin_count;
+ 	++spin_count;
 	update();
 	vscreen_update();
       }
@@ -124,8 +129,11 @@
 		       aptcfg->FindI(PACKAGE "::Spin-Interval", 500));
   }
 
-  std::string spin_string() const
+  std::string spin_string(const resolver_manager::state &state) const
   {
+    if(!state.background_thread_active)
+      return " ";
+
     switch(spin_count % 4)
       {
       case 0:
@@ -198,8 +206,13 @@
       {
 	// TODO: add a column-generating fragment that can
 	//       left/right justify stuff.
-	set_fragment(fragf(_("Resolving dependencies   %s%n%F"),
-			   spin_string().c_str(), key_hint_fragment()));
+
+	vector<fragment_column_entry> columns;
+
+	columns.push_back(fragment_column_entry(true, 1, fragment_column_entry::top, hardwrapbox(text_fragment("Resolving dependencies"))));
+	columns.push_back(fragment_column_entry(false, 1, fragment_column_entry::top, text_fragment(spin_string(state))));
+
+	set_fragment(fragment_columns(columns));
 	last_sol.nullify();
 	show();
 	return;
@@ -209,11 +222,16 @@
 
     // This test always fails the first time update() is called, since
     // sol is never NULL and last_sol is initialized to NULL.
-    if(sol == last_sol && state.solutions_exhausted == last_complete)
+    if(sol == last_sol && state.solutions_exhausted == last_complete &&
+       // If there's an active thread we need to redraw the widget to
+       // include the spinner.
+       !last_background_active &&
+       state.background_thread_active == last_background_active)
       return;
 
     last_sol = sol;
     last_complete = state.solutions_exhausted;
+    last_background_active = state.background_thread_active;
 
     if(sol.get_actions().empty())
       {
@@ -304,12 +322,20 @@
 	fragments.push_back(join_fragments(suggestions,
 					   L","));
 
-	fragments.push_back(newline_fragment());
+	vector<fragment_column_entry> columns;
+	columns.push_back(fragment_column_entry(true, 1, fragment_column_entry::top, hardwrapbox(sequence_fragment(fragments))));
+
+	columns.push_back(fragment_column_entry(false, 1, fragment_column_entry::top, NULL));
+
+	columns.push_back(fragment_column_entry(false, 1, fragment_column_entry::top, text_fragment(spin_string(state))));
+
 
-	fragments.push_back(key_hint_fragment());
+	fragments.clear();
+	fragments.push_back(fragment_columns(columns));
+	fragments.push_back(hardwrapbox(key_hint_fragment()));
 
 	fragment *f=sequence_fragment(fragments);
-	set_fragment(hardwrapbox(f));
+	set_fragment(f);
       }
 
     show();

Modified: branches/aptitude-0.3/aptitude/src/generic/resolver_manager.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/resolver_manager.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/resolver_manager.cc	Mon Sep 19 23:52:48 2005
@@ -116,6 +116,16 @@
 	{
 	  aptitude_resolver::solution *sol = do_get_solution(max_steps,
 							     job.sol_num);
+
+	  // Set the state variable BEFORE exiting the resolver; this
+	  // is done so that if there are no more jobs, the foreground
+	  // thread sees that we're out of the resolver when it
+	  // examines the solution.
+	  l.acquire();
+	  background_thread_in_resolver = false;
+	  background_resolver_cond.wake_all();
+	  l.release();
+
 	  job.k->success(*sol);
 	}
       catch(InterruptedException)
@@ -123,10 +133,20 @@
 	}
       catch(NoMoreSolutions)
 	{
+	  l.acquire();
+	  background_thread_in_resolver = false;
+	  background_resolver_cond.wake_all();
+	  l.release();
+
 	  job.k->no_more_solutions();
 	}
       catch(NoMoreTime)
 	{
+	  l.acquire();
+	  background_thread_in_resolver = false;
+	  background_resolver_cond.wake_all();
+	  l.release();
+
 	  job.k->no_more_time();
 	}
 



More information about the Aptitude-svn-commit mailing list