Package: apt-listchanges Severity: wishlist Tags: patch Hi,
The attached patch from Michael Vogt is used in Ubuntu to add a gtk frontend to apt-listchanges. Please consider also adding it to Debian. There are a couple of things that this patch changes that are not strictly necessary. If you would like them removed from the patch please let me know. (I'm thinking of the gettext bind error message, the recreation of the db, or python-gtk2 as Recommends rather than Suggests). Thanks, James
diff -pruN 2.74/apt-listchanges/apt-listchanges.glade 2.74ubuntu3/apt-listchanges/apt-listchanges.glade --- 2.74/apt-listchanges/apt-listchanges.glade 1970-01-01 01:00:00.000000000 +0100 +++ 2.74ubuntu3/apt-listchanges/apt-listchanges.glade 2005-05-06 18:49:57.000000000 +0100 @@ -0,0 +1,152 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> + +<widget class="GtkWindow" id="window_main"> + <property name="border_width">6</property> + <property name="visible">True</property> + <property name="title" translatable="yes">List the changes</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_CENTER</property> + <property name="modal">False</property> + <property name="default_width">600</property> + <property name="default_height">400</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <signal name="destroy_event" handler="on_window_main_destroy_event" last_modification_time="Sat, 05 Feb 2005 13:12:24 GMT"/> + + <child> + <widget class="GtkVBox" id="vbox1"> + <property name="border_width">6</property> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkLabel" id="label_header"> + <property name="visible">True</property> + <property name="label" translatable="yes" context="yes"><big><b>Changelogs</b></big> + +The following changes are found in the packages you are about to install:</property> + <property name="use_underline">True</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkScrolledWindow" id="scrolledwindow2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + <property name="window_placement">GTK_CORNER_TOP_LEFT</property> + + <child> + <widget class="GtkTextView" id="textview_main"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="overwrite">False</property> + <property name="accepts_tab">True</property> + <property name="justification">GTK_JUSTIFY_LEFT</property> + <property name="wrap_mode">GTK_WRAP_NONE</property> + <property name="cursor_visible">False</property> + <property name="pixels_above_lines">0</property> + <property name="pixels_below_lines">0</property> + <property name="pixels_inside_wrap">0</property> + <property name="left_margin">0</property> + <property name="right_margin">0</property> + <property name="indent">0</property> + <property name="text" translatable="yes">Reading changelogs. Please wait.</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkProgressBar" id="progressbar_main"> + <property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property> + <property name="fraction">0</property> + <property name="pulse_step">0.10000000149</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkHBox" id="hbox4"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkHButtonBox" id="hbuttonbox1"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkButton" id="button_close"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-close</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <signal name="clicked" handler="on_button_close_clicked" last_modification_time="Sat, 05 Feb 2005 11:13:29 GMT"/> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> +</widget> + +</glade-interface> diff -pruN 2.74/apt-listchanges/AptListChangesGtk.py 2.74ubuntu3/apt-listchanges/AptListChangesGtk.py --- 2.74/apt-listchanges/AptListChangesGtk.py 1970-01-01 01:00:00.000000000 +0100 +++ 2.74ubuntu3/apt-listchanges/AptListChangesGtk.py 2007-07-04 04:06:39.000000000 +0100 @@ -0,0 +1,77 @@ +# check if gtk is avialable + +from apt_listchanges import frontend + +import pygtk +pygtk.require('2.0') +import gtk +import gobject +import gtk.glade +import gettext +import locale + +# set the i18n dirs +gtk.glade.bindtextdomain("apt-listchanges", "/usr/share/locale") +gtk.glade.textdomain("apt-listchanges") + +try: + locale.setlocale(locale.LC_ALL,'') +except locale.Error: + sys.stderr.write("Can't set locale; make sure $LC_* and $LANG are correct!\n") +try: + _ = gettext.translation('apt-listchanges').gettext +except IOError: + _ = lambda str: str + + +class gtk2(frontend): + def flush_interface(self): + while gtk.events_pending(): + gtk.main_iteration() + + def cb_close(self, widget): + if self.button_close.get_property("sensitive") == False: + # window manager was used to close before the parsing was complete + sys.exit() + gtk.main_quit() + + def __init__(self, packages, config): + frontend.__init__(self,packages, config) + self.glade = gtk.glade.XML("/usr/share/apt-listchanges/apt-listchanges.glade") + self.window_main = self.glade.get_widget("window_main") + self.window_main.connect("destroy", self.cb_close) + self.glade.signal_connect("on_button_close_clicked", self.cb_close) + self.progressbar_main = self.glade.get_widget("progressbar_main") + self.button_close = self.glade.get_widget("button_close") + self.flush_interface() + + def display_output(self,text): + self.button_close.set_sensitive(True) + buf = self.glade.get_widget("textview_main").get_buffer() + buf.set_text(unicode(text, 'latin-1').encode("UTF-8")) + gtk.main() + + def update_progress(self): + if not hasattr(self,'progress'): + # First call + self.progress = 0.0 + self.progressbar_main.show() + self.progress += 1.0 + self.progressbar_main.set_fraction(self.progress / self.packages) + self.progressbar_main.set_text(("%i%%" % (self.progress*100 / self.packages))) + self.flush_interface() + + def progress_done(self): + self.progressbar_main.hide() + self.flush_interface() + + def confirm(self): + m = gtk.MessageDialog(self.window_main, + gtk.DIALOG_MODAL, + gtk.MESSAGE_QUESTION, + gtk.BUTTONS_YES_NO) + m.set_default_response(gtk.RESPONSE_YES) + m.set_markup("<big><b>%s</b></big>\n\n%s" % (_("Continue Installation?"), _("You can abort the installation if you select 'no'."))) + if m.run() == gtk.RESPONSE_NO: + return False + return True diff -pruN 2.74/apt-listchanges/apt_listchanges.py 2.74ubuntu3/apt-listchanges/apt_listchanges.py --- 2.74/apt-listchanges/apt_listchanges.py 2007-05-11 22:09:56.000000000 +0100 +++ 2.74ubuntu3/apt-listchanges/apt_listchanges.py 2007-07-04 03:52:19.000000000 +0100 @@ -23,7 +23,9 @@ # MA 02111-1307 USA # -import sys, os +import sys +import os +import os.path import re import gettext import locale @@ -114,6 +116,28 @@ def make_frontend(name, packages, config sys.stderr.write((_("The %s frontend is deprecated, using pager") + '\n') % name) name = 'pager' + if name == "mail" and not os.path.exists("/usr/sbin/sendmail"): + sys.stderr.write((_("The mail frontend needs a installed 'sendmail', using pager") + '\n')) + name = 'pager' + + # TODO: it would probably be nice to have a frontends subdir and + # import from that. that would mean a uniform mechanism for all + # frontends (that would become small files inside + if name == "gtk": + if os.environ.has_key("DISPLAY"): + try: + gtk = __import__("AptListChangesGtk") + frontends[name] = gtk.gtk2 + except ImportError, e: + sys.stderr.write(_("The gtk frontend needs a working python-gtk2 " + "and python-glade2.\n" + "Those imports can not be found. Falling back " + "to pager.\n" + "The error is: %s\n") % e) + name = 'pager' + else: + name = 'pager' + if not frontends.has_key(name): return None return frontends[name](packages, config) diff -pruN 2.74/apt-listchanges.py 2.74ubuntu3/apt-listchanges.py --- 2.74/apt-listchanges.py 2007-05-11 22:45:42.000000000 +0100 +++ 2.74ubuntu3/apt-listchanges.py 2007-09-28 07:56:52.000000000 +0100 @@ -34,7 +34,10 @@ import commands sys.path += ['./apt-listchanges', '/usr/share/apt-listchanges'] import apt_listchanges, DebianFiles, ALCConfig -locale.setlocale(locale.LC_ALL, '') +try: + locale.setlocale(locale.LC_ALL, '') +except locale.Error: + sys.stderr.write("Can't set locale; make sure $LC_* and $LANG are correct!\n") def _(x): try: return gettext.translation('apt-listchanges').lgettext(x) @@ -81,7 +84,14 @@ def main(): status.makeindex('Package') if config.save_seen: - seen = anydbm.open(config.save_seen, 'c') + # Open DB. Test if we can read it, and recreate on failure + try: + seen = anydbm.open(config.save_seen, 'c') + bool = seen.has_key('foo') + except anydbm.error: + sys.stderr.write(_("Recreating database %s, because it failed to load.\n") % config.save_seen) + os.remove(config.save_seen) + seen = anydbm.open(config.save_seen, 'c') # Will replace seen after changes have actually been seen seen_new = {} diff -pruN 2.74/debian/control 2.74ubuntu3/debian/control --- 2.74/debian/control 2007-05-11 22:09:56.000000000 +0100 +++ 2.74ubuntu3/debian/control 2007-06-18 22:20:06.000000000 +0100 @@ -1,18 +1,18 @@ Source: apt-listchanges Section: utils Priority: optional Maintainer: Pierre Habouzit <[EMAIL PROTECTED]> Uploaders: Matt Zimmerman <[EMAIL PROTECTED]> Standards-Version: 3.7.2 Build-Depends: debhelper (>= 5) Build-Depends-Indep: docbook-to-man, gettext, python-dev, po-debconf, - python-support (>= 0.4.0) + python-support (>= 0.4.0), libexpat1-dev Package: apt-listchanges Architecture: all Depends: ${python:Depends}, apt (>= 0.5.3), python-apt, debconf | debconf-2.0, ucf (>= 0.28), debianutils (>= 2.0.2) -Recommends: exim4 | mail-transport-agent +Recommends: exim4 | mail-transport-agent, python-glade2, python-gtk2 Suggests: x-terminal-emulator, www-browser Description: Display change history from .deb archives apt-listchanges is a tool to show what has been changed in a new diff -pruN 2.74/debian/preinst 2.74ubuntu3/debian/preinst --- 2.74/debian/preinst 2007-05-11 22:09:56.000000000 +0100 +++ 2.74ubuntu3/debian/preinst 2007-06-18 22:20:06.000000000 +0100 @@ -9,6 +9,8 @@ if test -d /usr/lib/site-python; then rm -f /usr/lib/site-python/apt_listchanges.pyc rm -f /usr/lib/site-python/DebianControlParser.pyo rm -f /usr/lib/site-python/DebianControlParser.pyc + rm -f /usr/lib/site-python/AptListChangesGtk.pyo + rm -f /usr/lib/site-python/AptListChangesGtk.pyc fi if [ -f $hook.disabled ]; then diff -pruN 2.74/debian/templates 2.74ubuntu3/debian/templates --- 2.74/debian/templates 2007-05-11 22:09:56.000000000 +0100 +++ 2.74ubuntu3/debian/templates 2007-06-18 22:20:06.000000000 +0100 @@ -1,6 +1,6 @@ Template: apt-listchanges/frontend Type: select -__Choices: pager, browser, xterm-pager, xterm-browser, text, mail, none +__Choices: pager, gtk, browser, xterm-pager, xterm-browser, text, mail, none Default: pager _Description: Method for changes display: apt-listchanges can display package changes in a number of different @@ -8,6 +8,7 @@ _Description: Method for changes display . pager : use your preferred pager to display changes one page at a time; + gtk : Display changes in a Gtk window; browser : display HTML-formatted changes using a web browser; xterm-pager : like pager, but in an xterm in the background; xterm-browser : like browser, but in an xterm in the background;