[Aptitude-svn-commit] r3546 - in branches/aptitude-0.3/aptitude: . src
Daniel Burrows
dburrows@costa.debian.org
Sat, 02 Jul 2005 15:04:42 +0000
Author: dburrows
Date: Sat Jul 2 15:04:39 2005
New Revision: 3546
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/pkg_item.cc
branches/aptitude-0.3/aptitude/src/pkg_item.h
Log:
Update pkg_item for wide characters.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Sat Jul 2 15:04:39 2005
@@ -1,5 +1,9 @@
2005-07-02 Daniel Burrows <dburrows@debian.org>
+ * src/pkg_item.cc, src/pkg_item.h:
+
+ Update the pkg_item code for wide characters.
+
* src/ui.h:
Undo that last change: most of the code passes statically
Modified: branches/aptitude-0.3/aptitude/src/pkg_item.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/pkg_item.cc (original)
+++ branches/aptitude-0.3/aptitude/src/pkg_item.cc Sat Jul 2 15:04:39 2005
@@ -24,6 +24,7 @@
#include <vscreen/config/column_definition.h>
#include <vscreen/config/keybindings.h>
#include <vscreen/fragment.h>
+#include <vscreen/transcode.h>
#include <vscreen/vs_util.h>
#include "download.h"
@@ -54,11 +55,11 @@
static const char *confirm_str=N_("Yes, I am aware this is a very bad idea");
-static void try_delete_essential(string s,
+static void try_delete_essential(wstring s,
const pkgCache::PkgIterator pkg,
bool purge)
{
- if(s==_(confirm_str))
+ if(s==transcode(_(confirm_str)))
{
undo_group *grp=new apt_undo_group;
@@ -80,7 +81,7 @@
fragment *f=wrapbox(fragf(_("%s is an essential package!%n%nAre you sure you want to remove it?%nType '%s' if you are."), pkg.Name(), _(confirm_str)));
vscreen_widget *w=vs_dialog_string(f,
- "",
+ L"",
arg(sigc::bind(sigc::ptr_fun(try_delete_essential),
pkg, purge)),
NULL,
@@ -300,9 +301,9 @@
win->mvaddnstr(y, 0, disp.c_str(), width);
}
-bool pkg_item::dispatch_char(chtype ch, vs_tree *owner)
+bool pkg_item::dispatch_key(const key &k, vs_tree *owner)
{
- if(bindings->key_matches(ch, "Versions"))
+ if(bindings->key_matches(k, "Versions"))
{
char buf[512];
snprintf(buf, 512, _("Available versions of %s"),
@@ -315,7 +316,7 @@
vscreen_widget *w=make_ver_screen(package);
insert_main_widget(w, menulabel, "", tablabel);
}
- else if(bindings->key_matches(ch, "Dependencies"))
+ else if(bindings->key_matches(k, "Dependencies"))
{
if(!visible_version().end())
{
@@ -330,7 +331,7 @@
w->show();
}
}
- else if(bindings->key_matches(ch, "ReverseDependencies"))
+ else if(bindings->key_matches(k, "ReverseDependencies"))
{
char buf[512];
snprintf(buf, 512, _("Packages depending on %s"), package.Name());
@@ -339,14 +340,14 @@
string tablabel(buf);
vscreen_widget *w=make_dep_screen(package, visible_version(), true);
- insert_main_widget(w, buf, "", tablabel);
+ insert_main_widget(w, menulabel, "", tablabel);
}
- else if(bindings->key_matches(ch, "InfoScreen"))
+ else if(bindings->key_matches(k, "InfoScreen"))
show_information();
- else if(bindings->key_matches(ch, "Changelog") &&
+ else if(bindings->key_matches(k, "Changelog") &&
!visible_version().end())
show_changelog();
- else if(bindings->key_matches(ch, "InstallSingle"))
+ else if(bindings->key_matches(k, "InstallSingle"))
{
if((*apt_cache_file)[package].CandidateVerIter(*apt_cache_file).end())
return true;
@@ -358,7 +359,7 @@
else
delete grp;
}
- else if(bindings->key_matches(ch, "ForbidUpgrade"))
+ else if(bindings->key_matches(k, "ForbidUpgrade"))
{
undo_group *grp=new apt_undo_group;
forbid_upgrade(grp);
@@ -368,7 +369,7 @@
else
delete grp;
}
- else if(bindings->key_matches(ch, "BugReport"))
+ else if(bindings->key_matches(k, "BugReport"))
{
// Try to report a bug on the package. (ew quoting ew)
string cmd=string("reportbug '")+package.Name()+"'";
@@ -395,7 +396,7 @@
apt_reload_cache(gen_progress_bar(), true);
}
- else if(bindings->key_matches(ch, "DpkgReconfigure"))
+ else if(bindings->key_matches(k, "DpkgReconfigure"))
// Don't bother with my internal su-to-root stuff here, since I don't
// need to touch the package lists in the subprocess.
{
@@ -436,7 +437,7 @@
apt_reload_cache(gen_progress_bar(), true);
}
}
- else if(bindings->key_matches(ch, "EditHier"))
+ else if(bindings->key_matches(k, "EditHier"))
{
vs_hier_editor *e=new vs_hier_editor;
e->set_package(package, visible_version());
@@ -448,7 +449,7 @@
sigc::mem_fun(*e, &vscreen_widget::destroy));
}
else
- return pkg_tree_node::dispatch_char(ch, owner);
+ return pkg_tree_node::dispatch_key(k, owner);
return true;
}
@@ -462,7 +463,7 @@
show_information();
}
-bool pkg_item::matches(string s) const
+bool pkg_item::matches(const string &s) const
{
return pkg_matches(s, package, visible_version());
}
@@ -482,14 +483,24 @@
return pkg.CurrentVer();
}
-const char *pkg_item::tag() const
+const wchar_t *pkg_item::tag()
{
- return package.Name();
+ // FIXME: ew
+ static wstring pkgname;
+
+ pkgname=transcode(package.Name(), "ASCII");
+
+ return pkgname.c_str();
}
-const char *pkg_item::label() const
+const wchar_t *pkg_item::label()
{
- return package.Name();
+ // FIXME: ew
+ static wstring pkgname;
+
+ pkgname=transcode(package.Name(), "ASCII");
+
+ return pkgname.c_str();
}
const pkgCache::PkgIterator &pkg_item::get_package() const
Modified: branches/aptitude-0.3/aptitude/src/pkg_item.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/pkg_item.h (original)
+++ branches/aptitude-0.3/aptitude/src/pkg_item.h Sat Jul 2 15:04:39 2005
@@ -77,7 +77,7 @@
const pkgCache::PkgIterator &get_package() const;
pkgCache::VerIterator visible_version() const;
- bool dispatch_char(chtype ch, vs_tree *owner);
+ bool dispatch_key(const key &k, vs_tree *owner);
void dispatch_mouse(short id, int x, mmask_t bstate, vs_tree *owner);
/** Returns the style that would be used to display the given