Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.sao.ru/cats/~satr/GGAD/cha-startup.html
Дата изменения: Wed Jul 12 23:54:24 2000
Дата индексирования: Tue Oct 2 02:06:18 2012
Кодировка:

Поисковые слова: п п п п п п п п р п р п р п р п
Gnome Application Basics

Gnome Application Basics

Table of Contents
Initializing the Libraries
Internationalization
Argument Parsing with popt
Saving Configuration Information
Session Management

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.

Initializing the Libraries

On startup, your application must initialize the GTK+ and Gnome libraries with a call to gnome_init(). gnome_init() (Figure 1) takes the place of gtk_init() for Gnome apps (it calls gtk_init() for you).

The first argument to gnome_init() 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).

#include <libgnomeui/gnome-init.h>

int gnome_init(const char* app_id, const char* app_version, int argc, char** argv);

Figure 1. Initializing Gnome

Like gtk_init(), gnome_init() parses the command-line arguments; unlike gtk_init(), it will not change argc and argv. If you want to parse application-specific options, you should use gnome_init_with_popt_table(), described in the next section.

The return value from gnome_init() is supposed to be non-zero if initialization fails, but the current implementation always returns 0. (gnome_init() 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.

[FOOTNOTE - reference after "always returns 0."] Most people consider this a misfeature, but gtk_init() shared the same problem until just before Gnome 1.0, so there was little to be done. Future versions will hopefully fix the problem.