[gnome-devel-docs] platform-demos: Reflow, edit, punctuate, reword image.py.page



commit cb7ce40f00548b6dfdd345ca7176651cc7c641b4
Author: Sindhu S <sindhus live in>
Date:   Thu Mar 6 22:31:32 2014 +0530

    platform-demos: Reflow, edit, punctuate, reword image.py.page
    
    Notable deletion: removal of instructions for using stock
    icons.

 platform-demos/C/image.py.page |  117 +++++++++++++++++++++++++---------------
 1 files changed, 73 insertions(+), 44 deletions(-)
---
diff --git a/platform-demos/C/image.py.page b/platform-demos/C/image.py.page
index e7aa568..66f2df5 100644
--- a/platform-demos/C/image.py.page
+++ b/platform-demos/C/image.py.page
@@ -15,6 +15,11 @@
       <email>mmcasetti gmail com</email>
       <years>2012</years>
     </credit>
+    <credit type="editor">
+      <name>Sindhu S</name>
+      <email>sindhus live in</email>
+      <years>2014</years>
+    </credit>
 
     <desc>A widget displaying an image</desc>
   </info>
@@ -24,31 +29,38 @@
   <p>This GtkApplication displays an image file from the current directory.</p>
 
   <note><p>
-    If the image file is not loaded successfully, the image will contain a "broken image" icon.  The 
<file>filename.png</file> needs to be in the current directory for this code to work.
+    If the image file is not loaded successfully, the image will contain a
+    "broken image" icon. <file>filename.png</file> needs to be in the
+    current directory for this code to work.
   </p></note>
 
-  <links type="section" />
+  <links type="section"/>
 
   <section id="code">
   <title>Code used to generate this example</title>
 
-  <code mime="text/x-python" style="numbered"><xi:include href="samples/image.py" 
parse="text"><xi:fallback/></xi:include></code>
+  <code mime="text/x-python" style="numbered">
+  <xi:include href="samples/image.py" parse="text"><xi:fallback/></xi:include>
+  </code>
+
+  <p>Another way to obtain what we have in the example is to create the image as
+  an instance of another class and add it to the instance of
+  <code>MyWindow</code> in the <code>do_activate(self)</code> method:</p>
 
-  <p>Another way to obtain what we have in the example is to create the image as an instance of another 
class and add it to the instance of <code>MyWindow</code> in the <code>do_activate(self)</code> method:</p>
-      <code mime="text/x-python">
-# a class to create a window
-class MyWindow(Gtk.ApplicationWindow):
+  <code mime="text/x-python">
+    # a class to create a window
+    class MyWindow(Gtk.ApplicationWindow):
     def __init__(self, app):
         Gtk.Window.__init__(self, title="Welcome to GNOME", application=app)
         self.set_default_size(300, 300)
 
-# a class to create an image
-class MyImage(Gtk.Image):
+    # a class to create an image
+    class MyImage(Gtk.Image):
     def __init__(self):
         Gtk.Image.__init__(self)
         self.set_from_file("gnome-image.png")
 
-class MyApplication(Gtk.Application):
+    class MyApplication(Gtk.Application):
     def __init__(self):
         Gtk.Application.__init__(self)
 
@@ -58,7 +70,9 @@ class MyApplication(Gtk.Application):
         # create an instance of MyImage and add it to the window
         win.add(MyImage())
         # show the window and everything on it
-        win.show_all()</code>
+        win.show_all()
+  </code>
+
   <note>
     <p>To use this code snippet, you will need to add the code that imports
     <code>Gtk</code> and <code>GdkPixbuf</code> from <code>gi.repository</code>
@@ -70,42 +84,57 @@ class MyApplication(Gtk.Application):
   <title>Useful methods for an Image widget</title>
 
   <list>
-    <item><p>To set a stock icon as image, you can use <code>set_from_stock(stock_id, size)</code> where 
<code>stock_id</code> is a stock icon such as <code>Gtk.STOCK_ABOUT</code> (more can be found at <link 
href="http://developer.gnome.org/gtk3/unstable/gtk3-Stock-Items";>Stock Items</link>, with the caveat that 
they should be modified as above) and <code>size</code> is a stock icon size to be chosen from 
<code>Gtk.IconSize.INVALID, Gtk.IconSize.MENU, Gtk.IconSize.SMALL_TOOLBAR, Gtk.IconSize.LARGE_TOOLBAR, 
Gtk.IconSize.BUTTON, Gtk.IconSize.DND, Gtk.IconSize.DIALOG</code>.</p></item>
-    <item><p>You can also use <code>set_from_icon_name(icon_name, size)</code>, where <code>icon_name</code> 
is a stock icon name such as <code>"gtk-about"</code> (more can be found as above) and <code>size</code> is 
as above.</p></item>
-    <item><p>To load an image over a network use <code>set_from_pixbuf(pixbuf)</code>, where 
<code>pixbuf</code> is a <link 
href="http://developer.gnome.org/gdk-pixbuf/unstable//index.html";>GdkPixbuf</link>.</p>
-    <code mime="text/python">
-from gi.repository import Gtk
-from gi.repository import GdkPixbuf
-import sys
-
-class MyWindow(Gtk.ApplicationWindow):
-    # create a window
-    def __init__(self, app):
-        Gtk.Window.__init__(self, title="Welcome to GNOME", application=app)
-        self.set_default_size(300, 300)
-
-        # create a pixbuf from file filename="gnome-image.png", with width=32
-        # and height=64 amd boolean preserve_aspect_ratio=False.
-        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale("gnome-image.png", 64, 128, False)
-
-        # create an image
-        image = Gtk.Image()
-        # set the content of the image as the pixbuf
-        image.set_from_pixbuf(pixbuf)
-        # add the image to the window
-        self.add(image)</code>
-    <p>If <code>preserve_aspect_ratio=True</code> we can use <code>new_from_file_at_size(filename, width, 
height)</code>. If <code>width</code> or <code>height</code> is <code>-1</code>, it is not constrained.</p>
-    <p>For loading from an input stream, see <code>new_from_stream()</code> and 
<code>new_from_stream_at_scale()</code> in the documentation</p>
+    <item>
+      <p>To load an image over a network use
+      <code>set_from_pixbuf(pixbuf)</code>, where <code>pixbuf</code> is a
+      <link href="https://developer.gnome.org/gdk-pixbuf/unstable/index.html";>
+      GdkPixbuf</link>.</p>
+      <code mime="text/python">
+        from gi.repository import Gtk
+        from gi.repository import GdkPixbuf
+        import sys
+
+        class MyWindow(Gtk.ApplicationWindow):
+            # create a window
+            def __init__(self, app):
+                Gtk.Window.__init__(self, title="Welcome to GNOME", application=app)
+                self.set_default_size(300, 300)
+
+                # create a pixbuf from file filename="gnome-image.png", with width=32
+                # and height=64 amd boolean preserve_aspect_ratio=False.
+                pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale("gnome-image.png", 64, 128, False)
+
+                # create an image
+                image = Gtk.Image()
+                # set the content of the image as the pixbuf
+                image.set_from_pixbuf(pixbuf)
+                # add the image to the window
+                self.add(image)
+        </code>
+        <p>If <code>preserve_aspect_ratio=True</code> we can use
+        <code>new_from_file_at_size(filename, width, height)</code>. If
+        <code>width</code> or <code>height</code> is <code>-1</code>, it is
+        not constrained.</p>
+        <p>For loading from an input stream, see <code>new_from_stream()</code>
+        and <code>new_from_stream_at_scale()</code> in the documentation.</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/unstable/GtkImage.html";>GtkImage</link></p></item>
-    <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkWindow.html";>GtkWindow</link></p></item>
-  </list>
-  </section>
+    <title>API References</title>
+
+    <p>In this sample we used the following:</p>
+    <list>
+      <item>
+        <p><link href="https://developer.gnome.org/gtk3/unstable/GtkImage.html";>
+        GtkImage</link></p>
+      </item>
+      <item>
+        <p><link href="https://developer.gnome.org/gtk3/unstable/GtkWindow.html";>
+        GtkWindow</link></p>
+      </item>
+    </list>
+
+q  </section>
 </page>


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