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 390d969bcffa927e38e2e04db24f3d52b8732360..3091d0952273f6363c9c2ab46280e40953a1bb60 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 67ec18c626a9536b7e9fa4a9261b68ca2f32b3bc..ec12d70395ef58555897e529ecddc8cba9def052 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 f691ec11de89b4e42b11cbbd8220fc9cbea3bca8..7b0810ba4d8a36629699b306bc7d379ab1363147 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 9f6f1f6bb2bd4d44d7b24b1bd23f8ece9a0db2e4..66fb781d1351cca1adb185e3dccc67de0184d067 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 1ee2745c1f980ac62789f255ae1d6cb43c130ac6..24783b20af122260ea4665b0797cfda8fc4592ca 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)) {