Hello all,
I recently had some time to check out the trunk and try out the new GUI
configuration tool. The box I tested on is running RedHat 9, which comes
with pygtk2 installed, so I decided to port driconf to pygtk2 rather than
try to figure out how to install an older pygtk in parallel with the new
one.
I'm attaching the patch (against driconf-0.0.11 from the DriConf wiki
page) in case anyone else is in a similar situation. I'm a python newbie,
but the lion's share of the changes were simple search and replace (the
PyGTK FAQ covered most, but not all of the necessary changes).
I also included a couple of minor visual tweaks: setting the initial
window size to match the window size after selecting a profile (kept the
window from being extended beyond the desktop borders when it was placed
in the lower right corner of the screen on startup), and setting the
window background to white when the DRI logo is displayed (since the wider
window exposed the gray background behind the image).
--
Leif Delgass
http://www.retinalburn.net
--- driconf.orig.py 2003-10-25 13:41:31.0 -0500
+++ driconf.py 2003-10-26 18:59:33.0 -0500
@@ -18,61 +18,64 @@
# Contact: http://fxk.de.vu/
+# Ported to PyGTK-2 by Leif Delgass <[EMAIL PROTECTED]>
+
import os
import locale
import dri
try:
import pygtk
-# make sure gtk version 1.2 is used.
-pygtk.require ("1.2")
+# make sure gtk version 2.x is used.
+pygtk.require ("2.0")
except ImportError:
# not supported everywhere, so ignore import errors
pass
-from gtk import *
+import gtk
from driconf_xpm import *
# global variable: main window
mainWindow = None
-class DataPixmap (GtkPixmap):
+class DataPixmap (gtk.Image):
""" A pixmap made from data. """
window = None
def __init__ (self, data):
""" Constructor. """
DataPixmap.window.realize()
style = DataPixmap.window.get_style()
-pixmap, mask = create_pixmap_from_xpm_d(DataPixmap.window.get_window(),
-style.bg[STATE_NORMAL],
-data)
-GtkPixmap.__init__ (self, pixmap, mask)
+pixmap, mask = gtk.create_pixmap_from_xpm_d(DataPixmap.window.window,
+style.bg[gtk.STATE_NORMAL],
+data)
+gtk.Image.__init__ (self)
+self.set_from_pixmap(pixmap, mask)
-class MessageDialog (GtkDialog):
+class MessageDialog (gtk.Dialog):
""" A simple message dialog with configurable buttons and a callback. """
def __init__ (self, title, message, buttons = ["OK"], callback = None,
- modal = TRUE):
+ modal = gtk.TRUE):
""" Constructor. """
-GtkDialog.__init__ (self)
+gtk.Dialog.__init__ (self)
if mainWindow:
self.set_transient_for (mainWindow)
self.callback = callback
self.set_title (title)
first = None
for name in buttons:
-button = GtkButton (name)
-button.set_flags (CAN_DEFAULT)
+button = gtk.Button (name)
+button.set_flags (gtk.CAN_DEFAULT)
button.connect ("clicked", self.clickedSignal, name)
button.show()
-self.action_area.pack_start (button, TRUE, FALSE, 10)
+self.action_area.pack_start (button, gtk.TRUE, gtk.FALSE, 10)
if not first:
first = button
-hbox = GtkHBox()
-label = GtkLabel (message)
-label.set_justify (JUSTIFY_LEFT)
-label.set_line_wrap (TRUE)
+hbox = gtk.HBox()
+label = gtk.Label (message)
+label.set_justify (gtk.JUSTIFY_LEFT)
+label.set_line_wrap (gtk.TRUE)
label.show()
-hbox.pack_start (label, TRUE, TRUE, 20)
+hbox.pack_start (label, gtk.TRUE, gtk.TRUE, 20)
hbox.show()
-self.vbox.pack_start (hbox, TRUE, TRUE, 10)
+self.vbox.pack_start (hbox, gtk.TRUE, gtk.TRUE, 10)
first.grab_default()
self.set_modal (modal)
self.show()
@@ -83,32 +86,32 @@
self.callback (name)
self.destroy()
-class WrappingCheckButton (GtkCheckButton):
+class WrappingCheckButton (gtk.CheckButton):
""" Check button with a line wrapping label. """
-def __init__ (self, label, justify=JUSTIFY_LEFT, wrap=TRUE,
- width=0, height=0):
+def __init__ (self, label, justify=gtk.JUSTIFY_LEFT, wrap=gtk.TRUE,
+ width=-1, height=-1):
""" Constructor. """
-GtkCheckButton.__init__ (self)
-checkHBox = GtkHBox()
-checkLabel = GtkLabel(label)
+gtk.CheckButton.__init__ (self)
+checkHBox = gtk.HBox()
+checkLabel = gtk.Label(label)
checkLabel.set_justify (justify)
checkLabel.set_line_wrap (wrap)
-checkLabel.set_us