]> Pileus Git - ~andy/gtk/blobdiff - demos/testpixbuf-scale.c
gtk: remove "gboolean homogeneous" from gtk_box_new()
[~andy/gtk] / demos / testpixbuf-scale.c
index 3eb9b0abfac208b2fc46bd47c2fa2d017af3055f..ee57763c84936bfb4e2f73120188eb6d50038b1e 100644 (file)
@@ -32,33 +32,27 @@ overall_changed_cb (GtkAdjustment *adjustment, gpointer data)
 }
 
 gboolean
-expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
+draw_cb (GtkWidget *widget, cairo_t *cr, gpointer data)
 {
-  GtkAllocation allocation;
   GdkPixbuf *dest;
-  cairo_t *cr;
+  int width, height;
 
-  gdk_window_set_back_pixmap (gtk_widget_get_window (widget),
-                              NULL, FALSE);
+  width = gtk_widget_get_allocated_width (widget);
+  height = gtk_widget_get_allocated_height (widget);
 
-  dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, event->area.width, event->area.height);
+  dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, width, height);
 
-  gtk_widget_get_allocation (widget, &allocation);
   gdk_pixbuf_composite_color (pixbuf, dest,
-                             0, 0, event->area.width, event->area.height,
-                             -event->area.x, -event->area.y,
-                              (double) allocation.width / gdk_pixbuf_get_width (pixbuf),
-                              (double) allocation.height / gdk_pixbuf_get_height (pixbuf),
+                             0, 0, width, height,
+                             0, 0,
+                              (double) width / gdk_pixbuf_get_width (pixbuf),
+                              (double) height / gdk_pixbuf_get_height (pixbuf),
                              interp_type, overall_alpha,
-                             event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555);
-
-  cr = gdk_cairo_create (event->window);
+                             0, 0, 16, 0xaaaaaa, 0x555555);
 
   gdk_cairo_set_source_pixbuf (cr, dest, 0, 0);
-  gdk_cairo_rectangle (cr, &event->area);
-  cairo_fill (cr);
+  cairo_paint (cr);
 
-  cairo_destroy (cr);
   g_object_unref (dest);
   
   return TRUE;
@@ -104,15 +98,15 @@ main(int argc, char **argv)
        g_signal_connect (window, "destroy",
                          G_CALLBACK (gtk_main_quit), NULL);
        
-       vbox = gtk_vbox_new (FALSE, 0);
+       vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
        gtk_container_add (GTK_CONTAINER (window), vbox);
 
-        combo_box = gtk_combo_box_new_text ();
+        combo_box = gtk_combo_box_text_new ();
 
-        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), "NEAREST");
-        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), "BILINEAR");
-        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), "TILES");
-        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), "HYPER");
+        gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), "NEAREST");
+        gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), "BILINEAR");
+        gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), "TILES");
+        gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), "HYPER");
 
         gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 1);
 
@@ -123,17 +117,17 @@ main(int argc, char **argv)
        alignment = gtk_alignment_new (0.0, 0.0, 0.0, 0.5);
        gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
 
-       hbox = gtk_hbox_new (FALSE, 4);
+       hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
        gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 
        label = gtk_label_new ("Overall Alpha:");
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
 
-       adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (overall_alpha, 0, 255, 1, 10, 0));
+       adjustment = gtk_adjustment_new (overall_alpha, 0, 255, 1, 10, 0);
        g_signal_connect (adjustment, "value_changed",
                          G_CALLBACK (overall_changed_cb), NULL);
        
-       hscale = gtk_hscale_new (adjustment);
+       hscale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, adjustment);
        gtk_scale_set_digits (GTK_SCALE (hscale), 0);
        gtk_box_pack_start (GTK_BOX (hbox), hscale, TRUE, TRUE, 0);
 
@@ -141,14 +135,14 @@ main(int argc, char **argv)
        gtk_widget_show_all (vbox);
 
        /* Compute the size without the drawing area, so we know how big to make the default size */
-        gtk_size_request_get_size (GTK_SIZE_REQUEST (vbox),
+        gtk_widget_get_preferred_size ( (vbox),
                                    &scratch_requisition, NULL);
 
        darea = gtk_drawing_area_new ();
        gtk_box_pack_start (GTK_BOX (vbox), darea, TRUE, TRUE, 0);
 
-       g_signal_connect (darea, "expose_event",
-                         G_CALLBACK (expose_cb), NULL);
+       g_signal_connect (darea, "draw",
+                         G_CALLBACK (draw_cb), NULL);
 
        gtk_window_set_default_size (GTK_WINDOW (window),
                                     gdk_pixbuf_get_width (pixbuf),