gcompat: get closer to working with gtk3
authorJens Axboe <axboe@kernel.dk>
Mon, 26 Mar 2012 17:30:24 +0000 (19:30 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 26 Mar 2012 17:30:24 +0000 (19:30 +0200)
Just need the draw event now, instead of the expose_event.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
Makefile
gclient.c
gcompat.c
gcompat.h
gfio.c

index 390d969..3091d09 100644 (file)
--- 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 \
index 67ec18c..ec12d70 100644 (file)
--- 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;
 }
index f691ec1..7b0810b 100644 (file)
--- 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
index 9f6f1f6..66fb781 100644 (file)
--- 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 1ee2745..24783b2 100644 (file)
--- 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)) {