]> Pileus Git - ~andy/gtk/blobdiff - tests/gtkoffscreenbox.c
Add gtk_icon_info_load_icon_async
[~andy/gtk] / tests / gtkoffscreenbox.c
index 1c19fd996e4ba622d1d90db427d149f045398a33..7aeb82cdfd397931dfee78f0bb742c790b4b3e04 100644 (file)
 
 static void        gtk_offscreen_box_realize       (GtkWidget       *widget);
 static void        gtk_offscreen_box_unrealize     (GtkWidget       *widget);
-static void        gtk_offscreen_box_size_request  (GtkWidget       *widget,
-                                                    GtkRequisition  *requisition);
+static void        gtk_offscreen_box_get_preferred_width  (GtkWidget *widget,
+                                                           gint      *minimum,
+                                                           gint      *natural);
+static void        gtk_offscreen_box_get_preferred_height (GtkWidget *widget,
+                                                           gint      *minimum,
+                                                           gint      *natural);
 static void        gtk_offscreen_box_size_allocate (GtkWidget       *widget,
                                                     GtkAllocation   *allocation);
 static gboolean    gtk_offscreen_box_damage        (GtkWidget       *widget,
@@ -119,7 +123,8 @@ gtk_offscreen_box_class_init (GtkOffscreenBoxClass *klass)
 
   widget_class->realize = gtk_offscreen_box_realize;
   widget_class->unrealize = gtk_offscreen_box_unrealize;
-  widget_class->size_request = gtk_offscreen_box_size_request;
+  widget_class->get_preferred_width = gtk_offscreen_box_get_preferred_width;
+  widget_class->get_preferred_height = gtk_offscreen_box_get_preferred_height;
   widget_class->size_allocate = gtk_offscreen_box_size_allocate;
   widget_class->draw = gtk_offscreen_box_draw;
 
@@ -247,7 +252,7 @@ gtk_offscreen_box_realize (GtkWidget *widget)
 {
   GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget);
   GtkAllocation allocation, child_area;
-  GtkStyle *style;
+  GtkStyleContext *context;
   GdkWindow *window;
   GdkWindowAttr attributes;
   gint attributes_mask;
@@ -340,11 +345,10 @@ gtk_offscreen_box_realize (GtkWidget *widget)
   g_signal_connect (offscreen_box->offscreen_window2, "from-embedder",
                    G_CALLBACK (offscreen_window_from_parent2), offscreen_box);
 
-  gtk_widget_style_attach (widget);
-  style = gtk_widget_get_style (widget);
-  gtk_style_set_background (style, window, GTK_STATE_NORMAL);
-  gtk_style_set_background (style, offscreen_box->offscreen_window1, GTK_STATE_NORMAL);
-  gtk_style_set_background (style, offscreen_box->offscreen_window2, GTK_STATE_NORMAL);
+  context = gtk_widget_get_style_context (widget);
+  gtk_style_context_set_background (context, window);
+  gtk_style_context_set_background (context, offscreen_box->offscreen_window1);
+  gtk_style_context_set_background (context, offscreen_box->offscreen_window2);
 
   gdk_window_show (offscreen_box->offscreen_window1);
   gdk_window_show (offscreen_box->offscreen_window2);
@@ -517,6 +521,30 @@ gtk_offscreen_box_size_request (GtkWidget      *widget,
   requisition->height = border_width * 2 + h;
 }
 
+static void
+gtk_offscreen_box_get_preferred_width (GtkWidget *widget,
+                                       gint      *minimum,
+                                       gint      *natural)
+{
+  GtkRequisition requisition;
+
+  gtk_offscreen_box_size_request (widget, &requisition);
+
+  *minimum = *natural = requisition.width;
+}
+
+static void
+gtk_offscreen_box_get_preferred_height (GtkWidget *widget,
+                                        gint      *minimum,
+                                        gint      *natural)
+{
+  GtkRequisition requisition;
+
+  gtk_offscreen_box_size_request (widget, &requisition);
+
+  *minimum = *natural = requisition.height;
+}
+
 static void
 gtk_offscreen_box_size_allocate (GtkWidget     *widget,
                                 GtkAllocation *allocation)
@@ -643,12 +671,11 @@ gtk_offscreen_box_draw (GtkWidget *widget,
     }
   else if (gtk_cairo_should_draw_window (cr, offscreen_box->offscreen_window1))
     {
-      gtk_paint_flat_box (gtk_widget_get_style (widget), cr,
-                          GTK_STATE_NORMAL, GTK_SHADOW_NONE,
-                          widget, "blah",
-                          0, 0,
-                          gdk_window_get_width (offscreen_box->offscreen_window1),
-                          gdk_window_get_height (offscreen_box->offscreen_window1));
+      gtk_render_background (gtk_widget_get_style_context (widget), cr,
+                             0, 0,
+
+                             gdk_window_get_width (offscreen_box->offscreen_window1),
+                             gdk_window_get_height (offscreen_box->offscreen_window1));
 
       if (offscreen_box->child1)
         gtk_container_propagate_draw (GTK_CONTAINER (widget),
@@ -657,12 +684,10 @@ gtk_offscreen_box_draw (GtkWidget *widget,
     }
   else if (gtk_cairo_should_draw_window (cr, offscreen_box->offscreen_window2))
     {
-      gtk_paint_flat_box (gtk_widget_get_style (widget), cr,
-                          GTK_STATE_NORMAL, GTK_SHADOW_NONE,
-                          widget, "blah",
-                          0, 0,
-                          gdk_window_get_width (offscreen_box->offscreen_window2),
-                          gdk_window_get_height (offscreen_box->offscreen_window2));
+      gtk_render_background (gtk_widget_get_style_context (widget), cr,
+                             0, 0,
+                             gdk_window_get_width (offscreen_box->offscreen_window2),
+                             gdk_window_get_height (offscreen_box->offscreen_window2));
 
       if (offscreen_box->child2)
         gtk_container_propagate_draw (GTK_CONTAINER (widget),