[Aptitude-svn-commit] r4221 - branches/aptitude-0.3/aptitude/src

Daniel Burrows dburrows at costa.debian.org
Sat Sep 24 05:09:00 UTC 2005


Author: dburrows
Date: Sat Sep 24 05:08:59 2005
New Revision: 4221

Added:
   branches/aptitude-0.3/aptitude/src/apt_undo_tree.cc
   branches/aptitude-0.3/aptitude/src/apt_undo_tree.h
Modified:
   branches/aptitude-0.3/aptitude/src/Makefile.am
Log:
Add a class that will serve as a base for trees that support undoing.

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	Sat Sep 24 05:08:59 2005
@@ -21,6 +21,8 @@
 	apt_info_tree.h\
 	apt_options.cc	\
 	apt_options.h	\
+	apt_undo_tree.cc \
+	apt_undo_tree.h \
 	broken_indicator.cc\
 	broken_indicator.h\
 	defaults.cc	\

Added: branches/aptitude-0.3/aptitude/src/apt_undo_tree.cc
==============================================================================
--- (empty file)
+++ branches/aptitude-0.3/aptitude/src/apt_undo_tree.cc	Sat Sep 24 05:08:59 2005
@@ -0,0 +1,46 @@
+// apt_undo_tree.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 "apt_undo_tree.h"
+
+#include "ui.h"
+
+#include <generic/apt.h>
+#include <generic/undo.h>
+
+apt_undo_tree::apt_undo_tree()
+{
+}
+
+bool apt_undo_tree::undo_undo_enabled()
+{
+  return apt_undos != NULL && apt_undos->size() > 0;
+}
+
+bool apt_undo_tree::undo_undo()
+{
+  if(apt_undos != NULL && apt_undos->size() > 0)
+    {
+      apt_undos->undo();
+      package_states_changed();
+      return true;
+    }
+  else
+    return false;
+}

Added: branches/aptitude-0.3/aptitude/src/apt_undo_tree.h
==============================================================================
--- (empty file)
+++ branches/aptitude-0.3/aptitude/src/apt_undo_tree.h	Sat Sep 24 05:08:59 2005
@@ -0,0 +1,50 @@
+// apt_undo_tree.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.
+//
+// Extends the basic menu_tree with support for the APT undo queue.
+// NB: this really ought to be a mixin for menu_redirect..
+
+#ifndef APT_UNDO_TREE_H
+#define APT_UNDO_TREE_H
+
+#include "menu_tree.h"
+
+class apt_undo_tree : public menu_tree
+{
+protected:
+  apt_undo_tree();
+public:
+  ref_ptr<apt_undo_tree> create()
+  {
+    ref_ptr<apt_undo_tree> rval = new apt_undo_tree;
+    rval->decref();
+    return rval;
+  }
+
+  /** \return \b true if the global APT undo queue is non-empty. */
+  bool undo_undo_enabled();
+
+  /** Execute the top undo from the global APT undo queue.
+   *
+   *  \return \b true.
+   */
+  bool undo_undo();
+};
+
+#endif // APT_UNDO_TREE_H



More information about the Aptitude-svn-commit mailing list