summaryrefslogtreecommitdiff
path: root/demos/gtk-demo/demos/combobox.py
diff options
context:
space:
mode:
Diffstat (limited to 'demos/gtk-demo/demos/combobox.py')
-rw-r--r--demos/gtk-demo/demos/combobox.py30
1 files changed, 4 insertions, 26 deletions
diff --git a/demos/gtk-demo/demos/combobox.py b/demos/gtk-demo/demos/combobox.py
index 1e4fa91b..2c5b8d31 100644
--- a/demos/gtk-demo/demos/combobox.py
+++ b/demos/gtk-demo/demos/combobox.py
@@ -29,7 +29,7 @@ How the options are displayed is controlled by cell renderers.
"""
-from gi.repository import Gtk, Gdk, GdkPixbuf, GLib
+from gi.repository import Gtk, Gdk, GdkPixbuf, GLib, GObject
(PIXBUF_COL,
@@ -167,35 +167,13 @@ class ComboboxApp:
entry = Gtk.Entry()
- # FIXME: a bug in PyGObject does not allow us to access dynamic
- # methods on GObject.Object, so bind properties the hard way
- # GObject.Object.bind_property(combo, 'active-id',
- # entry, 'text',
- # GObject.BindingFlags.BIDIRECTIONAL)
- self.combo_notify_id = \
- combo.connect('notify::active-id',
- self.combo_active_id_changed, entry)
- self.entry_notify_id = \
- entry.connect('notify::text',
- self.entry_text_changed, combo)
+ combo.bind_property('active-id',
+ entry, 'text',
+ GObject.BindingFlags.BIDIRECTIONAL)
box.add(entry)
self.window.show_all()
- def combo_active_id_changed(self, combo, pspec, entry):
- entry.disconnect(self.entry_notify_id)
- entry.set_text(combo.get_property('active-id'))
- self.entry_notify_id = \
- entry.connect('notify::text',
- self.entry_text_changed, combo)
-
- def entry_text_changed(self, entry, pspec, combo):
- combo.disconnect(self.combo_notify_id)
- combo.set_property('active-id', entry.get_text())
- self.combo_notify_id = \
- combo.connect('notify::active-id',
- self.combo_active_id_changed, entry)
-
def strip_underscore(self, s):
return s.replace('_', '')