summaryrefslogtreecommitdiff
path: root/gi/overrides/Gtk.py
diff options
context:
space:
mode:
Diffstat (limited to 'gi/overrides/Gtk.py')
-rw-r--r--gi/overrides/Gtk.py53
1 files changed, 49 insertions, 4 deletions
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 6c22829..31d1362 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -720,6 +720,9 @@ class TreeModel(Gtk.TreeModel):
for i in range(n_columns):
value = row[i]
+ if value is None:
+ continue # None means skip this row
+
self.set_value(treeiter, i, value)
def _convert_value(self, treeiter, column, value):
@@ -728,9 +731,9 @@ class TreeModel(Gtk.TreeModel):
# we may need to convert to a basic type
type_ = self.get_column_type(column)
- if type_ == gobject.TYPE_PYOBJECT:
+ if type_ == GObject.TYPE_PYOBJECT:
pass # short-circut branching
- elif type_ == gobject.TYPE_STRING:
+ elif type_ == GObject.TYPE_STRING:
if isinstance(value, str):
value = str(value)
elif sys.version_info < (3, 0):
@@ -740,12 +743,12 @@ class TreeModel(Gtk.TreeModel):
raise ValueError('Expected string or unicode for column %i but got %s%s' % (column, value, type(value)))
else:
raise ValueError('Expected a string for column %i but got %s' % (column, type(value)))
- elif type_ == gobject.TYPE_FLOAT or type_ == gobject.TYPE_DOUBLE:
+ elif type_ == GObject.TYPE_FLOAT or type_ == GObject.TYPE_DOUBLE:
if isinstance(value, float):
value = float(value)
else:
raise ValueError('Expected a float for column %i but got %s' % (column, type(value)))
- elif type_ == gobject.TYPE_LONG or type_ == gobject.TYPE_INT:
+ elif type_ == GObject.TYPE_LONG or type_ == GObject.TYPE_INT:
if isinstance(value, int):
value = int(value)
elif sys.version_info < (3, 0):
@@ -755,6 +758,35 @@ class TreeModel(Gtk.TreeModel):
raise ValueError('Expected an long for column %i but got %s' % (column, type(value)))
else:
raise ValueError('Expected an integer for column %i but got %s' % (column, type(value)))
+ elif type_ == GObject.TYPE_BOOLEAN:
+ if isinstance(value, (int, long)):
+ value = bool(value)
+ else:
+ raise ValueError('Expected a bool for column %i but got %s' % (column, type(value)))
+ else:
+ # use GValues directly to marshal to the correct type
+ # standard object checks should take care of validation
+ # so we don't have to do it here
+ value_container = GObject.Value()
+ value_container.init(type_)
+ if type_ == GObject.TYPE_CHAR:
+ value_container.set_char(value)
+ value = value_container
+ elif type_ == GObject.TYPE_UCHAR:
+ value_container.set_uchar(value)
+ value = value_container
+ elif type_ == GObject.TYPE_UINT:
+ value_container.set_uint(value)
+ value = value_container
+ elif type_ == GObject.TYPE_ULONG:
+ value_container.set_ulong(value)
+ value = value_container
+ elif type_ == GObject.TYPE_INT64:
+ value_container.set_int64(value)
+ value = value_container
+ elif type_ == GObject.TYPE_UINT64:
+ value_container.set_uint64(value)
+ value = value_container
return value
@@ -1143,6 +1175,12 @@ __all__.append('Adjustment')
class Table(Gtk.Table, Container):
def __init__(self, rows=1, columns=1, homogeneous=False, **kwds):
+ if 'n_rows' in kwds:
+ rows = kwds.pop('n_rows')
+
+ if 'n_columns' in kwds:
+ columns = kwds.pop('n_columns')
+
Gtk.Table.__init__(self, n_rows=rows, n_columns=columns, homogeneous=homogeneous, **kwds)
def attach(self, child, left_attach, right_attach, top_attach, bottom_attach, xoptions=Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL, xpadding=0, ypadding=0):
@@ -1168,6 +1206,13 @@ class Paned(Gtk.Paned):
Paned = override(Paned)
__all__.append('Paned')
+if Gtk._version != '2.0':
+ class Menu(Gtk.Menu):
+ def popup(self, parent_menu_shell, parent_menu_item, func, data, button, activate_time):
+ self.popup_for_device(None, parent_menu_shell, parent_menu_item, func, data, button, activate_time)
+ Menu = override(Menu)
+ __all__.append('Menu')
+
_Gtk_main_quit = Gtk.main_quit
@override(Gtk.main_quit)
def main_quit(*args):