Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > ba6e5e1a033bd8535c43a771ce407926 > files > 70

lib64cxx-gtk-utils2.2-devel-2.2.3-2.mga4.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.4"/>
<title>c++-gtk-utils: Cgu::Application Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">c++-gtk-utils
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.4 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceCgu.html">Cgu</a></li><li class="navelem"><a class="el" href="classCgu_1_1Application.html">Application</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-attribs">Public Attributes</a> &#124;
<a href="classCgu_1_1Application-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">Cgu::Application Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>This is a class for constructing and managing GtkApplication objects.  
 <a href="classCgu_1_1Application.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="application_8h_source.html">c++-gtk-utils/application.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:ab0372d293f014f4c8a6b6b3a593ad4be"><td class="memItemLeft" align="right" valign="top">typedef std::list&lt; <a class="el" href="classCgu_1_1WinBase.html">WinBase</a> * &gt;<br class="typebreak"/>
::<a class="el" href="classCgu_1_1Application.html#ab0372d293f014f4c8a6b6b3a593ad4be">size_type</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Application.html#ab0372d293f014f4c8a6b6b3a593ad4be">size_type</a></td></tr>
<tr class="separator:ab0372d293f014f4c8a6b6b3a593ad4be"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:af83ad81c3249fa23179f792d90a3cf3a"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Application.html#af83ad81c3249fa23179f792d90a3cf3a">Application</a> (const <a class="el" href="classCgu_1_1Application.html">Application</a> &amp;)=delete</td></tr>
<tr class="separator:af83ad81c3249fa23179f792d90a3cf3a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af4d018438df17508754a163d124a407f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classCgu_1_1Application.html">Application</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Application.html#af4d018438df17508754a163d124a407f">operator=</a> (const <a class="el" href="classCgu_1_1Application.html">Application</a> &amp;)=delete</td></tr>
<tr class="separator:af4d018438df17508754a163d124a407f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a47bf90e03ac829340aee4aca889a1a8a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Application.html#a47bf90e03ac829340aee4aca889a1a8a">add</a> (<a class="el" href="classCgu_1_1WinBase.html">Cgu::WinBase</a> *win)</td></tr>
<tr class="separator:a47bf90e03ac829340aee4aca889a1a8a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9c602205457e1fe7d6ee3cb332ae5cc1"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Application.html#a9c602205457e1fe7d6ee3cb332ae5cc1">remove</a> (<a class="el" href="classCgu_1_1WinBase.html">Cgu::WinBase</a> *win)</td></tr>
<tr class="separator:a9c602205457e1fe7d6ee3cb332ae5cc1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a140b6227d452bf4fb81f1d6c4a8dcc38"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">run</a> (int argc, char **argv)</td></tr>
<tr class="separator:a140b6227d452bf4fb81f1d6c4a8dcc38"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a089623a1789d5d74f831979be22f3942"><td class="memItemLeft" align="right" valign="top">GApplication *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Application.html#a089623a1789d5d74f831979be22f3942">get_g_app</a> () const </td></tr>
<tr class="separator:a089623a1789d5d74f831979be22f3942"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1622c61154ea23895f68e14139ca65a4"><td class="memItemLeft" align="right" valign="top">std::list&lt; <a class="el" href="classCgu_1_1WinBase.html">Cgu::WinBase</a> * &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Application.html#a1622c61154ea23895f68e14139ca65a4">get_windows</a> () const </td></tr>
<tr class="separator:a1622c61154ea23895f68e14139ca65a4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acb2bf7242cf30922be07f0566801aea6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classCgu_1_1Application.html#ab0372d293f014f4c8a6b6b3a593ad4be">size_type</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Application.html#acb2bf7242cf30922be07f0566801aea6">get_win_count</a> () const </td></tr>
<tr class="separator:acb2bf7242cf30922be07f0566801aea6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a40db192a050878640c90fa32d85ea41c"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Application.html#a40db192a050878640c90fa32d85ea41c">Application</a> (const char *prog_name, GApplicationFlags flags)</td></tr>
<tr class="separator:a40db192a050878640c90fa32d85ea41c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abae0c55dca8c0aef61175f2ff2345b68"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Application.html#abae0c55dca8c0aef61175f2ff2345b68">~Application</a> ()</td></tr>
<tr class="separator:abae0c55dca8c0aef61175f2ff2345b68"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-attribs"></a>
Public Attributes</h2></td></tr>
<tr class="memitem:a725e2bb7e2b33b107cf8d62bd93fbb54"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classCgu_1_1SafeEmitterArg.html">Cgu::SafeEmitterArg</a><br class="typebreak"/>
&lt; <a class="el" href="classCgu_1_1Application.html">Cgu::Application</a> * &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Application.html#a725e2bb7e2b33b107cf8d62bd93fbb54">activate</a></td></tr>
<tr class="separator:a725e2bb7e2b33b107cf8d62bd93fbb54"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a324a79089e8fa9ddf280c0ea00337e27"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classCgu_1_1SafeEmitterArg.html">Cgu::SafeEmitterArg</a><br class="typebreak"/>
&lt; <a class="el" href="classCgu_1_1Application.html">Cgu::Application</a> * &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Application.html#a324a79089e8fa9ddf280c0ea00337e27">startup</a></td></tr>
<tr class="separator:a324a79089e8fa9ddf280c0ea00337e27"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a21c48264406d1a59d413a2f1d9443f31"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classCgu_1_1SafeEmitterArg.html">Cgu::SafeEmitterArg</a><br class="typebreak"/>
&lt; <a class="el" href="classCgu_1_1Application.html">Cgu::Application</a> <br class="typebreak"/>
*, GApplicationCommandLine <br class="typebreak"/>
*, gint &amp; &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Application.html#a21c48264406d1a59d413a2f1d9443f31">command_line</a></td></tr>
<tr class="separator:a21c48264406d1a59d413a2f1d9443f31"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae5edd54c70c47bf0897dbe337ff0eecd"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classCgu_1_1SafeEmitterArg.html">Cgu::SafeEmitterArg</a><br class="typebreak"/>
&lt; <a class="el" href="classCgu_1_1Application.html">Cgu::Application</a> <br class="typebreak"/>
*, std::pair&lt; GFile **, gint &gt;<br class="typebreak"/>
, gchar * &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Application.html#ae5edd54c70c47bf0897dbe337ff0eecd">open</a></td></tr>
<tr class="separator:ae5edd54c70c47bf0897dbe337ff0eecd"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>This is a class for constructing and managing GtkApplication objects. </p>
<p>It is available since version 2.0.0-rc2. It is only compiled in with a GTK+3 installation, and if the library is not configured with the --without-gtk option.</p>
<p>In typical usage, a <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object is created in main(), and then a callback is attached to the 'activate', 'command_line' or 'open' emitter, depending on the flag passed to the <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Application</a> object's constructor. The <a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">run()</a> method of the <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Application</a> object is then called, and a window deriving from <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">Cgu::WinBase</a> is constructed in the callback and added to the <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Application</a> object or, if the program is a single instance program with only one main window and an instance is already running, a function is called to present that window.</p>
<p>The gio/gtk+ documentation at the time of writing does not explain key concepts, and in particular how the GtkApplication sub-class interacts with GApplication's g_application_run(). Here is an explanation:</p>
<dl class="section user"><dt></dt><dd>(a) If a <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object is constructed with the G_APPLICATION_FLAGS_NONE flag set, then calling the <a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">Cgu::Application::run()</a> method (which hands off to g_application_run()) will cause the 'activate' emitter to emit. No command line parameter should be passed to the run method (argc should be 0 or 1), otherwise GtkApplication will cause the start-up to abort. Unlike with gtk_main(), g_application_run() (and so <a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">Cgu::Application::run()</a>) does not consume any recognised glib/gtk+ options, such as --display, but regards these as application parameters. Such stripping out can be achieved by calling gtk_init() before constructing the <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object (but gtk_init() does not need to be called for any other purpose), or by using the GOptionGroup/GOptionEntry interface. g_application_run(), and so <a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">Cgu::Application::run()</a>, can be called with argc and argv set to 0, and that is generally the best approach if the G_APPLICATION_FLAGS_NONE flag is set. </dd></dl>
<dl class="section user"><dt></dt><dd>(b) If a <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object is constructed with the G_APPLICATION_HANDLES_OPEN flag set, then calling the <a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">Cgu::Application::run()</a> method will cause the 'activate' emitter to emit if no command line parameters were provided when the program was started (that is, if argc is 0 or 1), or cause the 'open' emitter to emit if parameters are passed (argc &gt; 1). Such parameters will be construed as files/uris, and will be passed to the 'open' emitter by array of GFile*'s. Unlike with gtk_main(), g_application_run() (and so <a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">Cgu::Application::run()</a>) does not consume any recognised glib/gtk+ options, such as --display, but regards these as application parameters and so as file/uri names. Such stripping out can be achieved by calling gtk_init() before constructing the <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object (but gtk_init() does not need to be called for any other purpose), or by using the GOptionGroup/GOptionEntry interface. </dd></dl>
<dl class="section user"><dt></dt><dd>(c) If a <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object is constructed with the G_APPLICATION_HANDLES_COMMAND_LINE flag set, then calling the <a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">Cgu::Application::run()</a> method will cause the 'command_line' emitter to emit. All the command line parameters will be passed on, and they can be obtained via the GApplicationCommandLine argument of the 'command_line' emitter. Unlike with gtk_main(), g_application_run() (and so <a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">Cgu::Application::run()</a>) does not consume any recognised glib/gtk+ options, such as --display, but regards these as command line parameters. Such stripping out can be achieved by calling gtk_init() before constructing the <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object (but gtk_init() does not need to be called for any other purpose), or by using the GOptionGroup/GOptionEntry interface.</dd></dl>
<p>There is little in this class that cannot also be done using the <a class="el" href="group__prog__present.html#prog_presenterAnchor">Cgu::prog_present</a> interface, which has the advantage of being more portable (<a class="el" href="group__prog__present.html#prog_presenterAnchor">Cgu::prog_present</a> does not depend on GTK+3), but this class is more convenient to use where a program requires multiple main application windows which can be independently opened and any of which are to keep the program alive until the last one is closed.</p>
<p><a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> objects are not singletons. It is possible to drop an <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Application</a> object out of scope or destroy it in some other way after closing or removing all its windows, then construct another with a different flag and then call <a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">run()</a> on the second one (although it would be a curious application that wanted to do so). It is also possible, but even more off-the-wall, to have two <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Application</a> objects in existence in the same process at the same time provided different dbus identifiers are supplied to the constructor for each, although <a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">run()</a> may only be called on one of them at any one time. However, this is something of a curiosity: in nearly all cases an application will only have one <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object, since the main purpose of <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> is to facilitate single instance programs.</p>
<p><a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">Cgu::WinBase</a> objects, and so <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a>, can be used with widget heirarchies or top level windows created using GtkBuilder. See <a class="el" href="GtkBuilder.html">Using c++-gtk-utils with GtkBuilder</a> for particulars about that.</p>
<p>Here is a compilable example, demonstrating the use of the GApplicationFlags options. It uses a GtkApplicationWindow object, as provided by GTK+ &gt;= 3.4, so that it can provide an application menu for, say, the gnome shell. For earlier versions of GTK+-3, the Message class can be constructed from a standard GtkWindow object, and the application menu code in the <a class="el" href="classCgu_1_1Application.html#a324a79089e8fa9ddf280c0ea00337e27">startup()</a> callback can be omitted.</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;ostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;list&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &lt;gtk/gtk.h&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="callback_8h.html" title="This file provides classes for type erasure. ">c++-gtk-utils/callback.h</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="application_8h.html">c++-gtk-utils/application.h</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="window_8h.html">c++-gtk-utils/window.h</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="shared__handle_8h.html">c++-gtk-utils/shared_handle.h</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="gobj__handle_8h.html">c++-gtk-utils/gobj_handle.h</a>&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="comment">// SETUP HERE: uncomment the flag to be tested:</span></div>
<div class="line"></div>
<div class="line"><span class="comment">//const GApplicationFlags app_flag = G_APPLICATION_FLAGS_NONE;</span></div>
<div class="line"><span class="keyword">const</span> GApplicationFlags app_flag = G_APPLICATION_HANDLES_OPEN;</div>
<div class="line"><span class="comment">//const GApplicationFlags app_flag = G_APPLICATION_HANDLES_COMMAND_LINE;</span></div>
<div class="line"></div>
<div class="line"><span class="keyword">using namespace </span>Cgu;</div>
<div class="line"></div>
<div class="line"><span class="comment">// *** Demonstration message class ***</span></div>
<div class="line"></div>
<div class="line"><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> <span class="keywordtype">void</span> message_button_clicked(GtkWidget*, <span class="keywordtype">void</span>*);</div>
<div class="line"></div>
<div class="line"><span class="keyword">class </span>Message: <span class="keyword">public</span> <a class="code" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">Cgu::WinBase</a> {</div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line">  <span class="keyword">friend</span> <span class="keywordtype">void</span> message_button_clicked(GtkWidget*, <span class="keywordtype">void</span>*);</div>
<div class="line">  Message(<span class="keyword">const</span> <span class="keywordtype">char</span>* text);</div>
<div class="line">};</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> message_button_clicked(GtkWidget* w, <span class="keywordtype">void</span>*) {</div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;Clicked&quot;</span> &lt;&lt; std::endl;</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line">Message::Message(<span class="keyword">const</span> <span class="keywordtype">char</span>* text, GApplication* app):</div>
<div class="line">    <a class="code" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">WinBase</a>{<span class="stringliteral">&quot;Message&quot;</span>, 0, <span class="keyword">false</span>, 0,</div>
<div class="line">            GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(app)))} {</div>
<div class="line">  GtkWidget* box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);</div>
<div class="line">  gtk_box_set_homogeneous(GTK_BOX(box), <span class="keyword">false</span>);</div>
<div class="line">  gtk_container_add(GTK_CONTAINER(get_win()), box);</div>
<div class="line">  GtkWidget* label = gtk_label_new(text);</div>
<div class="line">  gtk_box_pack_start(GTK_BOX(box), label,</div>
<div class="line">                     <span class="keyword">true</span>, <span class="keyword">false</span>, 0);</div>
<div class="line">  GtkWidget* button_box = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);</div>
<div class="line">  gtk_box_pack_start(GTK_BOX(box), button_box,</div>
<div class="line">                     <span class="keyword">false</span>, <span class="keyword">false</span>, 0);</div>
<div class="line">  GtkWidget* button = gtk_button_new_from_stock(GTK_STOCK_OK);</div>
<div class="line">  gtk_container_add(GTK_CONTAINER(button_box), button);</div>
<div class="line">  g_signal_connect(G_OBJECT(button), <span class="stringliteral">&quot;clicked&quot;</span>,</div>
<div class="line">                   G_CALLBACK(message_button_clicked), 0);</div>
<div class="line">  gtk_widget_set_can_default(button, <span class="keyword">true</span>);</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keyword">namespace </span>{</div>
<div class="line"></div>
<div class="line"><span class="comment">// *** for GtkApplicationWindow actions ***</span></div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> beep_app(GSimpleAction*, GVariant*, <span class="keywordtype">void</span>*) {</div>
<div class="line">  gdk_beep();</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> quit_app(GSimpleAction*, GVariant*, <span class="keywordtype">void</span>* data) {</div>
<div class="line">  <a class="code" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a>* app = <span class="keyword">static_cast&lt;</span><a class="code" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a>*<span class="keyword">&gt;</span>(data);</div>
<div class="line">  std::list&lt;Cgu::WinBase*&gt; wins = app-&gt;<a class="code" href="classCgu_1_1Application.html#a1622c61154ea23895f68e14139ca65a4">get_windows</a>();</div>
<div class="line">  <span class="keywordflow">for</span> (<span class="keyword">auto</span> iter = wins.begin(); iter != wins.end(); ++iter) {</div>
<div class="line">    <span class="keyword">delete</span> *iter;  <span class="comment">// this will also remove the Message object from</span></div>
<div class="line">                   <span class="comment">// the Cgu::Application object</span></div>
<div class="line">  }</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line">GActionEntry app_entries[] = {</div>
<div class="line">  { <span class="stringliteral">&quot;beep&quot;</span>, beep_app, NULL, NULL, NULL },</div>
<div class="line">  { <span class="stringliteral">&quot;quit&quot;</span>, quit_app, NULL, NULL, NULL },</div>
<div class="line">};</div>
<div class="line"></div>
<div class="line"><span class="comment">// *** callbacks ***</span></div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> startup(<a class="code" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a>* app) {</div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;startup() called&quot;</span> &lt;&lt; std::endl;</div>
<div class="line"></div>
<div class="line">  g_action_map_add_action_entries(G_ACTION_MAP(app-&gt;<a class="code" href="classCgu_1_1Application.html#a089623a1789d5d74f831979be22f3942">get_g_app</a>()),</div>
<div class="line">                                  app_entries,</div>
<div class="line">                                  G_N_ELEMENTS(app_entries),</div>
<div class="line">                                  app);</div>
<div class="line"></div>
<div class="line">  <a class="code" href="classCgu_1_1GobjHandle.html" title="This is a handle for managing the reference count of GObjects. ">Cgu::GobjHandle&lt;GMenu&gt;</a> menu{g_menu_new()};</div>
<div class="line">  g_menu_append(menu, <span class="stringliteral">&quot;Beep&quot;</span>, <span class="stringliteral">&quot;app.beep&quot;</span>);</div>
<div class="line">  g_menu_append(menu, <span class="stringliteral">&quot;_Quit&quot;</span>, <span class="stringliteral">&quot;app.quit&quot;</span>);</div>
<div class="line">  gtk_application_set_app_menu(GTK_APPLICATION(app-&gt;<a class="code" href="classCgu_1_1Application.html#a089623a1789d5d74f831979be22f3942">get_g_app</a>()),</div>
<div class="line">                               G_MENU_MODEL(menu.get()));</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> activate(<a class="code" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a>* app) {</div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;activate() called&quot;</span> &lt;&lt; std::endl;</div>
<div class="line"></div>
<div class="line">  <span class="comment">// probably if no arguments are passed, only one window is wanted,</span></div>
<div class="line">  <span class="comment">// which is now to present itself if it already exists: comment this</span></div>
<div class="line">  <span class="comment">// &#39;if&#39; block out if a new window is to be added on each occasion</span></div>
<div class="line">  <span class="comment">// the program is started</span></div>
<div class="line">  <span class="keywordflow">if</span> (app-&gt;<a class="code" href="classCgu_1_1Application.html#acb2bf7242cf30922be07f0566801aea6">get_win_count</a>() &gt; 0) {</div>
<div class="line">    gtk_window_present(app-&gt;<a class="code" href="classCgu_1_1Application.html#a1622c61154ea23895f68e14139ca65a4">get_windows</a>().front()-&gt;get_win());</div>
<div class="line">    <span class="keywordflow">return</span>;</div>
<div class="line">  }</div>
<div class="line">  <a class="code" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">WinBase</a>* dialog = <span class="keyword">new</span> Message(<span class="stringliteral">&quot;This is a message&quot;</span>, app-&gt;<a class="code" href="classCgu_1_1Application.html#a089623a1789d5d74f831979be22f3942">get_g_app</a>());</div>
<div class="line">  app-&gt;<a class="code" href="classCgu_1_1Application.html#a47bf90e03ac829340aee4aca889a1a8a">add</a>(dialog);</div>
<div class="line">  dialog-&gt;<a class="code" href="classCgu_1_1WinBase.html#ab9805d0954343258a2e12bf555c1d45b">show_all</a>();</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> command_line(<a class="code" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a>* app, GApplicationCommandLine* cl, gint&amp;) {</div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;command_line() called&quot;</span> &lt;&lt; std::endl;</div>
<div class="line"></div>
<div class="line">  <span class="comment">// probably if the G_APPLICATION_HANDLES_COMMAND_LINE flag is set,</span></div>
<div class="line">  <span class="comment">// only one window is wanted, which is now to present itself if it</span></div>
<div class="line">  <span class="comment">// already exists: comment this &#39;if&#39; block out if a new window is to</span></div>
<div class="line">  <span class="comment">// be added on each occasion the program is started</span></div>
<div class="line">  <span class="keywordflow">if</span> (app-&gt;<a class="code" href="classCgu_1_1Application.html#acb2bf7242cf30922be07f0566801aea6">get_win_count</a>() &gt; 0) {</div>
<div class="line">    gtk_window_present(app-&gt;<a class="code" href="classCgu_1_1Application.html#a1622c61154ea23895f68e14139ca65a4">get_windows</a>().front()-&gt;get_win());</div>
<div class="line">    <span class="keywordflow">return</span>;</div>
<div class="line">  }</div>
<div class="line">  std::string text(<span class="stringliteral">&quot;Command line options are:\n&quot;</span>);</div>
<div class="line">  <span class="keywordtype">int</span> argc = 0;</div>
<div class="line">  gchar** argv = g_application_command_line_get_arguments(cl, &amp;argc);</div>
<div class="line">  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> count = 0; count &lt; argc; ++count) {</div>
<div class="line">    <span class="keywordflow">try</span> {</div>
<div class="line">      text += argv[count];</div>
<div class="line">      text += <span class="charliteral">&#39;\n&#39;</span>;</div>
<div class="line">    }</div>
<div class="line">    <span class="keywordflow">catch</span> (...) {</div>
<div class="line">      g_strfreev(argv);</div>
<div class="line">      <span class="keywordflow">throw</span>; <span class="comment">// exceptions will be consumed by the callback handler and</span></div>
<div class="line">             <span class="comment">// a g_critical warning issued, but let&#39;s not leak memory</span></div>
<div class="line">    }</div>
<div class="line">  }</div>
<div class="line">  g_strfreev(argv);</div>
<div class="line">  <a class="code" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">WinBase</a>* dialog = <span class="keyword">new</span> Message(text.c_str(), app-&gt;<a class="code" href="classCgu_1_1Application.html#a089623a1789d5d74f831979be22f3942">get_g_app</a>()));</div>
<div class="line">  app-&gt;<a class="code" href="classCgu_1_1Application.html#a47bf90e03ac829340aee4aca889a1a8a">add</a>(dialog);</div>
<div class="line">  dialog-&gt;<a class="code" href="classCgu_1_1WinBase.html#ab9805d0954343258a2e12bf555c1d45b">show_all</a>();</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> open(<a class="code" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a>* app, std::pair&lt;GFile**, gint&gt; files, gchar*) {</div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;open() called&quot;</span> &lt;&lt; std::endl;</div>
<div class="line"></div>
<div class="line">  <span class="comment">// probably if the G_APPLICATION_HANDLES_OPEN flag is set and an</span></div>
<div class="line">  <span class="comment">// argument is passed, the adding of a new window is wanted on each</span></div>
<div class="line">  <span class="comment">// occasion the program is started</span></div>
<div class="line">  std::string text(<span class="stringliteral">&quot;Files are:\n&quot;</span>);</div>
<div class="line">  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> count = 0; count &lt; files.second; ++count) {</div>
<div class="line">    <a class="code" href="classCgu_1_1ScopedHandle.html" title="This is a generic scoped class for managing the lifetime of objects allocated on freestore. ">GcharScopedHandle</a> uri(g_file_get_uri(files.first[count]));</div>
<div class="line">    text += uri;</div>
<div class="line">    text += <span class="charliteral">&#39;\n&#39;</span>;</div>
<div class="line">  }</div>
<div class="line">  <a class="code" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">WinBase</a>* dialog = <span class="keyword">new</span> Message(text.c_str(), app-&gt;<a class="code" href="classCgu_1_1Application.html#a089623a1789d5d74f831979be22f3942">get_g_app</a>()));</div>
<div class="line">  app-&gt;<a class="code" href="classCgu_1_1Application.html#a47bf90e03ac829340aee4aca889a1a8a">add</a>(dialog);</div>
<div class="line">  dialog-&gt;<a class="code" href="classCgu_1_1WinBase.html#ab9805d0954343258a2e12bf555c1d45b">show_all</a>();</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line">} <span class="comment">// unnamed namespace</span></div>
<div class="line"></div>
<div class="line"><span class="comment">// *** main() ***</span></div>
<div class="line"></div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[]) {</div>
<div class="line"></div>
<div class="line">  <span class="comment">// gtk_init() is only relevant for the purposes of stripping out</span></div>
<div class="line">  <span class="comment">// glib/gtk+ recognised options - gtk_application_new() (and so the</span></div>
<div class="line">  <span class="comment">// Cgu::Application constructor) will call g_type_init() if the type</span></div>
<div class="line">  <span class="comment">// system needs initialization</span></div>
<div class="line">  gtk_init(&amp;argc, &amp;argv);</div>
<div class="line"></div>
<div class="line">  <a class="code" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Application</a> app{<span class="stringliteral">&quot;my_prog&quot;</span>, app_flag};</div>
<div class="line">  app.<a class="code" href="classCgu_1_1Application.html#a725e2bb7e2b33b107cf8d62bd93fbb54">activate</a>.connect(<a class="code" href="namespaceCgu_1_1Callback.html#a3e32d4f4961c618aa7e03bda00f398b8">Callback::make</a>(activate));</div>
<div class="line">  app.<a class="code" href="classCgu_1_1Application.html#a324a79089e8fa9ddf280c0ea00337e27">startup</a>.connect(<a class="code" href="namespaceCgu_1_1Callback.html#a3e32d4f4961c618aa7e03bda00f398b8">Callback::make</a>(startup));</div>
<div class="line">  app.<a class="code" href="classCgu_1_1Application.html#a21c48264406d1a59d413a2f1d9443f31">command_line</a>.connect(<a class="code" href="namespaceCgu_1_1Callback.html#a3e32d4f4961c618aa7e03bda00f398b8">Callback::make</a>(command_line));</div>
<div class="line">  app.<a class="code" href="classCgu_1_1Application.html#ae5edd54c70c47bf0897dbe337ff0eecd">open</a>.connect(<a class="code" href="namespaceCgu_1_1Callback.html#a3e32d4f4961c618aa7e03bda00f398b8">Callback::make</a>(open));</div>
<div class="line">  <span class="keywordflow">if</span> (app_flag == G_APPLICATION_FLAGS_NONE)</div>
<div class="line">    app.<a class="code" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">run</a>(0, 0);</div>
<div class="line">  <span class="keywordflow">else</span></div>
<div class="line">    app.<a class="code" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">run</a>(argc, argv);</div>
<div class="line"></div>
<div class="line">  <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
</div><!-- fragment --><p>One thing to note about this example is that the callbacks connected to the <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object always execute in the first instance of the program to be started (the instance in which <a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">Cgu::Application::run()</a> blocks). If the program is then restarted, <a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">Cgu::Application::run()</a> returns in the new program instance as soon as it has invoked the existing instance via dbus, following which the new program instance exits, so immediately disposing of the <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object and callbacks which were constructed on the restart. This is a feature of GApplication/GtkApplication: given the overhead of starting a new process, and that restarting a single-instance program is in any event an exceptional event, any additional overhead created by constructing and then destroying the <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object and callbacks in the new instance is trivial. </p>
</div><h2 class="groupheader">Member Typedef Documentation</h2>
<a class="anchor" id="ab0372d293f014f4c8a6b6b3a593ad4be"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef std::list&lt;<a class="el" href="classCgu_1_1WinBase.html">WinBase</a>*&gt;::<a class="el" href="classCgu_1_1Application.html#ab0372d293f014f4c8a6b6b3a593ad4be">size_type</a> <a class="el" href="classCgu_1_1Application.html#ab0372d293f014f4c8a6b6b3a593ad4be">Cgu::Application::size_type</a></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="af83ad81c3249fa23179f792d90a3cf3a"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">Cgu::Application::Application </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classCgu_1_1Application.html">Application</a> &amp;&#160;</td>
          <td class="paramname">)</td><td></td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">delete</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This class cannot be copied. The copy constructor is deleted. </p>

</div>
</div>
<a class="anchor" id="a40db192a050878640c90fa32d85ea41c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Cgu::Application::Application </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>prog_name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">GApplicationFlags&#160;</td>
          <td class="paramname"><em>flags</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This constructor will, via gtk_application_new(), cause g_type_init() to be called. If any GTK+ functions are to be called before an <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Application</a> object is constructed, g_type_init() (or gtk_init()) must be called explicitly. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">prog_name</td><td>An identifier name. This can comprise any valid ASCII characters "[A-Z][a-z][0-9]_-", although it is usually best to pass the program name. Unlike with gtk_application_new(), it does not need to comprise a full dbus bus name: this method will construct its own valid dbus bus name from prog_name in the org.cgu domain. </td></tr>
    <tr><td class="paramname">flags</td><td>The GApplicationFlags to be passed to the <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object. This class does not contain its own sub-class of GApplication to customize this, but adopts the behaviour of GtkApplication. That behaviour is explained in the introductory remarks. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="structCgu_1_1ApplicationNameError.html" title="This class is thrown when the program id name passed to the constructor of Cgu::Application is invali...">Cgu::ApplicationNameError</a></td><td>This exception will be thrown if the prog_name parameter does not meet the requirements referred to above. </td></tr>
    <tr><td class="paramname">std::bad_alloc</td><td>This method might throw std::bad_alloc if memory is exhausted and the system throws in that case.</td></tr>
  </table>
  </dd>
</dl>
<p>Since 2.0.0-rc2 </p>

</div>
</div>
<a class="anchor" id="abae0c55dca8c0aef61175f2ff2345b68"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">Cgu::Application::~Application </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>From version 2.0.0-rc3, as a safety feature the destructor removes any remaining <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">WinBase</a> objects associated with this <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Application</a> object (this would only be relevant if the user constructs the <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Application</a> object on free store, and then deletes it while the <a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">run()</a> method is still blocking for the purpose of constructing a different <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Application</a> object, but does not call the <a class="el" href="classCgu_1_1Application.html#a9c602205457e1fe7d6ee3cb332ae5cc1">remove()</a> method on all associated <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">WinBase</a> objects before doing so: constructing an <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Application</a> object on free store in this way would be highly unusual however).</p>
<p>Since 2.0.0-rc3 </p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a47bf90e03ac829340aee4aca889a1a8a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Application::add </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classCgu_1_1WinBase.html">Cgu::WinBase</a> *&#160;</td>
          <td class="paramname"><em>win</em>)</td><td></td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Add a <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">Cgu::WinBase</a> object to the <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object, and so also add its managed GtkWindow object to the GtkApplication object. Any <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">Cgu::WinBase</a> object passed to this method should not normally be modal and must have been constructed on free store with the new expression. It is passed by pointer because it will be self owning (its lifetime would normally be determined by user action, not by the program), although if it is removed from this <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object with <a class="el" href="classCgu_1_1Application.html#a9c602205457e1fe7d6ee3cb332ae5cc1">remove()</a>, the delete expression can (and normally should) be called on it. If a delete event occurs on the <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">WinBase</a> object so that the <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">WinBase</a> object destroys itself (say, by the user clicking on the window's close/delete button), or it destroys itself in some other way (say, by calling the <a class="el" href="classCgu_1_1WinBase.html#ab21c86300c0736555efdd57e3248c103">WinBase::close()</a> method), it will automatically be removed from this <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Application</a> object without further action being necessary. The <a class="el" href="classCgu_1_1WinBase.html#a1511e69c5050b32e90269d0eb3d201bd">WinBase::exec()</a> method should never be called on a <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">WinBase</a> object which has been added to an <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Application</a> object. The <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> class, and thus this method, does not employ mutexes to make it thread safe, as there should never be a reason to call <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> methods in other than the main GUI thread. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">win</td><td>The <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">Cgu::WinBase</a> object to be added. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This method might throw std::bad_alloc if memory is exhausted and the system throws in that case. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>As well as this method only being called in the main GUI thread, if the program by which it is called calls GTK+ directly in more than one thread and thus employs gdk_threads_enter()/gdk_threads_leave() (rather than, say, <a class="el" href="classCgu_1_1Notifier.html" title="Provides thread-safe signalling between a worker thread and the main program thread. ">Cgu::Notifier</a> or <a class="el" href="namespaceCgu_1_1Callback.html#ab8a459b25b1dba52fd43015c694bab1d">Cgu::Callback::post()</a>), it must be surrounded by gdk_threads_enter()/gdk_threads_leave() if called otherwise than in a GTK+ signal handler. (The best approach however is for a program only to address GTK+/GDK in the main program thread, for which purpose this library provides various functions and classes for inter-thread communication, such as <a class="el" href="classCgu_1_1Notifier.html" title="Provides thread-safe signalling between a worker thread and the main program thread. ">Cgu::Notifier</a> and <a class="el" href="namespaceCgu_1_1Callback.html#ab8a459b25b1dba52fd43015c694bab1d">Cgu::Callback::post()</a>: see <a class="el" href="Threading.html">Writing multi-threaded programs using c++-gtk-utils</a> for particulars about GTK+ thread safety.)</dd></dl>
<p>Since 2.0.0-rc2 </p>

</div>
</div>
<a class="anchor" id="a089623a1789d5d74f831979be22f3942"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">GApplication* Cgu::Application::get_g_app </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Get the underlying GApplication object (note, not the GtkApplication object, although the GApplication object can be cast to GtkApplication), so allowing any of gio's g_application_*() functions to be applied to it. In normal usage it will not be necessary to call this method. This method is thread safe and will not throw. </p>
<dl class="section return"><dt>Returns</dt><dd>The underlying GApplication object.</dd></dl>
<p>Since 2.0.0-rc2 </p>

</div>
</div>
<a class="anchor" id="acb2bf7242cf30922be07f0566801aea6"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classCgu_1_1Application.html#ab0372d293f014f4c8a6b6b3a593ad4be">size_type</a> Cgu::Application::get_win_count </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Gets the current count of <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">Cgu::WinBase</a> objects associated with this <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object. When it reaches 0, the application will normally end (but this can be prevented by calling g_application_hold()/g_application_release() on the GApplication object returned by <a class="el" href="classCgu_1_1Application.html#a089623a1789d5d74f831979be22f3942">get_g_app()</a>). This method can be used in the callback of one of this class's emitters to determine whether this is the first instance of a program to be started (assuming the first instance calls <a class="el" href="classCgu_1_1Application.html#a47bf90e03ac829340aee4aca889a1a8a">add()</a> to bring up a window), because in that case it will return 0 until <a class="el" href="classCgu_1_1Application.html#a47bf90e03ac829340aee4aca889a1a8a">add()</a> is called. Calling <a class="el" href="classCgu_1_1Application.html#a1622c61154ea23895f68e14139ca65a4">get_windows()</a>.size() will give the same result, but using this method is more efficient as it will avoid a copy of the list of windows. This method will not throw assuming that calling std::list::size() does not throw (as it would not on any sane implementation). The <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> class, and thus this method, does not employ mutexes to make it thread safe, as there should never be a reason to call <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> methods in other than the main GUI thread. </p>
<dl class="section return"><dt>Returns</dt><dd>The number of <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">Cgu::WinBase</a> objects currently associated with this <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object.</dd></dl>
<p>Since 2.0.0-rc2 </p>

</div>
</div>
<a class="anchor" id="a1622c61154ea23895f68e14139ca65a4"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">std::list&lt;<a class="el" href="classCgu_1_1WinBase.html">Cgu::WinBase</a>*&gt; Cgu::Application::get_windows </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Get the list of <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">Cgu::WinBase</a> objects associated with the application. The <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> class, and thus this method, does not employ mutexes to make it thread safe, as there should never be a reason to call <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> methods in other than the main GUI thread. </p>
<dl class="section return"><dt>Returns</dt><dd>A list of the top level <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">Cgu::WinBase</a> objects associated with the application, which will appear in the order in which they were added. If you need to access these, you will probably want to do a dynamic_cast or static_cast to the child type. </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This method might throw std::bad_alloc if memory is exhausted and the system throws in that case.</td></tr>
  </table>
  </dd>
</dl>
<p>Since 2.0.0-rc2 </p>

</div>
</div>
<a class="anchor" id="af4d018438df17508754a163d124a407f"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classCgu_1_1Application.html">Application</a>&amp; Cgu::Application::operator= </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classCgu_1_1Application.html">Application</a> &amp;&#160;</td>
          <td class="paramname">)</td><td></td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">delete</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This class cannot be copied. The assignment operator is deleted. </p>

</div>
</div>
<a class="anchor" id="a9c602205457e1fe7d6ee3cb332ae5cc1"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool Cgu::Application::remove </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classCgu_1_1WinBase.html">Cgu::WinBase</a> *&#160;</td>
          <td class="paramname"><em>win</em>)</td><td></td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Remove a <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">Cgu::WinBase</a> object from the <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object, and so also remove its managed GtkWindow object from the GtkApplication object. This method will not throw assuming that merely iterating through a list does not throw (as it would not on any sane implementation). The <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> class, and thus this method, does not employ mutexes to make it thread safe, as there should never be a reason to call <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> methods in other than the main GUI thread. Calling this method does not destroy the <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">WinBase</a> object. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">win</td><td>The <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">Cgu::WinBase</a> object to be removed. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if the <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">Cgu::WinBase</a> object was found in the <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object and so removed, otherwise false. </dd></dl>
<dl class="section note"><dt>Note</dt><dd>As well as this method only being called in the main GUI thread, if the program by which it is called calls GTK+ directly in more than one thread and thus employs gdk_threads_enter()/gdk_threads_leave() (rather than, say, <a class="el" href="classCgu_1_1Notifier.html" title="Provides thread-safe signalling between a worker thread and the main program thread. ">Cgu::Notifier</a> or <a class="el" href="namespaceCgu_1_1Callback.html#ab8a459b25b1dba52fd43015c694bab1d">Cgu::Callback::post()</a>), it must be surrounded by gdk_threads_enter()/gdk_threads_leave() if called otherwise than in a GTK+ signal handler. (The best approach however is for a program only to address GTK+/GDK in the main program thread, for which purpose this library provides various functions and classes for inter-thread communication, such as <a class="el" href="classCgu_1_1Notifier.html" title="Provides thread-safe signalling between a worker thread and the main program thread. ">Cgu::Notifier</a> and <a class="el" href="namespaceCgu_1_1Callback.html#ab8a459b25b1dba52fd43015c694bab1d">Cgu::Callback::post()</a>: see <a class="el" href="Threading.html">Writing multi-threaded programs using c++-gtk-utils</a> for particulars about GTK+ thread safety.)</dd></dl>
<p>Since 2.0.0-rc2 </p>

</div>
</div>
<a class="anchor" id="a140b6227d452bf4fb81f1d6c4a8dcc38"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int Cgu::Application::run </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>argc</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char **&#160;</td>
          <td class="paramname"><em>argv</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Calls g_application_run() in respect of the underlying GtkApplication object, so invoking one of this <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> class's emitters (the exact behaviour depends on the GApplication flags passed to the constructor and is explained in the introductory remarks above). This method is thread safe (although that is irrelevant to its purpose) and will not throw. In addition, if a callback connected to an emitter throws, the exception is consumed and a g_critical warning issued. This function blocks until the last <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">WinBase</a> object associated with this <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Application</a> object is destroyed or removed. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">argc</td><td>The argc from main() or 0. </td></tr>
    <tr><td class="paramname">argv</td><td>The argv from main() or 0. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The exit status from g_application_run().</dd></dl>
<p>Since 2.0.0-rc2 </p>

</div>
</div>
<h2 class="groupheader">Member Data Documentation</h2>
<a class="anchor" id="a725e2bb7e2b33b107cf8d62bd93fbb54"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classCgu_1_1SafeEmitterArg.html">Cgu::SafeEmitterArg</a>&lt;<a class="el" href="classCgu_1_1Application.html">Cgu::Application</a>*&gt; Cgu::Application::activate</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This <a class="el" href="classCgu_1_1SafeEmitterArg.html" title="A thread-safe class to execute callbacks connected to it, with provision for automatic disconnection...">SafeEmitterArg</a> object emits (and so executes any connected callback) when the underlying GApplication object emits its <em>activate</em> signal. The argument passed to the emitter's callback(s) is a pointer to the <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object. </p>
<dl class="section note"><dt>Note</dt><dd>When the callback executes, thread cancellation is blocked, and any exceptions are consumed with a g_critical message issued. The callback will always execute in the main GUI thread when executed in response to the <a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">run()</a> method. Because a <a class="el" href="classCgu_1_1SafeEmitterArg.html" title="A thread-safe class to execute callbacks connected to it, with provision for automatic disconnection...">SafeEmitterArg</a> object is used, the emitter object itself is thread safe.</dd></dl>
<p>Since 2.0.0-rc2 </p>

</div>
</div>
<a class="anchor" id="a21c48264406d1a59d413a2f1d9443f31"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classCgu_1_1SafeEmitterArg.html">Cgu::SafeEmitterArg</a>&lt;<a class="el" href="classCgu_1_1Application.html">Cgu::Application</a>*, GApplicationCommandLine*, gint&amp;&gt; Cgu::Application::command_line</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This <a class="el" href="classCgu_1_1SafeEmitterArg.html" title="A thread-safe class to execute callbacks connected to it, with provision for automatic disconnection...">SafeEmitterArg</a> object emits (and so executes any connected callback) when the underlying GApplication object emits its <em>command-line</em> signal. The second argument passed to the emitter's callback(s) is the one passed by that signal, that is to say the arguments are:</p>
<p>first: a pointer to the <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object.</p>
<p>second: a pointer to a GApplicationCommandLine object representing the passed command line (this is owned by gio and should not be unref'ed).</p>
<p>third: a gint&amp; reference to which the value to be returned to the GApplication's command-line signal can be passed: if no value is assigned to it or no callback has been attached to the signal, 0 will be returned, except that if an exception from a callback is consumed, -1 will be returned. If more than one callback is attached to the signal and no exception is consumed, the last one to assign a value will be have its value returned.</p>
<dl class="section note"><dt>Note</dt><dd>When the callback executes, thread cancellation is blocked, and any exceptions are consumed with a g_critical message issued and a return value of -1 set. The callback will always execute in the main GUI thread when executed in response to the <a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">run()</a> method. Because a <a class="el" href="classCgu_1_1SafeEmitterArg.html" title="A thread-safe class to execute callbacks connected to it, with provision for automatic disconnection...">SafeEmitterArg</a> object is used, the emitter object itself is thread safe.</dd></dl>
<p>Since 2.0.0-rc2 </p>

</div>
</div>
<a class="anchor" id="ae5edd54c70c47bf0897dbe337ff0eecd"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classCgu_1_1SafeEmitterArg.html">Cgu::SafeEmitterArg</a>&lt;<a class="el" href="classCgu_1_1Application.html">Cgu::Application</a>*, std::pair&lt;GFile**, gint&gt;, gchar*&gt; Cgu::Application::open</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This <a class="el" href="classCgu_1_1SafeEmitterArg.html" title="A thread-safe class to execute callbacks connected to it, with provision for automatic disconnection...">SafeEmitterArg</a> object emits (and so executes any connected callback) when the underlying GApplication object emits its <em>open</em> signal. The second and third arguments passed to the emitter's callback(s) are those passed by that signal, that is to say the arguments are:</p>
<p>first: a pointer to the <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object.</p>
<p>second: a std::pair object where the first member is an array of GFile*'s representing the files/uris passed as arguments, and the second member is the length of that array (the array is owned by gio and should not be freed).</p>
<p>third: a gchar* argument comprising the text of the "hint" (this is owned by gio and should not be freed).</p>
<dl class="section note"><dt>Note</dt><dd>When the callback executes, thread cancellation is blocked, and any exceptions are consumed with a g_critical message issued. The callback will always execute in the main GUI thread when executed in response to the <a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">run()</a> method. Because a <a class="el" href="classCgu_1_1SafeEmitterArg.html" title="A thread-safe class to execute callbacks connected to it, with provision for automatic disconnection...">SafeEmitterArg</a> object is used, the emitter object itself is thread safe.</dd></dl>
<p>Since 2.0.0-rc2 </p>

</div>
</div>
<a class="anchor" id="a324a79089e8fa9ddf280c0ea00337e27"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classCgu_1_1SafeEmitterArg.html">Cgu::SafeEmitterArg</a>&lt;<a class="el" href="classCgu_1_1Application.html">Cgu::Application</a>*&gt; Cgu::Application::startup</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This <a class="el" href="classCgu_1_1SafeEmitterArg.html" title="A thread-safe class to execute callbacks connected to it, with provision for automatic disconnection...">SafeEmitterArg</a> object emits (and so executes any connected callback) when the underlying GApplication object emits its <em>startup</em> signal (which it will do once, on the first occasion that <a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">run()</a> is called). The argument passed to the emitter's callback(s) is a pointer to the <a class="el" href="classCgu_1_1Application.html" title="This is a class for constructing and managing GtkApplication objects. ">Cgu::Application</a> object. This signal can be used to set up a desktop application menu or menu bar with a <a class="el" href="classCgu_1_1WinBase.html" title="This is a class for managing the lifetime of top level widgets. ">WinBase</a> object constructed from a GtkApplicationWindow object. </p>
<dl class="section note"><dt>Note</dt><dd>When the callback executes, thread cancellation is blocked, and any exceptions are consumed with a g_critical message issued. The callback will always execute in the main GUI thread when executed in response to the <a class="el" href="classCgu_1_1Application.html#a140b6227d452bf4fb81f1d6c4a8dcc38">run()</a> method. Because a <a class="el" href="classCgu_1_1SafeEmitterArg.html" title="A thread-safe class to execute callbacks connected to it, with provision for automatic disconnection...">SafeEmitterArg</a> object is used, the emitter object itself is thread safe.</dd></dl>
<p>Since 2.0.0-rc2 </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="application_8h_source.html">application.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Mon Sep 16 2013 20:45:31 for c++-gtk-utils by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.4
</small></address>
</body>
</html>