summaryrefslogtreecommitdiff
path: root/tools/glade/examples/editor/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/glade/examples/editor/src/main.c')
-rw-r--r--tools/glade/examples/editor/src/main.c56
1 files changed, 56 insertions, 0 deletions
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;
+}
+