⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gtkuimanager.html

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 5 页
字号:
If a name is not specified, it defaults to the action. If an action is not specified either, the element name is used. The name and action attributes must not contain '/' characters after parsing (since that would mess up path lookup) and must be usable as XML attributes when enclosed in doublequotes, thus they must not '"' characters or references to the &amp;quot; entity.</p><div class="example"><a name="id3960545"></a><p class="title"><b>Example&#160;27.&#160;A UI definition</b></p><div class="example-contents"><pre class="programlisting">&lt;ui&gt;  &lt;menubar&gt;    &lt;menu name="FileMenu" action="FileMenuAction"&gt;      &lt;menuitem name="New" action="New2Action" /&gt;      &lt;placeholder name="FileMenuAdditions" /&gt;    &lt;/menu&gt;    &lt;menu name="JustifyMenu" action="JustifyMenuAction"&gt;      &lt;menuitem name="Left" action="justify-left"/&gt;      &lt;menuitem name="Centre" action="justify-center"/&gt;      &lt;menuitem name="Right" action="justify-right"/&gt;      &lt;menuitem name="Fill" action="justify-fill"/&gt;    &lt;/menu&gt;  &lt;/menubar&gt;  &lt;toolbar action="toolbar1"&gt;    &lt;placeholder name="JustifyToolItems"&gt;      &lt;separator/&gt;      &lt;toolitem name="Left" action="justify-left"/&gt;      &lt;toolitem name="Centre" action="justify-center"/&gt;      &lt;toolitem name="Right" action="justify-right"/&gt;      &lt;toolitem name="Fill" action="justify-fill"/&gt;      &lt;separator/&gt;    &lt;/placeholder&gt;  &lt;/toolbar&gt;&lt;/ui&gt;</pre></div></div><br class="example-break"><p>The constructed widget hierarchy is very similar to the element treeof the XML, with the exception that placeholders are merged into theirparents. The correspondence of XML elements to widgets should bealmost obvious: </p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term">menubar</span></p></td><td><p>a <a class="link" href="GtkMenuBar.html" title="GtkMenuBar"><span class="type">GtkMenuBar</span></a></p></td></tr><tr><td><p><span class="term">toolbar</span></p></td><td><p>a <a class="link" href="GtkToolbar.html" title="GtkToolbar"><span class="type">GtkToolbar</span></a></p></td></tr><tr><td><p><span class="term">popup</span></p></td><td><p>a toplevel <a class="link" href="GtkMenu.html" title="GtkMenu"><span class="type">GtkMenu</span></a></p></td></tr><tr><td><p><span class="term">menu</span></p></td><td><p>a <a class="link" href="GtkMenu.html" title="GtkMenu"><span class="type">GtkMenu</span></a> attached to a menuitem</p></td></tr><tr><td><p><span class="term">menuitem</span></p></td><td><p>a <a class="link" href="GtkMenuItem.html" title="GtkMenuItem"><span class="type">GtkMenuItem</span></a> subclass, the exact type depends on theaction</p></td></tr><tr><td><p><span class="term">toolitem</span></p></td><td><p>a <a class="link" href="GtkToolItem.html" title="GtkToolItem"><span class="type">GtkToolItem</span></a> subclass, the exact type depends on theaction. Note that toolitem elements may contain a menu element, but onlyif their associated action specifies a <a class="link" href="GtkMenuToolButton.html" title="GtkMenuToolButton"><span class="type">GtkMenuToolButton</span></a> as proxy.</p></td></tr><tr><td><p><span class="term">separator</span></p></td><td><p>a <a class="link" href="GtkSeparatorMenuItem.html" title="GtkSeparatorMenuItem"><span class="type">GtkSeparatorMenuItem</span></a> or<a class="link" href="GtkSeparatorToolItem.html" title="GtkSeparatorToolItem"><span class="type">GtkSeparatorToolItem</span></a></p></td></tr><tr><td><p><span class="term">accelerator</span></p></td><td><p>a keyboard accelerator</p></td></tr></tbody></table></div><p></p><p>The "position" attribute determines where a constructed widget is positionedwrt. to its siblings in the partially constructed tree. If it is"top", the widget is prepended, otherwise it is appended.</p></div><hr><div class="refsect2" lang="en"><a name="UI-Merging"></a><h3>UI Merging</h3><p>The most remarkable feature of <a class="link" href="GtkUIManager.html" title="GtkUIManager"><span class="type">GtkUIManager</span></a> is that it can overlay a setof menuitems and toolitems over another one, and demerge them later.</p><p>Merging is done based on the names of the XML elements. Each element is identified by a path which consists of the names of its anchestors, separatedby slashes. For example, the menuitem named "Left" in the example abovehas the path <code class="literal">/ui/menubar/JustifyMenu/Left</code> and thetoolitem with the same name has path <code class="literal">/ui/toolbar1/JustifyToolItems/Left</code>.</p></div><hr><div class="refsect2" lang="en"><a name="id3960833"></a><h3>Accelerators</h3><p>Every action has an accelerator path. Accelerators are installed together withmenuitem proxies, but they can also be explicitly added with &lt;accelerator&gt;elements in the UI definition. This makes it possible to have accelerators foractions even if they have no visible proxies.</p></div><hr><div class="refsect2" lang="en"><a name="Smart-Separators"></a><h3>Smart Separators</h3><p>The separators created by <a class="link" href="GtkUIManager.html" title="GtkUIManager"><span class="type">GtkUIManager</span></a> are "smart", i.e. they do not show up in the UI unless they end up between two visible menu or tool items. Separatorswhich are located at the very beginning or end of the menu or toolbar containing them, or multiple separators next to each other, are hidden. This is a useful feature, since the merging of UI elements from multiple sources can make it hard or impossible to determine in advance whether a separator will end up in such an unfortunate position.</p><p>For separators in toolbars, you can set <code class="literal">expand="true"</code> toturn them from a small, visible separator to an expanding, invisible one.Toolitems following an expanding separator are effectively right-aligned.</p></div><hr><div class="refsect2" lang="en"><a name="id3959551"></a><h3>Empty Menus</h3><p>Submenus pose similar problems to separators inconnection with merging. It is impossible to know in advance whether they will end up empty after merging. <a class="link" href="GtkUIManager.html" title="GtkUIManager"><span class="type">GtkUIManager</span></a> offers two ways to treat empty submenus:</p><div class="itemizedlist"><ul type="disc"><li><p>make them disappear by hiding the menu item they're attached to</p></li><li><p>add an insensitive "Empty" item</p></li></ul></div><p>The behaviour is chosen based on the "hide_if_empty" property of the action to which the submenu is associated.</p></div><hr><div class="refsect2" lang="en"><a name="GtkUIManager-BUILDER-UI"></a><h3>GtkUIManager as GtkBuildable</h3><p>The GtkUIManager implementation of the GtkBuildable interface acceptsGtkActionGroup objects as &lt;child&gt; elements in UI definitions.</p><p>A GtkUIManager UI definition as described above can be embedded inan GtkUIManager &lt;object&gt; element in a GtkBuilder UI definition.</p><p>The widgets that are constructed by a GtkUIManager can be embedded inother parts of the constructed user interface with the help of the"constructor" attribute. See the example below.</p><div class="example"><a name="id3959617"></a><p class="title"><b>Example&#160;28.&#160;An embedded GtkUIManager UI definition</b></p><div class="example-contents"><pre class="programlisting">&lt;object class="GtkUIManager" id="uiman"&gt;  &lt;child&gt;    &lt;object class="GtkActionGroup"&gt;      &lt;child&gt;        &lt;object class="GtkAction" id="file"&gt;          &lt;property name="label"&gt;_File&lt;/property&gt;        &lt;/object&gt;      &lt;/child&gt;    &lt;/object&gt;  &lt;/child&gt;  &lt;ui&gt;    &lt;menubar name="menubar1"&gt;      &lt;menu action="file"&gt;      &lt;/menu&gt;    &lt;/menubar&gt;  &lt;/ui&gt;&lt;/object&gt;&lt;object class="GtkWindow" id="main-window"&gt;  &lt;child&gt;    &lt;object class="GtkMenuBar" id="menubar1" constructor="uiman"/&gt;  &lt;/child&gt;&lt;/object&gt;</pre></div></div><br class="example-break"></div></div><div class="refsect1" lang="en"><a name="id3959631"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3959651"></a><h3><a name="GtkUIManager-struct"></a>GtkUIManager</h3><a class="indexterm" name="id3959664"></a><pre class="programlisting">typedef struct _GtkUIManager GtkUIManager;</pre><p>The <span class="structname">GtkUIManager</span> struct contains only privatemembers and should not be accessed directly.</p></div><hr><div class="refsect2" lang="en"><a name="id3961161"></a><h3><a name="gtk-ui-manager-new"></a>gtk_ui_manager_new ()</h3><a class="indexterm" name="id3961176"></a><pre class="programlisting"><a class="link" href="GtkUIManager.html" title="GtkUIManager">GtkUIManager</a>*       gtk_ui_manager_new                  (void);</pre><p>Creates a new ui manager object.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> a new ui manager object.</td></tr></tbody></table></div><p class="since">Since  2.4</p></div><hr><div class="refsect2" lang="en"><a name="id3961223"></a><h3><a name="gtk-ui-manager-set-add-tearoffs"></a>gtk_ui_manager_set_add_tearoffs ()</h3><a class="indexterm" name="id3961239"></a><pre class="programlisting">void                gtk_ui_manager_set_add_tearoffs     (<a class="link" href="GtkUIManager.html" title="GtkUIManager">GtkUIManager</a> *self,                                                         <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> add_tearoffs);</pre><p>Sets the "add_tearoffs" property, which controls whether menus generated by this <a class="link" href="GtkUIManager.html" title="GtkUIManager"><span class="type">GtkUIManager</span></a> will have tearoff menu items. </p><p>Note that this only affects regular menus. Generated popup menus never have tearoff menu items.</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>self</code></em>&#160;:</span></p></td><td> a <a class="link" href="GtkUIManager.html" title="GtkUIManager"><span class="type">GtkUIManager</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>add_tearoffs</code></em>&#160;:</span></p></td><td> whether tearoff menu items are added</td></tr></tbody></table></div><p class="since">Since  2.4</p></div><hr><div class="refsect2" lang="en"><a name="id3961341"></a><h3><a name="gtk-ui-manager-get-add-tearoffs"></a>gtk_ui_manager_get_add_tearoffs ()</h3><a class="indexterm" name="id3961357"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a>            gtk_ui_manager_get_add_tearoffs     (<a class="link" href="GtkUIManager.html" title="GtkUIManager">GtkUIManager</a> *self);</pre><p>Returns whether menus generated by this <a class="link" href="GtkUIManager.html" title="GtkUIManager"><span class="type">GtkUIManager</span></a>will have tearoff menu items.</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>self</code></em>&#160;:</span></p></td><td> a <a class="link" href="GtkUIManager.html" title="GtkUIManager"><span class="type">GtkUIManager</span></a>

⌨️ 快捷键说明

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