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

📄 faqs.html

📁 gtk_text program sample&eg
💻 HTML
📖 第 1 页 / 共 4 页
字号:
        </div>        <div class="SECT2">          <h2 class="SECT2">            <a name="Z853">I want to use the arrow keys as a            control in my application, but GTK+ keeps stealing the            key press events to move the focus around.</a>          </h2>          <p>            Key press handling is somewhat complex. You might want            to read <a href="sec-gdkevent.html#SEC-GDKKEYFOCUS">the            section called <i>Keyboard Focus</i> in the chapter            called <i>GDK Basics</i></a> and <a href=             "z57.html#SEC-FOCUSWIDGET">the section called <i>            Focus</i> in the chapter called <i>GTK+ Basics</i></a>            for a brief overview. <a href=             "sec-gdkevent.html#SEC-GTKEVENTS">the section called            <i>Receiving GDK Events in GTK+</i> in the chapter            called <i>GDK Basics</i></a> is also relevant.          </p>          <p>            In short, key events are initially received by a            toplevel <tt class="CLASSNAME">GtkWindow</tt>. GTK+'s            key event behavior is more or less defined by default            key press event handler in <tt class="FILENAME">            gtkwindow.c</tt> (looking at this function is            instructive). It works as follows:          </p>          <ul>            <li>              <p>                If there's a focus widget, the key event signal is                emitted on the focus widget. If this emission                returns <span class="STRUCTNAME">TRUE</span>, as                described in <a href=                 "sec-gdkevent.html#SEC-GTKEVENTS">the section                called <i>Receiving GDK Events in GTK+</i> in the                chapter called <i>GDK Basics</i></a>, processing                stops.&#13;              </p>            </li>            <li>              <p>                If any of the accelerator groups attached to the                window contain an accelerator matching the event,                then processing stops.&#13;              </p>            </li>            <li>              <p>                If the key event hasn't been handled yet, there are                some default bindings; the arrow keys move the                focus around, for example.&#13;              </p>            </li>          </ul>          <p>            Thus, to override the arrow key behavior, you can            return <span class="STRUCTNAME">TRUE</span> from the            focus widget's signal emission, install an accelerator            for the arrow keys, or connect to <span class="SYMBOL">            "key_press_event"</span> on the toplevel window and use            <tt class="FUNCTION">            gtk_signal_emit_stop_by_name()</tt> to end the signal            emission before the <tt class="CLASSNAME">            GtkWindow</tt> default handler runs.          </p>        </div>        <div class="SECT2">          <h2 class="SECT2">            <a name="Z854">Does GTK+ have multiple inheritance?</a>          </h2>          <p>            No, but "interfaces" (in Java terms) or "pure virtual            classes" (in C++ terms) are planned for the next            version. See <a href="z144.html#SEC-OVERRIDESIGNALS">            the section called <i>Overridable Signals</i> in the            chapter called <i>Writing a <tt class="CLASSNAME">            GtkWidget</tt></i></a> for a discussion of an ugly            workaround used in <tt class="CLASSNAME">GtkWidget</tt>            to create "activatable" and "scrollable" interfaces.          </p>        </div>        <div class="SECT2">          <h2 class="SECT2">            <a name="Z855">I'm getting error messages from GDK. How            can I determine the cause of these?</a>          </h2>          <p>            First, run your program with the <tt class=            "APPLICATION">--sync</tt> option. This invokes <tt            class="FUNCTION">XSynchronize()</tt> to turn off event            buffering; it slows down the application, but causes            errors to be reported as soon as they occur.            Alternatively, some Xlib implementations let you turn            on synchronization by setting the global variable <span            class="STRUCTNAME">_Xdebug</span> to <span class=             "STRUCTNAME">TRUE</span> in a debugger.          </p>          <p>            Once errors are being reported synchronously, just run            your app in a debugger and wait for <tt class=            "FUNCTION">abort()</tt> to be called. For warnings, set            a breakpoint at <tt class="FUNCTION">g_logv()</tt>            which is the function called by the <tt class=            "FUNCTION">g_warning()</tt> macro.          </p>        </div>        <div class="SECT2">          <h2 class="SECT2">            <a name="Z856">How do I update the GUI without            returning control to the main loop?</a>          </h2>          <p>            Just do this:          </p>          <table border="0" bgcolor="#E0E0E0" width="100%">            <tr>              <td><pre class="PROGRAMLISTING">&#13; while (gtk_events_pending())   gtk_main_iteration();&#13;</pre>              </td>            </tr>          </table>          <p>            This code will handle all pending events, then return            control to you. You can also run nested instances of            <tt class="FUNCTION">gtk_main()</tt>; each call to <tt            class="FUNCTION">gtk_main_quit()</tt> exits one            instance. <tt class="FUNCTION">gnome_dialog_run()</tt>            uses this technique to block waiting for user input.          </p>        </div>        <div class="SECT2">          <h2 class="SECT2">            <a name="Z857">How should I format code to be included            in GTK+ or Gnome?</a>          </h2>          <p>            The GTK+ coding style is basically the GNU coding style            (<a href="http://www.gnu.org/prep/standards_toc.html"            target=            "_top">http://www.gnu.org/prep/standards_toc.html</a>).            The Gnome libraries are less consistent, but lean            toward the Linux kernel coding style (documented in <tt            class="FILENAME">            /usr/src/linux/Documentation/CodingStyle</tt> on many            Linux systems).          </p>          <p>            The GTK+ style uses two-space indentation, puts all            braces on a new line, and leaves one space between            identifiers and opening parentheses, like this:          </p>          <table border="0" bgcolor="#E0E0E0" width="100%">            <tr>              <td><pre class="PROGRAMLISTING">&#13;if (whatever)  {    foo (arg1, arg2);  }&#13;</pre>              </td>            </tr>          </table>          <p>            Emacs uses this style by default.          </p>          <p>            The Gnome style uses eight-space indentation and            Kernighan and Ritchie braces, like so:          </p>          <table border="0" bgcolor="#E0E0E0" width="100%">            <tr>              <td><pre class="PROGRAMLISTING">&#13;if (whatever) {        foo (arg1, arg2); }&#13;</pre>              </td>            </tr>          </table>          <p>            It also leaves a space between identifiers and opening            parentheses. To make Emacs use the Gnome style, add a            line like this to the top of your source files:          </p>          <table border="0" bgcolor="#E0E0E0" width="100%">            <tr>              <td><pre class="PROGRAMLISTING">&#13;/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 c-style: "K&amp;R" -*- */&#13;</pre>              </td>            </tr>          </table>          <p>            When preparing a patch for any piece of free software,            it's polite the style of the preexisting code. It's            customary to include a file called <tt class=            "FILENAME">HACKING</tt> in source code distributions            addressing this and similar issues; read it if it            exists.          </p>        </div>        <div class="SECT2">          <h2 class="SECT2">            <a name="Z858">Is there a GUI builder for GTK+ and            Gnome?</a>          </h2>          <p>            A very promising GUI builder called Glade is being            developed. Glade can generate source code in several            languages, or an XML description of your widgets. An            add-on module called <tt class="APPLICATION">            libglade</tt> loads these XML descriptions at runtime            and creates the described widgets. The next release of            the Gnome libraries will very likely include or require            <tt class="APPLICATION">libglade</tt>.          </p>        </div>        <div class="SECT2">          <h2 class="SECT2">            <a name="Z859">How well do GTK+ and Gnome support            internationalization?</a>          </h2>          <p>            GTK+ 1.2 supports most European and Asian languages.            GDK contains an API for loading fontsets and rendering            multibyte strings, though this book does not cover it.            The stock GTK+ widgets that handle text use this API            and will deal with multibyte strings correctly. GTK+            also supports input methods for Asian languages. GTK+            1.2 does <i class="EMPHASIS">not</i> support            right-to-left scripts, or scripts that require complex            ligatures and unusual line breaks. However, support for            these languages is a high priority for GTK+ 1.4. For            details on future plans, Owen Taylor's white paper at            <a href=            "http://developer.gnome.org/doc/whitepapers/gtki18n/"            target="_top">            http://developer.gnome.org/doc/whitepapers/gtki18n/</a> is            an excellent resource.          </p>          <p>            Both GTK+ and Gnome use the <tt class="APPLICATION">            gettext</tt> message catalog system to translate            user-visible strings, so any string the toolkit knows            how to render can be translated into foreign languages.            <a href="sec-i18n.html">the section called <i>            Internationalization</i> in the chapter called <i>Gnome            Application Basics</i></a> covers this topic.          </p>        </div>      </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="headers.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="online.html"><font color="#0000ff" size="2">            <b>Next &gt;&gt;&gt;</b></font></a>          </td>        </tr>        <tr>          <td colspan="2" align="left">            <font color="#000000" size="2"><b>Table of Header            Files</b></font>          </td>          <td colspan="2" align="right">            <font color="#000000" size="2"><b>Online            Resources</b></font>          </td>        </tr>      </table>    </div>  </body></html>

⌨️ 快捷键说明

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