[gnome-devel-docs] tutorials python: button widgets with better pages, commented samples and a page on signals



commit 3aa56ad1a9f9a796a1bb41bd5201117234180ff3
Author: Marta Maria Casetti <mmcasetti gmail com>
Date:   Sat Jun 16 17:56:25 2012 +0100

    tutorials python: button widgets with better pages, commented samples and a page on signals

 platform-demos/C/button.py.page            |   31 ++++++++++++++++++++++--
 platform-demos/C/checkbutton.py.page       |   35 ++++++++++++++++++++--------
 platform-demos/C/linkbutton.py.page        |   30 ++++++++++++++++-------
 platform-demos/C/radiobutton.py.page       |   34 ++++++++++++++++++++-------
 platform-demos/C/samples/button.py         |   19 +++++++++-----
 platform-demos/C/samples/checkbutton.py    |   21 +++++++++++-----
 platform-demos/C/samples/linkbutton.py     |   14 +++++++----
 platform-demos/C/samples/radiobutton.py    |   32 +++++++++++++++++--------
 platform-demos/C/samples/switch.py         |   25 ++++++++++++-------
 platform-demos/C/samples/togglebutton.py   |   26 ++++++++++++--------
 platform-demos/C/signals-callbacks.py.page |   27 +++++++++++++++++++++
 platform-demos/C/switch.py.page            |   29 ++++++++++++++++-------
 platform-demos/C/togglebutton.py.page      |   30 ++++++++++++++++-------
 13 files changed, 255 insertions(+), 98 deletions(-)
---
diff --git a/platform-demos/C/button.py.page b/platform-demos/C/button.py.page
index dd76ea4..f3d39ce 100644
--- a/platform-demos/C/button.py.page
+++ b/platform-demos/C/button.py.page
@@ -5,7 +5,7 @@
       id="button.py">
   <info>
     <link type="guide" xref="beginner.py#buttons"/>
-    <revision version="0.1" date="2012-05-05" status="draft"/>
+    <revision version="0.2" date="2012-05-05" status="draft"/>
 
     <credit type="author copyright">
       <name>Marta Maria Casetti</name>
@@ -21,6 +21,31 @@
   <media type="image" mime="image/png" src="media/button.png"/>
   <p>A button widget connected to a simple callback function.</p>
 
-<code mime="text/x-python" style="numbered">
-<xi:include href="samples/button.py" parse="text"><xi:fallback/></xi:include></code>
+  <section id="code">
+    <title>Code used to generate this example</title>
+    <code mime="text/x-python" style="numbered"><xi:include href="samples/button.py" parse="text"><xi:fallback/></xi:include></code>
+  </section>
+  <section id="methods">
+    <title>Useful methods for a Button widget</title>
+    <p>For an explanation of signals and callback functions, see <link href="signals-callbacks.py.page">this page</link>.</p>
+    <list>
+      <item><p><code>set_relief(Gtk.ReliefStyle.NONE)</code> sets to none the relief style of the edges of the Gtk.Button - as opposed to <code>Gtk.ReliefStyle.NORMAL</code>.</p></item>
+      <item><p>If the label of the button is a <link href="http://developer.gnome.org/gtk3/3.4/gtk3-Stock-Items.html";>stock icon</link>, <code>set_use_stock(True)</code> sets the label as the name of the corresponding stock icon.</p></item>
+      <item><p>To set an image (e.g. a stock image) for the button <code>button</code>:</p>
+        <code>
+image = Gtk.Image()
+image.set_from_stock(Gtk.STOCK_ABOUT, Gtk.IconSize.BUTTON)
+button.set_image(image)</code>
+      <p>You should not set a label for the button after this, otherwise it will show the label and not the image.</p></item>
+      <item><p>If we use <code>set_focus_on_click(False)</code> the button will not grab focus when it is clicked by the mouse. This could be useful in places like toolbars, so that the keyboard focus is not removed from the main area of the application.</p></item>
+    </list>
+  </section>
+  <section id="references">
+    <title>API References</title>
+    <p>In this sample we used the following:</p>
+    <list>
+      <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkButton.html";>GtkButton</link></p></item>
+      <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkWindow.html";>GtkWindow</link></p></item>
+    </list>
+  </section>
 </page>
diff --git a/platform-demos/C/checkbutton.py.page b/platform-demos/C/checkbutton.py.page
index 687b7df..f5d4aeb 100644
--- a/platform-demos/C/checkbutton.py.page
+++ b/platform-demos/C/checkbutton.py.page
@@ -20,14 +20,29 @@
   <media type="image" mime="image/png" src="media/checkbutton.png"/>
   <p>This CheckButton toggles the title.</p>
 
-<code mime="text/x-python" style="numbered"><xi:include href="samples/checkbutton.py" parse="text"><xi:fallback/></xi:include></code>
-<p>
-  In this sample we used the following:
-</p>
-<list>
-  <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkApplication.html";>GtkApplication</link></p></item>
-  <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkApplicationWindow.html";>GtkApplicationWindow</link></p></item>
-  <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkToggleButton.html";>GtkToggleButton</link></p></item>
-  <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkCheckButton.html";>GtkCheckButton</link></p></item>
-</list>
+  <section id="code">
+    <title>Code used to generate this example</title>
+
+    <code mime="text/x-python" style="numbered"><xi:include href="samples/checkbutton.py" parse="text"><xi:fallback/></xi:include></code>
+
+    <p>We could also create the CheckButton with <code>button = Gtk.CheckButton.new_with_label("Show Title")</code>.</p>
+
+  </section>
+
+  <section id="methods">
+    <title>Useful methods for a CheckButton widget</title>
+    <p>For a discussion on signals and callback functions, see <link href="signals-callbacks.py.page">this page</link>.</p>
+
+  </section>
+
+  <section id="references">
+    <title>API References</title>
+    <p>In this sample we used the following:</p>
+    <list>
+      <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkApplication.html";>GtkApplication</link></p></item>
+      <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkApplicationWindow.html";>GtkApplicationWindow</link></p></item>
+      <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkToggleButton.html";>GtkToggleButton</link></p></item>
+      <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkCheckButton.html";>GtkCheckButton</link></p></item>
+    </list>
+  </section>
 </page>
diff --git a/platform-demos/C/linkbutton.py.page b/platform-demos/C/linkbutton.py.page
index 476a91f..b264661 100644
--- a/platform-demos/C/linkbutton.py.page
+++ b/platform-demos/C/linkbutton.py.page
@@ -21,14 +21,26 @@
   <media type="image" mime="image/png" src="media/linkbutton.png"/>
   <p>A button that links to a web page.</p>
 
-<code mime="text/x-python" style="numbered">
-<xi:include href="samples/linkbutton.py" parse="text"><xi:fallback/></xi:include></code>
-<p>
-  In this sample we used the following:
-</p>
-<list>
-  <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkWindow.html";>GtkWindow</link></p></item>
-  <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkLinkButton.html";>GtkLinkButton</link></p></item>
-</list>
+  <section id="code">
+    <title>Code used to generate this example</title>
 
+    <code mime="text/x-python" style="numbered"><xi:include href="samples/linkbutton.py" parse="text"><xi:fallback/></xi:include></code>
+
+  </section>
+  <section id="methods">
+    <title>Useful methods for a LinkButton widget</title>
+    <list>
+      <item><p><code>get_visited()</code> returns the 'visited' state (<code>True</code> or <code>False</code>) of the URI where the LinkButton points. The button becomes visited when it is clicked.</p></item>
+      <item><p><code>set_visited(True)</code> sets the 'visited' state of the URI where the LinkButton points as <code>True</code> (analogously for <code>False</code>).</p></item>
+      <item><p>Each time the button is clicked, the signal <code>"activate-link"</code> is emitted. For an explanation of signals and callback functions, see <link href="signals-callbacks.py.page">this page</link>.</p></item>
+    </list>
+  </section>
+  <section id="references">
+    <title>API References</title>
+    <p>In this sample we used the following:</p>
+    <list>
+      <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkWindow.html";>GtkWindow</link></p></item>
+      <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkLinkButton.html";>GtkLinkButton</link></p></item>
+    </list>
+  </section>
 </page>
diff --git a/platform-demos/C/radiobutton.py.page b/platform-demos/C/radiobutton.py.page
index bf7df66..895565c 100644
--- a/platform-demos/C/radiobutton.py.page
+++ b/platform-demos/C/radiobutton.py.page
@@ -23,13 +23,29 @@
   <media type="image" mime="image/png" src="media/radiobutton.png"/>
   <p>Three RadioButtons. You can see in the terminal if they are turned off or on.</p>
 
-<code mime="text/x-python" style="numbered"><xi:include href="samples/radiobutton.py" parse="text"><xi:fallback/></xi:include></code>
-<p>
-  In this sample we used the following:
-</p>
-<list>
-  <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkWindow.html";>GtkWindow</link></p></item>
-  <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkGrid.html";>GtkGrid</link></p></item>
-  <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkRadioButton.html";>GtkRadioButton</link></p></item>
-</list>
+  <section id="code">
+    <title>Code used to generate this example</title>
+    <code mime="text/x-python" style="numbered"><xi:include href="samples/radiobutton.py" parse="text"><xi:fallback/></xi:include></code>
+  </section>
+
+  <section id="methods">
+    <title>Useful methods for a RadioButton widget</title>
+    <p>For an explanation of signals and callback functions, see <link href="signals-callbacks.py.page">this page</link>.</p>
+
+    <p>Instead of <code>button1 = Gtk.RadioButton(label="Button 1")</code> we could create the button and label it with</p>
+    <code>
+button1 = Gtk.RadioButton()
+button1.set_label("Button 1").</code>
+    <p>On the other hand, we cannot create the button as <code>button1.new_with_label("Button 1")</code> - it gives a segmentation error.</p>
+  </section>
+
+  <section id="references">
+    <title>API References</title>
+    <p>In this sample we used the following:</p>
+    <list>
+      <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkWindow.html";>GtkWindow</link></p></item>
+      <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkGrid.html";>GtkGrid</link></p></item>
+      <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkRadioButton.html";>GtkRadioButton</link></p></item>
+    </list>
+  </section>
 </page>
diff --git a/platform-demos/C/samples/button.py b/platform-demos/C/samples/button.py
index e17def3..16aa2b5 100644
--- a/platform-demos/C/samples/button.py
+++ b/platform-demos/C/samples/button.py
@@ -1,27 +1,32 @@
-from gi.repository import GLib
 from gi.repository import Gtk
-from gi.repository import Gio
 import sys
 
 class MyWindow(Gtk.ApplicationWindow):
+    # a window
     def __init__(self, app):
         Gtk.Window.__init__(self, title="GNOME Button", application=app)
+        self.set_default_size(250, 50)
+
+        # a button
         button = Gtk.Button()
-        button.set_label("Click me")        
+        # with a label
+        button.set_label("Click me")
+        # connect the signal "clicked" emitted by the button
+        # to the callback function do_clicked
         button.connect("clicked", self.do_clicked)
+        # add the button to the window
         self.add(button)
 
+    # callback function connected to the signal "clicked" of the button
     def do_clicked(self, button):
         print "You clicked me!"
 
 class MyApplication(Gtk.Application):
     def __init__(self):
-        Gtk.Application.__init__(self, application_id="org.gtk.example.grid")
-        
+        Gtk.Application.__init__(self)
+
     def do_activate(self):
         win = MyWindow(self)
-        win.set_default_size(250, 50)
-        win.set_position(Gtk.WindowPosition.CENTER)        
         win.show_all()
 
     def do_startup (self):
diff --git a/platform-demos/C/samples/checkbutton.py b/platform-demos/C/samples/checkbutton.py
index e82f918..8f1dd9d 100644
--- a/platform-demos/C/samples/checkbutton.py
+++ b/platform-demos/C/samples/checkbutton.py
@@ -1,32 +1,39 @@
-from gi.repository import GLib
 from gi.repository import Gtk
-from gi.repository import Gio
 import sys
 
 class MyWindow(Gtk.ApplicationWindow):
+    # a window
     def __init__(self, app):
         Gtk.Window.__init__(self, title="CheckButton Example", application=app)
         self.set_default_size(300, 100)
         self.set_border_width(10)
 
-        # a new checkbutton with a label, connected with the callback
-        button = Gtk.CheckButton.new_with_label("Show Title")
+        # a new checkbutton
+        button = Gtk.CheckButton()
+        #  with a label
+        button.set_label("Show Title")
+        # connect the signal "toggled" emitted by the checkbutton
+        # with the callback function toggled_cb
         button.connect("toggled", self.toggled_cb)
-        # default: is active
+        # by default, the checkbutton is active
         button.set_active(True)
 
+        # add the checkbutton to the window
         self.add(button)
 
-    # the button operates on the window
+    # callback function
     def toggled_cb(self, button):
+        # if the togglebutton is active, set the title of the window
+        # as "Checkbutton Example"
         if button.get_active():
             self.set_title("CheckButton Example")
+        # else, set it as "" (empty string)
         else:
             self.set_title("")
 
 class MyApplication(Gtk.Application):
     def __init__(self):
-        Gtk.Application.__init__(self, application_id="org.gtk.example.grid")
+        Gtk.Application.__init__(self)
 
     def do_activate(self):
         win = MyWindow(self)
diff --git a/platform-demos/C/samples/linkbutton.py b/platform-demos/C/samples/linkbutton.py
index a501803..a098361 100644
--- a/platform-demos/C/samples/linkbutton.py
+++ b/platform-demos/C/samples/linkbutton.py
@@ -1,22 +1,26 @@
-from gi.repository import GLib
 from gi.repository import Gtk
 import sys
 
 class MyWindow(Gtk.ApplicationWindow):
+    # a window
     def __init__(self, app):
         Gtk.Window.__init__(self, title="GNOME LinkButton", application=app)
-        button = Gtk.LinkButton("http://live.gnome.org";)
+        self.set_default_size(250, 50)
+
+        # a linkbutton pointing to the given URI
+        button = Gtk.LinkButton(uri="http://live.gnome.org";)
+        # with given text
         button.set_label("Link to GNOME live!")
+
+        # add the button to the window
         self.add(button)
 
 class MyApplication(Gtk.Application):
     def __init__(self):
-        Gtk.Application.__init__(self, application_id="org.gtk.example.grid")
+        Gtk.Application.__init__(self)
 
     def do_activate(self):
         win = MyWindow(self)
-        win.set_default_size(250, 50)
-        win.set_position(Gtk.WindowPosition.CENTER)
         win.show_all()
 
     def do_startup (self):
diff --git a/platform-demos/C/samples/radiobutton.py b/platform-demos/C/samples/radiobutton.py
index bf98900..f177ac1 100644
--- a/platform-demos/C/samples/radiobutton.py
+++ b/platform-demos/C/samples/radiobutton.py
@@ -1,6 +1,4 @@
-from gi.repository import GLib
 from gi.repository import Gtk
-from gi.repository import Gio
 import sys
 
 class MyWindow(Gtk.ApplicationWindow):
@@ -9,42 +7,56 @@ class MyWindow(Gtk.ApplicationWindow):
         self.set_default_size(250, 100)
         self.set_border_width(20)
 
-        # a new checkbutton with a label, connected with the callback
+        # a new radiobutton with a label
         button1 = Gtk.RadioButton(label="Button 1")
+        # connect the signal "toggled" emitted by the radiobutton
+        # with the callback function toggled_cb
         button1.connect("toggled", self.toggled_cb)
 
-        # another way to create a button - in the same group as button1
+        # another radiobutton, in the same group as button1
         button2 = Gtk.RadioButton.new_from_widget(button1)
+        # with label "Button 2"
         button2.set_label("Button 2")
+        # connect the signal "toggled" emitted by the radiobutton
+        # with the callback function toggled_cb
         button2.connect("toggled", self.toggled_cb)
+        # set button2 not active by default
         button2.set_active(False)
 
-        # yet another way
+        # another radiobutton, in the same group as button1,
+        # with label "Button 3"
         button3 = Gtk.RadioButton.new_with_label_from_widget(button1, "Button 3")
+        # connect the signal "toggled" emitted by the radiobutton
+        # with the callback function toggled_cb
         button3.connect("toggled", self.toggled_cb)
+        # set button3 not active by default
         button3.set_active(False)
 
-        # DO NOT use new_with_label, it gives a segmentation fault!
-
         # a grid to place the buttons
         grid = Gtk.Grid.new()
         grid.attach(button1, 0, 0, 1, 1);
         grid.attach(button2, 0, 1, 1, 1);
         grid.attach(button3, 0, 2, 1, 1);
-
+        # add the grid to the window
         self.add(grid)
 
+    # callback function
     def toggled_cb(self, button):
+        # a string to describe the state of the button
         state = "unknown"
+        # whenever the button is turned on, state is on
         if button.get_active():
             state = "on"
+        # else state is off
         else:
             state = "off"
-        print button.get_label() + " was turned " + state + "\n"
+        # whenever the function is called (a button is turned on or off)
+        # print on the terminal which button was turned on/off
+        print button.get_label() + " was turned " + state
 
 class MyApplication(Gtk.Application):
     def __init__(self):
-        Gtk.Application.__init__(self, application_id="org.gtk.example.grid")
+        Gtk.Application.__init__(self)
 
     def do_activate(self):
         win = MyWindow(self)
diff --git a/platform-demos/C/samples/switch.py b/platform-demos/C/samples/switch.py
index 54edc34..c830ee6 100644
--- a/platform-demos/C/samples/switch.py
+++ b/platform-demos/C/samples/switch.py
@@ -1,17 +1,20 @@
-from gi.repository import GLib
 from gi.repository import Gtk
 import sys
 
 class MyWindow(Gtk.ApplicationWindow):
+    # a window
     def __init__(self, app):
         Gtk.Window.__init__(self, title="Switch Example", application=app)
         self.set_default_size(300, 100)
         self.set_border_width(10)
 
-        # a switch, turned on by default, sends the signal notify::active
-        switcher = Gtk.Switch()
-        switcher.set_active(True)
-        switcher.connect("notify::active", self.activate_cb)
+        # a switch
+        switch = Gtk.Switch()
+        # turned on by default
+        switch.set_active(True)
+        # connect the signal notify::active emitted by the switch
+        # to the callback function activate_cb
+        switch.connect("notify::active", self.activate_cb)
 
         # a label
         label = Gtk.Label()
@@ -21,21 +24,25 @@ class MyWindow(Gtk.ApplicationWindow):
         grid = Gtk.Grid()
         grid.set_column_spacing (10);
         grid.attach (label, 0, 0, 1, 1);
-        grid.attach (switcher, 1, 0, 1, 1);
+        grid.attach (switch, 1, 0, 1, 1);
 
+        # add the grid to the window
         self.add(grid)
 
-    # the switch operates on the title of the window. Since the signal is
-    # notify::active we need the argument 'active'
+    # Callback function. Since the signal is notify::active
+    # we need the argument 'active'
     def activate_cb(self, button, active):
+        # if the button (i.e. the switch) is active, set the title
+        # of the window to "Switch Example"
         if button.get_active():
             self.set_title("Switch Example")
+        # else, set it to "" (empty string)
         else:
             self.set_title("")
 
 class MyApplication(Gtk.Application):
     def __init__(self):
-        Gtk.Application.__init__(self, application_id="org.example.spinner")
+        Gtk.Application.__init__(self)
 
     def do_activate(self):
         win = MyWindow(self)
diff --git a/platform-demos/C/samples/togglebutton.py b/platform-demos/C/samples/togglebutton.py
index 531672f..f741985 100644
--- a/platform-demos/C/samples/togglebutton.py
+++ b/platform-demos/C/samples/togglebutton.py
@@ -1,44 +1,48 @@
-from gi.repository import GLib
 from gi.repository import Gtk
-from gi.repository import Gio
 import sys
 
 class MyWindow(Gtk.ApplicationWindow):
+    # a window
     def __init__(self, app):
         Gtk.Window.__init__(self, title="ToggleButton Example", application=app)
         self.set_default_size(300, 300)
         self.set_border_width(30)
 
-        # a spinner animation, with extra horizontal and vertical space
-        spinner = Gtk.Spinner()
-        spinner.set_hexpand(True)
-        spinner.set_vexpand(True)
-        # we keep a reference to the spinner inside the class (we need it later)
-        self.spinner = spinner
+        # a spinner animation
+        self.spinner = Gtk.Spinner()
+        # with extra horizontal space
+        self.spinner.set_hexpand(True)
+        # with extra vertical space
+        self.spinner.set_vexpand(True)
 
         # a togglebutton
         button = Gtk.ToggleButton.new_with_label("Start/Stop")
+        # connect the signal "toggled" emitted by the togglebutton
+        # when its state is changed to the callback function toggled_cb
         button.connect("toggled", self.toggled_cb)
 
         # a grid to allocate the widgets
         grid = Gtk.Grid()
         grid.set_row_homogeneous(False);
         grid.set_row_spacing(15);
-        grid.attach(spinner, 0, 0, 1, 1);
+        grid.attach(self.spinner, 0, 0, 1, 1);
         grid.attach(button, 0, 1, 1, 1);
 
+        # add the grid to the window
         self.add(grid)
 
-    # the button operates on the window
+    # callback function for the signal "toggled"
     def toggled_cb(self, button):
+        # if the togglebutton is active, start the spinner
         if button.get_active():
             self.spinner.start()
+        # else, stop it
         else:
             self.spinner.stop()
 
 class MyApplication(Gtk.Application):
     def __init__(self):
-        Gtk.Application.__init__(self, application_id="org.example.spinner")
+        Gtk.Application.__init__(self)
 
     def do_activate(self):
         win = MyWindow(self)
diff --git a/platform-demos/C/signals-callbacks.py.page b/platform-demos/C/signals-callbacks.py.page
new file mode 100644
index 0000000..f29e424
--- /dev/null
+++ b/platform-demos/C/signals-callbacks.py.page
@@ -0,0 +1,27 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<page xmlns="http://projectmallard.org/1.0/";
+      xmlns:e="http://projectmallard.org/experimental/";
+      type="guide" style="task"
+      id="beginner.py">
+
+<info>
+  <link type="guide" xref="py"/>
+  <revision version="0.1" date="2012-06-16" status="stub"/>
+
+  <desc></desc>
+  <credit type="author copyright">
+    <name>Sebastian P&#246;lsterl</name>
+    <email>sebp k-d-w org</email>
+    <years>2011</years>
+  </credit>
+  <credit type="editor">
+    <name>Marta Maria Casetti</name>
+    <email>mmcasetti gmail com</email>
+    <years>2012</years>
+  </credit>
+</info>
+
+<title>Signals and callbacks</title>
+
+
+</page>
diff --git a/platform-demos/C/switch.py.page b/platform-demos/C/switch.py.page
index 0b9ebc2..35bca5d 100644
--- a/platform-demos/C/switch.py.page
+++ b/platform-demos/C/switch.py.page
@@ -26,13 +26,24 @@
 
   <p>This Switch makes the title appears and disappear.</p>
 
-<code mime="text/x-python" style="numbered"><xi:include href="samples/switch.py" parse="text"><xi:fallback/></xi:include></code>
-<p>
-  In this sample we used the following:
-</p>
-<list>
-  <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkSwitch.html";>GtkSwitch</link></p></item>
-  <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkLabel.html";>GtkLabel</link></p></item>
-  <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkGrid.html";>GtkGrid</link></p></item>
-</list>
+  <section id="code">
+    <title>Code used to generate this example</title>
+
+    <code mime="text/x-python" style="numbered"><xi:include href="samples/switch.py" parse="text"><xi:fallback/></xi:include></code>
+
+  </section>
+  <section id="methods">
+    <title>Useful methods for a Switch widget</title>
+    <p>For a discussion on signals and callback functions, see <link href="signals-callbacks.py.page">this page</link>.</p>
+
+  </section>
+  <section id="references">
+    <title>API References</title>
+    <p>In this sample we used the following:</p>
+    <list>
+      <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkSwitch.html";>GtkSwitch</link></p></item>
+      <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkLabel.html";>GtkLabel</link></p></item>
+      <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkGrid.html";>GtkGrid</link></p></item>
+    </list>
+  </section>
 </page>
diff --git a/platform-demos/C/togglebutton.py.page b/platform-demos/C/togglebutton.py.page
index 7fec6fa..149c7ef 100644
--- a/platform-demos/C/togglebutton.py.page
+++ b/platform-demos/C/togglebutton.py.page
@@ -22,13 +22,25 @@
   <media type="image" mime="image/png" src="media/togglebutton.png"/>
   <p>When this ToggleButton is in an active state, the spinner spins.</p>
 
-<code mime="text/x-python" style="numbered"><xi:include href="samples/togglebutton.py" parse="text"><xi:fallback/></xi:include></code>
-<p>
-  In this sample we used the following:
-</p>
-<list>
-  <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkToggleButton.html";>GtkToggleButton</link></p></item>
-  <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkWidget.html";>GtkWidget</link></p></item>
-  <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkSpinner.html";>GtkSpinner</link></p></item>
-</list>
+  <section id="code">
+    <title>Code used to generate this example</title>
+
+    <code mime="text/x-python" style="numbered"><xi:include href="samples/togglebutton.py" parse="text"><xi:fallback/></xi:include></code>
+
+  </section>
+
+  <section id="methods">
+    <title>Useful methods for a ToggleButton widget</title>
+    <p>For an explanation of signals and callback functions, see <link href="signals-callbacks.py.page">this page</link>.</p>
+  </section>
+
+  <section id="references">
+    <title>API References</title>
+    <p>In this sample we used the following:</p>
+    <list>
+      <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkToggleButton.html";>GtkToggleButton</link></p></item>
+      <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkWidget.html";>GtkWidget</link></p></item>
+      <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkSpinner.html";>GtkSpinner</link></p></item>
+    </list>
+  </section>
 </page>



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