--- a/pgconsole/dataview.py Thu Mar 07 18:26:52 2013 +0100
+++ b/pgconsole/dataview.py Sun Mar 10 16:14:53 2013 +0100
@@ -1,33 +1,36 @@
-import gtk, gobject, pango
+from gi.repository import GObject
+from gi.repository import Gtk
+from gi.repository import Pango
+
from cgi import escape
-class DataView(gtk.ScrolledWindow):
+class DataView(Gtk.ScrolledWindow):
def __init__(self):
super(DataView, self).__init__()
sw = self
- sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
- sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
- self.treeview = gtk.TreeView(gtk.ListStore(str))
- self.treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
+ sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+ sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
+ self.treeview = Gtk.TreeView(Gtk.ListStore(str))
+ self.treeview.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)
self.treeview.set_property("rubber-banding", True)
sw.add(self.treeview)
def load_data(self, names, rows):
x = [str] * (len(names) + 1)
- liststore = gtk.ListStore(*x)
+ liststore = Gtk.ListStore(*x)
for c in self.treeview.get_columns():
self.treeview.remove_column(c)
- tvcolumn = gtk.TreeViewColumn()
+ tvcolumn = Gtk.TreeViewColumn()
cell = DataViewCellRenderer()
cell.set_property('head', True)
tvcolumn.pack_start(cell, True)
tvcolumn.set_property('resizable', True)
- #tvcolumn.set_property('sizing', gtk.TREE_VIEW_COLUMN_FIXED)
+ #tvcolumn.set_property('sizing', Gtk.TREE_VIEW_COLUMN_FIXED)
tvcolumn.set_attributes(cell, text=0)
tvcolumn.set_min_width(2)
self.treeview.append_column(tvcolumn)
@@ -40,10 +43,10 @@
if typename:
title += '\n<span size="small">%s</span>' % typename
- tvcolumn = gtk.TreeViewColumn()
+ tvcolumn = Gtk.TreeViewColumn()
cell = DataViewCellRenderer()
- lab = gtk.Label()
+ lab = Gtk.Label()
lab.set_use_underline(False)
lab.set_markup(title)
lab.show()
@@ -63,21 +66,21 @@
-class DataViewCellRenderer(gtk.GenericCellRenderer):
+class DataViewCellRenderer(Gtk.CellRenderer):
__gtype_name__ = 'DataViewCellRenderer'
__gproperties__ = {
- 'text': (gobject.TYPE_STRING, None, None, '', gobject.PARAM_READWRITE),
- 'head': (gobject.TYPE_BOOLEAN, None, None, False, gobject.PARAM_READWRITE)}
+ 'text': (GObject.TYPE_STRING, None, None, '', GObject.PARAM_READWRITE),
+ 'head': (GObject.TYPE_BOOLEAN, None, None, False, GObject.PARAM_READWRITE)}
def __init__(self):
- gtk.GenericCellRenderer.__init__(self)
+ Gtk.CellRenderer.__init__(self)
self._props = {'text' : '', 'head' : False}
def do_set_property(self, pspec, value):
if not pspec.name in self._props:
- raise AttributeError, 'Unknown property: %s' % pspec.name
+ raise AttributeError('Unknown property: %s' % pspec.name)
self._props[pspec.name] = value
@@ -88,7 +91,7 @@
def on_get_size(self, widget, cell_area):
if cell_area == None:
pangoctx = widget.get_pango_context()
- layout = pango.Layout(pangoctx)
+ layout = Pango.Layout(pangoctx)
layout.set_width(-1)
layout.set_text(self.get_property('text') or 'NULL')
w,h = layout.get_pixel_size()
@@ -120,7 +123,7 @@
ctx.stroke()
pangoctx = widget.get_pango_context()
- layout = pango.Layout(pangoctx)
+ layout = Pango.Layout(pangoctx)
text = self.get_property('text')
head = self.get_property('head')
@@ -132,7 +135,7 @@
else:
layout.set_text(text)
- widget.style.paint_layout(window, gtk.STATE_NORMAL, True,
+ widget.style.paint_layout(window, Gtk.STATE_NORMAL, True,
cell_area, widget, '',
cell_area.x, cell_area.y,
layout)