📄 z91.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html> <head> <title> Adding a Status Bar </title> <meta name="GENERATOR" content= "Modular DocBook HTML Stylesheet Version 1.45"> <link rel="HOME" title="GTK+ / Gnome Application Development" href="ggad.html"> <link rel="UP" title="The Main Window: GnomeApp" href= "cha-main.html"> <link rel="PREVIOUS" title="Menus and Toolbars with GnomeUIInfo" href="sec-gnomeuiinfo.html"> <link rel="NEXT" title="Online Help" href="sec-help.html"> </head> <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink= "#840084" alink="#0000FF"> <div class="NAVHEADER"> <table width="100%" border="0" bgcolor="#ffffff" cellpadding= "1" cellspacing="0"> <tr> <th colspan="4" align="center"> <font color="#000000" size="2">GTK+ / Gnome Application Development</font> </th> </tr> <tr> <td width="25%" bgcolor="#ffffff" align="left"> <a href="sec-gnomeuiinfo.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="sec-help.html"><font color="#0000ff" size="2"> <b>Next >>></b></font></a> </td> </tr> </table> </div> <div class="SECT1"> <h1 class="SECT1"> <a name="Z91">Adding a Status Bar</a> </h1> <p> Adding a status bar is simple enough. Simply call the aptly-named <tt class="FUNCTION"> gnome_app_set_statusbar</tt> function (<a href= "z91.html#FL-SETSTATUSBAR">Figure 5</a>) with your statusbar widget as the second argument. </p> <p> However, there are some additional things to keep in mind. First, you can use either <tt class="CLASSNAME"> GtkStatusbar</tt> or <tt class="CLASSNAME">GnomeAppBar</tt> as a statusbar. Second, you probably want to use the statusbar to display help about menu items as the user moves over them; Gnome comes with convenience functions to do this. This section describes the two status bar widgets; <a href="sec-help.html">the section called <i>Online Help</i></a> discusses using the statusbar to display menu item help. </p> <div class="FIGURE"> <a name="FL-SETSTATUSBAR"></a> <div class="FUNCSYNOPSIS"> <a name="FL-SETSTATUSBAR.SYNOPSIS"></a> <table border="0" bgcolor="#E0E0E0" width="100%"> <tr> <td><pre class="FUNCSYNOPSISINFO">#include <libgnomeui/gnome-app.h></pre> </td> </tr> </table> <p> <code><code class="FUNCDEF">void <tt class="FUNCTION"> gnome_app_set_statusbar</tt></code>(GnomeApp* <tt class="PARAMETER"><i>app</i></tt>, GtkWidget* <tt class="PARAMETER"><i>statusbar</i></tt>);</code> </p> </div> <p> <b>Figure 5. Installing a Statusbar</b> </p> </div> <div class="SECT2"> <h2 class="SECT2"> <a name="SEC-APPBAR"><tt class="CLASSNAME"> GnomeAppBar</tt></a> </h2> <p> There's no real reason to prefer <tt class="CLASSNAME"> GnomeAppBar</tt> or <tt class="CLASSNAME"> GtkStatusbar</tt>; they simply have different APIs. The <tt class="CLASSNAME">GnomeAppBar</tt> widget was written later, with several goals in mind: </p> <ul> <li> <p> To simplify the <tt class="CLASSNAME"> GtkStatusbar</tt> API. </p> </li> <li> <p> To support an optional progress bar next to the status bar, similar to Netscape's. </p> </li> <li> <p> Eventual support for "interactive" use in the tradition of the Emacs "minibuffer." This is unfinished in Gnome 1.0, however. </p> </li> </ul> <p> To create a <tt class="CLASSNAME">GnomeAppBar</tt>, use <tt class="FUNCTION">gnome_appbar_new()</tt> (<a href= "z91.html#FL-APPBARNEW">Figure 6</a>). The constructor lets you configure the capabilities of <tt class= "CLASSNAME">GnomeAppBar</tt>: it can have a progress bar (or not), have a status text area (or not), and be interactive (or not). You must have either a status text area or a progress bar. <span class="STRUCTNAME"> GnomePreferencesType</span> is a kind of extended boolean value: </p> <ul> <li> <p> <span class="STRUCTNAME"> GNOME_PREFERENCES_NEVER</span> means the bar is never interactive. </p> </li> <li> <p> <span class="STRUCTNAME"> GNOME_PREFERENCES_USER</span> means the bar is interactive if the user has activated that feature as a Gnome-wide preference. </p> </li> <li> <p> <span class="STRUCTNAME"> GNOME_PREFERENCES_ALWAYS</span> means the bar is always interactive. </p> </li> </ul> <p> In Gnome 1.0, interactivity is incompletely implemented; so avoid <span class="STRUCTNAME"> GNOME_PREFERENCES_ALWAYS</span>. There are some experimental Gnome functions which provide an abstraction of certain user interactions, allowing users to choose between dialogs and the Emacs-style minibuffer approach; when these are more developed, <span class="STRUCTNAME"> GNOME_PREFERENCES_USER</span> will make sense even if you don't explicitly use the interactivity. So <span class= "STRUCTNAME">GNOME_PREFERENCES_USER</span> is the recommended setting. </p> <div class="FIGURE"> <a name="FL-APPBARNEW"></a> <div class="FUNCSYNOPSIS"> <a name="FL-APPBARNEW.SYNOPSIS"></a> <table border="0" bgcolor="#E0E0E0" width="100%"> <tr> <td><pre class="FUNCSYNOPSISINFO">#include <libgnomeui/gnome-appbar.h></pre> </td> </tr> </table> <p> <code><code class="FUNCDEF">GtkWidget* <tt class= "FUNCTION">gnome_appbar_new</tt></code>(gboolean <tt class="PARAMETER"><i>has_progress</i></tt>, gboolean <tt class="PARAMETER"><i>has_status</i></tt>, GnomePreferencesType <tt class="PARAMETER"><i> interactivity</i></tt>);</code> </p> </div> <p> <b>Figure 6. <tt class="CLASSNAME">GnomeAppBar</tt> Constructor</b> </p> </div> <p> Using a <span class="STRUCTNAME">GnomeAppBar</span> is simple. The progress-bar element presents a <tt class= "CLASSNAME">GtkProgress</tt> interface; to use it, simply extract the <tt class="CLASSNAME">GtkProgress</tt> with <tt class="FUNCTION">gnome_appbar_get_progress()</tt> (<a href="z91.html#FL-APPBARPROGRESS">Figure 7</a>) and use the <tt class="CLASSNAME">GtkProgress</tt> functions. Note that you should not make assumptions about the particular subclass of <tt class="CLASSNAME"> GtkProgress</tt>; in particular, do not cast it to <tt class="CLASSNAME">GtkProgressBar</tt>. </p> <div class="FIGURE"> <a name="FL-APPBARPROGRESS"></a> <div class="FUNCSYNOPSIS"> <a name="FL-APPBARPROGRESS.SYNOPSIS"></a> <table border="0" bgcolor="#E0E0E0" width="100%"> <tr> <td><pre class="FUNCSYNOPSISINFO">#include <libgnomeui/gnome-appbar.h></pre> </td> </tr> </table> <p> <code><code class="FUNCDEF">GtkProgress* <tt class= "FUNCTION"> gnome_appbar_get_progress</tt></code>(GnomeAppBar* <tt class="PARAMETER"><i>appbar</i></tt>);</code> </p> </div> <p> <b>Figure 7. Extracting <span class="STRUCTNAME"> GtkProgress</span></b> </p> </div> <p> Status texts are stored in a stack; when the bar is refreshed, the top item of the stack is displayed. The bar is refreshed anytime you manipulate the stack. So pushing some text onto the status stack will display that text. </p> <p> There are two other sources for the status text. You can set some "default" text; this is displayed if the stack is empty. The default default text is <span class= "STRUCTNAME">""</span>. You can also set the status text without changing the stack; this "transient" text is immediately displayed, but not stored. On the next
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -