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."
This commit is contained in:
Benjamin Otte 2014-10-03 06:59:14 +02:00
parent 2b6a4ba890
commit c9d9c9158f

View File

@ -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);
}