?? sec-gnomeuiinfo.html
字號(hào):
</tr> <tr> <td align="LEFT" valign="TOP"> <span class="STRUCTNAME"> GNOME_APP_UI_RADIOITEMS</span> </td> <td align="LEFT" valign="TOP"> Radio item group </td> <td align="LEFT" valign="TOP"> Array of radio items in the group </td> </tr> <tr> <td align="LEFT" valign="TOP"> <span class="STRUCTNAME">GNOME_APP_UI_SUBTREE</span> </td> <td align="LEFT" valign="TOP"> Submenu </td> <td align="LEFT" valign="TOP"> Array of <span class="STRUCTNAME">GnomeUIInfo</span> in the subtree </td> </tr> <tr> <td align="LEFT" valign="TOP"> <span class="STRUCTNAME"> GNOME_APP_UI_SEPARATOR</span> </td> <td align="LEFT" valign="TOP"> Separator </td> <td align="LEFT" valign="TOP"> None </td> </tr> <tr> <td align="LEFT" valign="TOP"> <span class="STRUCTNAME">GNOME_APP_UI_HELP</span> </td> <td align="LEFT" valign="TOP"> Help item </td> <td align="LEFT" valign="TOP"> Help node to load </td> </tr> </table> </div> <p> To create an entire menu tree, you include pointers to previous menu tables using the <tt class="FUNCTION"> GNOMEUIINFO_SUBTREE()</tt> macro: </p> <table border="0" bgcolor="#E0E0E0" width="100%"> <tr> <td><pre class="PROGRAMLISTING"> static GnomeUIInfo main_menu[] = { GNOMEUIINFO_SUBTREE(N_("_File"), file_menu), GNOMEUIINFO_END}; </pre> </td> </tr> </table> <p> In this particular case, there is a better macro to use, however: </p> <table border="0" bgcolor="#E0E0E0" width="100%"> <tr> <td><pre class="PROGRAMLISTING"> static GnomeUIInfo main_menu[] = { GNOMEUIINFO_MENU_FILE_TREE(file_menu), GNOMEUIINFO_END}; </pre> </td> </tr> </table> <p> The main advantage of this macro is standardization; it ensures that all Gnome file menus use the same key shortcut and have the same name. There are quite a few analagous macros; see <tt class="FILENAME"> libgnomeui/gnome-app-helper.h</tt> for the complete list. </p> <div class="SECT2"> <h2 class="SECT2"> <a name="Z89">Converting <span class="STRUCTNAME"> GnomeUIInfo</span> to a Widget</a> </h2> <p> Once you have a menu table, Gnome will process it and convert it to a widget. The functions are listed in <a href="sec-gnomeuiinfo.html#GNOMEAPP-APPHELPER">Figure 4</a> </p> <div class="FIGURE"> <a name="GNOMEAPP-APPHELPER"></a> <div class="FUNCSYNOPSIS"> <a name="GNOMEAPP-APPHELPER.SYNOPSIS"></a> <table border="0" bgcolor="#E0E0E0" width="100%"> <tr> <td><pre class="FUNCSYNOPSISINFO">#include <libgnomeui/gnome-app-helper.h></pre> </td> </tr> </table> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION"> gnome_app_create_menus</tt></code>(GnomeApp* <tt class="PARAMETER"><i>app</i></tt>, GnomeUIInfo* <tt class="PARAMETER"><i>uiinfo</i></tt>);</code> </p> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION"> gnome_app_create_menus_with_data</tt></code>(GnomeApp* <tt class="PARAMETER"><i>app</i></tt>, GnomeUIInfo* <tt class="PARAMETER"><i>uiinfo</i></tt>, gpointer <tt class="PARAMETER"><i>user_data</i></tt>);</code> </p> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION"> gnome_app_create_toolbar</tt></code>(GnomeApp* <tt class="PARAMETER"><i>app</i></tt>, GnomeUIInfo* <tt class="PARAMETER"><i>uiinfo</i></tt>);</code> </p> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION"> gnome_app_create_toolbar_with_data</tt></code>(GnomeApp* <tt class="PARAMETER"><i>app</i></tt>, GnomeUIInfo* <tt class="PARAMETER"><i>uiinfo</i></tt>, gpointer <tt class="PARAMETER"><i>user_data</i></tt>);</code> </p> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION"> gnome_app_fill_toolbar</tt></code>(GtkToolbar* <tt class="PARAMETER"><i>toolbar</i></tt>, GnomeUIInfo* <tt class="PARAMETER"><i>uiinfo</i></tt>, GtkAccelGroup* <tt class="PARAMETER"><i> accel_group</i></tt>);</code> </p> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION"> gnome_app_fill_toolbar_with_data</tt></code>(GtkToolbar* <tt class="PARAMETER"><i>toolbar</i></tt>, GnomeUIInfo* <tt class="PARAMETER"><i> uiinfo</i></tt>, GtkAccelGroup* <tt class= "PARAMETER"><i>accel_group</i></tt>, gpointer <tt class="PARAMETER"><i>data</i></tt>);</code> </p> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION"> gnome_app_fill_menu</tt></code>(GtkMenuShell* <tt class="PARAMETER"><i>menushell</i></tt>, GnomeUIInfo* <tt class="PARAMETER"><i>uiinfo</i></tt>, GtkAccelGroup* <tt class="PARAMETER"><i> accel_group</i></tt>, gboolean <tt class="PARAMETER"> <i>uline_accels</i></tt>, gint <tt class="PARAMETER"> <i>pos</i></tt>);</code> </p> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION"> gnome_app_fill_menu_with_data</tt></code>(GtkMenuShell* <tt class="PARAMETER"><i>menushell</i></tt>, GnomeUIInfo* <tt class="PARAMETER"><i> uiinfo</i></tt>, GtkAccelGroup* <tt class= "PARAMETER"><i>accel_group</i></tt>, gboolean <tt class="PARAMETER"><i>uline_accels</i></tt>, gint <tt class="PARAMETER"><i>pos</i></tt>, gpointer <tt class="PARAMETER"><i>user_data</i></tt>);</code> </p> </div> <p> <b>Figure 4. Creating Widgets from <span class= "STRUCTNAME">GnomeUIInfo</span></b> </p> </div> <p> If you are using the <tt class="CLASSNAME">GnomeApp</tt> widget, <tt class="FUNCTION"> gnome_app_create_menus()</tt> and <tt class="FUNCTION"> gnome_app_create_toolbar()</tt> create a menubar or toolbar from the <span class="STRUCTNAME"> GnomeUIInfo</span> table you provide, then attach that to the <tt class="CLASSNAME">GnomeApp</tt>. Most of the time these are the functions you want to use; they do everything automatically. There is a <span class= "STRUCTNAME">_with_data()</span> variant of each function which overrides the <span class="STRUCTNAME"> user_data</span> field of <span class="STRUCTNAME"> GnomeUIInfo</span>. </p> <p> If you have more specialized needs, you can manually fill a menubar or toolbar and then add it to the container of your choice. The <span class="STRUCTNAME">fill</span> functions require you to specify an accelerator group to add accelerators to; for <tt class="CLASSNAME"> GnomeApp</tt>, an accelerator group already exists in the widget struct (the <span class="STRUCTNAME"> accel_group</span> member). The <span class="STRUCTNAME"> fill</span> functions for menus take two additional arguments: you can toggle whether to parse the underscores in menu item labels to extract accelerators, and you can specify at which position in the <tt class= "CLASSNAME">GtkMenuShell</tt> the function will begin inserting menu items. </p> <p> (<tt class="CLASSNAME">GtkMenuShell</tt> is simply the base class for <tt class="CLASSNAME">GtkMenuBar</tt> and <tt class="CLASSNAME">GtkMenu</tt>, i.e. it is a widget that contains menu items. An accelerator group is just a collection of accelerators, normally attached to a <tt class="CLASSNAME">GtkWindow</tt>; use <span class= "STRUCTNAME">GNOME_APP(widget)->accel_group</span> in this case.) </p> <p> When you use a <span class="STRUCTNAME"> GnomeUIInfo</span> table to create a menubar or toolbar, pointers to the individual menu item or toolbar button widgets are placed in the <span class="STRUCTNAME"> widget</span> member of each <span class="STRUCTNAME"> GnomeUIInfo</span> struct. You can use these pointers to access the individual widgets; for example, if you create a check menu item you might want to set the state of the check. The pointer is also useful if you want to manually create some part of the menu; you can create an empty subtree item, for example, and manually build the contents of the subtree. </p> </div> <div class="SECT2"> <h2 class="SECT2"> <a name="Z90">GnomeHello: An Example</a> </h2> <p> The GnomeHello application has menus and a toolbar created using the <span class="STRUCTNAME"> GnomeUIInfo</span> method; the relevant code is in a separate file, <tt class="FILENAME">menus.c</tt>. Appendix E lists this file in its entirety. </p> </div> </div> <div class="NAVFOOTER"> <br> <br> <table width="100%" border="0" bgcolor="#ffffff" cellpadding= "1" cellspacing="0"> <tr> <td width="25%" bgcolor="#ffffff" align="left"> <a href="cha-main.html"><font color="#0000ff" size="2"> <b><<< Previous</b></font></a> </td> <td width="25%" colspan="2" bgcolor="#ffffff" align= "center"> <font color="#0000ff" size="2"><b><a href="ggad.html"> <font color="#0000ff" size="2"><b> Home</b></font></a></b></font> </td> <td width="25%" bgcolor="#ffffff" align="right"> <a href="z91.html"><font color="#0000ff" size="2"><b> Next >>></b></font></a> </td> </tr> <tr> <td colspan="2" align="left"> <font color="#000000" size="2"><b>The Main Window: <tt class="CLASSNAME">GnomeApp</tt></b></font> </td> <td colspan="2" align="right"> <font color="#000000" size="2"><b>Adding a Status Bar</b></font> </td> </tr> </table> </div> </body></html>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
減小字號(hào)
Ctrl + -