[Aptitude-svn-commit] r4350 - in branches/aptitude-0.3/aptitude: .
src src/cmdline
Daniel Burrows
dburrows at costa.debian.org
Fri Sep 30 00:08:35 UTC 2005
Author: dburrows
Date: Fri Sep 30 00:08:32 2005
New Revision: 4350
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/cmdline/cmdline_changelog.cc
branches/aptitude-0.3/aptitude/src/view_changelog.cc
Log:
Use the new changelog interface.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Fri Sep 30 00:08:32 2005
@@ -1,5 +1,9 @@
2005-09-29 Daniel Burrows <dburrows at debian.org>
+ * src/cmdline/cmdline_changelog.cc, src/view_changelog.cc:
+
+ Update the changelog viewers for the new interface.
+
* src/generic/apt/pkg_changelog.cc, src/generic/apt/pkg_changelog.h:
Base the package changelog downloader on the download_manager
Modified: branches/aptitude-0.3/aptitude/src/cmdline/cmdline_changelog.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/cmdline/cmdline_changelog.cc (original)
+++ branches/aptitude-0.3/aptitude/src/cmdline/cmdline_changelog.cc Fri Sep 30 00:08:32 2005
@@ -11,7 +11,6 @@
#include <aptitude.h>
#include <generic/apt/apt.h>
-#include <generic/apt/download_signal_log.h>
#include <generic/apt/pkg_changelog.h>
#include <apt-pkg/error.h>
@@ -20,6 +19,8 @@
#include <apt-pkg/sourcelist.h>
#include <apt-pkg/srcrecords.h>
+#include <sigc++/adaptors/bind.h>
+
using namespace std;
/** Represents the information needed to retrieve a changelog. */
@@ -84,11 +85,17 @@
return changelog_entity(pkg, ver, parser->Section());
}
+static void set_name(temp::name n, temp::name &target)
+{
+ target = n;
+}
+
/** Try to find a particular package version without knowing the
- * section that it occurs in.
+ * section that it occurs in. The resulting name will be invalid if
+ * no changelog could be found.
*/
-pkg_changelog *changelog_by_version(const std::string &pkg,
- const std::string &ver)
+temp::name changelog_by_version(const std::string &pkg,
+ const std::string &ver)
{
// Try forcing the particular version that was
// selected, using various sections. FIXME: relies
@@ -96,21 +103,25 @@
// works; in particular, that it only cares whether
// "section" has a first component.
- pkg_changelog *cl = get_changelog_from_source(pkg, ver, "",
- gen_cmdline_download_progress(),
- 500000, pkg);
-
- if(!cl)
- cl = get_changelog_from_source(pkg, ver, "contrib/foo",
- gen_cmdline_download_progress(),
- 500000, pkg);
-
- if(!cl)
- cl = get_changelog_from_source(pkg, ver, "non-free/foo",
- gen_cmdline_download_progress(),
- 500000, pkg);
+ temp::name rval;
+ download_manager::result res;
+
+ res = cmdline_do_download(get_changelog_from_source(pkg, ver, "", pkg,
+ sigc::bind(sigc::ptr_fun(set_name),
+ rval)));
+
+ if(res != download_manager::success || !rval.valid())
+ res = cmdline_do_download(get_changelog_from_source(pkg, ver, "contrib/foo", pkg,
+ sigc::bind(sigc::ptr_fun(set_name), rval)));
+
+ if(res != download_manager::success || !rval.valid())
+ res = cmdline_do_download(get_changelog_from_source(pkg, ver, "non-free/foo", pkg,
+ sigc::bind(sigc::ptr_fun(set_name), rval)));
- return cl;
+ if(res != download_manager::success)
+ return temp::name();
+ else
+ return rval;
}
/** Find a source record in the given set of source records
@@ -191,7 +202,7 @@
pkgCache::PkgIterator pkg=(*apt_cache_file)->FindPkg(package);
- pkg_changelog *cl=NULL;
+ temp::name filename;
// For real packages/versions, we can do a sanity check.
if(!pkg.end())
@@ -219,11 +230,10 @@
}
if(ver.end() && source == cmdline_version_version)
- cl = changelog_by_version(package, sourcestr);
+ filename = changelog_by_version(package, sourcestr);
else
- cl = get_changelog(ver,
- gen_cmdline_download_progress(),
- 500000);
+ cmdline_do_download(get_changelog(ver,
+ sigc::bind(sigc::ptr_fun(&set_name), filename)));
}
else
{
@@ -259,30 +269,30 @@
ent = find_src_ver(*apt_source_list, package, sourcestr);
if(ent.pkg.empty())
- cl = changelog_by_version(package, sourcestr);
+ filename = changelog_by_version(package, sourcestr);
break;
}
- if(cl == NULL && !ent.pkg.empty())
- cl = get_changelog_from_source(ent.pkg,
- ent.ver,
- ent.section,
- gen_cmdline_download_progress(),
- 500000,
- ent.pkg);
+ if(!filename.valid() && !ent.pkg.empty())
+ {
+ download_manager *m
+ = get_changelog_from_source(ent.pkg,
+ ent.ver,
+ ent.section,
+ ent.pkg,
+ sigc::bind(sigc::ptr_fun(&set_name), filename));
+
+ cmdline_do_download(m);
+ }
}
- if(!cl)
+ if(!filename.valid())
_error->Error(_("Couldn't find a changelog for %s"), input.c_str());
else
- {
- // Run the user's pager.
- system((string(pager)+" "+cl->get_filename()).c_str());
-
- delete cl;
- }
+ // Run the user's pager.
+ system((string(pager) + " " + filename.get_name()).c_str());
}
}
Modified: branches/aptitude-0.3/aptitude/src/view_changelog.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/view_changelog.cc (original)
+++ branches/aptitude-0.3/aptitude/src/view_changelog.cc Fri Sep 30 00:08:32 2005
@@ -1,3 +1,4 @@
+
// view_changelog.cc
//
// Copyright (C) 2004-2005 Daniel Burrows
@@ -27,12 +28,16 @@
#include "download_bar.h"
#include "menu_redirect.h"
#include "ui.h"
+#include "ui_download_manager.h"
#include <generic/apt/apt.h>
#include <generic/apt/pkg_changelog.h>
#include <generic/apt/config_signal.h>
#include <generic/apt/download_signal_log.h>
+#include <generic/util/util.h>
+
+#include <sigc++/adaptors/bind.h>
#include <sigc++/functors/mem_fun.h>
using namespace std;
@@ -74,8 +79,10 @@
}
protected:
- pkg_changelog_screen(pkg_changelog *_cl, int x=0, int y=0, int width=0, int height=0):
- vs_file_pager(_cl->get_filename()), last_search_forwards(true)
+ pkg_changelog_screen(const temp::name &filename,
+ int x = 0, int y = 0,
+ int width = 0, int height = 0):
+ vs_file_pager(filename.get_name()), last_search_forwards(true)
{
connect_key("Search", &global_bindings,
sigc::mem_fun(*this, &pkg_changelog_screen::do_search));
@@ -87,11 +94,11 @@
public:
static ref_ptr<pkg_changelog_screen>
- create(pkg_changelog *cl,
- int x=0, int y=0, int width=0, int height=0)
+ create(const temp::name &filename,
+ int x = 0, int y = 0, int width = 0, int height = 0)
{
ref_ptr<pkg_changelog_screen>
- rval(new pkg_changelog_screen(cl, x, y, width, height));
+ rval(new pkg_changelog_screen(filename, x, y, width, height));
rval->decref();
return rval;
}
@@ -129,9 +136,36 @@
return true;
}
};
-
typedef ref_ptr<pkg_changelog_screen> pkg_changelog_screen_ref;
+
+static void do_view_changelog(temp::name n,
+ pkgCache::VerIterator ver)
+{
+ string menulabel =
+ ssprintf(_("ChangeLog of %s"), ver.ParentPkg().Name());
+ string tablabel = ssprintf(_("%s changes"), ver.ParentPkg().Name());
+
+ pkg_changelog_screen_ref cs = pkg_changelog_screen::create(n);
+ vs_table_ref t = vs_table::create();
+ vs_scrollbar_ref s = vs_scrollbar::create(vs_scrollbar::VERTICAL);
+
+ cs->line_changed.connect(sigc::mem_fun(s.unsafe_get_ref(), &vs_scrollbar::set_slider));
+ s->scrollbar_interaction.connect(sigc::mem_fun(cs.unsafe_get_ref(), &pkg_changelog_screen::scroll_page));
+ cs->scroll_top();
+
+ t->add_widget_opts(cs, 0, 0, 1, 1,
+ vs_table::EXPAND|vs_table::SHRINK, vs_table::EXPAND);
+ t->add_widget_opts(s, 0, 1, 1, 1, 0,
+ vs_table::EXPAND | vs_table::FILL);
+
+ t->show_all();
+
+ create_menu_bindings(cs.unsafe_get_ref(), t);
+
+ insert_main_widget(t, menulabel, _("View the list of changes made to this Debian package."), tablabel);
+}
+
void view_changelog(pkgCache::VerIterator ver)
{
bool in_debian=false;
@@ -150,39 +184,18 @@
return;
}
+ download_manager *manager = get_changelog(ver,
+ sigc::bind(sigc::ptr_fun(&do_view_changelog), ver));
+
+ if(manager != NULL)
+ (new ui_download_manager(manager))->start();
+
+#if 0
download_signal_log *widget=gen_download_progress(true,
false,
_("Downloading Changelog"),
"",
_("Download Changelog"),
NULL);
- pkg_changelog *cl=get_changelog(ver, widget,
- aptcfg->FindI(PACKAGE "::UI::Download-Poll-Interval", 50000));
- widget->Complete();
- if(cl != NULL)
- {
- char buf[512];
- snprintf(buf, 512, _("ChangeLog of %s"), ver.ParentPkg().Name());
- string menulabel(buf);
- snprintf(buf, 512, _("%s changes"), ver.ParentPkg().Name());
- string tablabel(buf);
-
- pkg_changelog_screen_ref cs=pkg_changelog_screen::create(cl);
- delete cl;
- vs_table_ref t=vs_table::create();
- vs_scrollbar_ref s=vs_scrollbar::create(vs_scrollbar::VERTICAL);
-
- cs->line_changed.connect(sigc::mem_fun(s.unsafe_get_ref(), &vs_scrollbar::set_slider));
- s->scrollbar_interaction.connect(sigc::mem_fun(cs.unsafe_get_ref(), &pkg_changelog_screen::scroll_page));
- cs->scroll_top();
-
- t->add_widget_opts(cs, 0, 0, 1, 1, vs_table::EXPAND|vs_table::SHRINK, vs_table::EXPAND);
- t->add_widget_opts(s, 0, 1, 1, 1, 0, vs_table::EXPAND | vs_table::FILL);
-
- t->show_all();
-
- create_menu_bindings(cs.unsafe_get_ref(), t);
-
- insert_main_widget(t, menulabel, _("View the list of changes made to this Debian package."), tablabel);
- }
+#endif
}
More information about the Aptitude-svn-commit
mailing list