[gtkmm-documentation] Tutorial: Mention Gtk::Application instead of Gtk::Main.



commit e5579bec093ab6ee59685bb02afc05c5296c3b64
Author: Murray Cumming <murrayc murrayc com>
Date:   Sat Mar 3 12:42:38 2012 +0100

    Tutorial: Mention Gtk::Application instead of Gtk::Main.
    
    * docs/tutorial/C/gtkmm-tutorial-in.xml: Change code snippets and
    descriptions to use Gtk::Application.

 ChangeLog                             |    7 +++++++
 docs/tutorial/C/gtkmm-tutorial-in.xml |   29 +++++++++++++----------------
 2 files changed, 20 insertions(+), 16 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8da59ef..03822c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2012-03-03  Murray Cumming  <murrayc murrayc com>
 
+	Tutorial: Mention Gtk::Application instead of Gtk::Main.
+
+	* docs/tutorial/C/gtkmm-tutorial-in.xml: Change code snippets and 
+	descriptions to use Gtk::Application.
+
+2012-03-03  Murray Cumming  <murrayc murrayc com>
+
 	Use Gtk::Application instead of Gtk::Main.
 
 	* examples/: Use Gtk::Application instead of Gtk::Main, which will
diff --git a/docs/tutorial/C/gtkmm-tutorial-in.xml b/docs/tutorial/C/gtkmm-tutorial-in.xml
index c6fd478..acf934d 100644
--- a/docs/tutorial/C/gtkmm-tutorial-in.xml
+++ b/docs/tutorial/C/gtkmm-tutorial-in.xml
@@ -324,10 +324,10 @@ suffices.
 <para>
 The next line:
 
-<programlisting>Gtk::Main kit(argc, argv);</programlisting>
+<programlisting>Glib::RefPtr&lt;Gtk::Application&gt; app = Gtk::Application::create(argc, argv, "org.gtkmm.examples.base");</programlisting>
 
-creates a <classname>Gtk::Main</classname> object. This is needed in all &gtkmm;
-applications. The constructor for this object initializes &gtkmm;,  and checks the
+creates a <classname>Gtk::Applicaiton</classname> object, stored in a <classname>RefPtr</classname> smartpointer. This is needed in all &gtkmm;
+applications. The create() method for this object initializes &gtkmm;, and checks the
 arguments passed to your application on the command line, looking for
 standard options such as <literal>-display</literal>. It takes these from the argument list, leaving anything it does not
 recognize for your application to parse or ignore. This ensures
@@ -339,10 +339,10 @@ The next two lines of code create and display a window:
 </para>
 <programlisting>Gtk::Window window;</programlisting>
 <para>
-The last line shows the window and enters the &gtkmm; main processing loop, which will finish when the window is closed.
+The last line shows the window and enters the &gtkmm; main processing loop, which will finish when the window is closed. Your main() function will then return with an appropriate success or error code.
 </para>
 
-<programlisting>Gtk::Main::run(window);</programlisting>
+<programlisting>return app->run(window);</programlisting>
 
 <para>
 After putting the source code in <literal>simple.cc</literal> you can compile the above program with gcc using:
@@ -574,24 +574,22 @@ without comments:
 
 <programlisting>int main(int argc, char** argv)
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr&lt;Gtk::Application&gt; app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   HelloWorld helloworld;
-  Gtk::Main::run(helloworld);
-
-  return 0;
+  return app-&gt;run(helloworld);
 }</programlisting>
 
 <para>
-First we instantiate an object called <literal>kit</literal>. This is of type
-<classname>Gtk::Main</classname>. Every &gtkmm; program must have one of these. We pass
-our command-line arguments to its constructor. It takes the arguments
+First we instantiate an object stored in a <classname>RefPtr</classname> smartpointer called <literal>app</literal>. This is of type
+<classname>Gtk::Application</classname>. Every &gtkmm; program must have one of these. We pass
+our command-line arguments to its create() method. It takes the arguments
 it wants, and leaves you the rest, as we described earlier.
 </para>
 
 <para>
 Next we make an object of our <classname>HelloWorld</classname> class, whose constructor
-takes no arguments, but it isn't visible yet. When we call Gtk::Main::run(), giving it the helloworld Window, it shows the Window and starts the &gtkmm; <emphasis>event loop</emphasis>. During the event loop &gtkmm; idles, waiting for actions from the user, and responding appropriately. When the user closes the Window, run() will return, causing the final line of our main() function be to executed. The application will then finish.
+takes no arguments, but it isn't visible yet. When we call<methodname>Gtk::Application::run()</methodname>, giving it the helloworld Window, it shows the Window and starts the &gtkmm; <emphasis>event loop</emphasis>. During the event loop &gtkmm; idles, waiting for actions from the user, and responding appropriately. When the user closes the Window, run() will return, causing the final line of our main() function be to executed. The application will then finish.
 </para>
 
 </sect1>
@@ -5829,8 +5827,7 @@ m_entry.add_events(Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
 <title>Timeouts</title>
 
 <para>
-You may be wondering how to make &gtkmm; do useful work while it's idling along
-(well, sleeping actually) in <methodname>Gtk::Main::run()</methodname>. Happily,
+You may be wondering how to make &gtkmm; do useful work while it's idling along. Happily,
 you have several options. Using the following methods you can create a timeout
 method that will be called every few milliseconds.
 </para>
@@ -7179,7 +7176,7 @@ and hints for creating &gtkmm; applications.
     <title>Application Lifetime</title>
 <para>Most applications will have only one <classname>Window</classname>, or
     only one main window. These applications can use the
-    <methodname>Gtk::Main::run(Gtk::Window&amp;)</methodname> overload. It shows
+    <methodname>Gtk::Application::run(Gtk::Window&amp;)</methodname> overload. It shows
     the window and returns when the window has been hidden. This might happen
     when the user closes the window, or when your code decides to
     <methodname>hide()</methodname> the window. You can prevent the user from



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