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.000000000 -0500
+++ driconf.py  2003-10-26 18:59:33.000000000 -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_usize (width, height)
+        checkLabel.set_size_request (width, height)
         checkLabel.show()
-        checkHBox.pack_start (checkLabel, FALSE, FALSE, 0)
+        checkHBox.pack_start (checkLabel, gtk.FALSE, gtk.FALSE, 0)
         checkHBox.show()
         self.add (checkHBox)
 
-class WrappingOptionMenu (GtkButton):
-    """ Something that looks similar to a GtkOptionMenu ...
+class WrappingOptionMenu (gtk.Button):
+    """ Something that looks similar to a gtk.OptionMenu ...
 
     but can wrap the text and has a simpler interface. It acts as a
     bidirectional map from option descriptions (opt) to values (val)
     at the same time. """
-    def __init__ (self, optValList, callback, justify=JUSTIFY_LEFT, wrap=TRUE,
-                  width=0, height=0):
+    def __init__ (self, optValList, callback, justify=gtk.JUSTIFY_LEFT, wrap=gtk.TRUE,
+                  width=-1, height=-1):
         """ Constructor. """
-        GtkButton.__init__ (self)
+        gtk.Button.__init__ (self)
         self.callback = callback
         self.optDict = {}
         self.valDict = {}
@@ -117,21 +120,21 @@
             self.valDict[val] = opt
         firstOpt,firstVal = optValList[len(optValList)-1]
         self.value = firstVal
-        hbox = GtkHBox()
-        arrow = GtkArrow (ARROW_DOWN, SHADOW_OUT)
+        hbox = gtk.HBox()
+        arrow = gtk.Arrow (gtk.ARROW_DOWN, gtk.SHADOW_OUT)
         arrow.show()
-        self.label = GtkLabel(firstOpt)
+        self.label = gtk.Label(firstOpt)
         self.label.set_justify (justify)
         self.label.set_line_wrap (wrap)
-        self.label.set_usize (width, height)
+        self.label.set_size_request (width, height)
         self.label.show()
-        hbox.pack_start (self.label, TRUE, FALSE, 5)
-        hbox.pack_start (arrow, FALSE, FALSE, 0)
+        hbox.pack_start (self.label, gtk.TRUE, gtk.FALSE, 5)
+        hbox.pack_start (arrow, gtk.FALSE, gtk.FALSE, 0)
         hbox.show()
         self.add (hbox)
-        self.menu = GtkMenu()
+        self.menu = gtk.Menu()
         for opt,val in optValList:
-            item = GtkMenuItem (opt)
+            item = gtk.MenuItem (opt)
             item.connect("activate", self.menuSelect, opt)
             item.show()
             self.menu.append (item)
@@ -153,11 +156,11 @@
 
     def buttonPress (self, widget, event):
         """ Popup the menu. """
-        if event.type == GDK.BUTTON_PRESS:
+        if event.type == gtk.gdk.BUTTON_PRESS:
             self.menu.popup(None, None, None, event.button, event.time)
-            return TRUE
+            return gtk.TRUE
         else:
-            return FALSE
+            return gtk.FALSE
 
     def menuSelect (self, widget, opt):
         """ React to selection of a menu item by the user. """
@@ -187,14 +190,14 @@
         tooltipString = str(opt)
         page.tooltips.set_tip (self.check, tooltipString.encode(encoding))
         self.check.show()
-        page.table.attach (self.check, 0, 1, i, i+1, EXPAND|FILL, 0, 5, 5)
+        page.table.attach (self.check, 0, 1, i, i+1, gtk.EXPAND|gtk.FILL, 0, 5, 5)
         # a button to reset the option to its default value
         sensitive = self.check.get_active() and page.app.device.config.writable
-        self.resetButton = GtkButton ()
+        self.resetButton = gtk.Button ()
         pixmap = DataPixmap (tb_undo_xpm)
         pixmap.show()
         self.resetButton.add (pixmap)
-        self.resetButton.set_relief (RELIEF_NONE)
+        self.resetButton.set_relief (gtk.RELIEF_NONE)
         self.resetButton.set_sensitive (sensitive)
         self.resetButton.connect ("clicked", self.resetOpt)
         self.resetButton.show()
@@ -215,7 +218,7 @@
         # the widget for editing the option value
         self.initWidget (opt, value, valid)
         self.widget.set_sensitive (sensitive)
-        page.table.attach (self.widget, 1, 2, i, i+1, FILL, 0, 5, 5)
+        page.table.attach (self.widget, 1, 2, i, i+1, gtk.FILL, 0, 5, 5)
 
     def initWidget (self, opt, value, valid=1):
         """ Initialize the option widget.
@@ -226,18 +229,18 @@
         if not valid:
             type = "invalid"
         if type == "bool":
-            self.toggleLabel = GtkLabel()
+            self.toggleLabel = gtk.Label("")
             self.toggleLabel.show()
-            self.widget = GtkToggleButton ()
+            self.widget = gtk.ToggleButton ()
             self.widget.add (self.toggleLabel)
             # need to set_active here, so that the toggled signal isn't
             # triggered in updateWidget and the config marked as modified.
             self.widget.set_active (value)
             self.widget.connect ("toggled", self.activateSignal)
         elif type == "int" and opt.valid and len(opt.valid) == 1:
-            adjustment = GtkAdjustment (value, opt.valid[0].start,
+            adjustment = gtk.Adjustment (value, opt.valid[0].start,
                                         opt.valid[0].end, 1, 10)
-            self.widget = GtkSpinButton (adjustment, digits=0)
+            self.widget = gtk.SpinButton (adjustment, digits=0)
             adjustment.connect ("value_changed", self.activateSignal)
         elif type == "enum" or \
              (type != "invalid" and opt.valid and
@@ -255,7 +258,7 @@
             self.widget = WrappingOptionMenu (optValList, self.activateSignal,
                                               width=180)
         else:
-            self.widget = GtkEntry ()
+            self.widget = gtk.Entry ()
             if type == "invalid":
                 self.widget.set_text (value)
             else:
@@ -267,17 +270,17 @@
     def updateWidget (self, value, valid=1):
         """ Update the option widget to a new value. """
         active = self.check.get_active()
-        if self.widget.__class__ == GtkToggleButton:
+        if self.widget.__class__ == gtk.ToggleButton:
             if value:
                 self.toggleLabel.set_text ("Yes")
             else:
                 self.toggleLabel.set_text ("No")
             self.widget.set_active (value)
-        elif self.widget.__class__ == GtkSpinButton:
+        elif self.widget.__class__ == gtk.SpinButton:
             self.widget.set_value (value)
         elif self.widget.__class__ == WrappingOptionMenu:
             return self.widget.setValue(str(value))
-        elif self.widget.__class__ == GtkEntry:
+        elif self.widget.__class__ == gtk.Entry:
             if self.opt.type == "bool" and valid:
                 if value:
                     newText = "true"
@@ -297,16 +300,16 @@
         Returns None if the widget is not activated. """
         if not self.check.get_active():
             return None
-        elif self.widget.__class__ == GtkToggleButton:
+        elif self.widget.__class__ == gtk.ToggleButton:
             if self.widget.get_active():
                 return "true"
             else:
                 return "false"
-        elif self.widget.__class__ == GtkSpinButton:
+        elif self.widget.__class__ == gtk.SpinButton:
             return str(self.widget.get_value_as_int())
         elif self.widget.__class__ == WrappingOptionMenu:
             return self.widget.getValue()
-        elif self.widget.__class__ == GtkEntry:
+        elif self.widget.__class__ == gtk.Entry:
             return self.widget.get_text()
         else:
             return None
@@ -314,16 +317,16 @@
     def checkOpt (self, widget):
         """ Handler for 'check button (maybe) toggled'. """
         if self.check.get_active():
-            self.widget.set_sensitive (TRUE)
-            self.resetButton.set_sensitive (TRUE)
+            self.widget.set_sensitive (gtk.TRUE)
+            self.resetButton.set_sensitive (gtk.TRUE)
         else:
-            self.widget.set_sensitive (FALSE)
-            self.resetButton.set_sensitive (FALSE)
+            self.widget.set_sensitive (gtk.FALSE)
+            self.resetButton.set_sensitive (gtk.FALSE)
         self.page.optionModified (self)
 
     def activateSignal (self, widget, dummy=None):
         """ Handler for 'widget was activated by the user'. """
-        if self.widget.__class__ == GtkToggleButton:
+        if self.widget.__class__ == gtk.ToggleButton:
             value = self.widget.get_active()
             if value:
                 self.toggleLabel.set_text ("Yes")
@@ -340,33 +343,33 @@
         """ Validate the current value from the option widget.
 
         This is only interesting if the check button is active. Only
-        GtkEntry widgets should ever give invalid values in practice.
+        gtk.Entry widgets should ever give invalid values in practice.
         Invalid option widgets are highlighted. """
         value = self.getValue()
         if value == None:
             return 1
         valid = self.opt.validate (value)
         if not valid:
-            if self.widget.__class__ == GtkEntry:
+            if self.widget.__class__ == gtk.Entry:
                 style = self.widget.get_style().copy()
-                style.fg[STATE_NORMAL] = self.widget.get_colormap().alloc(65535, 0, 0)
+                style.text[gtk.STATE_NORMAL] = 
self.widget.get_colormap().alloc_color("red")
                 self.widget.set_style (style)
         else:
-            if self.widget.__class__ == GtkEntry:
-                self.widget.set_rc_style()
+            if self.widget.__class__ == gtk.Entry:
+                self.widget.set_style (None)
         return valid
 
-class SectionPage (GtkScrolledWindow):
+class SectionPage (gtk.ScrolledWindow):
     """ One page in the DriverPanel with one OptionLine per option. """
     def __init__ (self, optSection, app):
         """ Constructor. """
-        GtkScrolledWindow.__init__ (self)
-        self.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC)
-        self.set_usize (500, 200)
+        gtk.ScrolledWindow.__init__ (self)
+        self.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+        self.set_size_request (500, 200)
         self.optSection = optSection
         self.app = app
-        self.tooltips = GtkTooltips()
-        self.table = GtkTable (len(optSection.optList), 3)
+        self.tooltips = gtk.Tooltips()
+        self.table = gtk.Table (len(optSection.optList), 3)
         self.optLines = []
         for i in range (len(optSection.optList)):
             self.optLines.append (OptionLine (self, i, optSection.optList[i]))
@@ -402,12 +405,12 @@
                     self.app.device.config.modifiedCallback()
                 self.app.options[name] = value
 
-class UnknownSectionPage(GtkScrolledWindow):
+class UnknownSectionPage(gtk.ScrolledWindow):
     """ Special section page for options unknown to the driver. """
     def __init__ (self, driver, app):
         """ Constructor. """
-        GtkScrolledWindow.__init__ (self)
-        self.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC)
+        gtk.ScrolledWindow.__init__ (self)
+        self.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
         self.app = app
         # copy options (dict function does not exist in Python 2.1 :( )
         self.opts = {}
@@ -422,18 +425,18 @@
         if len(self.opts) == 0:
             return
         # list all remaining options here
-        self.list = GtkCList(2, ["Option", "Value"])
+        self.list = gtk.CList(2, ["Option", "Value"])
         for name,val in self.opts.items():
             self.list.append ([str(name),str(val)])
-        self.list.set_column_justification (1, JUSTIFY_RIGHT)
+        self.list.set_column_justification (1, gtk.JUSTIFY_RIGHT)
         self.list.columns_autosize()
         self.list.show()
-        self.vbox = GtkVBox()
-        self.vbox.pack_start (self.list, TRUE, TRUE, 0)
-        self.removeButton = GtkButton ("Remove")
+        self.vbox = gtk.VBox()
+        self.vbox.pack_start (self.list, gtk.TRUE, gtk.TRUE, 0)
+        self.removeButton = gtk.Button ("Remove")
         self.removeButton.show()
         self.removeButton.connect ("clicked", self.removeSelection)
-        self.vbox.pack_start (self.removeButton, FALSE, FALSE, 0)
+        self.vbox.pack_start (self.removeButton, gtk.FALSE, gtk.FALSE, 0)
         self.vbox.show()
         self.add_with_viewport (self.vbox)
 
@@ -453,25 +456,25 @@
             self.list.remove (row)
             self.app.device.config.modifiedCallback()
 
-class DriverPanel (GtkFrame):
+class DriverPanel (gtk.Frame):
     """ Panel for driver settings for a specific application. """
     def __init__ (self, driver, app):
         """ Constructor. """
-        GtkFrame.__init__ (self, "Application: " + app.name)
+        gtk.Frame.__init__ (self, "Application: " + app.name)
         self.driver = driver
         self.app = app
-        table = GtkTable(2, 2)
-        execLabel = GtkLabel ("Executable:")
+        table = gtk.Table(2, 2)
+        execLabel = gtk.Label ("Executable:")
         execLabel.show()
         table.attach (execLabel, 0, 1, 0, 1, 0, 0, 5, 5)
-        self.execEntry = GtkEntry()
+        self.execEntry = gtk.Entry()
         if app.executable != None:
             self.execEntry.set_text (app.executable)
         self.execEntry.set_sensitive (app.device.config.writable)
         self.execEntry.connect ("changed", self.execChanged)
         self.execEntry.show()
-        table.attach (self.execEntry, 1, 2, 0, 1, EXPAND|FILL, 0, 5, 5)
-        notebook = GtkNotebook()
+        table.attach (self.execEntry, 1, 2, 0, 1, gtk.EXPAND|gtk.FILL, 0, 5, 5)
+        notebook = gtk.Notebook()
         self.sectPages = []
         self.sectLabels = []
         for sect in driver.optSections:
@@ -479,9 +482,9 @@
             sectPage.show()
             desc = sect.getDesc([lang])
             if desc:
-                sectLabel = GtkLabel (desc.encode(encoding))
+                sectLabel = gtk.Label (desc.encode(encoding))
             else:
-                sectLabel = GtkLabel ("(no description)")
+                sectLabel = gtk.Label ("(no description)")
             sectLabel.show()
             notebook.append_page (sectPage, sectLabel)
             self.sectPages.append (sectPage)
@@ -489,16 +492,16 @@
         unknownPage = UnknownSectionPage (driver, app)
         if len(unknownPage.opts) > 0:
             unknownPage.show()
-            unknownLabel = GtkLabel ("Unknown")
+            unknownLabel = gtk.Label ("Unknown")
             unknownLabel.show()
             notebook.append_page (unknownPage, unknownLabel)
             self.sectPages.append (unknownPage)
             self.sectLabels.append (sectLabel)
             MessageDialog ("Notice",
-                           "This application configuration contains options that are 
not known to the driver. Either you edited your configuration file manually or the 
driver configuration changed. See the page named \"Unknown\" for details. It is 
probably safe to remove these options. Otherwise they are left unchanged.", 
modal=FALSE)
+                           "This application configuration contains options that are 
not known to the driver. Either you edited your configuration file manually or the 
driver configuration changed. See the page named \"Unknown\" for details. It is 
probably safe to remove these options. Otherwise they are left unchanged.", 
modal=gtk.FALSE)
         self.validate()
         notebook.show()
-        table.attach (notebook, 0, 2, 1, 2, FILL, EXPAND|FILL, 5, 5)
+        table.attach (notebook, 0, 2, 1, 2, gtk.FILL, gtk.EXPAND|gtk.FILL, 5, 5)
         table.show()
         self.add (table)
 
@@ -516,10 +519,10 @@
             valid = sectPage.validate()
             if not valid:
                 style = self.sectLabels[index].get_style().copy()
-                style.fg[STATE_NORMAL] = 
self.sectLabels[index].get_colormap().alloc(65535, 0, 0)
-                self.sectLabels[index].set_style(style)
+                style.fg[gtk.STATE_NORMAL] = 
self.sectLabels[index].get_colormap().alloc_color("red")
             else:
-                self.sectLabels[index].set_rc_style()
+                style = None
+            self.sectLabels[index].set_style(style)
             allValid = allValid and valid
             index = index+1
         return allValid
@@ -541,25 +544,25 @@
         """ Change the application name. """
         self.set_label ("Application: " + self.app.name)
 
-class BasicDialog (GtkDialog):
+class BasicDialog (gtk.Dialog):
     """ Base class for NameDialog and DeviceDialog. """
     def __init__ (self, title, callback):
-        GtkDialog.__init__ (self)
+        gtk.Dialog.__init__ (self)
         self.set_transient_for (mainWindow)
         self.set_title (title)
         self.callback = callback
-        ok = GtkButton ("OK")
-        ok.set_flags (CAN_DEFAULT)
+        ok = gtk.Button ("OK")
+        ok.set_flags (gtk.CAN_DEFAULT)
         ok.connect ("clicked", self.okSignal)
         ok.show()
-        self.action_area.pack_start (ok, TRUE, FALSE, 10)
-        cancel = GtkButton ("Cancel")
-        cancel.set_flags (CAN_DEFAULT)
+        self.action_area.pack_start (ok, gtk.TRUE, gtk.FALSE, 10)
+        cancel = gtk.Button ("Cancel")
+        cancel.set_flags (gtk.CAN_DEFAULT)
         cancel.connect ("clicked", self.cancelSignal)
         cancel.show()
-        self.action_area.pack_start (cancel, TRUE, FALSE, 10)
+        self.action_area.pack_start (cancel, gtk.TRUE, gtk.FALSE, 10)
         ok.grab_default()
-        self.set_modal (TRUE)
+        self.set_modal (gtk.TRUE)
 
     def okSignal (self, widget):
         self.callback()
@@ -573,19 +576,20 @@
     def __init__ (self, title, callback, name, data):
         BasicDialog.__init__ (self, title, callback)
         self.data = data
-        hbox = GtkHBox()
-        label = GtkLabel ("Name:")
+        hbox = gtk.HBox()
+        label = gtk.Label ("Name:")
         label.show()
-        hbox.pack_start (label, TRUE, TRUE, 10)
-        self.entry = GtkEntry()
+        hbox.pack_start (label, gtk.TRUE, gtk.TRUE, 10)
+        self.entry = gtk.Entry()
         self.entry.set_text (name)
         self.entry.select_region (0, len(name))
         self.entry.connect ("activate", self.okSignal)
         self.entry.show()
-        hbox.pack_start (self.entry, TRUE, TRUE, 10)
+        hbox.pack_start (self.entry, gtk.TRUE, gtk.TRUE, 10)
         hbox.show()
-        self.vbox.pack_start (hbox, TRUE, TRUE, 10)
+        self.vbox.pack_start (hbox, gtk.TRUE, gtk.TRUE, 10)
         self.show()
+
         self.entry.grab_focus()
 
     def okSignal (self, widget):
@@ -597,27 +601,27 @@
     def __init__ (self, title, callback, data):
         BasicDialog.__init__ (self, title, callback)
         self.data = data
-        table = GtkTable (2, 2)
-        screenLabel = GtkLabel ("Screen:")
+        table = gtk.Table (2, 2)
+        screenLabel = gtk.Label ("Screen:")
         screenLabel.show()
         table.attach (screenLabel, 0, 1, 0, 1, 0, 0, 5, 5)
-        self.screenCombo = GtkCombo()
+        self.screenCombo = gtk.Combo()
         self.screenCombo.set_popdown_strings (
             [""]+map(str,range(len(dpy.screens))))
         self.screenCombo.entry.connect ("activate", self.screenSignal)
         self.screenCombo.list.connect ("select_child", self.screenSignal)
         self.screenCombo.show()
-        table.attach (self.screenCombo, 1, 2, 0, 1, EXPAND|FILL, EXPAND, 5, 5)
-        driverLabel = GtkLabel ("Driver:")
+        table.attach (self.screenCombo, 1, 2, 0, 1, gtk.EXPAND|gtk.FILL, gtk.EXPAND, 
5, 5)
+        driverLabel = gtk.Label ("Driver:")
         driverLabel.show()
         table.attach (driverLabel, 0, 1, 1, 2, 0, 0, 5, 5)
-        self.driverCombo = GtkCombo()
+        self.driverCombo = gtk.Combo()
         self.driverCombo.set_popdown_strings (
             [""]+[str(driver.name) for driver in dri.DisplayInfo.drivers.values()])
         self.driverCombo.show()
-        table.attach (self.driverCombo, 1, 2, 1, 2, EXPAND|FILL, EXPAND, 5, 5)
+        table.attach (self.driverCombo, 1, 2, 1, 2, gtk.EXPAND|gtk.FILL, gtk.EXPAND, 
5, 5)
         table.show()
-        self.vbox.pack_start (table, TRUE, TRUE, 5)
+        self.vbox.pack_start (table, gtk.TRUE, gtk.TRUE, 5)
         self.show()
 
     def screenSignal (self, widget, data=None):
@@ -637,7 +641,7 @@
                        self.driverCombo.entry.get_text(), self.data)
         self.destroy()
 
-class ConfigTree (GtkCTree):
+class ConfigTree (gtk.CTree):
     """ Configuration tree.
 
     Hierarchy levels: Config (file), Device, Application """
@@ -646,10 +650,10 @@
         pass
     
     def __init__ (self, configList):
-        GtkCTree.__init__ (self, 1, 0)
-        self.set_usize (200, 0)
-        self.set_selection_mode (SELECTION_BROWSE)
-        self.defaultFg = self.get_style().fg[STATE_NORMAL]
+        gtk.CTree.__init__ (self, 1, 0)
+        self.set_size_request (200, -1)
+        self.set_selection_mode (gtk.SELECTION_BROWSE)
+        self.defaultFg = self.get_style().fg[gtk.STATE_NORMAL]
         self.configList = []
         for config in configList:
             self.addConfig (config)
@@ -668,8 +672,8 @@
             siblingNode = None
         fileName = str(config.fileName)
         fileNode = self.insert_node (None, siblingNode, [fileName], 0,
-                                     None,None,None,None, FALSE, TRUE)
-        config.modified = FALSE
+                                     None,None,None,None, gtk.FALSE, gtk.TRUE)
+        config.modified = gtk.FALSE
         config.modifiedCallback = self.configModified
         config.node = fileNode
         self.node_set_row_data (fileNode, ("config", config))
@@ -689,7 +693,7 @@
             name = "general"
         name = str(name)
         devNode = self.insert_node (parent, None, [name], 0,
-                                    None,None,None,None, FALSE, TRUE)
+                                    None,None,None,None, gtk.FALSE, gtk.TRUE)
         device.node = devNode
         self.node_set_row_data (devNode, ("device", device))
         return devNode
@@ -710,11 +714,11 @@
         if driver:
             if driver.validate (app.options):
                 style = self.get_style().copy()
-                style.fg[STATE_NORMAL] = self.defaultFg
+                style.fg[gtk.STATE_NORMAL] = self.defaultFg
                 self.node_set_row_style(app.node, style)
             else:
                 style = self.get_style().copy()
-                style.fg[STATE_NORMAL] = self.get_colormap().alloc(65535, 0, 0)
+                style.fg[gtk.STATE_NORMAL] = self.get_colormap().alloc_color("red")
                 self.node_set_row_style(app.node, style)
 
     def getSelection (self):
@@ -725,7 +729,7 @@
             raise SelectionError
         return self.selection[0]
 
-    def configModified (self, b=TRUE):
+    def configModified (self, b=gtk.TRUE):
         try:
             node = self.getSelection()
         except SelectionError:
@@ -756,12 +760,12 @@
                 driver = None
                 MessageDialog ("Error",
                                "Parsing the driver's configuration information: " + 
str(problem),
-                               modal=FALSE)
+                               modal=gtk.FALSE)
             else:
                 if driver == None:
                     MessageDialog ("Notice",
                                    "Can't determine the driver for this device.",
-                                   modal=FALSE)
+                                   modal=gtk.FALSE)
         else:
             driver = None
             app = None
@@ -939,7 +943,7 @@
         mainWindow.commitDriverPanel()
         file.write (str(config))
         file.close()
-        config.modifiedCallback(FALSE)
+        config.modifiedCallback(gtk.FALSE)
 
     def reloadConfig (self, widget):
         self.doReloadConfig ()
@@ -993,23 +997,25 @@
         self.remove_node (config.node)
         self.addConfig (newConfig, sibling)
 
-class MainWindow (GtkWindow):
+class MainWindow (gtk.Window):
     """ The main window consiting of ConfigTree, DriverPanel and toolbar. """
     def __init__ (self, configList):
-        GtkWindow.__init__ (self)
+        gtk.Window.__init__ (self)
         self.set_title ("DRI Configuration")
-        self.connect ("destroy", mainquit)
+        #self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
+        self.set_default_size(722, 390)
+        self.connect ("destroy", gtk.mainquit)
         self.connect ("delete_event", self.exitHandler)
-        self.vbox = GtkVBox()
-        self.paned = GtkHPaned()
+        self.vbox = gtk.VBox()
+        self.paned = gtk.HPaned()
         self.configTree = ConfigTree (configList)
         self.configTree.show()
         self.paned.add1(self.configTree)
         self.paned.show()
         DataPixmap.window = self
-        self.toolbar = GtkToolbar (ORIENTATION_HORIZONTAL, TOOLBAR_BOTH)
-        self.toolbar.set_button_relief (RELIEF_NONE)
-        self.toolbar.set_space_style (TOOLBAR_SPACE_LINE)
+        self.toolbar = gtk.Toolbar()
+        self.toolbar.set_orientation(gtk.ORIENTATION_HORIZONTAL)
+        self.toolbar.set_style(gtk.TOOLBAR_BOTH)
         self.saveButton = self.toolbar.append_item (
             "Save", "Save selected configuration file", "priv",
             DataPixmap (tb_save_xpm), self.configTree.saveConfig)
@@ -1039,14 +1045,17 @@
         if len(configList) != 0:
             self.activateConfigButtons (configList[0])
         self.toolbar.show()
-        self.vbox.pack_start (self.toolbar, FALSE, TRUE, 0)
-        self.vbox.pack_start (self.paned, TRUE, TRUE, 0)
+        self.vbox.pack_start (self.toolbar, gtk.FALSE, gtk.TRUE, 0)
+        self.vbox.pack_start (self.paned, gtk.TRUE, gtk.TRUE, 0)
         self.vbox.show()
         self.add (self.vbox)
         self.curDriverPanel = None
         self.logo = DataPixmap (drilogo_xpm)
         self.logo.show()
         self.paned.add2 (self.logo)
+        style = self.get_style().copy ()
+        style.bg[gtk.STATE_NORMAL] = self.get_colormap().alloc_color ("white")
+        self.set_style (style)
 
     def commitDriverPanel (self):
         if self.curDriverPanel != None:
@@ -1065,10 +1074,14 @@
             self.curDriverPanel = DriverPanel (driver, app)
             self.curDriverPanel.show ()
             self.paned.add2 (self.curDriverPanel)
+            self.set_style (None)
         elif self.curDriverPanel != None:
             self.curDriverPanel = None
             self.logo.show()
             self.paned.add2 (self.logo)
+            style = self.get_style().copy ()
+            style.bg[gtk.STATE_NORMAL] = self.get_colormap().alloc_color ("white")
+            self.set_style (style)
 
     def removeApp (self, app):
         if self.curDriverPanel != None and self.curDriverPanel.app == app:
@@ -1086,10 +1099,10 @@
         modified = config.modified
         self.saveButton  .set_sensitive (writable and modified)
         self.newButton   .set_sensitive (writable)
-        self.removeButton.set_sensitive (FALSE)
-        self.upButton    .set_sensitive (FALSE)
-        self.downButton  .set_sensitive (FALSE)
-        self.renameButton.set_sensitive (FALSE)
+        self.removeButton.set_sensitive (gtk.FALSE)
+        self.upButton    .set_sensitive (gtk.FALSE)
+        self.downButton  .set_sensitive (gtk.FALSE)
+        self.renameButton.set_sensitive (gtk.FALSE)
 
     def activateDeviceButtons (self, device):
         writable = device.config.writable
@@ -1099,7 +1112,7 @@
         self.removeButton.set_sensitive (writable)
         self.upButton    .set_sensitive (writable)
         self.downButton  .set_sensitive (writable)
-        self.renameButton.set_sensitive (FALSE)
+        self.renameButton.set_sensitive (gtk.FALSE)
 
     def activateAppButtons (self, app):
         writable = app.device.config.writable
@@ -1112,24 +1125,24 @@
         self.renameButton.set_sensitive (writable)
 
     def exitHandler (self, widget, event=None):
-        modified = FALSE
+        modified = gtk.FALSE
         for config in self.configTree.getConfigList():
             if config.modified:
-                modified = TRUE
+                modified = gtk.TRUE
                 break
         if modified:
             MessageDialog ("Question",
                            "There are unsaved modifications. Exit anyway?",
                            ["Yes", "No"], self.doExit)
-            return TRUE
+            return gtk.TRUE
         elif event == None:
-            mainquit()
+            gtk.mainquit()
         else:
-            return FALSE
+            return gtk.FALSE
 
     def doExit (self, choice):
         if choice == "Yes":
-            mainquit()
+            gtk.mainquit()
 
 def fileIsWritable(filename):
     """ Find out if a file is writable.
@@ -1164,16 +1177,16 @@
     try:
         dpy = dri.DisplayInfo ()
     except dri.DRIError, problem:
-        MessageDialog ("Error", str(problem), callback = lambda n: mainquit())
-        mainloop()
+        MessageDialog ("Error", str(problem), callback = lambda n: gtk.mainquit())
+        gtk.mainloop()
         return
     except dri.XMLError, problem:
         MessageDialog ("Error",
                        "There are errors in a driver's configuration information:\n"+
                        str(problem)+
                        "\nThis should not happen. It probably means that you have to 
update driconf.",
-                       callback = lambda n: mainquit())
-        mainloop()
+                       callback = lambda n: gtk.mainquit())
+        gtk.mainloop()
         return
 
     # read or create configuration files
@@ -1233,4 +1246,4 @@
                        + " for you.")
 
     # run
-    mainloop()
+    gtk.mainloop()

Reply via email to