[gtk+] tests: Use a drawing area in animated-resizing
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] tests: Use a drawing area in animated-resizing
- Date: Fri, 18 Nov 2016 20:46:36 +0000 (UTC)
commit e950d0cd8b14217f43a3ac71d453acc01abfdcde
Author: Benjamin Otte <otte redhat com>
Date: Fri Nov 18 15:02:49 2016 +0100
tests: Use a drawing area in animated-resizing
tests/animated-resizing.c | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/tests/animated-resizing.c b/tests/animated-resizing.c
index 042ed61..f0f5269 100644
--- a/tests/animated-resizing.c
+++ b/tests/animated-resizing.c
@@ -66,17 +66,16 @@ ensure_resources(cairo_surface_t *target)
}
}
-static gboolean
-on_window_draw (GtkWidget *widget,
- cairo_t *cr)
+static void
+on_draw (GtkDrawingArea *da,
+ cairo_t *cr,
+ int width,
+ int height,
+ gpointer data)
{
GRand *rand = g_rand_new_with_seed(0);
int i;
- int width, height;
-
- width = gtk_widget_get_allocated_width (widget);
- height = gtk_widget_get_allocated_height (widget);
ensure_resources (cairo_get_target (cr));
@@ -108,8 +107,6 @@ on_window_draw (GtkWidget *widget,
}
g_rand_free(rand);
-
- return FALSE;
}
static void
@@ -168,6 +165,7 @@ int
main(int argc, char **argv)
{
GError *error = NULL;
+ GtkWidget *da;
GdkDisplay *display;
GdkMonitor *monitor;
GdkRectangle monitor_bounds;
@@ -195,8 +193,10 @@ main(int argc, char **argv)
gtk_window_set_keep_above (GTK_WINDOW (window), TRUE);
gtk_window_set_gravity (GTK_WINDOW (window), GDK_GRAVITY_CENTER);
- g_signal_connect (window, "draw",
- G_CALLBACK (on_window_draw), NULL);
+ da = gtk_drawing_area_new ();
+ gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), on_draw, NULL, NULL);
+ gtk_container_add (GTK_CONTAINER (window), da);
+
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
@@ -212,7 +212,7 @@ main(int argc, char **argv)
monitor_bounds.x + (monitor_bounds.width - window_width) / 2,
monitor_bounds.y + (monitor_bounds.height - window_height) / 2);
- gtk_widget_show (window);
+ gtk_widget_show_all (window);
gtk_main ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]