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

📄 cha-dialogs-special.html

📁 GTK+_ Gnome Application Development
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>  <head>    <title>      Special Dialog Types    </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="User Communication: Dialogs" href=     "cha-dialogs.html">    <link rel="PREVIOUS" title="A Dialog Example" href="z101.html">    <link rel="NEXT" title="Convenience Routines" href=     "sec-dialogs-convenience.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="z101.html"><font color="#0000ff" size="2"><b>            &lt;&lt;&lt; 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-dialogs-convenience.html"><font color=             "#0000ff" size="2"><b>Next &gt;&gt;&gt;</b></font></a>          </td>        </tr>      </table>    </div>    <div class="SECT1">      <h1 class="SECT1">        <a name="CHA-DIALOGS-SPECIAL">Special Dialog Types</a>      </h1>      <p>        This section describes some special kinds of dialog that        exist for your convenience, and for UI consistency. Of        course nearly everything said so far about <tt class=         "CLASSNAME">GnomeDialog</tt> also applies to its        subclasses.      </p>      <div class="SECT2">        <h2 class="SECT2">          <a name="SEC-GNOMEABOUT"><tt class="CLASSNAME">          GnomeAbout</tt></a>        </h2>        <p>          Gnome applications should have an "About Foo" menu item          which displays this widget (where "Foo" is the name of          your application). Using it is ridiculously easy; there's          only one function involved, <tt class="FUNCTION">          gnome_about_new()</tt> (<a href=           "cha-dialogs-special.html#FL-ABOUT">Figure 7</a>). The          arguments are, respectively: the title of your          application, the version of your application, a one-line          copyright notice, a <span class="STRUCTNAME">          NULL</span>-terminated vector of author's names, a short          paragraph saying anything you want to say, and an image          filename to display as your application's logo. Only the          <span class="STRUCTNAME">authors</span> argument is          required; the others can be <span class="STRUCTNAME">          NULL</span>, but your dialog will look fairly strange if          all of them are.        </p>        <div class="FIGURE">          <a name="FL-ABOUT"></a>          <div class="FUNCSYNOPSIS">            <a name="FL-ABOUT.SYNOPSIS"></a>            <table border="0" bgcolor="#E0E0E0" width="100%">              <tr>                <td><pre class="FUNCSYNOPSISINFO">       #include &lt;libgnomeui/gnome-about.h&gt;      </pre>                </td>              </tr>            </table>            <p>              <code><code class="FUNCDEF">GtkWidget* <tt class=               "FUNCTION">gnome_about_new</tt></code>(const gchar*              <tt class="PARAMETER"><i>title</i></tt>, const gchar*              <tt class="PARAMETER"><i>version</i></tt>, const              gchar* <tt class="PARAMETER"><i>copyright</i></tt>,              const gchar** <tt class="PARAMETER"><i>              authors</i></tt>, const gchar* <tt class="PARAMETER">              <i>comments</i></tt>, const gchar* <tt class=               "PARAMETER"><i>logo</i></tt>);</code>            </p>          </div>          <p>            <b>Figure 7. <tt class="CLASSNAME">GnomeAbout</tt></b>          </p>        </div>        <p>          <tt class="CLASSNAME">GnomeAbout</tt> automatically          closes when clicked, so you don't really need to worry          about it; just create and show the dialog. Remember to          ensure only one instance exists at any given time, as          explained in <a href=          "cha-dialogs.html#SEC-DIALOGS-TOUCHES">the section called          <i>Finishing Touches</i></a>.        </p>        <p>          Here's a menu item callback to show an about dialog, from          the Gnome calendar application:        </p>        <table border="0" bgcolor="#E0E0E0" width="100%">          <tr>            <td><pre class="PROGRAMLISTING">&#13;static voidabout_calendar_cmd (GtkWidget *widget, void *data){   GtkWidget *about;   const gchar *authors[] = {     "Miguel de Icaza &lt;miguel@kernel.org&gt;",     "Federico Mena &lt;federico@gimp.org&gt;",     "Arturo Espinosa &lt;arturo@nuclecu.unam.mx&gt;",     NULL   };   about = gnome_about_new (_("Gnome Calendar"), VERSION,                            "(C) 1998 the Free Software Foundation",                            authors,                            _("The GNOME personal calendar and schedule manager."),                            NULL);   gtk_window_set_modal (GTK_WINDOW (about), TRUE);   gtk_widget_show (about);}      </pre>            </td>          </tr>        </table>        <p>          Note that the authors give both their name and email          address; that way people can use the dialog to decide          where to send hate mail and bug reports. (Or thank you          notes!) The <tt class="FUNCTION">VERSION</tt> macro comes          from <tt class="FILENAME">config.h</tt>, and is defined          by <tt class="FILENAME">configure</tt>. The Gnome          Calendar authors chose to prevent multiple dialog          instances by making the dialog modal---the user can't          re-select the menu item while the dialog is open. It is          probably better to use the technique described in <a          href="cha-dialogs.html#SEC-DIALOGS-TOUCHES">the section          called <i>Finishing Touches</i></a>, so the dialog is          deiconified and raised if the user reselects the menu          item.        </p>      </div>      <div class="SECT2">        <h2 class="SECT2">          <a name="SEC-PROPERTYBOX"><tt class="CLASSNAME">          GnomePropertyBox</tt></a>        </h2>        <p>          <tt class="CLASSNAME">GnomePropertyBox</tt> is used for          application preferences, or to edit the properties of a          user-visible object. It's a dialog with a <tt class=           "CLASSNAME">GtkNotebook</tt> inside, and four buttons:          "OK," "Apply," "Close," and "Help." The "OK" button is          equivalent in all respects to clicking "Apply" followed          by "Close." "Apply" should immediately make any changes          the user has requested using the widgets you've placed in          the <tt class="CLASSNAME">GnomePropertyBox</tt>.          Unsurprisingly, "Help" should display help. "OK" and          "Close" are handled automatically by the property box, so          you can ignore them.        </p>        <p>          You don't need to deal with the property box's buttons          directly; instead <tt class="CLASSNAME">          GnomePropertyBox</tt> emits <span class="SYMBOL">          "apply"</span> and <span class="SYMBOL">"help"</span>          signals. Handlers for these should look like:        </p>        <table border="0" bgcolor="#E0E0E0" width="100%">          <tr>            <td><pre class="PROGRAMLISTING">&#13;void handler(GtkWidget* propertybox, gint page_num, gpointer data);      </pre>            </td>          </tr>        </table>        <p>          <span class="STRUCTNAME">page_num</span> is the          currently-active page of the <tt class="CLASSNAME">          GtkNotebook</tt> inside the dialog. (<tt class=          "CLASSNAME">GtkNotebook</tt> pages are numbered from          front to back, starting with 0; the front page is the          first one you add to the notebook.) For <span class=           "SYMBOL">"help"</span>, the page number lets you provide          context-sensitive help. When the user clicks the "Apply"          or "OK" button, the <span class="SYMBOL">"apply"</span>          signal is emitted once per page, then emitted a final          time with <span class="STRUCTNAME">-1</span> as the <span          class="STRUCTNAME">page_num</span> value. The multiple          emissions of <span class="SYMBOL">"apply"</span> are          something of an anachronism, because it has become de          facto standard behavior to simply apply all pages when          the <span class="STRUCTNAME">-1</span> page number is          received.        </p>        <p>          To create a property box, you first create the dialog,          then create each page and add it. Creating a <tt class=           "CLASSNAME">GnomePropertyBox</tt> is straightforward; <tt          class="FUNCTION">gnome_property_box_new()</tt> takes no          arguments.        </p>        <div class="FIGURE">          <a name="FL-PROPERTYBOX"></a>          <div class="FUNCSYNOPSIS">            <a name="FL-PROPERTYBOX.SYNOPSIS"></a>            <table border="0" bgcolor="#E0E0E0" width="100%">              <tr>                <td><pre class="FUNCSYNOPSISINFO">       #include &lt;libgnomeui/gnome-propertybox.h&gt;      </pre>                </td>

⌨️ 快捷键说明

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