From cd0d2db8d4a8863bb48eca8bb197bd73d2f6c9a4 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 26 Mar 2012 19:30:24 +0200 Subject: [PATCH] gcompat: get closer to working with gtk3 Just need the draw event now, instead of the expose_event. Signed-off-by: Jens Axboe --- Makefile | 2 -- gclient.c | 8 +++++--- gcompat.c | 14 ++++++++++++++ gcompat.h | 5 +++++ gfio.c | 10 ++++++---- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 390d969b..3091d095 100644 --- a/Makefile +++ b/Makefile @@ -12,8 +12,6 @@ UNAME := $(shell uname) GTK_CFLAGS = `pkg-config --cflags gtk+-2.0 gthread-2.0` GTK_LDFLAGS = `pkg-config --libs gtk+-2.0 gthread-2.0` -GTK_CFLAGS += -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED - SOURCE := gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \ eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \ lib/rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \ diff --git a/gclient.c b/gclient.c index 67ec18c6..ec12d703 100644 --- a/gclient.c +++ b/gclient.c @@ -892,7 +892,7 @@ static int on_expose_lat_drawing_area(GtkWidget *w, GdkEvent *event, gpointer p) struct graph *g = p; cairo_t *cr; - cr = gdk_cairo_create(w->window); + cr = gdk_cairo_create(gtk_widget_get_window(w)); #if 0 if (graph_has_tooltips(g)) { g_object_set(w, "has-tooltip", TRUE, NULL); @@ -909,10 +909,12 @@ static int on_expose_lat_drawing_area(GtkWidget *w, GdkEvent *event, gpointer p) static gint on_config_lat_drawing_area(GtkWidget *w, GdkEventConfigure *event, gpointer data) { + guint width = gtk_widget_get_allocated_width(w); + guint height = gtk_widget_get_allocated_height(w); struct graph *g = data; - graph_set_size(g, w->allocation.width, w->allocation.height); - graph_set_size(g, w->allocation.width, w->allocation.height); + graph_set_size(g, width, height); + graph_set_size(g, width, height); graph_set_position(g, 0, 0); return TRUE; } diff --git a/gcompat.c b/gcompat.c index f691ec11..7b0810ba 100644 --- a/gcompat.c +++ b/gcompat.c @@ -33,3 +33,17 @@ gchar *gtk_combo_box_text_get_active_text(GtkComboBoxText *combo_box) } #endif + +#if GTK_MAJOR_VERSION < 3 + +guint gtk_widget_get_allocated_width(GtkWidget *w) +{ + return w->allocation.width; +} + +guint gtk_widget_get_allocated_height(GtkWidget *w) +{ + return w->allocation.height; +} + +#endif diff --git a/gcompat.h b/gcompat.h index 9f6f1f6b..66fb781d 100644 --- a/gcompat.h +++ b/gcompat.h @@ -24,4 +24,9 @@ static inline GtkWidget *gtk_dialog_get_content_area(GtkDialog *dialog) } #endif +#if GTK_MAJOR_VERSION < 3 +guint gtk_widget_get_allocated_width(GtkWidget *w); +guint gtk_widget_get_allocated_height(GtkWidget *w); +#endif + #endif diff --git a/gfio.c b/gfio.c index 1ee2745c..24783b20 100644 --- a/gfio.c +++ b/gfio.c @@ -315,11 +315,13 @@ static void gfio_ui_setup_log(struct gui *ui) static gint on_config_drawing_area(GtkWidget *w, GdkEventConfigure *event, gpointer data) { + guint width = gtk_widget_get_allocated_width(w); + guint height = gtk_widget_get_allocated_height(w); struct gfio_graphs *g = data; - graph_set_size(g->iops_graph, w->allocation.width / 2.0, w->allocation.height); - graph_set_position(g->iops_graph, w->allocation.width / 2.0, 0.0); - graph_set_size(g->bandwidth_graph, w->allocation.width / 2.0, w->allocation.height); + graph_set_size(g->iops_graph, width / 2.0, height); + graph_set_position(g->iops_graph, width / 2.0, 0.0); + graph_set_size(g->bandwidth_graph, width / 2.0, height); graph_set_position(g->bandwidth_graph, 0, 0); return TRUE; } @@ -355,7 +357,7 @@ static int on_expose_drawing_area(GtkWidget *w, GdkEvent *event, gpointer p) struct gfio_graphs *g = p; cairo_t *cr; - cr = gdk_cairo_create(w->window); + cr = gdk_cairo_create(gtk_widget_get_window(w)); if (graph_has_tooltips(g->iops_graph) || graph_has_tooltips(g->bandwidth_graph)) { -- 2.25.1