[gtk+] gtk-demo: Replace old code



commit c9d9c9158f117e07e359108649f4601b584b7612
Author: Benjamin Otte <otte redhat com>
Date:   Fri Oct 3 06:59:14 2014 +0200

    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."

 demos/gtk-demo/textview.c |   18 +++++-------------
 1 files changed, 5 insertions(+), 13 deletions(-)
---
diff --git a/demos/gtk-demo/textview.c b/demos/gtk-demo/textview.c
index 775ede6..9422759 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);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]