Commit e7daae91 authored by John (J5) Palmieri's avatar John (J5) Palmieri

demo fixes to keep up with Gtk+

* treeiter changes to reflect caller-allocate annotations
* fix some flag handling
* use get_indicies_with_depth instead of get_indices for paths
parent 3d9fd639
......@@ -87,12 +87,16 @@ def mark_set_callback(buffer, new_location, mark, data):
update_statusbar(buffer, data)
def update_resize_grip(widget, event, statusbar):
pass
# FIXME: for some reason we get attribute errors in handlers
# if we try to access flags without first evaluating
# the parent struct
Gdk.WindowState
# FIXME: event should be a Gdk.EventWindowState but is only a Gdk.Event
if event.changed_mask and (Gdk.WindowState.MAXIMIZED or
if event.window_state.changed_mask and (Gdk.WindowState.MAXIMIZED or
Gdk.WindowState.FULLSCREEN):
maximized = event.new_window_state and (Gdk.WindowState.MAXIMIZED or
maximized = event.window_state.new_window_state and (Gdk.WindowState.MAXIMIZED or
Gdk.WindowState.FULLSCREEN)
statusbar.set_has_resize_grip(not maximized)
......
......@@ -113,10 +113,9 @@ class ComboboxApp:
# FIXME: make new_from_indices work
# make constructor take list or string of indices
iter = Gtk.TreeIter()
path = Gtk.TreePath.new_from_string('0:8')
model.get_iter(iter, path)
combo.set_active_iter(iter)
(success, treeiter) = model.get_iter(path)
combo.set_active_iter(treeiter)
# A GtkComboBoxEntry with validation.
frame = Gtk.Frame(label='Editable')
......@@ -164,29 +163,30 @@ class ComboboxApp:
return store
def set_sensitive(self, cell_layout, cell, tree_model, iter, data):
def set_sensitive(self, cell_layout, cell, tree_model, treeiter, data):
"""
A GtkCellLayoutDataFunc that demonstrates how one can control
sensitivity of rows. This particular function does nothing
useful and just makes the second row insensitive.
"""
path = tree_model.get_path(iter)
indices = path.get_indices()
path = tree_model.get_path(treeiter)
indices = path.get_indices_with_depth()
sensitive = not(indices[0] == 1)
cell.set_property('sensitive', sensitive)
def is_separator(self, model, iter, data):
def is_separator(self, model, treeiter, data):
"""
A GtkTreeViewRowSeparatorFunc that demonstrates how rows can be
rendered as separators. This particular function does nothing
useful and just turns the fourth row into a separator.
"""
path = model.get_path(iter)
indices = path.get_indices()
path = model.get_path(treeiter)
indices = path.get_indices_with_depth()
result = (indices[0] == 4)
return result
......@@ -251,7 +251,7 @@ class ComboboxApp:
{'group': None, 'capital': 'Trenton'}
)
parent = Gtk.TreeIter()
parent = None
store = Gtk.TreeStore(str)
......@@ -263,8 +263,8 @@ class ComboboxApp:
return store
def is_capital_sensistive(self, cell_layout, cell, tree_model, iter, data):
sensitive = not tree_model.iter_has_child(iter)
def is_capital_sensistive(self, cell_layout, cell, tree_model, treeiter, data):
sensitive = not tree_model.iter_has_child(treeiter)
cell.set_property('sensitive', sensitive)
......
......@@ -173,9 +173,7 @@ class GtkDemoApp(object):
Gtk.Window.set_default_icon_list(list)
def selection_cb(self, selection, model):
treeiter = Gtk.TreeIter()
(success, m) = selection.get_selected(treeiter)
(success, m, treeiter) = selection.get_selected()
if not success:
return
......@@ -212,8 +210,7 @@ class GtkDemoApp(object):
self.source_buffer.insert(end, code)
def row_activated_cb(self, view, path, col, store):
treeiter = Gtk.TreeIter()
store.get_iter(treeiter, path)
(success, treeiter) = store.get_iter(path)
demo = store.get_value(treeiter, 1)
demo.module.main()
......@@ -246,8 +243,8 @@ class GtkDemoApp(object):
style = 2)
first_iter = Gtk.TreeIter()
tree_store.get_iter_first(first_iter)
(success, first_iter) = tree_store.get_iter_first()
selection.select_iter(first_iter)
selection.connect('changed', self.selection_cb, tree_store)
tree_view.connect('row_activated', self.row_activated_cb, tree_store)
......@@ -270,7 +267,7 @@ class GtkDemoApp(object):
tree_view.grab_focus()
return box
return box
def create_text(self, is_source):
scrolled_window = Gtk.ScrolledWindow(hadjustment = None,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment