widget-factory: add an about dialog

This is a first step towards making widget-factory an installed
demo.
This commit is contained in:
Matthias Clasen 2012-02-09 07:57:11 -05:00
parent bc95f03f37
commit b4c31b070f
2 changed files with 30 additions and 1 deletions

View File

@ -22,6 +22,7 @@
*
*/
#include "config.h"
#include <gtk/gtk.h>
static void
@ -35,6 +36,30 @@ dark_toggled (GtkCheckMenuItem *item, gpointer data)
NULL);
}
static void
show_about (GtkMenuItem *item, GtkWidget *window)
{
const gchar *authors[] = {
"Andrea Cimitan",
"Cosimo Cecchi"
};
gtk_show_about_dialog (GTK_WINDOW (window),
"program-name", "GTK+ Widget Factory",
"version", g_strdup_printf ("%s,\nRunning against GTK+ %d.%d.%d",
PACKAGE_VERSION,
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ()),
"copyright", "(C) 1997-2009 The GTK+ Team",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to demonstrate GTK+ themes and widgets",
"authors", authors,
"title", "About GTK+ Widget Factory",
NULL);
}
int
main (int argc, char *argv[])
{
@ -58,6 +83,9 @@ main (int argc, char *argv[])
g_signal_connect (widget, "toggled", G_CALLBACK (dark_toggled), NULL);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), dark);
widget = (GtkWidget*) gtk_builder_get_object (builder, "aboutmenuitem");
g_signal_connect (widget, "activate", G_CALLBACK (show_about), window);
g_object_unref (G_OBJECT (builder));
gtk_widget_show (window);

View File

@ -54,6 +54,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
<object class="GtkAccelGroup" id="accelgroup1"/>
<object class="GtkWindow" id="window">
<property name="can_focus">False</property>
<property name="title">GTK+ Widget Factory</property>
<signal name="destroy" handler="gtk_main_quit" swapped="no"/>
<signal name="delete-event" handler="gtk_false" swapped="no"/>
<child>
@ -390,7 +391,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem10">
<object class="GtkImageMenuItem" id="aboutmenuitem">
<property name="label">gtk-about</property>
<property name="visible">True</property>
<property name="can_focus">False</property>