[pygobject] gkt-demo: Change main info/source notebook into a GtkStack



commit a309b3baf5ee99139cc2d1817339233e24391bc2
Author: Simon Feltman <sfeltman src gnome org>
Date:   Tue Nov 12 18:41:35 2013 -0800

    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.

 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 caae77b..ab70455 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()
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]