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

Daniel Burrows dburrows@costa.debian.org
Sat, 25 Jun 2005 21:42:05 +0000


Author: dburrows
Date: Sat Jun 25 21:42:03 2005
New Revision: 3441

Added:
   branches/aptitude-0.3/aptitude/src/pkg_item_with_subtree.cc
Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/Makefile.am
   branches/aptitude-0.3/aptitude/src/pkg_item_with_subtree.h
Log:
Transcode package names as appropriate.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Sat Jun 25 21:42:03 2005
@@ -1,5 +1,12 @@
 2005-06-25  Daniel Burrows  <dburrows@debian.org>
 
+	* src/Makefile.am, src/pkg_item_with_subtree.cc, src/pkg_item_with_subtree.h:
+
+	  Transcode the package name to force it into the wide character
+	  set; move the column-generation function for the
+	  item-with-subtree class into a .cc file to avoid polluting other
+	  headers with too much junk.
+
 	* src/vscreen/curses++.h, src/vscreen/vscreen_widget.h:
 
 	  Expose the addwstr family of functions.

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 Jun 25 21:42:03 2005
@@ -56,6 +56,7 @@
 	pkg_info_screen.h \
 	pkg_item.cc	\
 	pkg_item.h	\
+	pkg_item_with_subtree.cc \
 	pkg_item_with_subtree.h \
 	pkg_grouppolicy.h\
 	pkg_grouppolicy.cc\

Added: branches/aptitude-0.3/aptitude/src/pkg_item_with_subtree.cc
==============================================================================
--- (empty file)
+++ branches/aptitude-0.3/aptitude/src/pkg_item_with_subtree.cc	Sat Jun 25 21:42:03 2005
@@ -0,0 +1,43 @@
+// pkg_item_with_subtree.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 "pkg_item_with_subtree.h"
+
+#include <vscreen/transcode.h>
+
+column_disposition pkg_item_with_subtree::setup_column(int type)
+{
+  if(type==name)
+    {
+      std::wstring name;
+      if(!transcode(get_pkg().Name(), name))
+	name=L"INTERNAL ERROR OCCURED";
+
+      // Interesting question: would it be reasonable to use graphical
+      // characters here?  What about Unicode graphical characters?
+      if(hierarchical)
+	return column_disposition(std::wstring(expanded?L"--\\ ":L"--- ")+name, get_basex());
+      else
+	{
+	  return column_disposition(std::wstring(L"-> ")+name, get_basex());
+	}
+    }
+  else
+    return pkg_columnizer::setup_column(type);
+}

Modified: branches/aptitude-0.3/aptitude/src/pkg_item_with_subtree.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/pkg_item_with_subtree.h	(original)
+++ branches/aptitude-0.3/aptitude/src/pkg_item_with_subtree.h	Sat Jun 25 21:42:03 2005
@@ -37,18 +37,7 @@
   {
     bool expanded, hierarchical;
   protected:
-    column_disposition setup_column(int type)
-    {
-      if(type==name)
-	{
-	  if(hierarchical)
-	    return column_disposition(std::string(expanded?"--\\ ":"--- ")+get_pkg().Name(), get_basex());
-	  else
-	    return column_disposition(std::string("-> ")+get_pkg().Name(), get_basex());
-	}
-      else
-	return pkg_columnizer::setup_column(type);
-    }
+    column_disposition setup_column(int type);
   public:
     pkg_with_subtree_columnizer(bool _expanded, bool _hierarchical,
 				const pkgCache::PkgIterator &_pkg,
@@ -73,13 +62,13 @@
     win->getmaxyx(height, width);
     pkg_columnizer::setup_columns();
 
-    std::string disp=pkg_with_subtree_columnizer(vs_subtree<child, sorter>::get_expanded(),
-						 hierarchical,
-						 get_package(),
-						 visible_version(),
-						 pkg_columnizer::get_columns(),
-						 basex).layout_columns(width);
-    win->mvaddnstr(y, 0, disp.c_str(), width);
+    std::wstring disp=pkg_with_subtree_columnizer(vs_subtree<child, sorter>::get_expanded(),
+						  hierarchical,
+						  get_package(),
+						  visible_version(),
+						  pkg_columnizer::get_columns(),
+						  basex).layout_columns(width);
+    win->mvaddnstr(y, 0, disp, width);
   }
 
   bool dispatch_char(chtype ch, vs_tree *owner)