Package: subterfugue Version: 0.2.1a-9.4 Severity: wishlist Tags: patch Hi,
since subterfugue Recommends: python-gtk2, it would be really nice, if it also used GTK 2.0. The attached patch ports the only file which uses pygtk to GTK 2.0 - I removed many settings which seem to have no influence on the layout of the GUI. Also followed all deprecation warnings from pygtk, so the new code should work for a while ;) Greetings, Tobi -- System Information: Debian Release: testing/unstable APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/dash Kernel: Linux 2.6.17-2-686 Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8) Versions of packages subterfugue depends on: ii python2.3 2.3.5-15 An interactive high-level object-o Versions of packages subterfugue recommends: ii python-gtk2 2.8.6-5 Python bindings for the GTK+ widge -- no debconf information
--- /usr/lib/subterfugue/tricks/NetThrottleUI.py 2004-08-13 14:16:57.000000000 +0200 +++ NetThrottleUI.py 2006-09-05 23:16:44.882039814 +0200 @@ -5,11 +5,10 @@ import sys import pygtk -pygtk.require('1.2') +pygtk.require('2.0') -from gtk import * -import GtkExtra -import GDK +import gtk +import gobject button_info = ( ("0", 0), @@ -23,68 +22,55 @@ class window1Widget: def __init__(self, command, limit): # modified from code generated by glc/glade - window1=GtkWindow(WINDOW_TOPLEVEL) + window1 = gtk.Window(gtk.WINDOW_TOPLEVEL) window1.set_title("NetThrottle: %s" % command) - window1.set_usize(-1, -1) - window1.set_policy(FALSE, TRUE, FALSE) - window1.set_position(WIN_POS_NONE) + window1.set_resizable(False) - hbox1=GtkHBox() + hbox1 = gtk.HBox() window1.add(hbox1) - hbox1.set_usize(-1, -1) - hbox1.set_homogeneous(FALSE) + hbox1.set_homogeneous(False) hbox1.set_spacing(3) - hbuttonbox1=GtkHButtonBox() - hbox1.pack_start(hbuttonbox1, FALSE, FALSE, 0) - hbuttonbox1.set_usize(-1, -1) - hbuttonbox1.set_homogeneous(FALSE) + hbuttonbox1 = gtk.HButtonBox() + hbox1.pack_start(hbuttonbox1, False, False, 0) + hbuttonbox1.set_homogeneous(False) hbuttonbox1.set_spacing(0) hbuttonbox1.set_border_width(2) - hbuttonbox1.set_child_size_default(80, 10) - hbuttonbox1.set_child_ipadding_default(3, 0) hbuttonbox1.set_spacing(0) - hbuttonbox1.set_layout(BUTTONBOX_DEFAULT_STYLE) for label, value in button_info: - b = GtkButton(label) + b = gtk.Button(label) set_button(b, value) - hbuttonbox1.pack_start(b, TRUE, TRUE, 0) - b.set_flags(CAN_FOCUS) - b.set_usize(-1, -1) + hbuttonbox1.pack_start(b, True, True, 0) + b.set_flags(gtk.CAN_FOCUS) b.show() b.connect("clicked", buttonclick) hbuttonbox1.show() - self.hbuttonbox1=hbuttonbox1 + self.hbuttonbox1 = hbuttonbox1 - spinbutton1_adj = GtkAdjustment(0, 0, 1000000000, 1, 1000, 1000) - spinbutton1=GtkSpinButton(spinbutton1_adj, 1.0, 0) - hbox1.pack_start(spinbutton1, TRUE, TRUE, 0) - spinbutton1.set_flags(CAN_FOCUS) - spinbutton1.set_usize(100, -1) - spinbutton1.set_numeric(TRUE) - spinbutton1.set_update_policy(UPDATE_ALWAYS) - spinbutton1.set_editable(TRUE) - spinbutton1.set_visibility(TRUE) + spinbutton1_adj = gtk.Adjustment(0, 0, 1000000000, 1, 1000, 1000) + spinbutton1 = gtk.SpinButton(spinbutton1_adj, 1.0, 0) + hbox1.pack_start(spinbutton1, True, True, 0) + spinbutton1.set_flags(gtk.CAN_FOCUS) + spinbutton1.set_numeric(True) + spinbutton1.set_update_policy(gtk.UPDATE_ALWAYS) + spinbutton1.set_editable(True) + spinbutton1.set_visibility(True) spinbutton1.set_value(limit) spinbutton1.show() - self.spinbutton1=spinbutton1 - self.spinbutton1_adj=spinbutton1_adj + self.spinbutton1 = spinbutton1 + self.spinbutton1_adj = spinbutton1_adj - progressbar1=GtkProgressBar() - hbox1.pack_start(progressbar1, TRUE, TRUE, 0) - progressbar1.set_usize(-1, -1) - progressbar1.set_format_string("%v") - progressbar1.set_show_text(TRUE) - progressbar1.configure(0, 0, limit) + progressbar1 = gtk.ProgressBar() + hbox1.pack_start(progressbar1, True, True, 0) progressbar1.show() - self.progressbar1=progressbar1 + self.progressbar1 = progressbar1 hbox1.show() - self.hbox1=hbox1 + self.hbox1 = hbox1 window1.show() - self.window1=window1 + self.window1 = window1 # we're doing this instead of using a dictionary because older versions of # pygtk didn't make widgets immutable, apparently @@ -109,35 +95,36 @@ def change_limit(l): global limit limit = l - v = window1.progressbar1.get_value() - window1.progressbar1.configure(min(v, limit), 0, limit) print int(limit) sys.stdout.flush() def set_current(v): global limit - window1.progressbar1.set_value(min(limit, v)) + print "%i %i\n" % (limit, v) + window1.progressbar1.set_fraction(float(min(limit, v)) / limit) + window1.progressbar1.set_text("%i" % min(limit, v)) def do_read(fd, cond): - if cond & GDK.INPUT_EXCEPTION: # might get SIGPIPE? - sys.exit("input stream exception") - #print 'do_read: fd %s, cond %s' % (fd, cond) + if cond & gobject.IO_ERR: # might get SIGPIPE? + sys.exit("input stream error") + print 'do_read: fd %s, cond %s' % (fd, cond) s = os.read(fd, 80) - if len(s) == 0: + if cond & gobject.IO_HUP: # SF exited sys.exit(0) - #print 'do_read: got %s' % repr(s) + print 'do_read: got %s' % repr(s) words = string.split(s) # FIX this hack s = words[0] set_current(string.atoi(s)) + return True limit = string.atoi(sys.argv[2]) if __name__ == '__main__': command = sys.argv[1] - window1=window1Widget(command, limit) - window1.window1.connect("delete_event", mainquit) + window1 = window1Widget(command, limit) + window1.window1.connect("delete_event", gtk.main_quit) window1.spinbutton1_adj.connect("value_changed", valuechanged) - input_add(0, GDK.INPUT_READ|GDK.INPUT_EXCEPTION, do_read) + gobject.io_add_watch(0, gobject.IO_IN | gobject.IO_ERR | gobject.IO_HUP, do_read) - mainloop() + gtk.main()