gtk/demos/gtk-demo/builder.c
Johan Dahlin 12b46f84bf Move the about dialog to the glade file, add accessible tags examples to
2008-01-29  Johan Dahlin  <johan@gnome.org>

	* demos/gtk-demo/builder.c: (quit_activate), (about_activate),
	(do_builder):
	* demos/gtk-demo/demo.ui:
	Move the about dialog to the glade file, add accessible tags
	examples to the markup file.


svn path=/trunk/; revision=19426
2008-01-29 14:12:08 +00:00

69 lines
1.4 KiB
C

/* Builder
*
* Demonstrates an interface loaded from a XML description.
*/
#include <gtk/gtk.h>
#include "demo-common.h"
static GtkBuilder *builder;
void
quit_activate (GtkAction *action)
{
GtkWidget *window;
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
gtk_widget_destroy (window);
}
void
about_activate (GtkAction *action)
{
GtkWidget *about_dlg;
about_dlg = GTK_WIDGET (gtk_builder_get_object (builder, "aboutdialog1"));
gtk_dialog_run (GTK_DIALOG (about_dlg));
gtk_widget_hide (about_dlg);
}
GtkWidget *
do_builder (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
GError *err = NULL;
gchar *filename;
if (!window)
{
builder = gtk_builder_new ();
filename = demo_find_file ("demo.ui", NULL);
gtk_builder_add_from_file (builder, filename, &err);
g_free (filename);
if (err)
{
g_error ("ERROR: %s\n", err->message);
return NULL;
}
gtk_builder_connect_signals (builder, NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
gtk_window_set_screen (GTK_WINDOW (window),
gtk_widget_get_screen (do_widget));
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
}
if (!GTK_WIDGET_VISIBLE (window))
{
gtk_widget_show_all (window);
}
else
{
gtk_widget_destroy (window);
window = NULL;
}
return window;
}