aboutdialog

About widget, is very common, and found in all GUI based programs,
under the help menu.
If you want to use an about dialog in your program, you can use
this aboutdialog.

The about dialog box, shows the authors, translators, version,
copyrights, and license etc, of your program. Its a very handy
tool, and can save you lots of time if youre keen on implementing
one.

First create this dialog box, and set its properties using
the acessor methods.

The properties are listed as "name","type", 
eg: name,gchararray, which means, the property
'name', should have a value that is of type gchararray [i.e a char pointer].

The various properties of dialog boxes, are,
{logo,GdkPixbuf
logo-icon-name,gchararray
website,gchararray
authors,GStrv
documenters,GStrv
translators,gchararray
license,gchararray
comments,gchararray
copyright,gchararray
version,gchararray
name,gchararray
}

The API functions for aboutdialog go like this.

	gtk_about_dialog_get_$(PROPERTY)
		and friends are functions, that retireve properties values
		of property $(PROPERTY)
	
	gtk_about_dialog_set_$(PROPERTY)
		and friends are functions, that assign properties values
		of property $(PROPERTY)

You can create a aboutdialog using
	gtk_about_dialog_new()
and set/get properties using the various functions shown above.
Generally property get/set functions are called as accessors.

One very useful function to create an about dialog, and show it is
void gtk_show_about_dialog
	 (GtkWindow       *parent,
	 const gchar     *first_property_name,
	...);

	This saves developer time, and is a one-stop widget, creation,
	show API.

	
Example:
{	
As experienced GObject users know, you may instantiate types
using the syntax like this.
	
		about = g_object_new(GTK_TYPE_ABOUT_DIALOG,
		"name",               name,
		"version",            version,
		"copyright",          copyright,
		"comments",           comments,
		"authors",            authors,
		"documenters",        documenters,
		"translator_credits", translator_credits,
		"logo",               logo,
	        "website", website,
	        "license", "GNU GPL-2.0",
		NULL);
		gtk_dialog_run(GTK_DIALOG(about));


A clear usage of the about dialog is found in this, code which uses,
gtk_show_about_dialog, to create, show and destroy the dialog
widget.

/* Code taken from eccvs2, http://eccvs.sf.net/ */

void about_action_cb (GtkAction* action)
{
	gchar* authors[] = { "Santhosh Kumar ", 
			     "Sameema ", 
			     "Karthikeyan ", NULL };
	gchar* artists[] = { "Gnanasambantham ",
			     "Sakthivel ",
			     "Chinnusamy ", NULL };
	gchar* comments = { "eccvs is a simple version control system" };
	gchar* copyright = { "Copyright (c) Santhosh Kumar, Sameema, Karthikeyan" };
	gchar* documenters[] = { "Sameema ",
				 "Santhosh Kumar ",
				NULL };	
	static GdkPixbuf* logo;
	gchar* name = PACKAGE;
	gchar* version = VERSION;
	gchar* website = "http://eccvs.sourceforge.net";
	gchar* website_label = "eccvs website";

	if (!logo) {
		GError* error = NULL;
		logo = gdk_pixbuf_new_from_file (ECCVS_ICONS_DIR "/eccvs-logo.jpg", &error);
		if (error) {
			g_warning ("Unable to load eccvs logo: %s\n", error->message);
			g_error_free (error);
		}
	}
	
	gtk_show_about_dialog (app->window,
				 "authors", authors, 
				"artists", artists,
				"comments", comments, "copyright", copyright, 
				"documenters", documenters, "logo", logo, "name", 
				 name, "version", version, "website", website, 
				"website-label", website_label, NULL);
}

}


After creating an  about dialog box, you may, choose to show
this using gtk_dialog_run(), which will actually run the dialog
widget.

Image: 

see also: dialog,



Last Modified on Fri Jul 1 19:51:33 IST 2005
This is part of the GtkBook project Hosted Here
This code, documents and images are © Muthiah Annamalai
This document is under Creative Commons License given by LICENSE