diff options
author | Simon Feltman <sfeltman@src.gnome.org> | 2013-11-12 18:41:35 -0800 |
---|---|---|
committer | Simon Feltman <sfeltman@src.gnome.org> | 2013-11-12 19:44:19 -0800 |
commit | a309b3baf5ee99139cc2d1817339233e24391bc2 (patch) | |
tree | c5e815836a5331dd372935ab371dd44a3077e63b | |
parent | 69ff43bf6292fb3ddaea027cfc595139c4f1655d (diff) | |
download | pygobject-a309b3baf5ee99139cc2d1817339233e24391bc2.tar.gz |
gkt-demo: Change main info/source notebook into a GtkStack
Use the new in 3.10 GtkStack and GtkStackSwitcher for switching between Info
and Source tabs. Beyond giving a newer look and feel to the demo, this also
provides an example for how to use a GtkStack.
-rwxr-xr-x | demos/gtk-demo/gtk-demo.py | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/demos/gtk-demo/gtk-demo.py b/demos/gtk-demo/gtk-demo.py index caae77b3..ab704559 100755 --- a/demos/gtk-demo/gtk-demo.py +++ b/demos/gtk-demo/gtk-demo.py @@ -122,23 +122,34 @@ class GtkDemoApp(Gtk.Application): self.window.set_default_size(600, 400) self.setup_default_icon() - hbox = Gtk.HBox(homogeneous=False, spacing=0) + hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, + homogeneous=False, + spacing=0) self.window.add(hbox) tree = self.create_tree() - hbox.pack_start(tree, False, False, 0) + hbox.pack_start(child=tree, expand=False, fill=False, padding=0) - notebook = Gtk.Notebook() - hbox.pack_start(notebook, True, True, 0) + # Right vbox contains info/source panels + right_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, + homogeneous=False, + spacing=0) + hbox.pack_start(child=right_vbox, expand=True, fill=True, padding=0) + + stack = Gtk.Stack(transition_type=Gtk.StackTransitionType.SLIDE_LEFT_RIGHT, + homogeneous=True) + switcher = Gtk.StackSwitcher(stack=stack) + right_vbox.pack_start(child=switcher, expand=False, fill=False, padding=0) + right_vbox.pack_start(child=stack, expand=True, fill=True, padding=0) text_widget, info_buffer = self.create_text_view() - notebook.append_page(text_widget, Gtk.Label.new_with_mnemonic('_Info')) + stack.add_titled(text_widget, name='info', title='Info') self.info_buffer = info_buffer self.info_buffer.create_tag('title', font='Sans 18') text_widget, self.source_buffer = self.create_source_view() - notebook.append_page(text_widget, Gtk.Label.new_with_mnemonic('_Source')) + stack.add_titled(text_widget, name='source', title='Source') self.window.show_all() |