Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Gtk+/Gnome Application Development
Prev Home Next

Gnome Application Basics

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.

Gtk+/Gnome Application Development
Prev Home Next

 
 
  Published under free license. Design by Interspire