summaryrefslogtreecommitdiff
path: root/tools/glade/examples
diff options
context:
space:
mode:
Diffstat (limited to 'tools/glade/examples')
-rw-r--r--tools/glade/examples/editor/AUTHORS1
-rw-r--r--tools/glade/examples/editor/ChangeLog44
-rw-r--r--tools/glade/examples/editor/Makefile.am30
-rw-r--r--tools/glade/examples/editor/NEWS0
-rw-r--r--tools/glade/examples/editor/README16
-rw-r--r--tools/glade/examples/editor/acconfig.h7
-rwxr-xr-xtools/glade/examples/editor/autogen.sh159
-rw-r--r--tools/glade/examples/editor/configure.in31
-rw-r--r--tools/glade/examples/editor/editor.glade492
-rw-r--r--tools/glade/examples/editor/editor.gladep8
-rw-r--r--tools/glade/examples/editor/po/ChangeLog0
-rw-r--r--tools/glade/examples/editor/po/POTFILES.in6
-rw-r--r--tools/glade/examples/editor/src/Makefile.am17
-rw-r--r--tools/glade/examples/editor/src/callbacks.c670
-rw-r--r--tools/glade/examples/editor/src/callbacks.h116
-rw-r--r--tools/glade/examples/editor/src/interface.c456
-rw-r--r--tools/glade/examples/editor/src/interface.h9
-rw-r--r--tools/glade/examples/editor/src/main.c56
-rw-r--r--tools/glade/examples/editor/src/support.c144
-rw-r--r--tools/glade/examples/editor/src/support.h67
20 files changed, 2329 insertions, 0 deletions
diff --git a/tools/glade/examples/editor/AUTHORS b/tools/glade/examples/editor/AUTHORS
new file mode 100644
index 00000000..f3b6641e
--- /dev/null
+++ b/tools/glade/examples/editor/AUTHORS
@@ -0,0 +1 @@
+Damon Chaplin <damon@gnome.org>
diff --git a/tools/glade/examples/editor/ChangeLog b/tools/glade/examples/editor/ChangeLog
new file mode 100644
index 00000000..21f50001
--- /dev/null
+++ b/tools/glade/examples/editor/ChangeLog
@@ -0,0 +1,44 @@
+2005-09-12 Damon Chaplin <damon@gnome.org>
+
+ * autogen.sh: don't use -path option of find, as Solaris doesn't have
+ it. (#301929)
+
+2003-10-10 Damon Chaplin <damon@gnome.org>
+
+ * src/callbacks.c (on_About_activate): make sure we only show one
+ About dialog. Patch from Steve Chaplin.
+
+2003-10-08 Damon Chaplin <damon@gnome.org>
+
+ * src/callbacks.c (on_main_window_delete_event): use exit() rather
+ than gtk_exit() which is now deprecated.
+
+2002-11-02 Damon Chaplin <damon@gnome.org>
+
+ * AUTHORS: and again. This is getting annoying!
+
+2001-04-20 Damon Chaplin <damon@ximian.com>
+
+ * AUTHORS: updated my email address.
+
+2000-09-23 Damon Chaplin <damon@helixcode.com>
+
+ * src/Makefile.am (bin_PROGRAMS): changed name to glade-editor rather
+ than glade_editor, which was output due to a bug in Glade.
+
+1999-06-29 Damon Chaplin <damon@karuna.freeserve.co.uk>
+
+ * src/callbacks.[hc]: renamed on_Quit_activate and on_Delete_activate
+ to on_Exit_activate and on_Clear_activate to match menus. 'Exit' and
+ 'Clear' are the standard Gnome menu items.
+
+ * Makefile.am (install-data-local): used $(srcdir) when installing
+ pixmaps.
+
+ * editor.glade: updated menubar to use underlined accelerator keys.
+ Added handlebox around menubar and toolbar, and set toolbar button
+ relief to None. (The handlebox doesn't seem to work too well - you
+ need to set the border width to 2 for the shadow to display properly.)
+ Set default window size of the main window to 600x450, reset the width
+ and height, and turned Shrink off.
+
diff --git a/tools/glade/examples/editor/Makefile.am b/tools/glade/examples/editor/Makefile.am
new file mode 100644
index 00000000..37b60f39
--- /dev/null
+++ b/tools/glade/examples/editor/Makefile.am
@@ -0,0 +1,30 @@
+## Process this file with automake to produce Makefile.in
+
+SUBDIRS = src po
+
+EXTRA_DIST = \
+ autogen.sh \
+ editor.glade \
+ editor.gladep
+
+install-data-local:
+ @$(NORMAL_INSTALL)
+ if test -d $(srcdir)/pixmaps; then \
+ $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/pixmaps; \
+ for pixmap in $(srcdir)/pixmaps/*; do \
+ if test -f $$pixmap; then \
+ $(INSTALL_DATA) $$pixmap $(DESTDIR)$(pkgdatadir)/pixmaps; \
+ fi \
+ done \
+ fi
+
+dist-hook:
+ if test -d pixmaps; then \
+ mkdir $(distdir)/pixmaps; \
+ for pixmap in pixmaps/*; do \
+ if test -f $$pixmap; then \
+ cp -p $$pixmap $(distdir)/pixmaps; \
+ fi \
+ done \
+ fi
+
diff --git a/tools/glade/examples/editor/NEWS b/tools/glade/examples/editor/NEWS
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tools/glade/examples/editor/NEWS
diff --git a/tools/glade/examples/editor/README b/tools/glade/examples/editor/README
new file mode 100644
index 00000000..7aaa9c6c
--- /dev/null
+++ b/tools/glade/examples/editor/README
@@ -0,0 +1,16 @@
+
+This is a simple example application built with Glade.
+
+It is a text editor, with standard commands to open and save files,
+cut/copy/paste text, and set the font.
+
+The signal handler code in src/callbacks.c has been commented to make it
+easy to understand how a Glade application is put together.
+
+It is not built normally as part of Glade. To build it, you must cd into the
+editor directory, remove the 'NO-AUTO-GEN' file, then run:
+
+./autogen.sh
+make
+
+Then run src/glade-editor.
diff --git a/tools/glade/examples/editor/acconfig.h b/tools/glade/examples/editor/acconfig.h
new file mode 100644
index 00000000..0a76fa0d
--- /dev/null
+++ b/tools/glade/examples/editor/acconfig.h
@@ -0,0 +1,7 @@
+#undef ENABLE_NLS
+#undef HAVE_CATGETS
+#undef HAVE_GETTEXT
+#undef GETTEXT_PACKAGE
+#undef HAVE_LC_MESSAGES
+#undef HAVE_STPCPY
+#undef HAVE_LIBSM
diff --git a/tools/glade/examples/editor/autogen.sh b/tools/glade/examples/editor/autogen.sh
new file mode 100755
index 00000000..9bbea2c0
--- /dev/null
+++ b/tools/glade/examples/editor/autogen.sh
@@ -0,0 +1,159 @@
+#!/bin/sh
+# Run this to generate all the initial makefiles, etc.
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+DIE=0
+
+if [ -n "$GNOME2_DIR" ]; then
+ ACLOCAL_FLAGS="-I $GNOME2_DIR/share/aclocal $ACLOCAL_FLAGS"
+ LD_LIBRARY_PATH="$GNOME2_DIR/lib:$LD_LIBRARY_PATH"
+ PATH="$GNOME2_DIR/bin:$PATH"
+ export PATH
+ export LD_LIBRARY_PATH
+fi
+
+(test -f $srcdir/configure.in) || {
+ echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
+ echo " top-level package directory"
+ exit 1
+}
+
+(autoconf --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: You must have \`autoconf' installed."
+ echo "Download the appropriate package for your distribution,"
+ echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
+ DIE=1
+}
+
+(grep "^AC_PROG_INTLTOOL" $srcdir/configure.in >/dev/null) && {
+ (intltoolize --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: You must have \`intltool' installed."
+ echo "You can get it from:"
+ echo " ftp://ftp.gnome.org/pub/GNOME/"
+ DIE=1
+ }
+}
+
+(grep "^AM_PROG_XML_I18N_TOOLS" $srcdir/configure.in >/dev/null) && {
+ (xml-i18n-toolize --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: You must have \`xml-i18n-toolize' installed."
+ echo "You can get it from:"
+ echo " ftp://ftp.gnome.org/pub/GNOME/"
+ DIE=1
+ }
+}
+
+(grep "^AM_PROG_LIBTOOL" $srcdir/configure.in >/dev/null) && {
+ (libtool --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: You must have \`libtool' installed."
+ echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/"
+ DIE=1
+ }
+}
+
+(grep "^AM_GLIB_GNU_GETTEXT" $srcdir/configure.in >/dev/null) && {
+ (grep "sed.*POTFILES" $srcdir/configure.in) > /dev/null || \
+ (glib-gettextize --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: You must have \`glib' installed."
+ echo "You can get it from: ftp://ftp.gtk.org/pub/gtk"
+ DIE=1
+ }
+}
+
+(automake --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: You must have \`automake' installed."
+ echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/"
+ DIE=1
+ NO_AUTOMAKE=yes
+}
+
+
+# if no automake, don't bother testing for aclocal
+test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: Missing \`aclocal'. The version of \`automake'"
+ echo "installed doesn't appear recent enough."
+ echo "You can get automake from ftp://ftp.gnu.org/pub/gnu/"
+ DIE=1
+}
+
+if test "$DIE" -eq 1; then
+ exit 1
+fi
+
+if test -z "$*"; then
+ echo "**Warning**: I am going to run \`configure' with no arguments."
+ echo "If you wish to pass any to it, please specify them on the"
+ echo \`$0\'" command line."
+ echo
+fi
+
+case $CC in
+xlc )
+ am_opt=--include-deps;;
+esac
+
+for coin in `find $srcdir -name configure.in -print`
+do
+ dr=`dirname $coin`
+ if test -f $dr/NO-AUTO-GEN; then
+ echo skipping $dr -- flagged as no auto-gen
+ else
+ echo processing $dr
+ ( cd $dr
+
+ aclocalinclude="$ACLOCAL_FLAGS"
+
+ if grep "^AM_GLIB_GNU_GETTEXT" configure.in >/dev/null; then
+ echo "Creating $dr/aclocal.m4 ..."
+ test -r $dr/aclocal.m4 || touch $dr/aclocal.m4
+ echo "Running glib-gettextize... Ignore non-fatal messages."
+ echo "no" | glib-gettextize --force --copy
+ echo "Making $dr/aclocal.m4 writable ..."
+ test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
+ fi
+ if grep "^AC_PROG_INTLTOOL" configure.in >/dev/null; then
+ echo "Running intltoolize..."
+ intltoolize --copy --force --automake
+ fi
+ if grep "^AM_PROG_XML_I18N_TOOLS" configure.in >/dev/null; then
+ echo "Running xml-i18n-toolize..."
+ xml-i18n-toolize --copy --force --automake
+ fi
+ if grep "^AM_PROG_LIBTOOL" configure.in >/dev/null; then
+ if test -z "$NO_LIBTOOLIZE" ; then
+ echo "Running libtoolize..."
+ libtoolize --force --copy
+ fi
+ fi
+ echo "Running aclocal $aclocalinclude ..."
+ aclocal $aclocalinclude
+ if grep "^AM_CONFIG_HEADER" configure.in >/dev/null; then
+ echo "Running autoheader..."
+ autoheader
+ fi
+ echo "Running automake --gnu $am_opt ..."
+ automake --add-missing --gnu $am_opt
+ echo "Running autoconf ..."
+ autoconf
+ )
+ fi
+done
+
+conf_flags="--enable-maintainer-mode"
+
+if test x$NOCONFIGURE = x; then
+ echo Running $srcdir/configure $conf_flags "$@" ...
+ $srcdir/configure $conf_flags "$@" \
+ && echo Now type \`make\' to compile. || exit 1
+else
+ echo Skipping configure process.
+fi
diff --git a/tools/glade/examples/editor/configure.in b/tools/glade/examples/editor/configure.in
new file mode 100644
index 00000000..43574665
--- /dev/null
+++ b/tools/glade/examples/editor/configure.in
@@ -0,0 +1,31 @@
+dnl Process this file with autoconf to produce a configure script.
+
+AC_INIT(configure.in)
+AM_INIT_AUTOMAKE(glade-editor, 0.1)
+AM_CONFIG_HEADER(config.h)
+AM_MAINTAINER_MODE
+
+AC_ISC_POSIX
+AC_PROG_CC
+AM_PROG_CC_STDC
+AC_HEADER_STDC
+
+pkg_modules="gtk+-2.0 >= 2.0.0"
+PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
+AC_SUBST(PACKAGE_CFLAGS)
+AC_SUBST(PACKAGE_LIBS)
+
+GETTEXT_PACKAGE=glade-editor
+AC_SUBST(GETTEXT_PACKAGE)
+AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE")
+
+dnl Add the languages which your application supports here.
+ALL_LINGUAS=""
+AM_GLIB_GNU_GETTEXT
+
+AC_OUTPUT([
+Makefile
+src/Makefile
+po/Makefile.in
+])
+
diff --git a/tools/glade/examples/editor/editor.glade b/tools/glade/examples/editor/editor.glade
new file mode 100644
index 00000000..51296416
--- /dev/null
+++ b/tools/glade/examples/editor/editor.glade
@@ -0,0 +1,492 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+
+<widget class="GtkWindow" id="main_window">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Glade Text Editor</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="default_width">600</property>
+ <property name="default_height">450</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <signal name="delete_event" handler="on_main_window_delete_event"/>
+
+ <child>
+ <widget class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkHandleBox" id="handlebox2">
+ <property name="visible">True</property>
+ <property name="shadow_type">GTK_SHADOW_OUT</property>
+ <property name="handle_position">GTK_POS_LEFT</property>
+ <property name="snap_edge">GTK_POS_TOP</property>
+
+ <child>
+ <widget class="GtkMenuBar" id="menubar1">
+ <property name="visible">True</property>
+
+ <child>
+ <widget class="GtkMenuItem" id="File">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_File</property>
+ <property name="use_underline">True</property>
+
+ <child>
+ <widget class="GtkMenu" id="File_menu">
+
+ <child>
+ <widget class="GtkImageMenuItem" id="New">
+ <property name="visible">True</property>
+ <property name="label">gtk-new</property>
+ <property name="use_stock">True</property>
+ <signal name="activate" handler="on_New_activate"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkImageMenuItem" id="Open">
+ <property name="visible">True</property>
+ <property name="label">gtk-open</property>
+ <property name="use_stock">True</property>
+ <signal name="activate" handler="on_Open_activate"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkImageMenuItem" id="Save">
+ <property name="visible">True</property>
+ <property name="label">gtk-save</property>
+ <property name="use_stock">True</property>
+ <signal name="activate" handler="on_Save_activate"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkImageMenuItem" id="Save_As">
+ <property name="visible">True</property>
+ <property name="label">gtk-save-as</property>
+ <property name="use_stock">True</property>
+ <signal name="activate" handler="on_Save_As_activate"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkMenuItem" id="separator1">
+ <property name="visible">True</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkImageMenuItem" id="Exit">
+ <property name="visible">True</property>
+ <property name="label">gtk-quit</property>
+ <property name="use_stock">True</property>
+ <signal name="activate" handler="on_Exit_activate"/>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkMenuItem" id="Edit">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Edit</property>
+ <property name="use_underline">True</property>
+
+ <child>
+ <widget class="GtkMenu" id="Edit_menu">
+
+ <child>
+ <widget class="GtkImageMenuItem" id="Cut">
+ <property name="visible">True</property>
+ <property name="label">gtk-cut</property>
+ <property name="use_stock">True</property>
+ <signal name="activate" handler="on_Cut_activate"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkImageMenuItem" id="Copy">
+ <property name="visible">True</property>
+ <property name="label">gtk-copy</property>
+ <property name="use_stock">True</property>
+ <signal name="activate" handler="on_Copy_activate"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkImageMenuItem" id="Paste">
+ <property name="visible">True</property>
+ <property name="label">gtk-paste</property>
+ <property name="use_stock">True</property>
+ <signal name="activate" handler="on_Paste_activate"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkImageMenuItem" id="Clear">
+ <property name="visible">True</property>
+ <property name="label">gtk-delete</property>
+ <property name="use_stock">True</property>
+ <signal name="activate" handler="on_Clear_activate"/>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkMenuItem" id="View">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_View</property>
+ <property name="use_underline">True</property>
+
+ <child>
+ <widget class="GtkMenu" id="View_menu">
+
+ <child>
+ <widget class="GtkMenuItem" id="Font">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Change _Font...</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_Font_activate"/>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkMenuItem" id="Help">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Help</property>
+ <property name="use_underline">True</property>
+
+ <child>
+ <widget class="GtkMenu" id="Help_menu">
+
+ <child>
+ <widget class="GtkMenuItem" id="About">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_About...</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_About_activate"/>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHandleBox" id="handlebox1">
+ <property name="border_width">2</property>
+ <property name="visible">True</property>
+ <property name="shadow_type">GTK_SHADOW_OUT</property>
+ <property name="handle_position">GTK_POS_LEFT</property>
+ <property name="snap_edge">GTK_POS_TOP</property>
+
+ <child>
+ <widget class="GtkToolbar" id="toolbar1">
+ <property name="visible">True</property>
+ <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
+ <property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
+ <property name="tooltips">True</property>
+
+ <child>
+ <widget class="button" id="button1">
+ <property name="visible">True</property>
+ <property name="label">gtk-new</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="on_new_button_clicked"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="button" id="button2">
+ <property name="visible">True</property>
+ <property name="label">gtk-open</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="on_open_button_clicked"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="button" id="button3">
+ <property name="visible">True</property>
+ <property name="label">gtk-save</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="on_save_button_clicked"/>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+ <child>
+ <widget class="GtkTextView" id="text1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="justification">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap_mode">GTK_WRAP_WORD</property>
+ <property name="cursor_visible">True</property>
+ <property name="pixels_above_lines">0</property>
+ <property name="pixels_below_lines">0</property>
+ <property name="pixels_inside_wrap">0</property>
+ <property name="left_margin">0</property>
+ <property name="right_margin">0</property>
+ <property name="indent">0</property>
+ <property name="text" translatable="yes"></property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkStatusbar" id="statusbar1">
+ <property name="visible">True</property>
+ <property name="has_resize_grip">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+<widget class="GtkFileSelection" id="open_file_selection">
+ <property name="border_width">10</property>
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Open File</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="show_fileops">True</property>
+ <signal name="delete_event" handler="on_open_filesel_delete_event"/>
+
+ <child internal-child="cancel_button">
+ <widget class="GtkButton" id="cancel_button1">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <signal name="clicked" handler="on_open_filesel_cancel_button_clicked"/>
+ </widget>
+ </child>
+
+ <child internal-child="ok_button">
+ <widget class="GtkButton" id="ok_button1">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <signal name="clicked" handler="on_open_filesel_ok_button_clicked"/>
+ </widget>
+ </child>
+</widget>
+
+<widget class="GtkFontSelectionDialog" id="font_selection">
+ <property name="border_width">4</property>
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Select Font</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <signal name="delete_event" handler="on_fontsel_delete_event"/>
+
+ <child internal-child="cancel_button">
+ <widget class="GtkButton" id="cancel_button2">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <signal name="clicked" handler="on_fontsel_cancel_button_clicked"/>
+ </widget>
+ </child>
+
+ <child internal-child="apply_button">
+ <widget class="GtkButton" id="apply_button1">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <signal name="clicked" handler="on_fontsel_apply_button_clicked"/>
+ </widget>
+ </child>
+
+ <child internal-child="ok_button">
+ <widget class="GtkButton" id="ok_button2">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <signal name="clicked" handler="on_fontsel_ok_button_clicked"/>
+ </widget>
+ </child>
+
+ <child internal-child="font_selection">
+ <widget class="GtkFontSelection" id="fontselection1">
+ <property name="border_width">4</property>
+ <property name="visible">True</property>
+ <property name="preview_text" translatable="yes">abcdefghijk ABCDEFGHIJK</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+</widget>
+
+<widget class="GtkDialog" id="about_dialog">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">About The Glade Text Editor</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="has_separator">True</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area2">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="button7">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes"> OK </property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="response_id">0</property>
+ <signal name="clicked" handler="on_about_ok_clicked"/>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">The Glade Text Editor
+
+v 1.0
+
+(Example program for Glade)</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_CENTER</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">12</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">10</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+<widget class="GtkFileSelection" id="save_file_selection">
+ <property name="border_width">10</property>
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Save File</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="show_fileops">True</property>
+ <signal name="delete_event" handler="on_save_filesel_delete_event"/>
+
+ <child internal-child="cancel_button">
+ <widget class="GtkButton" id="cancel_button3">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <signal name="clicked" handler="on_save_filesel_cancel_button_clicked"/>
+ </widget>
+ </child>
+
+ <child internal-child="ok_button">
+ <widget class="GtkButton" id="ok_button3">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <signal name="clicked" handler="on_save_filesel_ok_button_clicked"/>
+ </widget>
+ </child>
+</widget>
+
+</glade-interface>
diff --git a/tools/glade/examples/editor/editor.gladep b/tools/glade/examples/editor/editor.gladep
new file mode 100644
index 00000000..ab20f90f
--- /dev/null
+++ b/tools/glade/examples/editor/editor.gladep
@@ -0,0 +1,8 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
+
+<glade-project>
+ <name>Editor</name>
+ <program_name>glade-editor</program_name>
+ <gnome_support>FALSE</gnome_support>
+</glade-project>
diff --git a/tools/glade/examples/editor/po/ChangeLog b/tools/glade/examples/editor/po/ChangeLog
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tools/glade/examples/editor/po/ChangeLog
diff --git a/tools/glade/examples/editor/po/POTFILES.in b/tools/glade/examples/editor/po/POTFILES.in
new file mode 100644
index 00000000..ab2d29e6
--- /dev/null
+++ b/tools/glade/examples/editor/po/POTFILES.in
@@ -0,0 +1,6 @@
+# List of source files containing translatable strings.
+
+src/main.c
+src/interface.c
+src/callbacks.c
+src/support.c
diff --git a/tools/glade/examples/editor/src/Makefile.am b/tools/glade/examples/editor/src/Makefile.am
new file mode 100644
index 00000000..d9ab60b1
--- /dev/null
+++ b/tools/glade/examples/editor/src/Makefile.am
@@ -0,0 +1,17 @@
+## Process this file with automake to produce Makefile.in
+
+INCLUDES = \
+ -DPACKAGE_DATA_DIR=\""$(datadir)"\" \
+ -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
+ @PACKAGE_CFLAGS@
+
+bin_PROGRAMS = glade-editor
+
+glade_editor_SOURCES = \
+ main.c \
+ support.c support.h \
+ interface.c interface.h \
+ callbacks.c callbacks.h
+
+glade_editor_LDADD = @PACKAGE_LIBS@ $(INTLLIBS)
+
diff --git a/tools/glade/examples/editor/src/callbacks.c b/tools/glade/examples/editor/src/callbacks.c
new file mode 100644
index 00000000..bb653be2
--- /dev/null
+++ b/tools/glade/examples/editor/src/callbacks.c
@@ -0,0 +1,670 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <gtk/gtk.h>
+
+#include "callbacks.h"
+#include "interface.h"
+#include "support.h"
+
+
+/* We create the dialog boxes once and keep pointers to them in static
+ variables so we can reuse them. */
+static GtkWidget *open_filesel = NULL;
+static GtkWidget *save_filesel = NULL;
+static GtkWidget *fontsel = NULL;
+
+/* This is the filename of the file currently being edited, in on-disk
+ encoding (which may be UTF-8 or the locale's encoding). */
+static gchar *current_filename = NULL;
+
+/* This flag is set to TRUE if the file has been changed. We don't actually
+ use it here, but the program could be extended to prompt to save changes. */
+static gboolean file_changed = FALSE;
+
+/* A key used to store pointers to the main window. */
+static const gchar *MainWindowKey = "MainWindowKey";
+
+/* The size of chunks to read in when opening files. */
+#define BUFFER_SIZE 8192
+
+
+/* Static functions. */
+static void new_file (GtkWidget *main_window);
+static void open_file (GtkWidget *main_window);
+static void save_as (GtkWidget *main_window);
+
+static void real_open_file (GtkWidget *main_window,
+ const gchar *filename);
+static void real_save_file (GtkWidget *main_window,
+ const gchar *filename);
+
+
+/***************************************************************************
+ * Main Window Signals.
+ ***************************************************************************/
+
+/* This is called when the main window gets a "delete_event" signal, which
+ typically happens when the user clicks on the close icon on the window's
+ title bar. If we didn't handle this, the window would be destroyed but
+ our application would not exit. */
+gboolean
+on_main_window_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ exit (0);
+
+ /* Shouldn't reach here, but we add it to stop compiler warnings. */
+ return FALSE;
+}
+
+
+/***************************************************************************
+ * File Menu Commands.
+ ***************************************************************************/
+void
+on_New_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ GtkWidget *main_window;
+
+ /* We use the Glade utility function lookup_widget() to get a pointer to the
+ main window. The first argument is any widget in the window/dialog and
+ the second argument is the name of the widget you want to get. */
+ main_window = lookup_widget (GTK_WIDGET (menuitem), "main_window");
+ new_file (main_window);
+}
+
+
+void
+on_Open_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ GtkWidget *main_window;
+
+ main_window = lookup_widget (GTK_WIDGET (menuitem), "main_window");
+ open_file (main_window);
+}
+
+
+void
+on_Save_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ GtkWidget *main_window;
+
+ main_window = lookup_widget (GTK_WIDGET (menuitem), "main_window");
+
+ /* If the current document doesn't have a filename yet, we call save_as
+ to show the file selection dialog. */
+ if (current_filename == NULL)
+ save_as (main_window);
+ else
+ real_save_file (main_window, current_filename);
+}
+
+
+void
+on_Save_As_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ GtkWidget *main_window;
+
+ main_window = lookup_widget (GTK_WIDGET (menuitem), "main_window");
+ save_as (main_window);
+}
+
+
+void
+on_Exit_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ gtk_exit (0);
+}
+
+
+/***************************************************************************
+ * Edit Menu Commands.
+ * The GtkTextView class makes this very easy for us by providing action
+ * signals that perform clipboard functions.
+ ***************************************************************************/
+
+void
+on_Cut_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ GtkWidget *text, *statusbar;
+
+ text = lookup_widget (GTK_WIDGET (menuitem), "text1");
+ g_signal_emit_by_name (G_OBJECT (text), "cut_clipboard", NULL);
+
+ statusbar = lookup_widget (GTK_WIDGET (menuitem), "statusbar1");
+ gtk_statusbar_pop (GTK_STATUSBAR (statusbar), 1);
+ gtk_statusbar_push (GTK_STATUSBAR (statusbar), 1, "Text cut to clipboard.");
+}
+
+
+void
+on_Copy_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ GtkWidget *text, *statusbar;
+
+ text = lookup_widget (GTK_WIDGET (menuitem), "text1");
+ g_signal_emit_by_name (G_OBJECT (text), "copy_clipboard", NULL);
+
+ statusbar = lookup_widget (GTK_WIDGET (menuitem), "statusbar1");
+ gtk_statusbar_pop (GTK_STATUSBAR (statusbar), 1);
+ gtk_statusbar_push (GTK_STATUSBAR (statusbar), 1, "Text copied.");
+}
+
+
+void
+on_Paste_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ GtkWidget *text, *statusbar;
+
+ text = lookup_widget (GTK_WIDGET (menuitem), "text1");
+ g_signal_emit_by_name (G_OBJECT (text), "paste_clipboard", NULL);
+
+ statusbar = lookup_widget (GTK_WIDGET (menuitem), "statusbar1");
+ gtk_statusbar_pop (GTK_STATUSBAR (statusbar), 1);
+ gtk_statusbar_push (GTK_STATUSBAR (statusbar), 1, "Text pasted.");
+}
+
+
+void
+on_Clear_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ GtkWidget *text, *statusbar;
+ GtkTextBuffer *buffer;
+
+ text = lookup_widget (GTK_WIDGET (menuitem), "text1");
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
+ gtk_text_buffer_delete_selection (buffer, TRUE, TRUE);
+
+ statusbar = lookup_widget (GTK_WIDGET (menuitem), "statusbar1");
+ gtk_statusbar_pop (GTK_STATUSBAR (statusbar), 1);
+ gtk_statusbar_push (GTK_STATUSBAR (statusbar), 1, "Text deleted.");
+}
+
+
+/***************************************************************************
+ * Toolbar Buttons.
+ ***************************************************************************/
+
+void
+on_new_button_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkWidget *main_window;
+
+ main_window = lookup_widget (GTK_WIDGET (button), "main_window");
+ new_file (main_window);
+}
+
+
+void
+on_open_button_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkWidget *main_window;
+
+ main_window = lookup_widget (GTK_WIDGET (button), "main_window");
+ open_file (main_window);
+}
+
+
+void
+on_save_button_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkWidget *main_window;
+
+ main_window = lookup_widget (GTK_WIDGET (button), "main_window");
+
+ if (current_filename == NULL)
+ save_as (main_window);
+ else
+ real_save_file (main_window, current_filename);
+}
+
+
+/***************************************************************************
+ * Font Selection Dialog.
+ ***************************************************************************/
+
+/* This is called when the 'Change Font' command is used. We just need to
+ show the font selection dialog. */
+void
+on_Font_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ GtkWidget *main_window;
+
+ main_window = lookup_widget (GTK_WIDGET (menuitem), "main_window");
+ if (!fontsel)
+ {
+ fontsel = create_font_selection ();
+ gtk_object_set_data (GTK_OBJECT (fontsel), MainWindowKey, main_window);
+
+ /* Make sure the dialog doesn't disappear behind the main window. */
+ gtk_window_set_transient_for (GTK_WINDOW (fontsel),
+ GTK_WINDOW (main_window));
+ }
+ gtk_widget_show (fontsel);
+
+ /* We make sure the dialog is visible. */
+ gtk_window_present (GTK_WINDOW (fontsel));
+}
+
+
+gboolean
+on_fontsel_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ gtk_widget_hide (gtk_widget_get_toplevel (widget));
+ return TRUE;
+}
+
+
+void
+on_fontsel_ok_button_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkWidget *fontsel;
+
+ /* We do the same thing as apply, but we close the dialog after. */
+ on_fontsel_apply_button_clicked (button, NULL);
+ fontsel = gtk_widget_get_toplevel (GTK_WIDGET (button));
+ gtk_widget_hide (fontsel);
+}
+
+
+void
+on_fontsel_cancel_button_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ gtk_widget_hide (gtk_widget_get_toplevel (GTK_WIDGET (button)));
+}
+
+
+void
+on_fontsel_apply_button_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkWidget *fontsel, *main_window, *text, *statusbar;
+ gchar *font_name;
+ PangoFontDescription *font_desc;
+
+ fontsel = gtk_widget_get_toplevel (GTK_WIDGET (button));
+ main_window = gtk_object_get_data (GTK_OBJECT (fontsel), MainWindowKey);
+ text = lookup_widget (main_window, "text1");
+ statusbar = lookup_widget (main_window, "statusbar1");
+
+ font_name = gtk_font_selection_dialog_get_font_name (GTK_FONT_SELECTION_DIALOG (fontsel));
+ font_desc = pango_font_description_from_string (font_name);
+ g_free (font_name);
+
+ /* We copy the current style, and update the font. */
+ gtk_widget_modify_font (text, font_desc);
+ pango_font_description_free (font_desc);
+
+ gtk_statusbar_pop (GTK_STATUSBAR (statusbar), 1);
+ gtk_statusbar_push (GTK_STATUSBAR (statusbar), 1, "Font updated.");
+}
+
+
+/***************************************************************************
+ * Open File Selection Dialog.
+ ***************************************************************************/
+
+void
+on_open_filesel_ok_button_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkWidget *filesel, *main_window;
+ const gchar *filename;
+
+ filesel = gtk_widget_get_toplevel (GTK_WIDGET (button));
+ main_window = gtk_object_get_data (GTK_OBJECT (filesel), MainWindowKey);
+ gtk_widget_hide (filesel);
+ filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
+ real_open_file (main_window, filename);
+}
+
+
+void
+on_open_filesel_cancel_button_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ gtk_widget_hide (gtk_widget_get_toplevel (GTK_WIDGET (button)));
+}
+
+
+gboolean
+on_open_filesel_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ gtk_widget_hide (gtk_widget_get_toplevel (widget));
+ return TRUE;
+}
+
+
+/***************************************************************************
+ * Save File Selection Dialog.
+ ***************************************************************************/
+
+void
+on_save_filesel_ok_button_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkWidget *filesel, *main_window;
+ const gchar *filename;
+
+ filesel = gtk_widget_get_toplevel (GTK_WIDGET (button));
+ main_window = gtk_object_get_data (GTK_OBJECT (filesel), MainWindowKey);
+ gtk_widget_hide (filesel);
+ filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
+ real_save_file (main_window, filename);
+}
+
+
+void
+on_save_filesel_cancel_button_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ gtk_widget_hide (gtk_widget_get_toplevel (GTK_WIDGET (button)));
+}
+
+
+gboolean
+on_save_filesel_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ gtk_widget_hide (gtk_widget_get_toplevel (widget));
+ return TRUE;
+}
+
+
+/***************************************************************************
+ * About Dialog.
+ ***************************************************************************/
+
+void
+on_About_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ static GtkWidget *about = NULL;
+
+ if (about == NULL)
+ {
+ GtkWidget *main_window;
+
+ about = create_about_dialog ();
+ /* set the widget pointer to NULL when the widget is destroyed */
+ g_signal_connect (G_OBJECT (about),
+ "destroy",
+ G_CALLBACK (gtk_widget_destroyed),
+ &about);
+
+ main_window = lookup_widget (GTK_WIDGET (menuitem), "main_window");
+ /* Make sure the dialog doesn't disappear behind the main window. */
+ gtk_window_set_transient_for (GTK_WINDOW (about),
+ GTK_WINDOW (main_window));
+ /* Do not allow user to resize the dialog */
+ gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
+ }
+
+ /* Make sure the dialog is visible. */
+ gtk_window_present (GTK_WINDOW (about));
+}
+
+
+void
+on_about_ok_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button)));
+}
+
+
+/***************************************************************************
+ * Text Widget signals.
+ ***************************************************************************/
+
+/*
+ * Text changed callback. This signal is emitted whenever the text in the
+ * GtkTextView changes. We don't use this at present, but it could be used to
+ * prompt to save changes before opening new files or quitting.
+ */
+void
+on_text_changed (GtkTextBuffer *buffer,
+ gpointer user_data)
+{
+ file_changed = TRUE;
+}
+
+
+/***************************************************************************
+ * Private functions.
+ ***************************************************************************/
+
+/* This sets the window title according to the current filename. */
+void
+set_window_title (GtkWidget *main_window)
+{
+ gchar *title, *filename_utf8 = NULL;
+
+ /* We need to convert the filename to UTF-8. */
+ if (current_filename)
+ filename_utf8 = g_filename_to_utf8 (current_filename, -1, NULL, NULL,
+ NULL);
+
+ title = g_strdup_printf ("Editor: %s\n",
+ filename_utf8 ? g_basename (filename_utf8)
+ : "untitled");
+
+ gtk_window_set_title (GTK_WINDOW (main_window), title);
+ g_free (title);
+ g_free (filename_utf8);
+}
+
+
+/* This creates a new document, by clearing the text widget and setting the
+ current filename to NULL. */
+static void
+new_file (GtkWidget *main_window)
+{
+ GtkWidget *text, *statusbar;
+ GtkTextBuffer *buffer;
+ GtkTextIter start, end;
+
+ text = lookup_widget (GTK_WIDGET (main_window), "text1");
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
+ gtk_text_buffer_get_bounds (buffer, &start, &end);
+ gtk_text_buffer_delete (buffer, &start, &end);
+
+ g_free (current_filename);
+ current_filename = NULL;
+ file_changed = FALSE;
+ set_window_title (main_window);
+
+ statusbar = lookup_widget (main_window, "statusbar1");
+ gtk_statusbar_pop (GTK_STATUSBAR (statusbar), 1);
+ gtk_statusbar_push (GTK_STATUSBAR (statusbar), 1, "New file.");
+}
+
+
+/* This shows the file selection dialog to open a file. */
+static void
+open_file (GtkWidget *main_window)
+{
+ /* We use the same file selection widget each time, so first
+ of all we create it if it hasn't already been created. */
+ if (open_filesel == NULL)
+ {
+ open_filesel = create_open_file_selection ();
+ /* Make sure the dialog doesn't disappear behind the main window. */
+ gtk_window_set_transient_for (GTK_WINDOW (open_filesel),
+ GTK_WINDOW (main_window));
+ }
+
+ /* We save a pointer to the main window inside the file selection's
+ data list, so we can get it easily in the callbacks. */
+ gtk_object_set_data (GTK_OBJECT (open_filesel), MainWindowKey, main_window);
+
+ /* We make sure the dialog is visible. */
+ gtk_window_present (GTK_WINDOW (open_filesel));
+}
+
+
+/* This shows the file selection dialog to save a file. */
+static void
+save_as (GtkWidget *main_window)
+{
+ if (save_filesel == NULL)
+ {
+ save_filesel = create_save_file_selection ();
+ /* Make sure the dialog doesn't disappear behind the main window. */
+ gtk_window_set_transient_for (GTK_WINDOW (save_filesel),
+ GTK_WINDOW (main_window));
+ }
+
+ gtk_object_set_data (GTK_OBJECT (save_filesel), MainWindowKey, main_window);
+
+ /* If the current document has a filename we use that as the default. */
+ if (current_filename)
+ gtk_file_selection_set_filename (GTK_FILE_SELECTION (save_filesel),
+ current_filename);
+
+ /* We make sure the dialog is visible. */
+ gtk_window_present (GTK_WINDOW (save_filesel));
+}
+
+
+/* This loads the given file, which is in on-disk encoding (which may not
+ be UTF-8). */
+static void
+real_open_file (GtkWidget *main_window, const gchar *filename)
+{
+ GtkWidget *text, *statusbar;
+ GtkTextBuffer *text_buffer;
+ GtkTextIter start, end;
+ FILE *fp;
+ gchar buffer[BUFFER_SIZE];
+ gint bytes_read;
+
+ text = lookup_widget (main_window, "text1");
+ text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
+ statusbar = lookup_widget (main_window, "statusbar1");
+ gtk_statusbar_pop (GTK_STATUSBAR (statusbar), 1);
+ gtk_text_buffer_get_bounds (text_buffer, &start, &end);
+ gtk_text_buffer_delete (text_buffer, &start, &end);
+ g_free (current_filename);
+ current_filename = NULL;
+ file_changed = FALSE;
+
+ fp = fopen (filename, "r");
+ if (fp == NULL)
+ {
+ gtk_statusbar_push (GTK_STATUSBAR (statusbar), 1, "Couldn't open file.");
+ return;
+ }
+
+ for (;;)
+ {
+ bytes_read = fread (buffer, sizeof (gchar), BUFFER_SIZE, fp);
+
+ if (bytes_read > 0)
+ {
+ gtk_text_buffer_get_end_iter (text_buffer, &end);
+ gtk_text_buffer_insert (text_buffer, &end, buffer, bytes_read);
+ }
+
+ if (bytes_read != BUFFER_SIZE && (feof (fp) || ferror (fp)))
+ break;
+ }
+
+ /* If there is an error while loading, we reset everything to a good state.
+ */
+ if (ferror (fp))
+ {
+ fclose (fp);
+ gtk_text_buffer_get_bounds (text_buffer, &start, &end);
+ gtk_text_buffer_delete (text_buffer, &start, &end);
+ set_window_title (main_window);
+ gtk_statusbar_push (GTK_STATUSBAR (statusbar), 1, "Error loading file.");
+ return;
+ }
+
+ fclose (fp);
+
+ current_filename = g_strdup (filename);
+ set_window_title (main_window);
+ gtk_statusbar_pop (GTK_STATUSBAR (statusbar), 1);
+ gtk_statusbar_push (GTK_STATUSBAR (statusbar), 1, "File opened.");
+}
+
+
+/* This saves the file, which is in on-disk encoding (which may not
+ be UTF-8). */
+static void
+real_save_file (GtkWidget *main_window, const gchar *filename)
+{
+ GtkWidget *text, *statusbar;
+ GtkTextBuffer *text_buffer;
+ GtkTextIter start, end;
+ gchar *data;
+ FILE *fp;
+ gint bytes_written, len;
+
+ if (current_filename == NULL || strcmp (current_filename, filename))
+ {
+ g_free (current_filename);
+ current_filename = g_strdup (filename);
+ set_window_title (main_window);
+ }
+
+ text = lookup_widget (GTK_WIDGET (main_window), "text1");
+ text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
+ statusbar = lookup_widget (main_window, "statusbar1");
+
+ gtk_text_buffer_get_bounds (text_buffer, &start, &end);
+ data = gtk_text_buffer_get_text (text_buffer, &start, &end, TRUE);
+
+ fp = fopen (filename, "w");
+ if (fp == NULL)
+ {
+ g_free (data);
+ return;
+ }
+
+ len = strlen (data);
+ bytes_written = fwrite (data, sizeof (gchar), len, fp);
+ fclose (fp);
+
+ g_free (data);
+
+ gtk_statusbar_pop (GTK_STATUSBAR (statusbar), 1);
+ if (len != bytes_written)
+ {
+ gtk_statusbar_push (GTK_STATUSBAR (statusbar), 1, "Error saving file.");
+ return;
+ }
+
+ file_changed = FALSE;
+ gtk_statusbar_push (GTK_STATUSBAR (statusbar), 1, "File saved.");
+}
+
diff --git a/tools/glade/examples/editor/src/callbacks.h b/tools/glade/examples/editor/src/callbacks.h
new file mode 100644
index 00000000..9418a3e2
--- /dev/null
+++ b/tools/glade/examples/editor/src/callbacks.h
@@ -0,0 +1,116 @@
+#include <gtk/gtk.h>
+
+
+gboolean
+on_main_window_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data);
+
+void
+on_New_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_Open_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_Save_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_Save_As_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_Exit_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_Cut_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_Copy_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_Paste_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_Clear_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_Font_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_About_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_new_button_clicked (GtkButton *button,
+ gpointer user_data);
+
+void
+on_open_button_clicked (GtkButton *button,
+ gpointer user_data);
+
+void
+on_save_button_clicked (GtkButton *button,
+ gpointer user_data);
+
+gboolean
+on_open_filesel_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data);
+
+void
+on_open_filesel_ok_button_clicked (GtkButton *button,
+ gpointer user_data);
+
+void
+on_open_filesel_cancel_button_clicked (GtkButton *button,
+ gpointer user_data);
+
+gboolean
+on_fontsel_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data);
+
+void
+on_fontsel_ok_button_clicked (GtkButton *button,
+ gpointer user_data);
+
+void
+on_fontsel_cancel_button_clicked (GtkButton *button,
+ gpointer user_data);
+
+void
+on_fontsel_apply_button_clicked (GtkButton *button,
+ gpointer user_data);
+
+void
+on_about_ok_clicked (GtkButton *button,
+ gpointer user_data);
+
+gboolean
+on_save_filesel_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data);
+
+void
+on_save_filesel_ok_button_clicked (GtkButton *button,
+ gpointer user_data);
+
+void
+on_save_filesel_cancel_button_clicked (GtkButton *button,
+ gpointer user_data);
+
+void set_window_title (GtkWidget *main_window);
+
+void
+on_text_changed (GtkTextBuffer *buffer,
+ gpointer user_data);
diff --git a/tools/glade/examples/editor/src/interface.c b/tools/glade/examples/editor/src/interface.c
new file mode 100644
index 00000000..c9b50a30
--- /dev/null
+++ b/tools/glade/examples/editor/src/interface.c
@@ -0,0 +1,456 @@
+/*
+ * DO NOT EDIT THIS FILE - it is generated by Glade.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+
+#include "callbacks.h"
+#include "interface.h"
+#include "support.h"
+
+#define GLADE_HOOKUP_OBJECT(component,widget,name) \
+ g_object_set_data_full (G_OBJECT (component), name, \
+ gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
+
+#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
+ g_object_set_data (G_OBJECT (component), name, widget)
+
+GtkWidget*
+create_main_window (void)
+{
+ GtkWidget *main_window;
+ GtkWidget *vbox1;
+ GtkWidget *handlebox2;
+ GtkWidget *menubar1;
+ GtkWidget *File;
+ GtkWidget *File_menu;
+ GtkWidget *New;
+ GtkWidget *Open;
+ GtkWidget *Save;
+ GtkWidget *Save_As;
+ GtkWidget *separator1;
+ GtkWidget *Exit;
+ GtkWidget *Edit;
+ GtkWidget *Edit_menu;
+ GtkWidget *Cut;
+ GtkWidget *Copy;
+ GtkWidget *Paste;
+ GtkWidget *Clear;
+ GtkWidget *View;
+ GtkWidget *View_menu;
+ GtkWidget *Font;
+ GtkWidget *Help;
+ GtkWidget *Help_menu;
+ GtkWidget *About;
+ GtkWidget *handlebox1;
+ GtkWidget *toolbar1;
+ GtkWidget *button1;
+ GtkWidget *button2;
+ GtkWidget *button3;
+ GtkWidget *scrolledwindow1;
+ GtkWidget *text1;
+ GtkWidget *statusbar1;
+ GtkAccelGroup *accel_group;
+
+ accel_group = gtk_accel_group_new ();
+
+ main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (main_window), _("Glade Text Editor"));
+ gtk_window_set_default_size (GTK_WINDOW (main_window), 600, 450);
+
+ vbox1 = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (vbox1);
+ gtk_container_add (GTK_CONTAINER (main_window), vbox1);
+
+ handlebox2 = gtk_handle_box_new ();
+ gtk_widget_show (handlebox2);
+ gtk_box_pack_start (GTK_BOX (vbox1), handlebox2, FALSE, TRUE, 0);
+
+ menubar1 = gtk_menu_bar_new ();
+ gtk_widget_show (menubar1);
+ gtk_container_add (GTK_CONTAINER (handlebox2), menubar1);
+
+ File = gtk_menu_item_new_with_mnemonic (_("_File"));
+ gtk_widget_show (File);
+ gtk_container_add (GTK_CONTAINER (menubar1), File);
+
+ File_menu = gtk_menu_new ();
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (File), File_menu);
+
+ New = gtk_image_menu_item_new_from_stock ("gtk-new", accel_group);
+ gtk_widget_show (New);
+ gtk_container_add (GTK_CONTAINER (File_menu), New);
+
+ Open = gtk_image_menu_item_new_from_stock ("gtk-open", accel_group);
+ gtk_widget_show (Open);
+ gtk_container_add (GTK_CONTAINER (File_menu), Open);
+
+ Save = gtk_image_menu_item_new_from_stock ("gtk-save", accel_group);
+ gtk_widget_show (Save);
+ gtk_container_add (GTK_CONTAINER (File_menu), Save);
+
+ Save_As = gtk_image_menu_item_new_from_stock ("gtk-save-as", accel_group);
+ gtk_widget_show (Save_As);
+ gtk_container_add (GTK_CONTAINER (File_menu), Save_As);
+
+ separator1 = gtk_menu_item_new ();
+ gtk_widget_show (separator1);
+ gtk_container_add (GTK_CONTAINER (File_menu), separator1);
+ gtk_widget_set_sensitive (separator1, FALSE);
+
+ Exit = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group);
+ gtk_widget_show (Exit);
+ gtk_container_add (GTK_CONTAINER (File_menu), Exit);
+
+ Edit = gtk_menu_item_new_with_mnemonic (_("_Edit"));
+ gtk_widget_show (Edit);
+ gtk_container_add (GTK_CONTAINER (menubar1), Edit);
+
+ Edit_menu = gtk_menu_new ();
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (Edit), Edit_menu);
+
+ Cut = gtk_image_menu_item_new_from_stock ("gtk-cut", accel_group);
+ gtk_widget_show (Cut);
+ gtk_container_add (GTK_CONTAINER (Edit_menu), Cut);
+
+ Copy = gtk_image_menu_item_new_from_stock ("gtk-copy", accel_group);
+ gtk_widget_show (Copy);
+ gtk_container_add (GTK_CONTAINER (Edit_menu), Copy);
+
+ Paste = gtk_image_menu_item_new_from_stock ("gtk-paste", accel_group);
+ gtk_widget_show (Paste);
+ gtk_container_add (GTK_CONTAINER (Edit_menu), Paste);
+
+ Clear = gtk_image_menu_item_new_from_stock ("gtk-delete", accel_group);
+ gtk_widget_show (Clear);
+ gtk_container_add (GTK_CONTAINER (Edit_menu), Clear);
+
+ View = gtk_menu_item_new_with_mnemonic (_("_View"));
+ gtk_widget_show (View);
+ gtk_container_add (GTK_CONTAINER (menubar1), View);
+
+ View_menu = gtk_menu_new ();
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (View), View_menu);
+
+ Font = gtk_menu_item_new_with_mnemonic (_("Change _Font..."));
+ gtk_widget_show (Font);
+ gtk_container_add (GTK_CONTAINER (View_menu), Font);
+
+ Help = gtk_menu_item_new_with_mnemonic (_("_Help"));
+ gtk_widget_show (Help);
+ gtk_container_add (GTK_CONTAINER (menubar1), Help);
+
+ Help_menu = gtk_menu_new ();
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (Help), Help_menu);
+
+ About = gtk_menu_item_new_with_mnemonic (_("_About..."));
+ gtk_widget_show (About);
+ gtk_container_add (GTK_CONTAINER (Help_menu), About);
+
+ handlebox1 = gtk_handle_box_new ();
+ gtk_widget_show (handlebox1);
+ gtk_box_pack_start (GTK_BOX (vbox1), handlebox1, FALSE, TRUE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (handlebox1), 2);
+
+ toolbar1 = gtk_toolbar_new ();
+ gtk_widget_show (toolbar1);
+ gtk_container_add (GTK_CONTAINER (handlebox1), toolbar1);
+ gtk_toolbar_set_style (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_BOTH);
+
+ button1 = gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar1),
+ "gtk-new",
+ NULL,
+ NULL, NULL, NULL, -1);
+ gtk_widget_show (button1);
+
+ button2 = gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar1),
+ "gtk-open",
+ NULL,
+ NULL, NULL, NULL, -1);
+ gtk_widget_show (button2);
+
+ button3 = gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar1),
+ "gtk-save",
+ NULL,
+ NULL, NULL, NULL, -1);
+ gtk_widget_show (button3);
+
+ scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scrolledwindow1);
+ gtk_box_pack_start (GTK_BOX (vbox1), scrolledwindow1, TRUE, TRUE, 0);
+ GTK_WIDGET_UNSET_FLAGS (scrolledwindow1, GTK_CAN_FOCUS);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_SHADOW_IN);
+
+ text1 = gtk_text_view_new ();
+ gtk_widget_show (text1);
+ gtk_container_add (GTK_CONTAINER (scrolledwindow1), text1);
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text1), GTK_WRAP_WORD);
+
+ statusbar1 = gtk_statusbar_new ();
+ gtk_widget_show (statusbar1);
+ gtk_box_pack_start (GTK_BOX (vbox1), statusbar1, FALSE, TRUE, 0);
+
+ g_signal_connect ((gpointer) main_window, "delete_event",
+ G_CALLBACK (on_main_window_delete_event),
+ NULL);
+ g_signal_connect ((gpointer) New, "activate",
+ G_CALLBACK (on_New_activate),
+ NULL);
+ g_signal_connect ((gpointer) Open, "activate",
+ G_CALLBACK (on_Open_activate),
+ NULL);
+ g_signal_connect ((gpointer) Save, "activate",
+ G_CALLBACK (on_Save_activate),
+ NULL);
+ g_signal_connect ((gpointer) Save_As, "activate",
+ G_CALLBACK (on_Save_As_activate),
+ NULL);
+ g_signal_connect ((gpointer) Exit, "activate",
+ G_CALLBACK (on_Exit_activate),
+ NULL);
+ g_signal_connect ((gpointer) Cut, "activate",
+ G_CALLBACK (on_Cut_activate),
+ NULL);
+ g_signal_connect ((gpointer) Copy, "activate",
+ G_CALLBACK (on_Copy_activate),
+ NULL);
+ g_signal_connect ((gpointer) Paste, "activate",
+ G_CALLBACK (on_Paste_activate),
+ NULL);
+ g_signal_connect ((gpointer) Clear, "activate",
+ G_CALLBACK (on_Clear_activate),
+ NULL);
+ g_signal_connect ((gpointer) Font, "activate",
+ G_CALLBACK (on_Font_activate),
+ NULL);
+ g_signal_connect ((gpointer) About, "activate",
+ G_CALLBACK (on_About_activate),
+ NULL);
+ g_signal_connect ((gpointer) button1, "clicked",
+ G_CALLBACK (on_new_button_clicked),
+ NULL);
+ g_signal_connect ((gpointer) button2, "clicked",
+ G_CALLBACK (on_open_button_clicked),
+ NULL);
+ g_signal_connect ((gpointer) button3, "clicked",
+ G_CALLBACK (on_save_button_clicked),
+ NULL);
+
+ /* Store pointers to all widgets, for use by lookup_widget(). */
+ GLADE_HOOKUP_OBJECT_NO_REF (main_window, main_window, "main_window");
+ GLADE_HOOKUP_OBJECT (main_window, vbox1, "vbox1");
+ GLADE_HOOKUP_OBJECT (main_window, handlebox2, "handlebox2");
+ GLADE_HOOKUP_OBJECT (main_window, menubar1, "menubar1");
+ GLADE_HOOKUP_OBJECT (main_window, File, "File");
+ GLADE_HOOKUP_OBJECT (main_window, File_menu, "File_menu");
+ GLADE_HOOKUP_OBJECT (main_window, New, "New");
+ GLADE_HOOKUP_OBJECT (main_window, Open, "Open");
+ GLADE_HOOKUP_OBJECT (main_window, Save, "Save");
+ GLADE_HOOKUP_OBJECT (main_window, Save_As, "Save_As");
+ GLADE_HOOKUP_OBJECT (main_window, separator1, "separator1");
+ GLADE_HOOKUP_OBJECT (main_window, Exit, "Exit");
+ GLADE_HOOKUP_OBJECT (main_window, Edit, "Edit");
+ GLADE_HOOKUP_OBJECT (main_window, Edit_menu, "Edit_menu");
+ GLADE_HOOKUP_OBJECT (main_window, Cut, "Cut");
+ GLADE_HOOKUP_OBJECT (main_window, Copy, "Copy");
+ GLADE_HOOKUP_OBJECT (main_window, Paste, "Paste");
+ GLADE_HOOKUP_OBJECT (main_window, Clear, "Clear");
+ GLADE_HOOKUP_OBJECT (main_window, View, "View");
+ GLADE_HOOKUP_OBJECT (main_window, View_menu, "View_menu");
+ GLADE_HOOKUP_OBJECT (main_window, Font, "Font");
+ GLADE_HOOKUP_OBJECT (main_window, Help, "Help");
+ GLADE_HOOKUP_OBJECT (main_window, Help_menu, "Help_menu");
+ GLADE_HOOKUP_OBJECT (main_window, About, "About");
+ GLADE_HOOKUP_OBJECT (main_window, handlebox1, "handlebox1");
+ GLADE_HOOKUP_OBJECT (main_window, toolbar1, "toolbar1");
+ GLADE_HOOKUP_OBJECT (main_window, button1, "button1");
+ GLADE_HOOKUP_OBJECT (main_window, button2, "button2");
+ GLADE_HOOKUP_OBJECT (main_window, button3, "button3");
+ GLADE_HOOKUP_OBJECT (main_window, scrolledwindow1, "scrolledwindow1");
+ GLADE_HOOKUP_OBJECT (main_window, text1, "text1");
+ GLADE_HOOKUP_OBJECT (main_window, statusbar1, "statusbar1");
+
+ gtk_window_add_accel_group (GTK_WINDOW (main_window), accel_group);
+
+ return main_window;
+}
+
+GtkWidget*
+create_open_file_selection (void)
+{
+ GtkWidget *open_file_selection;
+ GtkWidget *ok_button1;
+ GtkWidget *cancel_button1;
+
+ open_file_selection = gtk_file_selection_new (_("Open File"));
+ gtk_container_set_border_width (GTK_CONTAINER (open_file_selection), 10);
+
+ ok_button1 = GTK_FILE_SELECTION (open_file_selection)->ok_button;
+ gtk_widget_show (ok_button1);
+ GTK_WIDGET_SET_FLAGS (ok_button1, GTK_CAN_DEFAULT);
+
+ cancel_button1 = GTK_FILE_SELECTION (open_file_selection)->cancel_button;
+ gtk_widget_show (cancel_button1);
+ GTK_WIDGET_SET_FLAGS (cancel_button1, GTK_CAN_DEFAULT);
+
+ g_signal_connect ((gpointer) open_file_selection, "delete_event",
+ G_CALLBACK (on_open_filesel_delete_event),
+ NULL);
+ g_signal_connect ((gpointer) ok_button1, "clicked",
+ G_CALLBACK (on_open_filesel_ok_button_clicked),
+ NULL);
+ g_signal_connect ((gpointer) cancel_button1, "clicked",
+ G_CALLBACK (on_open_filesel_cancel_button_clicked),
+ NULL);
+
+ /* Store pointers to all widgets, for use by lookup_widget(). */
+ GLADE_HOOKUP_OBJECT_NO_REF (open_file_selection, open_file_selection, "open_file_selection");
+ GLADE_HOOKUP_OBJECT_NO_REF (open_file_selection, ok_button1, "ok_button1");
+ GLADE_HOOKUP_OBJECT_NO_REF (open_file_selection, cancel_button1, "cancel_button1");
+
+ return open_file_selection;
+}
+
+GtkWidget*
+create_font_selection (void)
+{
+ GtkWidget *font_selection;
+ GtkWidget *ok_button2;
+ GtkWidget *cancel_button2;
+ GtkWidget *apply_button1;
+ GtkWidget *fontselection1;
+
+ font_selection = gtk_font_selection_dialog_new (_("Select Font"));
+ gtk_container_set_border_width (GTK_CONTAINER (font_selection), 4);
+
+ ok_button2 = GTK_FONT_SELECTION_DIALOG (font_selection)->ok_button;
+ gtk_widget_show (ok_button2);
+ GTK_WIDGET_SET_FLAGS (ok_button2, GTK_CAN_DEFAULT);
+
+ cancel_button2 = GTK_FONT_SELECTION_DIALOG (font_selection)->cancel_button;
+ gtk_widget_show (cancel_button2);
+ GTK_WIDGET_SET_FLAGS (cancel_button2, GTK_CAN_DEFAULT);
+
+ apply_button1 = GTK_FONT_SELECTION_DIALOG (font_selection)->apply_button;
+ gtk_widget_show (apply_button1);
+ GTK_WIDGET_SET_FLAGS (apply_button1, GTK_CAN_DEFAULT);
+
+ fontselection1 = GTK_FONT_SELECTION_DIALOG (font_selection)->fontsel;
+ gtk_widget_show (fontselection1);
+ gtk_container_set_border_width (GTK_CONTAINER (fontselection1), 4);
+
+ g_signal_connect ((gpointer) font_selection, "delete_event",
+ G_CALLBACK (on_fontsel_delete_event),
+ NULL);
+ g_signal_connect ((gpointer) ok_button2, "clicked",
+ G_CALLBACK (on_fontsel_ok_button_clicked),
+ NULL);
+ g_signal_connect ((gpointer) cancel_button2, "clicked",
+ G_CALLBACK (on_fontsel_cancel_button_clicked),
+ NULL);
+ g_signal_connect ((gpointer) apply_button1, "clicked",
+ G_CALLBACK (on_fontsel_apply_button_clicked),
+ NULL);
+
+ /* Store pointers to all widgets, for use by lookup_widget(). */
+ GLADE_HOOKUP_OBJECT_NO_REF (font_selection, font_selection, "font_selection");
+ GLADE_HOOKUP_OBJECT_NO_REF (font_selection, ok_button2, "ok_button2");
+ GLADE_HOOKUP_OBJECT_NO_REF (font_selection, cancel_button2, "cancel_button2");
+ GLADE_HOOKUP_OBJECT_NO_REF (font_selection, apply_button1, "apply_button1");
+ GLADE_HOOKUP_OBJECT_NO_REF (font_selection, fontselection1, "fontselection1");
+
+ return font_selection;
+}
+
+GtkWidget*
+create_about_dialog (void)
+{
+ GtkWidget *about_dialog;
+ GtkWidget *dialog_vbox2;
+ GtkWidget *label2;
+ GtkWidget *dialog_action_area2;
+ GtkWidget *button7;
+
+ about_dialog = gtk_dialog_new ();
+ gtk_window_set_title (GTK_WINDOW (about_dialog), _("About The Glade Text Editor"));
+
+ dialog_vbox2 = GTK_DIALOG (about_dialog)->vbox;
+ gtk_widget_show (dialog_vbox2);
+
+ label2 = gtk_label_new (_("The Glade Text Editor\n\nv 1.0\n\n(Example program for Glade)"));
+ gtk_widget_show (label2);
+ gtk_box_pack_start (GTK_BOX (dialog_vbox2), label2, TRUE, TRUE, 10);
+ gtk_misc_set_padding (GTK_MISC (label2), 12, 0);
+
+ dialog_action_area2 = GTK_DIALOG (about_dialog)->action_area;
+ gtk_widget_show (dialog_action_area2);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area2), GTK_BUTTONBOX_END);
+
+ button7 = gtk_button_new_with_mnemonic (_(" OK "));
+ gtk_widget_show (button7);
+ gtk_dialog_add_action_widget (GTK_DIALOG (about_dialog), button7, 0);
+ GTK_WIDGET_SET_FLAGS (button7, GTK_CAN_DEFAULT);
+
+ g_signal_connect ((gpointer) button7, "clicked",
+ G_CALLBACK (on_about_ok_clicked),
+ NULL);
+
+ /* Store pointers to all widgets, for use by lookup_widget(). */
+ GLADE_HOOKUP_OBJECT_NO_REF (about_dialog, about_dialog, "about_dialog");
+ GLADE_HOOKUP_OBJECT_NO_REF (about_dialog, dialog_vbox2, "dialog_vbox2");
+ GLADE_HOOKUP_OBJECT (about_dialog, label2, "label2");
+ GLADE_HOOKUP_OBJECT_NO_REF (about_dialog, dialog_action_area2, "dialog_action_area2");
+ GLADE_HOOKUP_OBJECT (about_dialog, button7, "button7");
+
+ gtk_widget_grab_default (button7);
+ return about_dialog;
+}
+
+GtkWidget*
+create_save_file_selection (void)
+{
+ GtkWidget *save_file_selection;
+ GtkWidget *ok_button3;
+ GtkWidget *cancel_button3;
+
+ save_file_selection = gtk_file_selection_new (_("Save File"));
+ gtk_container_set_border_width (GTK_CONTAINER (save_file_selection), 10);
+
+ ok_button3 = GTK_FILE_SELECTION (save_file_selection)->ok_button;
+ gtk_widget_show (ok_button3);
+ GTK_WIDGET_SET_FLAGS (ok_button3, GTK_CAN_DEFAULT);
+
+ cancel_button3 = GTK_FILE_SELECTION (save_file_selection)->cancel_button;
+ gtk_widget_show (cancel_button3);
+ GTK_WIDGET_SET_FLAGS (cancel_button3, GTK_CAN_DEFAULT);
+
+ g_signal_connect ((gpointer) save_file_selection, "delete_event",
+ G_CALLBACK (on_save_filesel_delete_event),
+ NULL);
+ g_signal_connect ((gpointer) ok_button3, "clicked",
+ G_CALLBACK (on_save_filesel_ok_button_clicked),
+ NULL);
+ g_signal_connect ((gpointer) cancel_button3, "clicked",
+ G_CALLBACK (on_save_filesel_cancel_button_clicked),
+ NULL);
+
+ /* Store pointers to all widgets, for use by lookup_widget(). */
+ GLADE_HOOKUP_OBJECT_NO_REF (save_file_selection, save_file_selection, "save_file_selection");
+ GLADE_HOOKUP_OBJECT_NO_REF (save_file_selection, ok_button3, "ok_button3");
+ GLADE_HOOKUP_OBJECT_NO_REF (save_file_selection, cancel_button3, "cancel_button3");
+
+ return save_file_selection;
+}
+
diff --git a/tools/glade/examples/editor/src/interface.h b/tools/glade/examples/editor/src/interface.h
new file mode 100644
index 00000000..2b323163
--- /dev/null
+++ b/tools/glade/examples/editor/src/interface.h
@@ -0,0 +1,9 @@
+/*
+ * DO NOT EDIT THIS FILE - it is generated by Glade.
+ */
+
+GtkWidget* create_main_window (void);
+GtkWidget* create_open_file_selection (void);
+GtkWidget* create_font_selection (void);
+GtkWidget* create_about_dialog (void);
+GtkWidget* create_save_file_selection (void);
diff --git a/tools/glade/examples/editor/src/main.c b/tools/glade/examples/editor/src/main.c
new file mode 100644
index 00000000..d18e0a89
--- /dev/null
+++ b/tools/glade/examples/editor/src/main.c
@@ -0,0 +1,56 @@
+/*
+ * Initial main.c file generated by Glade. Edit as required.
+ * Glade will not overwrite this file.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+
+#include "callbacks.h"
+#include "interface.h"
+#include "support.h"
+
+int
+main (int argc, char *argv[])
+{
+ GtkWidget *main_window, *statusbar, *text;
+ GtkTextBuffer *buffer;
+
+#ifdef ENABLE_NLS
+ bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+#endif
+
+ gtk_set_locale ();
+ gtk_init (&argc, &argv);
+
+ add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
+
+ main_window = create_main_window ();
+ set_window_title (main_window);
+ gtk_widget_show (main_window);
+
+ /* We use the support function lookup_widget(), which is provided by Glade
+ so you can get a pointer to any widget in a component, simply by passing
+ any widget in the component, and the name of the widget you want.
+ Here we pass the toplevel widget in the component, main_window, and
+ we want to get the status bar widget which is called "statusbar1". */
+ statusbar = lookup_widget (main_window, "statusbar1");
+ gtk_statusbar_push (GTK_STATUSBAR (statusbar), 1,
+ "Welcome to the Glade Text Editor.");
+
+ /* We also need to connect a signal to the GtkTextBuffer, to know when the
+ text has changed. We can't connect the signal in Glade as GtkTextBuffer
+ is not a widget. */
+ text = lookup_widget (main_window, "text1");
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
+ g_signal_connect (buffer, "changed", G_CALLBACK (on_text_changed), NULL);
+
+ gtk_main ();
+ return 0;
+}
+
diff --git a/tools/glade/examples/editor/src/support.c b/tools/glade/examples/editor/src/support.c
new file mode 100644
index 00000000..3f5998d9
--- /dev/null
+++ b/tools/glade/examples/editor/src/support.c
@@ -0,0 +1,144 @@
+/*
+ * DO NOT EDIT THIS FILE - it is generated by Glade.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <gtk/gtk.h>
+
+#include "support.h"
+
+GtkWidget*
+lookup_widget (GtkWidget *widget,
+ const gchar *widget_name)
+{
+ GtkWidget *parent, *found_widget;
+
+ for (;;)
+ {
+ if (GTK_IS_MENU (widget))
+ parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
+ else
+ parent = widget->parent;
+ if (!parent)
+ parent = g_object_get_data (G_OBJECT (widget), "GladeParentKey");
+ if (parent == NULL)
+ break;
+ widget = parent;
+ }
+
+ found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
+ widget_name);
+ if (!found_widget)
+ g_warning ("Widget not found: %s", widget_name);
+ return found_widget;
+}
+
+static GList *pixmaps_directories = NULL;
+
+/* Use this function to set the directory containing installed pixmaps. */
+void
+add_pixmap_directory (const gchar *directory)
+{
+ pixmaps_directories = g_list_prepend (pixmaps_directories,
+ g_strdup (directory));
+}
+
+/* This is an internally used function to find pixmap files. */
+static gchar*
+find_pixmap_file (const gchar *filename)
+{
+ GList *elem;
+
+ /* We step through each of the pixmaps directory to find it. */
+ elem = pixmaps_directories;
+ while (elem)
+ {
+ gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
+ G_DIR_SEPARATOR_S, filename);
+ if (g_file_test (pathname, G_FILE_TEST_EXISTS))
+ return pathname;
+ g_free (pathname);
+ elem = elem->next;
+ }
+ return NULL;
+}
+
+/* This is an internally used function to create pixmaps. */
+GtkWidget*
+create_pixmap (GtkWidget *widget,
+ const gchar *filename)
+{
+ gchar *pathname = NULL;
+ GtkWidget *pixmap;
+
+ if (!filename || !filename[0])
+ return gtk_image_new ();
+
+ pathname = find_pixmap_file (filename);
+
+ if (!pathname)
+ {
+ g_warning (_("Couldn't find pixmap file: %s"), filename);
+ return gtk_image_new ();
+ }
+
+ pixmap = gtk_image_new_from_file (pathname);
+ g_free (pathname);
+ return pixmap;
+}
+
+/* This is an internally used function to create pixmaps. */
+GdkPixbuf*
+create_pixbuf (const gchar *filename)
+{
+ gchar *pathname = NULL;
+ GdkPixbuf *pixbuf;
+ GError *error = NULL;
+
+ if (!filename || !filename[0])
+ return NULL;
+
+ pathname = find_pixmap_file (filename);
+
+ if (!pathname)
+ {
+ g_warning (_("Couldn't find pixmap file: %s"), filename);
+ return NULL;
+ }
+
+ pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
+ if (!pixbuf)
+ {
+ fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
+ pathname, error->message);
+ g_error_free (error);
+ }
+ g_free (pathname);
+ return pixbuf;
+}
+
+/* This is used to set ATK action descriptions. */
+void
+glade_set_atk_action_description (AtkAction *action,
+ const gchar *action_name,
+ const gchar *description)
+{
+ gint n_actions, i;
+
+ n_actions = atk_action_get_n_actions (action);
+ for (i = 0; i < n_actions; i++)
+ {
+ if (!strcmp (atk_action_get_name (action, i), action_name))
+ atk_action_set_description (action, i, description);
+ }
+}
+
diff --git a/tools/glade/examples/editor/src/support.h b/tools/glade/examples/editor/src/support.h
new file mode 100644
index 00000000..92201b97
--- /dev/null
+++ b/tools/glade/examples/editor/src/support.h
@@ -0,0 +1,67 @@
+/*
+ * DO NOT EDIT THIS FILE - it is generated by Glade.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+
+/*
+ * Standard gettext macros.
+ */
+#ifdef ENABLE_NLS
+# include <libintl.h>
+# undef _
+# define _(String) dgettext (PACKAGE, String)
+# ifdef gettext_noop
+# define N_(String) gettext_noop (String)
+# else
+# define N_(String) (String)
+# endif
+#else
+# define textdomain(String) (String)
+# define gettext(String) (String)
+# define dgettext(Domain,Message) (Message)
+# define dcgettext(Domain,Message,Type) (Message)
+# define bindtextdomain(Domain,Directory) (Domain)
+# define _(String) (String)
+# define N_(String) (String)
+#endif
+
+
+/*
+ * Public Functions.
+ */
+
+/*
+ * This function returns a widget in a component created by Glade.
+ * Call it with the toplevel widget in the component (i.e. a window/dialog),
+ * or alternatively any widget in the component, and the name of the widget
+ * you want returned.
+ */
+GtkWidget* lookup_widget (GtkWidget *widget,
+ const gchar *widget_name);
+
+
+/* Use this function to set the directory containing installed pixmaps. */
+void add_pixmap_directory (const gchar *directory);
+
+
+/*
+ * Private Functions.
+ */
+
+/* This is used to create the pixmaps used in the interface. */
+GtkWidget* create_pixmap (GtkWidget *widget,
+ const gchar *filename);
+
+/* This is used to create the pixbufs used in the interface. */
+GdkPixbuf* create_pixbuf (const gchar *filename);
+
+/* This is used to set ATK action descriptions. */
+void glade_set_atk_action_description (AtkAction *action,
+ const gchar *action_name,
+ const gchar *description);
+