gtkactiongroup.html

来自「最新gtk中文资料集」· HTML 代码 · 共 1,383 行 · 第 1/5 页

HTML
1,383
字号
Actions are organised into groups.  An action group is essentially amap from names to <a class="link" href="GtkAction.html" title="GtkAction"><span class="type">GtkAction</span></a> objects.</p><p>All actions that would make sense to use in a particular contextshould be in a single group.  Multiple action groups may be used for aparticular user interface.  In fact, it is expected that most nontrivial applications will make use of multiple groups.  For example, in an applicationthat can edit multiple documents, one group holding global actions (e.g. quit, about, new), and one group per document holding actions that act on that document (eg. save, cut/copy/paste, etc).  Each window's menus would be constructed from a combination of two action groups.</p><p><a name="Action-Accel"></a>Accelerators are handled by the GTK+ accelerator map. All actions are assigned an accelerator path (which normally has the form <code class="literal">&lt;Actions&gt;/<em class="replaceable"><code>group-name</code></em>/<em class="replaceable"><code>action-name</code></em></code>) and a shortcut is associated with this accelerator path. All menuitems and toolitems take on this accelerator path. The GTK+ accelerator map code makes sure that the correct shortcut is displayed next to the menu item.</p><div class="refsect2" lang="en"><a name="GtkActionGroup-BUILDER-UI"></a><h3>GtkActionGroup as GtkBuildable</h3><p>The GtkActionGroup implementation of the GtkBuildable interface acceptsGtkAction objects as &lt;child&gt; elements in UI definitions.</p><p>Note that it is probably more common to define actions and action groupsin the code, since they are directly related to what the code can do.</p><p>The GtkActionGroup implementation of the GtkBuildable interface supports a custom &lt;accelerator&gt; element, which has attributes named key andmodifiers and allows to specify accelerators. This is similar to the &lt;accelerator&gt; element of GtkWidget, the main difference is that it doesn't allow you to specify a signal.</p><div class="example"><a name="id3969115"></a><p class="title"><b>Example&#160;29.&#160;A <span class="structname">GtkDialog</span> UI definition fragment.</b></p><div class="example-contents"><pre class="programlisting">&lt;object class="GtkActionGroup" id="actiongroup"&gt;  &lt;child&gt;      &lt;object class="GtkAction" id="About"&gt;          &lt;property name="name"&gt;About&lt;/property&gt;          &lt;property name="stock_id"&gt;gtk-about&lt;/property&gt;          &lt;signal handler="about_activate" name="activate"/&gt;      &lt;/object&gt;      &lt;accelerator key="F1" modifiers="GDK_CONTROL_MASK | GDK_SHIFT_MASK"/&gt;  &lt;/child&gt;&lt;/object&gt;</pre></div></div><br class="example-break"></div></div><div class="refsect1" lang="en"><a name="id3969132"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3969150"></a><h3><a name="GtkActionGroup-struct"></a>GtkActionGroup</h3><a class="indexterm" name="id3969163"></a><pre class="programlisting">typedef struct _GtkActionGroup GtkActionGroup;</pre><p>The <span class="structname">GtkActionGroup</span> struct contains only private members and should not be accessed directly.</p></div><hr><div class="refsect2" lang="en"><a name="id3969184"></a><h3><a name="gtk-action-group-new"></a>gtk_action_group_new ()</h3><a class="indexterm" name="id3970527"></a><pre class="programlisting"><a class="link" href="GtkActionGroup.html" title="GtkActionGroup">GtkActionGroup</a>*     gtk_action_group_new                (const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *name);</pre><p>Creates a new <a class="link" href="GtkActionGroup.html" title="GtkActionGroup"><span class="type">GtkActionGroup</span></a> object. The name of the action groupis used when associating <a class="link" href="GtkActionGroup.html#Action-Accel">keybindings</a> with the actions.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>name</code></em>&#160;:</span></p></td><td> the name of the action group.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> the new <a class="link" href="GtkActionGroup.html" title="GtkActionGroup"><span class="type">GtkActionGroup</span></a></td></tr></tbody></table></div><p class="since">Since  2.4</p></div><hr><div class="refsect2" lang="en"><a name="id3970621"></a><h3><a name="gtk-action-group-get-name"></a>gtk_action_group_get_name ()</h3><a class="indexterm" name="id3970637"></a><pre class="programlisting">const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a>*        gtk_action_group_get_name           (<a class="link" href="GtkActionGroup.html" title="GtkActionGroup">GtkActionGroup</a> *action_group);</pre><p>Gets the name of the action group.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>action_group</code></em>&#160;:</span></p></td><td> the action group</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> the name of the action group.</td></tr></tbody></table></div><p class="since">Since  2.4</p></div><hr><div class="refsect2" lang="en"><a name="id3970707"></a><h3><a name="gtk-action-group-get-sensitive"></a>gtk_action_group_get_sensitive ()</h3><a class="indexterm" name="id3970722"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a>            gtk_action_group_get_sensitive      (<a class="link" href="GtkActionGroup.html" title="GtkActionGroup">GtkActionGroup</a> *action_group);</pre><p>Returns <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the group is sensitive.  The constituent actionscan only be logically sensitive (see <a class="link" href="GtkAction.html#gtk-action-is-sensitive"><code class="function">gtk_action_is_sensitive()</code></a>) ifthey are sensitive (see <a class="link" href="GtkAction.html#gtk-action-get-sensitive"><code class="function">gtk_action_get_sensitive()</code></a>) and their groupis sensitive.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>action_group</code></em>&#160;:</span></p></td><td> the action group</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the group is sensitive.</td></tr></tbody></table></div><p class="since">Since  2.4</p></div><hr><div class="refsect2" lang="en"><a name="id3970838"></a><h3><a name="gtk-action-group-set-sensitive"></a>gtk_action_group_set_sensitive ()</h3><a class="indexterm" name="id3970853"></a><pre class="programlisting">void                gtk_action_group_set_sensitive      (<a class="link" href="GtkActionGroup.html" title="GtkActionGroup">GtkActionGroup</a> *action_group,                                                         <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> sensitive);</pre><p>Changes the sensitivity of <em class="parameter"><code>action_group</code></em></p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>action_group</code></em>&#160;:</span></p></td><td> the action group</td></tr><tr><td><p><span class="term"><em class="parameter"><code>sensitive</code></em>&#160;:</span></p></td><td> new sensitivity</td></tr></tbody></table></div><p class="since">Since  2.4</p></div><hr><div class="refsect2" lang="en"><a name="id3970938"></a><h3><a name="gtk-action-group-get-visible"></a>gtk_action_group_get_visible ()</h3><a class="indexterm" name="id3970954"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a>            gtk_action_group_get_visible        (<a class="link" href="GtkActionGroup.html" title="GtkActionGroup">GtkActionGroup</a> *action_group);</pre><p>Returns <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the group is visible.  The constituent actionscan only be logically visible (see <a class="link" href="GtkAction.html#gtk-action-is-visible"><code class="function">gtk_action_is_visible()</code></a>) ifthey are visible (see <a class="link" href="GtkAction.html#gtk-action-get-visible"><code class="function">gtk_action_get_visible()</code></a>) and their groupis visible.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>action_group</code></em>&#160;:</span></p></td><td> the action group</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the group is visible.</td></tr></tbody></table></div><p class="since">Since  2.4</p></div><hr><div class="refsect2" lang="en"><a name="id3971070"></a><h3><a name="gtk-action-group-set-visible"></a>gtk_action_group_set_visible ()</h3><a class="indexterm" name="id3971086"></a><pre class="programlisting">void                gtk_action_group_set_visible        (<a class="link" href="GtkActionGroup.html" title="GtkActionGroup">GtkActionGroup</a> *action_group,                                                         <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> visible);</pre><p>Changes the visible of <em class="parameter"><code>action_group</code></em>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>action_group</code></em>&#160;:</span></p></td><td> the action group</td></tr><tr><td><p><span class="term"><em class="parameter"><code>visible</code></em>&#160;:</span></p></td><td> new visiblity</td></tr></tbody></table></div><p class="since">Since  2.4</p></div><hr><div class="refsect2" lang="en"><a name="id3971171"></a><h3><a name="gtk-action-group-get-action"></a>gtk_action_group_get_action ()</h3><a class="indexterm" name="id3971187"></a><pre class="programlisting"><a class="link" href="GtkAction.html" title="GtkAction">GtkAction</a>*          gtk_action_group_get_action         (<a class="link" href="GtkActionGroup.html" title="GtkActionGroup">GtkActionGroup</a> *action_group,                                                         const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *action_name);</pre>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?