summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2001-11-06 18:25:15 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-11-06 18:25:15 +0000
commit9bb17278c47fe892962494ab6e942c7a103c598f (patch)
tree5a6e1ad9d66356b8a22d0151e18ac00bc8cd7947
parentd73ad69c8de87911765398191734e39d7411b1b8 (diff)
downloadgtk+-9bb17278c47fe892962494ab6e942c7a103c598f.tar.gz
wacky easter egg
2001-11-06 Havoc Pennington <hp@redhat.com> * demos/gtk-demo/textview.c (easter_egg_callback): wacky easter egg
-rw-r--r--ChangeLog4
-rw-r--r--ChangeLog.pre-2-04
-rw-r--r--ChangeLog.pre-2-104
-rw-r--r--ChangeLog.pre-2-24
-rw-r--r--ChangeLog.pre-2-44
-rw-r--r--ChangeLog.pre-2-64
-rw-r--r--ChangeLog.pre-2-84
-rw-r--r--demos/gtk-demo/textview.c87
8 files changed, 115 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 83721f0ab4..cb8c8eaa46 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2001-11-06 Havoc Pennington <hp@redhat.com>
+
+ * demos/gtk-demo/textview.c (easter_egg_callback): wacky easter egg
+
Tue Nov 6 10:13:16 2001 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkgc-x11.c: Fix misplaced HAVE_XFT.
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index 83721f0ab4..cb8c8eaa46 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -1,3 +1,7 @@
+2001-11-06 Havoc Pennington <hp@redhat.com>
+
+ * demos/gtk-demo/textview.c (easter_egg_callback): wacky easter egg
+
Tue Nov 6 10:13:16 2001 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkgc-x11.c: Fix misplaced HAVE_XFT.
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 83721f0ab4..cb8c8eaa46 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,7 @@
+2001-11-06 Havoc Pennington <hp@redhat.com>
+
+ * demos/gtk-demo/textview.c (easter_egg_callback): wacky easter egg
+
Tue Nov 6 10:13:16 2001 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkgc-x11.c: Fix misplaced HAVE_XFT.
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index 83721f0ab4..cb8c8eaa46 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -1,3 +1,7 @@
+2001-11-06 Havoc Pennington <hp@redhat.com>
+
+ * demos/gtk-demo/textview.c (easter_egg_callback): wacky easter egg
+
Tue Nov 6 10:13:16 2001 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkgc-x11.c: Fix misplaced HAVE_XFT.
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 83721f0ab4..cb8c8eaa46 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,7 @@
+2001-11-06 Havoc Pennington <hp@redhat.com>
+
+ * demos/gtk-demo/textview.c (easter_egg_callback): wacky easter egg
+
Tue Nov 6 10:13:16 2001 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkgc-x11.c: Fix misplaced HAVE_XFT.
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 83721f0ab4..cb8c8eaa46 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,7 @@
+2001-11-06 Havoc Pennington <hp@redhat.com>
+
+ * demos/gtk-demo/textview.c (easter_egg_callback): wacky easter egg
+
Tue Nov 6 10:13:16 2001 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkgc-x11.c: Fix misplaced HAVE_XFT.
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 83721f0ab4..cb8c8eaa46 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,7 @@
+2001-11-06 Havoc Pennington <hp@redhat.com>
+
+ * demos/gtk-demo/textview.c (easter_egg_callback): wacky easter egg
+
Tue Nov 6 10:13:16 2001 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkgc-x11.c: Fix misplaced HAVE_XFT.
diff --git a/demos/gtk-demo/textview.c b/demos/gtk-demo/textview.c
index 7693862ade..ced9c80525 100644
--- a/demos/gtk-demo/textview.c
+++ b/demos/gtk-demo/textview.c
@@ -10,6 +10,8 @@
#include <gtk/gtk.h>
#include <stdlib.h> /* for exit() */
+static void easter_egg_callback (GtkWidget *button, gpointer data);
+
#define gray50_width 2
#define gray50_height 2
static char gray50_bits[] = {
@@ -379,6 +381,10 @@ attach_widgets (GtkTextView *text_view)
if (i == 0)
{
widget = gtk_button_new_with_label ("Click Me");
+
+ g_signal_connect (G_OBJECT (widget), "clicked",
+ G_CALLBACK (easter_egg_callback),
+ NULL);
}
else if (i == 1)
{
@@ -505,3 +511,84 @@ do_textview (void)
return window;
}
+static void
+recursive_attach_view (int depth,
+ GtkTextView *view,
+ GtkTextChildAnchor *anchor)
+{
+ GtkWidget *child_view;
+ GtkWidget *event_box;
+ GdkColor color;
+ GtkWidget *align;
+
+ if (depth > 4)
+ return;
+
+ child_view = gtk_text_view_new_with_buffer (gtk_text_view_get_buffer (view));
+
+ /* Event box is to add a black border around each child view */
+ event_box = gtk_event_box_new ();
+ gdk_color_parse ("black", &color);
+ gtk_widget_modify_bg (event_box, GTK_STATE_NORMAL, &color);
+
+ align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
+ gtk_container_set_border_width (GTK_CONTAINER (align), 1);
+
+ gtk_container_add (GTK_CONTAINER (event_box), align);
+ gtk_container_add (GTK_CONTAINER (align), child_view);
+
+ gtk_text_view_add_child_at_anchor (view, event_box, anchor);
+
+ recursive_attach_view (depth + 1, GTK_TEXT_VIEW (child_view), anchor);
+}
+
+static void
+easter_egg_callback (GtkWidget *button,
+ gpointer data)
+{
+ static GtkWidget *window = NULL;
+ GtkTextBuffer *buffer;
+ GtkWidget *view;
+ GtkTextIter iter;
+ GtkTextChildAnchor *anchor;
+ GtkWidget *sw;
+
+ if (window)
+ {
+ gtk_window_present (GTK_WINDOW (window));
+ return;
+ }
+
+ buffer = gtk_text_buffer_new (NULL);
+
+ gtk_text_buffer_get_start_iter (buffer, &iter);
+
+ gtk_text_buffer_insert (buffer, &iter,
+ "This buffer is shared by a set of nested text views.\n Nested view:\n", -1);
+ anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
+ gtk_text_buffer_insert (buffer, &iter,
+ "\nDon't do this in real applications, please.\n", -1);
+
+ view = gtk_text_view_new_with_buffer (buffer);
+
+ recursive_attach_view (0, GTK_TEXT_VIEW (view), anchor);
+
+ g_object_unref (G_OBJECT (buffer));
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+
+ gtk_container_add (GTK_CONTAINER (window), sw);
+ gtk_container_add (GTK_CONTAINER (sw), view);
+
+ g_object_add_weak_pointer (G_OBJECT (window),
+ (gpointer *) &window);
+
+ gtk_window_set_default_size (GTK_WINDOW (window), 300, 400);
+
+ gtk_widget_show_all (window);
+}
+