diff options
author | Simon Feltman <sfeltman@src.gnome.org> | 2013-11-12 19:32:18 -0800 |
---|---|---|
committer | Simon Feltman <sfeltman@src.gnome.org> | 2013-11-12 19:44:18 -0800 |
commit | 69ff43bf6292fb3ddaea027cfc595139c4f1655d (patch) | |
tree | 5b698254ff43461294dc388df9f0ee84fc21e5ab /demos | |
parent | 890fb7b97823985d5c800284ead43a49174db244 (diff) | |
download | pygobject-69ff43bf6292fb3ddaea027cfc595139c4f1655d.tar.gz |
gtk-demo: Cleanup deprecated calls throughout demo code
Specify constructor arguments as keyword args for various object
creation calls. Update combobox demo to use bind_property instead of manual
signal connections with update callbacks.
Diffstat (limited to 'demos')
-rw-r--r-- | demos/gtk-demo/demos/Entry/entry_buffer.py | 6 | ||||
-rw-r--r-- | demos/gtk-demo/demos/Entry/entry_completion.py | 6 | ||||
-rw-r--r-- | demos/gtk-demo/demos/Entry/search_entry.py | 8 | ||||
-rw-r--r-- | demos/gtk-demo/demos/Tree View/liststore.py | 8 | ||||
-rw-r--r-- | demos/gtk-demo/demos/Tree View/treemodel_filelist.py | 2 | ||||
-rw-r--r-- | demos/gtk-demo/demos/Tree View/treemodel_filetree.py | 2 | ||||
-rw-r--r-- | demos/gtk-demo/demos/appwindow.py | 4 | ||||
-rw-r--r-- | demos/gtk-demo/demos/combobox.py | 30 | ||||
-rw-r--r-- | demos/gtk-demo/demos/dialogs.py | 26 | ||||
-rw-r--r-- | demos/gtk-demo/demos/expander.py | 9 | ||||
-rw-r--r-- | demos/gtk-demo/demos/images.py | 2 | ||||
-rw-r--r-- | demos/gtk-demo/demos/infobars.py | 23 | ||||
-rw-r--r-- | demos/gtk-demo/demos/links.py | 10 | ||||
-rw-r--r-- | demos/gtk-demo/demos/menus.py | 4 | ||||
-rw-r--r-- | demos/gtk-demo/demos/pickers.py | 8 | ||||
-rw-r--r-- | demos/gtk-demo/demos/pixbuf.py | 4 | ||||
-rw-r--r-- | demos/gtk-demo/demos/rotatedtext.py | 2 |
17 files changed, 64 insertions, 90 deletions
diff --git a/demos/gtk-demo/demos/Entry/entry_buffer.py b/demos/gtk-demo/demos/Entry/entry_buffer.py index dc4643c4..09c60fd5 100644 --- a/demos/gtk-demo/demos/Entry/entry_buffer.py +++ b/demos/gtk-demo/demos/Entry/entry_buffer.py @@ -30,10 +30,8 @@ from gi.repository import Gtk class EntryBufferApp: def __init__(self): - self.window = Gtk.Dialog('Gtk.EntryBuffer', - None, - 0, - [Gtk.STOCK_CLOSE, Gtk.ResponseType.NONE]) + self.window = Gtk.Dialog(title='Gtk.EntryBuffer') + self.window.add_buttons(Gtk.STOCK_CLOSE, Gtk.ResponseType.NONE) self.window.connect('response', self.destroy) self.window.connect('destroy', lambda x: Gtk.main_quit()) self.window.set_resizable(False) diff --git a/demos/gtk-demo/demos/Entry/entry_completion.py b/demos/gtk-demo/demos/Entry/entry_completion.py index c65dd98a..f8a8e029 100644 --- a/demos/gtk-demo/demos/Entry/entry_completion.py +++ b/demos/gtk-demo/demos/Entry/entry_completion.py @@ -31,10 +31,8 @@ from gi.repository import Gtk class EntryBufferApp: def __init__(self): - self.window = Gtk.Dialog('Gtk.EntryCompletion', - None, - 0, - [Gtk.STOCK_CLOSE, Gtk.ResponseType.NONE]) + self.window = Gtk.Dialog(title='Gtk.EntryCompletion') + self.window.add_buttons(Gtk.STOCK_CLOSE, Gtk.ResponseType.NONE) self.window.connect('response', self.destroy) self.window.connect('destroy', lambda x: Gtk.main_quit()) self.window.set_resizable(False) diff --git a/demos/gtk-demo/demos/Entry/search_entry.py b/demos/gtk-demo/demos/Entry/search_entry.py index 4fc8fab9..bdf4f57d 100644 --- a/demos/gtk-demo/demos/Entry/search_entry.py +++ b/demos/gtk-demo/demos/Entry/search_entry.py @@ -34,8 +34,8 @@ class SearchboxApp: def __init__(self, demoapp): self.demoapp = demoapp - self.window = Gtk.Dialog('Search Entry', - buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.NONE)) + self.window = Gtk.Dialog(title='Search Entry') + self.window.add_buttons(Gtk.STOCK_CLOSE, Gtk.ResponseType.NONE) self.window.connect('response', lambda x, y: self.window.destroy()) self.window.connect('destroy', Gtk.main_quit) @@ -65,12 +65,12 @@ class SearchboxApp: notebook.set_show_border(False) hbox.pack_start(notebook, False, False, 0) - find_button = Gtk.Button('Find') + find_button = Gtk.Button(label='Find') find_button.connect('clicked', self.start_search, entry) notebook.append_page(find_button, None) find_button.show() - cancel_button = Gtk.Button('Cancel') + cancel_button = Gtk.Button(label='Cancel') cancel_button.connect('clicked', self.stop_search, entry) notebook.append_page(cancel_button, None) cancel_button.show() diff --git a/demos/gtk-demo/demos/Tree View/liststore.py b/demos/gtk-demo/demos/Tree View/liststore.py index b7ac57a4..bad99d3a 100644 --- a/demos/gtk-demo/demos/Tree View/liststore.py +++ b/demos/gtk-demo/demos/Tree View/liststore.py @@ -27,7 +27,7 @@ it. See the Stock Browser demo for a more advanced example. """ -from gi.repository import Gtk, GObject +from gi.repository import Gtk, GObject, GLib class Bug: @@ -73,7 +73,7 @@ class ListStoreApp: vbox = Gtk.VBox(spacing=8) self.window.add(vbox) - label = Gtk.Label('This is the bug list (note: not based on real data, it would be nice to have a nice ODBC interface to bugzilla or so, though).') + label = Gtk.Label(label='This is the bug list (note: not based on real data, it would be nice to have a nice ODBC interface to bugzilla or so, though).') vbox.pack_start(label, False, False, 0) sw = Gtk.ScrolledWindow() @@ -94,11 +94,11 @@ class ListStoreApp: self.window.show_all() self.window.connect('delete-event', self.window_closed) - self.timeout = GObject.timeout_add(80, self.spinner_timeout) + self.timeout = GLib.timeout_add(80, self.spinner_timeout) def window_closed(self, window, event): if self.timeout != 0: - GObject.source_remove(self.timeout) + GLib.source_remove(self.timeout) def spinner_timeout(self): if self.model is None: diff --git a/demos/gtk-demo/demos/Tree View/treemodel_filelist.py b/demos/gtk-demo/demos/Tree View/treemodel_filelist.py index 96c26207..f3c7565c 100644 --- a/demos/gtk-demo/demos/Tree View/treemodel_filelist.py +++ b/demos/gtk-demo/demos/Tree View/treemodel_filelist.py @@ -177,7 +177,7 @@ class GenericTreeModelExample: def __init__(self): # Create a new window - self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) + self.window = gtk.Window(type=gtk.WINDOW_TOPLEVEL) self.window.set_size_request(300, 200) diff --git a/demos/gtk-demo/demos/Tree View/treemodel_filetree.py b/demos/gtk-demo/demos/Tree View/treemodel_filetree.py index 3179de25..0549436f 100644 --- a/demos/gtk-demo/demos/Tree View/treemodel_filetree.py +++ b/demos/gtk-demo/demos/Tree View/treemodel_filetree.py @@ -235,7 +235,7 @@ class GenericTreeModelExample: def __init__(self): # Create a new window - self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) + self.window = gtk.Window(type=gtk.WINDOW_TOPLEVEL) self.window.set_size_request(300, 200) self.window.connect("delete_event", self.delete_event) diff --git a/demos/gtk-demo/demos/appwindow.py b/demos/gtk-demo/demos/appwindow.py index f8c1ab38..60632f12 100644 --- a/demos/gtk-demo/demos/appwindow.py +++ b/demos/gtk-demo/demos/appwindow.py @@ -323,8 +323,8 @@ def main(demoapp=None): window.set_title('Application Window') window.set_icon_name('gtk-open') window.connect_after('destroy', _quit) - table = Gtk.Table(rows=1, - columns=5, + table = Gtk.Table(n_rows=1, + n_columns=5, homogeneous=False) window.add(table) 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('_', '') diff --git a/demos/gtk-demo/demos/dialogs.py b/demos/gtk-demo/demos/dialogs.py index f6da745f..4c3e34ad 100644 --- a/demos/gtk-demo/demos/dialogs.py +++ b/demos/gtk-demo/demos/dialogs.py @@ -88,12 +88,12 @@ class DialogsApp: self.window.show_all() def _interactive_dialog_clicked(self, button): - dialog = Gtk.Dialog('Interactive Dialog', - self.window, - Gtk.DialogFlags.MODAL | - Gtk.DialogFlags.DESTROY_WITH_PARENT, - (Gtk.STOCK_OK, Gtk.ResponseType.OK, - "_Non-stock Button", Gtk.ResponseType.CANCEL)) + dialog = Gtk.Dialog(title='Interactive Dialog', + transient_for=self.window, + modal=True, + destroy_with_parent=True) + dialog.add_buttons(Gtk.STOCK_OK, Gtk.ResponseType.OK, + "_Non-stock Button", Gtk.ResponseType.CANCEL) content_area = dialog.get_content_area() hbox = Gtk.HBox(spacing=8) @@ -105,7 +105,7 @@ class DialogsApp: hbox.pack_start(stock, False, False, 0) - table = Gtk.Table(2, 2, False) + table = Gtk.Table(n_rows=2, n_columns=2, homogeneous=False) table.set_row_spacings(4) table.set_col_spacings(4) hbox.pack_start(table, True, True, 0) @@ -134,12 +134,12 @@ class DialogsApp: dialog.destroy() def _message_dialog_clicked(self, button): - dialog = Gtk.MessageDialog(self.window, - Gtk.DialogFlags.MODAL | - Gtk.DialogFlags.DESTROY_WITH_PARENT, - Gtk.MessageType.INFO, - Gtk.ButtonsType.OK, - "This message box has been popped up the following\nnumber of times:") + dialog = Gtk.MessageDialog(transient_for=self.window, + modal=True, + destroy_with_parent=True, + message_type=Gtk.MessageType.INFO, + buttons=Gtk.ButtonsType.OK, + text="This message box has been popped up the following\nnumber of times:") dialog.format_secondary_text('%d' % self.dialog_counter) dialog.run() diff --git a/demos/gtk-demo/demos/expander.py b/demos/gtk-demo/demos/expander.py index 1e8326db..eb5149fa 100644 --- a/demos/gtk-demo/demos/expander.py +++ b/demos/gtk-demo/demos/expander.py @@ -30,9 +30,8 @@ from gi.repository import Gtk class ExpanderApp: def __init__(self): - self.window = Gtk.Dialog("GtkExpander", - None, 0, - (Gtk.STOCK_CLOSE, Gtk.ResponseType.NONE)) + self.window = Gtk.Dialog(title="GtkExpander") + self.window.add_buttons(Gtk.STOCK_CLOSE, Gtk.ResponseType.NONE) self.window.set_resizable(False) self.window.connect('response', lambda window, x: window.destroy()) self.window.connect('destroy', Gtk.main_quit) @@ -42,13 +41,13 @@ class ExpanderApp: content_area.pack_start(vbox, True, True, 0) vbox.set_border_width(5) - label = Gtk.Label('Expander demo. Click on the triangle for details.') + label = Gtk.Label(label='Expander demo. Click on the triangle for details.') vbox.pack_start(label, True, True, 0) expander = Gtk.Expander(label='Details') vbox.pack_start(expander, False, False, 0) - label = Gtk.Label('Details can be shown or hidden') + label = Gtk.Label(label='Details can be shown or hidden') expander.add(label) self.window.show_all() diff --git a/demos/gtk-demo/demos/images.py b/demos/gtk-demo/demos/images.py index b94eb32e..3dac4ccd 100644 --- a/demos/gtk-demo/demos/images.py +++ b/demos/gtk-demo/demos/images.py @@ -282,7 +282,7 @@ class ImagesApp: def cleanup_cb(self, widget): if self.load_timeout: - GObject.source_remove(self.load_timeout) + GLib.source_remove(self.load_timeout) if self.pixbuf_loader: try: diff --git a/demos/gtk-demo/demos/infobars.py b/demos/gtk-demo/demos/infobars.py index 047df515..c36de2b5 100644 --- a/demos/gtk-demo/demos/infobars.py +++ b/demos/gtk-demo/demos/infobars.py @@ -40,13 +40,13 @@ class InfobarApp: bar = Gtk.InfoBar() vbox.pack_start(bar, False, False, 0) bar.set_message_type(Gtk.MessageType.INFO) - label = Gtk.Label('This is an info bar with message type Gtk.MessageType.INFO') + label = Gtk.Label(label='This is an info bar with message type Gtk.MessageType.INFO') bar.get_content_area().pack_start(label, False, False, 0) bar = Gtk.InfoBar() vbox.pack_start(bar, False, False, 0) bar.set_message_type(Gtk.MessageType.WARNING) - label = Gtk.Label('This is an info bar with message type Gtk.MessageType.WARNING') + label = Gtk.Label(label='This is an info bar with message type Gtk.MessageType.WARNING') bar.get_content_area().pack_start(label, False, False, 0) bar = Gtk.InfoBar() @@ -54,19 +54,19 @@ class InfobarApp: bar.connect('response', self.on_bar_response) vbox.pack_start(bar, False, False, 0) bar.set_message_type(Gtk.MessageType.QUESTION) - label = Gtk.Label('This is an info bar with message type Gtk.MessageType.QUESTION') + label = Gtk.Label(label='This is an info bar with message type Gtk.MessageType.QUESTION') bar.get_content_area().pack_start(label, False, False, 0) bar = Gtk.InfoBar() vbox.pack_start(bar, False, False, 0) bar.set_message_type(Gtk.MessageType.ERROR) - label = Gtk.Label('This is an info bar with message type Gtk.MessageType.ERROR') + label = Gtk.Label(label='This is an info bar with message type Gtk.MessageType.ERROR') bar.get_content_area().pack_start(label, False, False, 0) bar = Gtk.InfoBar() vbox.pack_start(bar, False, False, 0) bar.set_message_type(Gtk.MessageType.OTHER) - label = Gtk.Label('This is an info bar with message type Gtk.MessageType.OTHER') + label = Gtk.Label(label='This is an info bar with message type Gtk.MessageType.OTHER') bar.get_content_area().pack_start(label, False, False, 0) frame = Gtk.Frame(label="Info bars") @@ -77,17 +77,18 @@ class InfobarApp: frame.add(vbox2) # Standard message dialog - label = Gtk.Label('An example of different info bars') + label = Gtk.Label(label='An example of different info bars') vbox2.pack_start(label, False, False, 0) self.window.show_all() def on_bar_response(self, info_bar, response_id): - dialog = Gtk.MessageDialog(self.window, - Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, - Gtk.MessageType.INFO, - Gtk.ButtonsType.OK, - 'You clicked on an info bar') + dialog = Gtk.MessageDialog(transient_for=self.window, + modal=True, + destroy_with_parent=True, + message_type=Gtk.MessageType.INFO, + buttons=Gtk.ButtonsType.OK, + text='You clicked on an info bar') dialog.format_secondary_text('Your response has id %d' % response_id) dialog.run() dialog.destroy() diff --git a/demos/gtk-demo/demos/links.py b/demos/gtk-demo/demos/links.py index e6ca731c..e907abdf 100644 --- a/demos/gtk-demo/demos/links.py +++ b/demos/gtk-demo/demos/links.py @@ -35,7 +35,7 @@ class LinksApp: self.window.set_border_width(12) self.window.connect('destroy', Gtk.main_quit) - label = Gtk.Label("""Some <a href="http://en.wikipedia.org/wiki/Text" + label = Gtk.Label(label="""Some <a href="http://en.wikipedia.org/wiki/Text" title="plain text">text</a> may be marked up as hyperlinks, which can be clicked or activated via <a href="keynav">keynav</a>""") @@ -53,10 +53,10 @@ or activated via <a href="keynav">keynav</a>""") markup = """The term <i>keynav</i> is a shorthand for keyboard navigation and refers to the process of using a program (exclusively) via keyboard input.""" - dialog = Gtk.MessageDialog(parent, - Gtk.DialogFlags.DESTROY_WITH_PARENT, - Gtk.MessageType.INFO, - Gtk.ButtonsType.OK, + dialog = Gtk.MessageDialog(transient_for=parent, + destroy_with_parent=True, + message_type=Gtk.MessageType.INFO, + buttons=Gtk.ButtonsType.OK, text=markup, use_markup=True) dialog.present() diff --git a/demos/gtk-demo/demos/menus.py b/demos/gtk-demo/demos/menus.py index 42d5cf68..fbc2daa5 100644 --- a/demos/gtk-demo/demos/menus.py +++ b/demos/gtk-demo/demos/menus.py @@ -73,11 +73,11 @@ class MenusApp: box2.set_border_width(10) box1.pack_start(box2, False, True, 0) - button = Gtk.Button('Flip') + button = Gtk.Button(label='Flip') button.connect('clicked', self.change_orientation, menubar) box2.pack_start(button, True, True, 0) - button = Gtk.Button('Close') + button = Gtk.Button(label='Close') button.connect('clicked', lambda x: self.window.destroy()) box2.pack_start(button, True, True, 0) button.set_can_default(True) diff --git a/demos/gtk-demo/demos/pickers.py b/demos/gtk-demo/demos/pickers.py index f17f7d1c..b58720a5 100644 --- a/demos/gtk-demo/demos/pickers.py +++ b/demos/gtk-demo/demos/pickers.py @@ -33,25 +33,25 @@ class PickersApp: self.window.connect('destroy', Gtk.main_quit) self.window.set_border_width(10) - table = Gtk.Table(4, 2, False) + table = Gtk.Table(n_rows=4, n_columns=2, homogeneous=False) table.set_col_spacing(0, 10) table.set_row_spacings(3) self.window.add(table) table.set_border_width(10) - label = Gtk.Label('Color:') + label = Gtk.Label(label='Color:') label.set_alignment(0.0, 0.5) picker = Gtk.ColorButton() table.attach_defaults(label, 0, 1, 0, 1) table.attach_defaults(picker, 1, 2, 0, 1) - label = Gtk.Label('Font:') + label = Gtk.Label(label='Font:') label.set_alignment(0.0, 0.5) picker = Gtk.FontButton() table.attach_defaults(label, 0, 1, 1, 2) table.attach_defaults(picker, 1, 2, 1, 2) - label = Gtk.Label('File:') + label = Gtk.Label(label='File:') label.set_alignment(0.0, 0.5) picker = Gtk.FileChooserButton.new('Pick a File', Gtk.FileChooserAction.OPEN) diff --git a/demos/gtk-demo/demos/pixbuf.py b/demos/gtk-demo/demos/pixbuf.py index a2250ba7..778874bc 100644 --- a/demos/gtk-demo/demos/pixbuf.py +++ b/demos/gtk-demo/demos/pixbuf.py @@ -81,7 +81,7 @@ class PixbufApp: self.da = Gtk.DrawingArea() self.da.connect('draw', self.draw_cb) self.window.add(self.da) - self.timeout_id = GObject.timeout_add(self.FRAME_DELAY, self.timeout_cb) + self.timeout_id = GLib.timeout_add(self.FRAME_DELAY, self.timeout_cb) self.window.show_all() def load_pixbufs(self): @@ -171,7 +171,7 @@ class PixbufApp: return True def cleanup_cb(self, widget): - GObject.source_remove(self.timeout_id) + GLib.source_remove(self.timeout_id) Gtk.main_quit() diff --git a/demos/gtk-demo/demos/rotatedtext.py b/demos/gtk-demo/demos/rotatedtext.py index 3985b6d7..232f9fd3 100644 --- a/demos/gtk-demo/demos/rotatedtext.py +++ b/demos/gtk-demo/demos/rotatedtext.py @@ -75,7 +75,7 @@ class RotatedTextApp: da.connect('draw', self.rotated_text_draw) - label = Gtk.Label(UTF8_TEXT) + label = Gtk.Label(label=UTF8_TEXT) box.add(label) label.set_angle(45) |