Hello, I thought I would mail around a little Tip for everyone. This is
very basic but also very useful. I will show how to construct a Help |
About dialog to give information about yourself and the software that is
normally left until last, or never done at all. The GnomeAbout widget
makes the creation of such a dialog ridiculously easy.
I am using the GLib data types in here, but if you would prefer, then you
can just use the standard C datatypes instead.
The basic prototype of a GnomeAbout widget looks like this:
GtkWidget *gnome_about_new (const gchar *title, const gchar *version,
const gchar *copyright, const gchar *authors, const gchar *comments, const
gchar *logo);
I will give an example bit of code below. I haven't set up anything
useful, it justs shows the About dialog on the screen, but I hope you can
implement it in your code. Plugging into menus is a different issue, but
you probably wouldn't be developing an application unless you knew how to
create menus. Maybe that can be covered next:
/*-------------Cut Here----------*/
#include <gnome.h>
const gchar *authors[] = {"Andrew Polshaw", "Mr. Belpit", NULL};
const gchar *id[] = {"AboutDialog"};
void CloseApp(GtkWidget *window, gpointer data)
{
gtk_main_quit();
}
gint main (gint argc, gchar *argv[])
{
GtkWidget *about;
gnome_init(id, "1.0", argc, argv);
/* This creates the dialog */
about = gnome_about_new("Groovy Program", "1.0", "(c) P2P", (const gchar
**) authors, "A really simple example of how to use GnomeAbout", NULL);
gtk_signal_connect(GTK_OBJECT(about), "destroy",
GTK_SIGNAL_FUNC(CloseApp), NULL);
gtk_widget_show(about);
gtk_main();
return 0;
}
/*----------Cut Here--------------*/
I hope you can use this in any of your applications.