?? cha-startup.html
字號:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html> <head> <title> Gnome Application Basics </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="Building a Gnome Application" href= "build-app.html"> <link rel="PREVIOUS" title="Installing Support Files" href= "z72.html"> <link rel="NEXT" title="Internationalization" href= "sec-i18n.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="z72.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-i18n.html"><font color="#0000ff" size="2"> <b>Next >>></b></font></a> </td> </tr> </table> </div> <div class="CHAPTER"> <h1> <a name="CHA-STARTUP">Gnome Application Basics</a> </h1> <div class="TOC"> <dl> <dt> <b>Table of Contents</b> </dt> <dt> <a href="cha-startup.html#Z76">Initializing the Libraries</a> </dt> <dt> <a href="sec-i18n.html">Internationalization</a> </dt> <dt> <a href="z77.html">Argument Parsing with <tt class= "APPLICATION">popt</tt></a> </dt> <dt> <a href="z79.html">Saving Configuration Information</a> </dt> <dt> <a href="sec-sessionmanagement.html">Session Management</a> </dt> </dl> </div> <p> This chapter describes the most rudimentary aspects of a Gnome application, including initializing the libraries, marking strings for translation, parsing command line arguments, saving configuration files, and responding to requests from the session manager. From here on, the book assumes you know how to write a simple GTK+-only application. </p> <div class="SECT1"> <h1 class="SECT1"> <a name="Z76">Initializing the Libraries</a> </h1> <p> On startup, your application must initialize the GTK+ and Gnome libraries with a call to <tt class="FUNCTION"> gnome_init()</tt>. <tt class="FUNCTION">gnome_init()</tt> (<a href="cha-startup.html#FL-GNOMEINIT">Figure 1</a>) takes the place of <tt class="FUNCTION">gtk_init()</tt> for Gnome apps (it calls <tt class="FUNCTION"> gtk_init()</tt> for you). </p> <p> The first argument to <tt class="FUNCTION"> gnome_init()</tt> is a short name for your application, and the second is a string representing the application's version. These are used internally by the Gnome libraries (in some default messages provided by the argument parser, for example). </p> <div class="FIGURE"> <a name="FL-GNOMEINIT"></a> <div class="FUNCSYNOPSIS"> <a name="FL-GNOMEINIT.SYNOPSIS"></a> <table border="0" bgcolor="#E0E0E0" width="100%"> <tr> <td><pre class="FUNCSYNOPSISINFO">#include <libgnomeui/gnome-init.h></pre> </td> </tr> </table> <p> <code><code class="FUNCDEF">int <tt class="FUNCTION"> gnome_init</tt></code>(const char* <tt class= "PARAMETER"><i>app_id</i></tt>, const char* <tt class="PARAMETER"><i>app_version</i></tt>, int <tt class="PARAMETER"><i>argc</i></tt>, char** <tt class= "PARAMETER"><i>argv</i></tt>);</code> </p> </div> <p> <b>Figure 1. Initializing Gnome</b> </p> </div> <p> Like <tt class="FUNCTION">gtk_init()</tt>, <tt class= "FUNCTION">gnome_init()</tt> parses the command-line arguments; unlike <tt class="FUNCTION">gtk_init()</tt>, it will not change <span class="STRUCTNAME">argc</span> and <span class="STRUCTNAME">argv</span>. If you want to parse application-specific options, you should use <tt class="FUNCTION">gnome_init_with_popt_table()</tt>, described in the next section. </p> <p> The return value from <tt class="FUNCTION"> gnome_init()</tt> is supposed to be non-zero if initialization fails, but the current implementation always returns 0. (<tt class="FUNCTION">gnome_init()</tt> will simply abort if there's a problem, such as a missing X server.) Common practice is to ignore this return value, at least in Gnome 1.0, but it's a good idea to check it anyway in case future versions do return an error. </p> <p> [FOOTNOTE - reference after "always returns 0."] Most people consider this a misfeature, but <tt class= "FUNCTION">gtk_init()</tt> shared the same problem until just before Gnome 1.0, so there was little to be done. Future versions will hopefully fix the problem. </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="z72.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-i18n.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>Installing Support Files</b></font> </td> <td colspan="2" align="right"> <font color="#000000" size="2"><b> Internationalization</b></font> </td> </tr> </table> </div> </body></html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -