[Aptitude-devel] r3055 - in branches/aptitude-0.3/aptitude: . src

Daniel Burrows dburrows@costa.debian.org
Sat, 23 Apr 2005 00:51:18 +0000


Author: dburrows
Date: Sat Apr 23 00:51:15 2005
New Revision: 3055

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/ui.cc
Log:
Hook up the solution-related commands to keys.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Sat Apr 23 00:51:15 2005
@@ -1,5 +1,10 @@
 2005-04-22  Daniel Burrows  <dburrows@debian.org>
 
+	* src/ui.cc:
+
+	  Hook up the various solution-related commands to do *something*,
+	  although some of them are still incomplete.
+
 	* src/generic/aptcache.h:
 
 	  Clarify the documentation of apply_current_solution.

Modified: branches/aptitude-0.3/aptitude/src/ui.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/ui.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/ui.cc	Sat Apr 23 00:51:15 2005
@@ -74,6 +74,7 @@
 
 #include <generic/apt.h>
 #include <generic/apt_undo_group.h>
+#include <generic/aptitude_resolver.h>
 #include <generic/config_signal.h>
 
 #include "dep_item.h"
@@ -1167,6 +1168,56 @@
 }
 #endif
 
+static void do_next_solution()
+{
+  if(apt_cache_file && !(*apt_cache_file)->solutions_exhausted())
+    (*apt_cache_file)->next_solution();
+  else
+    beep();
+}
+
+static void do_prev_solution()
+{
+  if(apt_cache_file && !(*apt_cache_file)->solutions_at_start())
+    (*apt_cache_file)->previous_solution();
+  else
+    beep();
+}
+
+static void do_apply_solution()
+{
+  if(apt_cache_file && (*apt_cache_file)->resolver_exists())
+    {
+      undo_group *undo=new apt_undo_group;
+      try
+	{
+	  (*apt_cache_file)->apply_current_solution(undo);
+	}
+      catch(NoMoreSolutions)
+	{
+	  show_message(_("Unable to find a solution to apply."),
+		       NULL,
+		       get_color("Error"));
+	}
+      catch(NoMoreTime)
+	{
+	  show_message(_("Ran out of time while trying to find a solution."),
+		       NULL,
+		       get_color("Error"));
+	}
+
+      if(!undo->empty())
+	apt_undos->add_item(undo);
+      else
+	delete undo;
+    }
+}
+
+static void do_examine_solution()
+{
+  show_message("This would be a truly fascinating and engaging dialog box...were it not for the fact that I have yet to write the code for it.  Please try again later.");
+}
+
 // NOTE ON TRANSLATIONS!
 //
 //   Implicitly translating stuff in the widget set would be ugly.  Everything
@@ -1539,6 +1590,18 @@
   main_stacked->connect_key_post("Undo",
 				 &global_bindings,
 				 sigc::ptr_fun(do_undo));
+  main_stacked->connect_key_post("NextSolution",
+				 &global_bindings,
+				 sigc::ptr_fun(do_next_solution));
+  main_stacked->connect_key_post("PrevSolution",
+				 &global_bindings,
+				 sigc::ptr_fun(do_prev_solution));
+  main_stacked->connect_key_post("ApplySolution",
+				 &global_bindings,
+				 sigc::ptr_fun(do_apply_solution));
+  main_stacked->connect_key_post("ExamineSolution",
+				 &global_bindings,
+				 sigc::ptr_fun(do_examine_solution));
 
   main_table=new vs_table;
   main_stacked->add_widget(main_table);