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

Daniel Burrows dburrows@costa.debian.org
Tue, 26 Apr 2005 00:19:14 +0000


Author: dburrows
Date: Tue Apr 26 00:19:10 2005
New Revision: 3084

Added:
   branches/aptitude-0.3/aptitude/src/solution_dialog.cc
   branches/aptitude-0.3/aptitude/src/solution_dialog.h
Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/Makefile.am
   branches/aptitude-0.3/aptitude/src/broken_indicator.cc
Log:
Add a start on a dynamic solution dialog.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Tue Apr 26 00:19:10 2005
@@ -1,3 +1,12 @@
+2005-04-25  Daniel Burrows  <dburrows@debian.org>
+
+	* src/broken_indicator.cc, src/solution_dialog.cc, src/solution_dialog.h:
+
+	  Add a start on a dynamically updating solution dialog.  The
+	  change to broken_indicator just removes an unnecessary
+	  translatable format string (now what's translated is an argument
+	  to the format string).
+
 2005-04-23  Daniel Burrows  <dburrows@debian.org>
 
 	* src/broken_indicator.cc:

Modified: branches/aptitude-0.3/aptitude/src/Makefile.am
==============================================================================
--- branches/aptitude-0.3/aptitude/src/Makefile.am	(original)
+++ branches/aptitude-0.3/aptitude/src/Makefile.am	Tue Apr 26 00:19:10 2005
@@ -73,6 +73,8 @@
 	pkg_view.h	\
 	reason_fragment.cc\
 	reason_fragment.h\
+	solution_dialog.cc\
+	solution_dialog.h\
 	solution_fragment.cc\
 	solution_fragment.h\
 	strhash.h	\

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	Tue Apr 26 00:19:10 2005
@@ -103,7 +103,7 @@
 
 	if(sol.get_actions().empty())
 	  {
-	    set_fragment(fragf(_("%CInternal error: unexpected null solution."), get_color("Error")));
+	    set_fragment(fragf("%C%s", get_color("Error"), _("Internal error: unexpected null solution.")));
 	    show();
 	    return;
 	  }

Added: branches/aptitude-0.3/aptitude/src/solution_dialog.cc
==============================================================================
--- (empty file)
+++ branches/aptitude-0.3/aptitude/src/solution_dialog.cc	Tue Apr 26 00:19:10 2005
@@ -0,0 +1,110 @@
+// solution_dialog.cc
+//
+//   Copyright (C) 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 the Free Software Foundation; either version 2 of
+//   the License, or (at your option) any later version.
+//
+//   This program is distributed in the hope that it will be useful,
+//   but WITHOUT ANY WARRANTY; without even the implied warranty of
+//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//   General Public License for more details.
+//
+//   You should have received a copy of the GNU General Public License
+//   along with this program; see the file COPYING.  If not, write to
+//   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+//   Boston, MA 02111-1307, USA.
+
+#include "solution_dialog.h"
+#include "solution_fragment.h"
+
+#include <aptitude.h>
+
+#include <vscreen/config/keybindings.h>
+#include <vscreen/fragment.h>
+#include <vscreen/vs_button.h>
+#include <vscreen/vs_center.h>
+#include <vscreen/vs_frame.h>
+#include <vscreen/vs_text_layout.h>
+
+#include <generic/apt.h>
+#include <generic/aptitude_resolver.h>
+
+class solution_dialog:public vs_text_layout
+{
+  aptitude_resolver::solution last_sol;
+
+  void handle_cache_reload()
+  {
+    if(apt_cache_file)
+      {
+	(*apt_cache_file)->package_state_changed.connect(sigc::mem_fun(*this, &solution_dialog::update));
+	(*apt_cache_file)->selected_solution_changed.connect(sigc::mem_fun(*this, &solution_dialog::update));
+      }
+
+    update();
+  }
+public:
+  solution_dialog()
+  {
+    if(apt_cache_file)
+      {
+	(*apt_cache_file)->package_state_changed.connect(sigc::mem_fun(*this, &solution_dialog::update));
+	(*apt_cache_file)->selected_solution_changed.connect(sigc::mem_fun(*this, &solution_dialog::update));
+      }
+
+    cache_closed.connect(sigc::mem_fun(*this, &solution_dialog::update));
+    cache_reloaded.connect(sigc::mem_fun(*this, &solution_dialog::handle_cache_reload));
+
+    update();
+  }
+
+  void update()
+  {
+    if(!apt_cache_file)
+      {
+	set_fragment(fragf("%s", _("The package cache is not available.")));
+	last_sol.nullify();
+	return;
+      }
+
+    if(!(*apt_cache_file)->resolver_exists())
+      {
+	// This makes ASS-U-MPTIONS about how resolver_exists works.
+	set_fragment(fragf("%s", _("No packages are broken.")));
+	last_sol.nullify();
+	return;
+      }
+
+    try
+      {
+	aptitude_resolver::solution sol=(*apt_cache_file)->get_current_solution();
+
+	if(sol == last_sol)
+	  return;
+
+	last_sol=sol;
+
+	if(sol.get_actions().empty())
+	  set_fragment(fragf(_("Internal error: unexpected null solution.")));
+	else
+	  set_fragment(solution_fragment(sol));
+      }
+    catch(NoMoreSolutions)
+      {
+	set_fragment(fragf(_("No resolution found.")));
+      }
+    catch(NoMoreTime)
+      {
+	set_fragment(fragf(_("Time exhausted while searching for a solution (you can select \"Next Solution\" or press %s to try harder)."),
+			   global_bindings.keyname("NextSolution").c_str()));
+      }
+  }
+};
+
+vscreen_widget *make_solution_dialog()
+{
+  return new vs_center(new vs_frame(new solution_dialog));
+}

Added: branches/aptitude-0.3/aptitude/src/solution_dialog.h
==============================================================================
--- (empty file)
+++ branches/aptitude-0.3/aptitude/src/solution_dialog.h	Tue Apr 26 00:19:10 2005
@@ -0,0 +1,29 @@
+// solution_dialog.h                                 -*-c++-*-
+//
+//   Copyright (C) 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 the Free Software Foundation; either version 2 of
+//   the License, or (at your option) any later version.
+//
+//   This program is distributed in the hope that it will be useful,
+//   but WITHOUT ANY WARRANTY; without even the implied warranty of
+//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//   General Public License for more details.
+//
+//   You should have received a copy of the GNU General Public License
+//   along with this program; see the file COPYING.  If not, write to
+//   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+//   Boston, MA 02111-1307, USA.
+//
+// Display the current solution.
+
+#ifndef SOLUTION_DIALOG_H
+#define SOLUTION_DIALOG_H
+
+class vscreen_widget;
+
+vscreen_widget *make_solution_dialog();
+
+#endif // SOLUTION_DIALOG_H