summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2014-10-03 06:59:14 +0200
committerBenjamin Otte <otte@redhat.com>2014-10-03 06:59:14 +0200
commitc9d9c9158f117e07e359108649f4601b584b7612 (patch)
tree58d34f875cd544af393cd71efb3337f6d405cdaa /demos
parent2b6a4ba8907c82ba1844711606a3cf6292fe25e2 (diff)
downloadgtk+-c9d9c9158f117e07e359108649f4601b584b7612.tar.gz
gtk-demo: Replace old code
"Hey I know, let's do an easter egg!" "What kind of easter egg?" "We can nest lots of textviews!" "Sounds cool!" ... "But how does one see a textview inside a textview?" "What do you mean?" "Well, it just looks like black text on a white background." "You mean it's the same as if we just duplicated the text?" "Yeah!" "Hrm, maybe we can put a frame around it." "Sounds good. I'll stuff the textviews in a GtkFrame." "What? Why? Let's use a GtkEventBox and override its background" "Why is that a good idea when we have GtkFrame?" "Because I said so!" "Okay."
Diffstat (limited to 'demos')
-rw-r--r--demos/gtk-demo/textview.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/demos/gtk-demo/textview.c b/demos/gtk-demo/textview.c
index 775ede6864..9422759ef7 100644
--- a/demos/gtk-demo/textview.c
+++ b/demos/gtk-demo/textview.c
@@ -539,26 +539,18 @@ recursive_attach_view (int depth,
GtkTextView *view,
GtkTextChildAnchor *anchor)
{
- GtkWidget *child_view;
- GtkWidget *event_box;
- GdkRGBA color;
+ GtkWidget *child_view, *frame;
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_rgba_parse (&color, "black");
- gtk_widget_override_background_color (event_box, 0, &color);
+ /* Frame is to add a black border around each child view */
+ frame = gtk_frame_new (NULL);
+ gtk_container_add (GTK_CONTAINER (frame), child_view);
- gtk_widget_set_halign (child_view, GTK_ALIGN_FILL);
- gtk_widget_set_valign (child_view, GTK_ALIGN_FILL);
-
- gtk_container_add (GTK_CONTAINER (event_box), child_view);
-
- gtk_text_view_add_child_at_anchor (view, event_box, anchor);
+ gtk_text_view_add_child_at_anchor (view, frame, anchor);
recursive_attach_view (depth + 1, GTK_TEXT_VIEW (child_view), anchor);
}