merge_all_tap_menus() has been moved to menus.c.
[obnox/wireshark/wip.git] / gtk / tcp_graph.c
index 0fa588d7ddcb0e83b6ac5f78d7f74cea9a9210fa..d89d90b71cc5244d5307c0ac6da9eca64d5dfb81 100644 (file)
 #include <math.h>
 #include <string.h>
 
+#if defined(GDK_DISABLE_DEPRECATED)
+# undef GDK_DISABLE_DEPRECATED
+#endif
+
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
+#if GTK_CHECK_VERSION(3,0,0)
+# include <gdk/gdkkeysyms-compat.h>
+#endif
 
 #include <epan/packet.h>
 #include <epan/ipproto.h>
 
 #include "../globals.h"
 #include "../simple_dialog.h"
-#include "../color.h"
 #include "../stat_menu.h"
 
 #include "gtk/gui_utils.h"
 #include "gtk/dlg_utils.h"
 #include "gtk/gui_stat_menu.h"
 
+#include "gtk/old-gtk-compat.h"
 
 #define TH_FIN    0x01
 #define TH_SYN    0x02
@@ -122,7 +129,7 @@ typedef enum {
        ELMT_NONE=0,
        ELMT_RECT=1,
        ELMT_LINE=2,
-       ELMT_ARC=3
+       ELMT_ELLIPSE=3
 } ElementType;
 
 struct rect_params {
@@ -134,18 +141,16 @@ struct line_params {
        struct line dim;
 };
 
-struct arc_params {
+struct ellipse_params {
        struct rect dim;
-       gint filled;
-       gint angle1, angle2;
 };
 
 struct element {
        ElementType type;
-       GdkGC *gc;
+       GdkColor *elment_color_p;
        struct segment *parent;
        union {
-               struct arc_params arc;
+               struct ellipse_params ellipse;
                struct rect_params rect;
                struct line_params line;
        } p;
@@ -159,7 +164,11 @@ struct element_list {
 struct axis {
        struct graph *g;                        /* which graph we belong to */
        GtkWidget *drawing_area;
+#if GTK_CHECK_VERSION(2,22,0)
+       cairo_surface_t *surface[2];
+#else
        GdkPixmap *pixmap[2];
+#endif
        int displayed;
 #define AXIS_ORIENTATION       1 << 0
        int flags;
@@ -178,8 +187,8 @@ struct axis {
 #define RMARGIN_WIDTH  30
 
 struct style_tseq_tcptrace {
-       GdkGC *gc_seq;
-       GdkGC *gc_ack[2];
+       GdkColor seq_color;
+       GdkColor ack_color[2];
        int flags;
 };
 
@@ -296,13 +305,21 @@ struct graph {
        int flags;
        GtkWidget *toplevel;    /* keypress handler needs this */
        GtkWidget *drawing_area;
-        GtkWidget *text;       /* text widget for seg list - probably
-                                 * temporary */
+       GtkWidget *text;        /* text widget for seg list - probably
+                                                * temporary
+                                                */
        PangoFontDescription *font;     /* font used for annotations etc. */
+#if GTK_CHECK_VERSION(3,0,0)
+#else
        GdkGC *fg_gc;
-       GdkGC *bg_gc;
+#endif
+#if GTK_CHECK_VERSION(2,22,0)
+       cairo_surface_t *title_surface;
+       cairo_surface_t *surface[2];
+#else
        GdkPixmap *title_pixmap;
        GdkPixmap *pixmap[2];
+#endif
        int displayed;                  /* which of both pixmaps is on screen right now */
        struct {
                GtkWidget *control_panel;
@@ -349,7 +366,10 @@ struct graph {
        } gt;
 };
 
+#if GTK_CHECK_VERSION(3,0,0)
+#else
 static GdkGC *xor_gc = NULL;
+#endif
 static int refnum=0;
 
 #define debug(section) if (debugging & section)
@@ -414,7 +434,7 @@ static void graph_destroy (struct graph * );
 static void graph_initialize_values (struct graph * );
 static void graph_init_sequence (struct graph * );
 static void draw_element_line (struct graph * , struct element * );
-static void draw_element_arc (struct graph * , struct element * );
+static void draw_element_ellipse (struct graph * , struct element * );
 static void graph_display (struct graph * );
 static void graph_pixmaps_create (struct graph * );
 static void graph_pixmaps_switch (struct graph * );
@@ -430,7 +450,7 @@ static void graph_segment_list_get (struct graph * );
 static void graph_segment_list_free (struct graph * );
 static void graph_select_segment (struct graph * , int , int );
 static int line_detect_collision (struct element * , int , int );
-static int arc_detect_collision (struct element * , int , int );
+static int ellipse_detect_collision (struct element * , int , int );
 static void axis_pixmaps_create (struct axis * );
 static void axis_pixmaps_switch (struct axis * );
 static void axis_display (struct axis * );
@@ -493,9 +513,9 @@ static void wscale_make_elmtlist(struct graph *);
 static int rint (double );     /* compiler template for Windows */
 #endif
 
-/* 
- * Uncomment the following define to revert WIN32 to 
- * use original mouse button controls 
+/*
+ * Uncomment the following define to revert WIN32 to
+ * use original mouse button controls
  */
 
 /* #define ORIGINAL_WIN32_BUTTONS 1 */
@@ -558,7 +578,7 @@ static char helptext[] =
 static void debug_coord (struct graph *g, const char *c)
 {
        static unsigned count = 0;
-       
+
        count++;
        printf("%u: %s\n", count, c);
        printf("%u:  g->geom.width %d\n", count, g->geom.width);
@@ -580,17 +600,17 @@ static void set_busy_cursor(GdkWindow *w)
 
        cursor = gdk_cursor_new(GDK_WATCH);
        gdk_window_set_cursor(w, cursor);
-       gdk_flush(); 
-       gdk_cursor_destroy(cursor);
+       gdk_flush();
+       gdk_cursor_unref(cursor);
 }
 
 static void unset_busy_cursor(GdkWindow *w)
 {
        gdk_window_set_cursor(w, NULL);
-       gdk_flush(); 
+       gdk_flush();
 }
 #ifdef MAIN_MENU_USE_UIMANAGER
-void tcp_graph_cb (GtkAction *action, gpointer user_data)
+void tcp_graph_cb (GtkAction *action, gpointer user_data _U_)
 {
        struct segment current;
        struct graph *g;
@@ -608,6 +628,8 @@ void tcp_graph_cb (GtkAction *action, gpointer user_data)
                graph_type = GRAPH_RTT;
        }else if(strcmp(name, "/Analyze/StatisticsMenu/TCPStreamGraphMenu/Window-Scaling-Graph") == 0){
                graph_type = GRAPH_WSCALE;
+       }else{
+               return;
        }
 
        debug(DBS_FENTRY) puts ("tcp_graph_cb()");
@@ -668,19 +690,23 @@ static void create_gui (struct graph *g)
 
 static void create_drawing_area (struct graph *g)
 {
+#if GTK_CHECK_VERSION(3,0,0)
+       GtkStyleContext *context;
+#else
        GdkColormap *colormap;
        GdkColor color;
+#endif
        char window_title[WINDOW_TITLE_LENGTH];
        struct segment current;
        struct tcpheader *thdr;
-
-       debug(DBS_FENTRY) puts ("create_drawing_area()");
+       GtkAllocation widget_alloc;
 #if 0
-       g->font = gdk_font_load ("-sony-fixed-medium-r-normal--16-150-75-75"
-                                                       "-c-80-iso8859-2");
-       g->font = gdk_font_load ("-biznet-fotinostypewriter-medium-r-normal-*-*-120"
-                                                       "-*-*-m-*-iso8859-2");
+       /* Prep. to include the controls in the graph window */
+       GtkWidget *frame;
+       GtkWidget *vbox;
+       GtkWidget *hbox;
 #endif
+       debug(DBS_FENTRY) puts ("create_drawing_area()");
        thdr=select_tcpip_session (&cfile, &current);
        g_snprintf (window_title, WINDOW_TITLE_LENGTH, "TCP Graph %d: %s %s:%d -> %s:%d",
                        refnum,
@@ -738,33 +764,53 @@ static void create_drawing_area (struct graph *g)
                                | GDK_POINTER_MOTION_HINT_MASK);
 
 #if 0
+       /* Prep. to include the controls in the graph window */
+
+       vbox = gtk_vbox_new (FALSE, 0);
+       gtk_container_add (GTK_CONTAINER (g->toplevel), vbox);
+       gtk_container_set_border_width (GTK_CONTAINER (g->toplevel), 5);
+       gtk_widget_show (vbox);
+
        frame = gtk_frame_new (NULL);
        gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
        gtk_container_add (GTK_CONTAINER (frame), g->drawing_area);
-
-       box = gtk_hbox_new (FALSE, 0);
-       gtk_box_pack_start (GTK_BOX (box), g->gui.control_panel, FALSE, FALSE, 0);
-       gtk_box_pack_start (GTK_BOX (box), frame, TRUE, TRUE, 0);
-       gtk_container_add (GTK_CONTAINER (g->toplevel), box);
-       gtk_container_set_border_width (GTK_CONTAINER (g->toplevel), 5);
+       gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
        gtk_widget_show (frame);
-       gtk_widget_show (box);
+
+
+       /*gtk_box_pack_start (GTK_BOX (vbox), g->gui.control_panel, FALSE, FALSE, 0);*/
+
+       hbox=gtk_hbox_new(FALSE, 3);
+       gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
+       gtk_container_set_border_width(GTK_CONTAINER(hbox), 3);
+       gtk_box_set_child_packing(GTK_BOX(vbox), hbox, FALSE, FALSE, 0, GTK_PACK_START);
+       gtk_widget_show(hbox);
+
+       create_ctrl_area(g, hbox);
+
 #endif
 
        gtk_container_add (GTK_CONTAINER (g->toplevel), g->drawing_area);
        gtk_widget_show (g->toplevel);
 
        /* in case we didn't get what we asked for */
-       g->wp.width = GTK_WIDGET (g->drawing_area)->allocation.width -
-                                               g->wp.x - RMARGIN_WIDTH;
-       g->wp.height = GTK_WIDGET (g->drawing_area)->allocation.height -
-                                               g->wp.y - g->x_axis->s.height;
-
-        g->font = g->drawing_area->style->font_desc;
-
-       colormap = gdk_window_get_colormap (g->drawing_area->window);
+       gtk_widget_get_allocation(GTK_WIDGET (g->drawing_area), &widget_alloc);
+       g->wp.width = widget_alloc.width - g->wp.x - RMARGIN_WIDTH;
+       g->wp.height = widget_alloc.height - g->wp.y - g->x_axis->s.height;
+
+#if GTK_CHECK_VERSION(3,0,0)
+       context = gtk_widget_get_style_context (g->drawing_area);
+       gtk_style_context_get (context, GTK_STATE_NORMAL,
+                                          "font", &g->font,
+                                          NULL);
+#else
+       g->font = gtk_widget_get_style(g->drawing_area)->font_desc;
+#endif
+#if GTK_CHECK_VERSION(3,0,0)
+#else
+       colormap = gtk_widget_get_colormap(GTK_WIDGET(g->drawing_area));
        if (!xor_gc) {
-               xor_gc = gdk_gc_new (g->drawing_area->window);
+               xor_gc = gdk_gc_new (gtk_widget_get_window(g->drawing_area));
                gdk_gc_set_function (xor_gc, GDK_XOR);
                if (!gdk_color_parse ("gray15", &color)) {
                        /*
@@ -782,23 +828,7 @@ static void create_drawing_area (struct graph *g)
                }
                gdk_gc_set_foreground (xor_gc, &color);
        }
-       g->fg_gc = gdk_gc_new (g->drawing_area->window);
-       g->bg_gc = gdk_gc_new (g->drawing_area->window);
-       if (!gdk_color_parse ("white", &color)) {
-               /*
-                * XXX - do more than just warn.
-                */
-               simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
-                   "Could not parse color white.");
-       }
-       if (!gdk_colormap_alloc_color (colormap, &color, FALSE, TRUE)) {
-               /*
-                * XXX - do more than just warn.
-                */
-               simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
-                   "Could not allocate color white.");
-       }
-       gdk_gc_set_foreground (g->bg_gc, &color);
+       g->fg_gc = gdk_gc_new (gtk_widget_get_window(g->drawing_area));
 
        /* this is probably quite an ugly way to get rid of the first configure
         * event
@@ -813,6 +843,7 @@ static void create_drawing_area (struct graph *g)
         * !!! NEMLLO BY TO BYT NA KONCI graph_init_sequence()? !!!
         *
         */
+#endif
        g_signal_connect(g->drawing_area, "configure_event", G_CALLBACK(configure_event),
                        NULL);
 
@@ -1147,7 +1178,7 @@ static void callback_zoom_inout (GtkWidget *toggle, gpointer data)
 {
        struct graph *g = (struct graph * )data;
 
-       if (GTK_TOGGLE_BUTTON (toggle)->active)
+       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (toggle)))
                g->zoom.flags &= ~ZOOM_OUT;
        else
                g->zoom.flags |= ZOOM_OUT;
@@ -1203,7 +1234,7 @@ static void callback_zoom_flags (GtkWidget *toggle, gpointer data)
        struct graph *g = (struct graph * )data;
        int flag = (long)g_object_get_data(G_OBJECT(toggle), "flag");
 
-       if (GTK_TOGGLE_BUTTON (toggle)->active)
+       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (toggle)))
                g->zoom.flags |= flag;
        else
                g->zoom.flags &= ~flag;
@@ -1408,7 +1439,7 @@ static void callback_mag_flags (GtkWidget *toggle, gpointer data)
        struct graph *g = (struct graph * )data;
        int flag = (long)g_object_get_data(G_OBJECT(toggle), "flag");
 
-       if (GTK_TOGGLE_BUTTON (toggle)->active)
+       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (toggle)))
                g->magnify.flags |= flag;
        else
                g->magnify.flags &= ~flag;
@@ -1445,7 +1476,7 @@ static void callback_zoomlock_h (GtkWidget *toggle, gpointer data)
 {
        struct graph *g = (struct graph * )data;
 
-       if (GTK_TOGGLE_BUTTON (toggle)->active)
+       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (toggle)))
                g->zoom.flags |= ZOOM_HLOCK;
        else
                g->zoom.flags &= ~ZOOM_HLOCK;
@@ -1455,7 +1486,7 @@ static void callback_zoomlock_v (GtkWidget *toggle, gpointer data)
 {
        struct graph *g = (struct graph * )data;
 
-       if (GTK_TOGGLE_BUTTON (toggle)->active)
+       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (toggle)))
                g->zoom.flags |= ZOOM_VLOCK;
        else
                g->zoom.flags &= ~ZOOM_VLOCK;
@@ -1492,10 +1523,10 @@ static void callback_cross_on_off (GtkWidget *toggle, gpointer data)
 {
        struct graph *g = (struct graph * )data;
 
-       if (GTK_TOGGLE_BUTTON (toggle)->active) {
+       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (toggle))) {
                int x, y;
                g->cross.draw = TRUE;
-               gdk_window_get_pointer (g->drawing_area->window, &x, &y, 0);
+               gdk_window_get_pointer (gtk_widget_get_window(g->drawing_area), &x, &y, 0);
                cross_draw (g, x, y);
        } else {
                g->cross.draw = FALSE;
@@ -1548,7 +1579,7 @@ static GtkWidget *control_panel_create_graph_type_group (struct graph *g)
        gtk_box_pack_start (GTK_BOX (graph_box), graph_tput, TRUE, TRUE, 0);
        gtk_box_pack_start (GTK_BOX (graph_box), graph_tseqstevens, TRUE, TRUE, 0);
        gtk_box_pack_start (GTK_BOX (graph_box), graph_tseqttrace, TRUE, TRUE, 0);
-       gtk_box_pack_start (GTK_BOX (graph_box), graph_wscale, TRUE, TRUE, 0); 
+       gtk_box_pack_start (GTK_BOX (graph_box), graph_wscale, TRUE, TRUE, 0);
        gtk_box_pack_start (GTK_BOX (graph_box), graph_sep, TRUE, TRUE, 0);
        gtk_box_pack_start (GTK_BOX (graph_box), graph_init, TRUE, TRUE, 0);
        graph_frame = gtk_frame_new ("Graph type:");
@@ -1584,7 +1615,7 @@ static void callback_graph_type (GtkWidget *toggle, gpointer data)
 
        new_type = (long)g_object_get_data(G_OBJECT(toggle),"new-graph-type");
 
-       if (!GTK_TOGGLE_BUTTON (toggle)->active)
+       if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (toggle)))
                return;
 
        old_type = g->type;
@@ -1720,10 +1751,20 @@ static void graph_destroy (struct graph *g)
        window_destroy (g->gui.control_panel);
        window_destroy (g->toplevel);
        /* window_destroy (g->text); */
-       gdk_gc_unref (g->fg_gc);
-       gdk_gc_unref (g->bg_gc);
-       gdk_pixmap_unref (g->pixmap[0]);
-       gdk_pixmap_unref (g->pixmap[1]);
+#if GTK_CHECK_VERSION(2,22,0)
+       if(g->title_surface){
+                cairo_surface_destroy (g->title_surface);
+       }
+       if(g->surface[0]){
+                cairo_surface_destroy (g->surface[0]);
+       }
+       if(g->surface[1]){
+                cairo_surface_destroy (g->surface[1]);
+       }
+#else
+       g_object_unref (g->pixmap[0]);
+       g_object_unref (g->pixmap[1]);
+#endif /* GTK_CHECK_VERSION(2,22,0) */
        g_free (g->x_axis);
        g_free (g->y_axis);
        g_free ( (gpointer) (g->title) );
@@ -2009,68 +2050,138 @@ static void graph_element_lists_free (struct graph *g)
 
 static void graph_title_pixmap_create (struct graph *g)
 {
+#if GTK_CHECK_VERSION(2,22,0)
+       if(g->title_surface){
+               cairo_surface_destroy (g->title_surface);
+               g->title_surface = NULL;
+       }
+
+       g->title_surface = gdk_window_create_similar_surface (gtk_widget_get_window(g->drawing_area),
+                       CAIRO_CONTENT_COLOR,
+                       g->x_axis->p.width,
+                       g->wp.y);
+
+#else
        if (g->title_pixmap)
-               gdk_pixmap_unref (g->title_pixmap);
+               g_object_unref (g->title_pixmap);
 
-       g->title_pixmap = gdk_pixmap_new (g->drawing_area->window,
+       g->title_pixmap = gdk_pixmap_new (gtk_widget_get_window(g->drawing_area),
                                                        g->x_axis->p.width, g->wp.y, -1);
+#endif
 }
 
 static void graph_title_pixmap_draw (struct graph *g)
 {
        int i;
+       cairo_t *cr;
+
+#if GTK_CHECK_VERSION(2,22,0)
+       cr = cairo_create (g->title_surface);
+#else
+       cr = gdk_cairo_create (g->title_pixmap);
+#endif
+       cairo_set_source_rgb (cr, 1, 1, 1);
+       cairo_rectangle (cr, 0, 0,  g->x_axis->p.width, g->wp.y);
+       cairo_fill (cr);
+       cairo_destroy (cr);
+       cr = NULL;
 
-       gdk_draw_rectangle(g->title_pixmap, g->bg_gc, TRUE, 0, 0,
-                           g->x_axis->p.width, g->wp.y);
        for (i=0; g->title[i]; i++) {
                gint w, h;
-                PangoLayout *layout;
-                layout = gtk_widget_create_pango_layout(g->drawing_area,
-                                                        g->title[i]);
-                pango_layout_get_pixel_size(layout, &w, &h);
-                gdk_draw_layout(g->title_pixmap, g->fg_gc,
-                                g->wp.width/2 - w/2, 20 + i*(h+3), layout);
-                g_object_unref(G_OBJECT(layout));
+        PangoLayout *layout;
+        layout = gtk_widget_create_pango_layout(g->drawing_area,
+                                                g->title[i]);
+        pango_layout_get_pixel_size(layout, &w, &h);
+#if GTK_CHECK_VERSION(2,22,0)
+               cr = cairo_create (g->title_surface);
+#else
+               cr = gdk_cairo_create (g->title_pixmap);
+#endif
+               cairo_move_to (cr, g->wp.width/2 - w/2, 20 + i*(h+3));
+               pango_cairo_show_layout (cr, layout);
+               cairo_destroy (cr);
+        g_object_unref(G_OBJECT(layout));
        }
 }
 
 static void graph_title_pixmap_display (struct graph *g)
 {
-       gdk_draw_pixmap (g->drawing_area->window, g->fg_gc, g->title_pixmap,
-                         0, 0, g->wp.x, 0, g->x_axis->p.width, g->wp.y);
+       cairo_t *cr;
+
+       cr = gdk_cairo_create (gtk_widget_get_window(g->drawing_area));
+#if GTK_CHECK_VERSION(2,22,0)
+       cairo_set_source_surface (cr, g->title_surface, g->wp.x, 0);
+#else
+       gdk_cairo_set_source_pixmap (cr, g->title_pixmap, g->wp.x, 0);
+#endif
+       cairo_rectangle (cr, g->wp.x, 0, g->x_axis->p.width, g->wp.y);
+       cairo_fill (cr);
+       cairo_destroy (cr);
 }
 
 static void graph_pixmaps_create (struct graph *g)
 {
        debug(DBS_FENTRY) puts ("graph_pixmaps_create()");
+#if GTK_CHECK_VERSION(2,22,0)
+       if(g->surface[0]){
+               cairo_surface_destroy (g->surface[0]);
+               g->surface[0] = NULL;
+       }
+
+       if(g->surface[1]){
+               cairo_surface_destroy (g->surface[1]);
+               g->surface[1] = NULL;
+       }
 
+       g->surface[0] = gdk_window_create_similar_surface (gtk_widget_get_window(g->drawing_area),
+                       CAIRO_CONTENT_COLOR,
+                       g->wp.width,
+                       g->wp.height);
+
+       g->surface[1] = gdk_window_create_similar_surface (gtk_widget_get_window(g->drawing_area),
+                       CAIRO_CONTENT_COLOR,
+                       g->wp.width,
+                       g->wp.height);
+
+       g->displayed = 0;
+#else
        if (g->pixmap[0])
-               gdk_pixmap_unref (g->pixmap[0]);
+               g_object_unref (g->pixmap[0]);
        if (g->pixmap[1])
-               gdk_pixmap_unref (g->pixmap[1]);
+               g_object_unref (g->pixmap[1]);
 
-       g->pixmap[0] = gdk_pixmap_new (g->drawing_area->window,
+       g->pixmap[0] = gdk_pixmap_new (gtk_widget_get_window(g->drawing_area),
                                                                        g->wp.width, g->wp.height, -1);
-       g->pixmap[1] = gdk_pixmap_new (g->drawing_area->window,
+       g->pixmap[1] = gdk_pixmap_new (gtk_widget_get_window(g->drawing_area),
                                                                        g->wp.width, g->wp.height, -1);
 
        g->displayed = 0;
+#endif /* GTK_CHECK_VERSION(2,22,0) */
 }
 
 static void graph_display (struct graph *g)
 {
-       set_busy_cursor (g->drawing_area->window);
+       set_busy_cursor (gtk_widget_get_window(g->drawing_area));
        graph_pixmap_draw (g);
-       unset_busy_cursor (g->drawing_area->window);
+       unset_busy_cursor (gtk_widget_get_window(g->drawing_area));
        graph_pixmaps_switch (g);
        graph_pixmap_display (g);
 }
 
 static void graph_pixmap_display (struct graph *g)
 {
-    gdk_draw_pixmap (g->drawing_area->window, g->fg_gc,
-                                       g->pixmap[g->displayed], 0, 0, g->wp.x, g->wp.y,
-                                       g->wp.width, g->wp.height);
+       cairo_t *cr;
+
+       cr = gdk_cairo_create (gtk_widget_get_window(g->drawing_area));
+#if GTK_CHECK_VERSION(2,22,0)
+       cairo_set_source_surface (cr, g->surface[g->displayed], g->wp.x, g->wp.y);
+#else
+       gdk_cairo_set_source_pixmap (cr, g->pixmap[g->displayed], g->wp.x, g->wp.y);
+#endif /* GTK_CHECK_VERSION(2,22,0) */
+       cairo_rectangle (cr, g->wp.x, g->wp.y, g->wp.width, g->wp.height);
+       cairo_fill (cr);
+       cairo_destroy (cr);
+
     if (g->cross.erase_needed) {
        cross_xor(g, g->cross.x, g->cross.y);
     }
@@ -2086,12 +2197,22 @@ static void graph_pixmap_draw (struct graph *g)
        struct element_list *list;
        struct element *e;
        int not_disp;
+       cairo_t *cr;
 
        debug(DBS_FENTRY) puts ("graph_display()");
        not_disp = 1 ^ g->displayed;
 
-       gdk_draw_rectangle (g->pixmap[not_disp], g->bg_gc, TRUE,
-                                                       0, 0, g->wp.width, g->wp.height);
+#if GTK_CHECK_VERSION(2,22,0)
+       cr = cairo_create (g->surface[not_disp]);
+#else
+       cr = gdk_cairo_create (g->pixmap[not_disp]);
+#endif /* GTK_CHECK_VERSION(2,22,0) */
+       cairo_set_source_rgb (cr, 1, 1, 1);
+       cairo_rectangle (cr, 0, 0, g->wp.width, g->wp.height);
+       cairo_fill (cr);
+       cairo_destroy (cr);
+       cr = NULL;
+
        for (list=g->elists; list; list=list->next)
                for (e=list->elements; e->type != ELMT_NONE; e++) {
                        switch (e->type) {
@@ -2100,8 +2221,8 @@ static void graph_pixmap_draw (struct graph *g)
                        case ELMT_LINE:
                                draw_element_line (g, e);
                                break;
-                       case ELMT_ARC:
-                               draw_element_arc (g, e);
+                       case ELMT_ELLIPSE:
+                               draw_element_ellipse (g, e);
                                break;
                        default:
                                break;
@@ -2112,6 +2233,7 @@ static void graph_pixmap_draw (struct graph *g)
 static void draw_element_line (struct graph *g, struct element *e)
 {
        int xx1, xx2, yy1, yy2;
+       cairo_t *cr;
 
        debug(DBS_GRAPH_DRAWING) printf ("line element: (%.2f,%.2f)->(%.2f,%.2f), "
                                "seg %d ... ", e->p.line.dim.x1, e->p.line.dim.y1,
@@ -2145,44 +2267,111 @@ static void draw_element_line (struct graph *g, struct element *e)
        if (yy1 < 0)
                yy1 = 0;
        debug(DBS_GRAPH_DRAWING) printf ("line: (%d,%d)->(%d,%d)\n", xx1, yy1, xx2,yy2);
-       gdk_draw_line (g->pixmap[1^g->displayed], e->gc, xx1, yy1, xx2, yy2);
+
+       g_assert(e->elment_color_p!=NULL);
+
+#if GTK_CHECK_VERSION(2,22,0)
+       cr = cairo_create (g->surface[1^g->displayed]);
+#else
+       cr = gdk_cairo_create (g->pixmap[1^g->displayed]);
+#endif
+       cairo_set_line_width (cr, 1.0);
+       if(e->elment_color_p!=NULL){
+               gdk_cairo_set_source_color (cr, e->elment_color_p);
+       }
+       cairo_move_to(cr, xx1+0.5, yy1+0.5);
+       cairo_line_to(cr, xx2+0.5, yy2+0.5);
+       cairo_stroke(cr);
+       cairo_destroy(cr);
 }
 
-static void draw_element_arc (struct graph *g, struct element *e)
+static void draw_element_ellipse (struct graph *g, struct element *e)
 {
+#if GTK_CHECK_VERSION(2,22,0)
+       cairo_t *cr;
+       gdouble w = e->p.ellipse.dim.width;
+       gdouble h = e->p.ellipse.dim.height;
+       gdouble x = e->p.ellipse.dim.x + g->geom.x - g->wp.x;
+       gdouble y = g->geom.height-1 - e->p.ellipse.dim.y + g->geom.y - g->wp.y;
+
+       debug(DBS_GRAPH_DRAWING) printf ("ellipse: (x, y) -> (w, h): (%f, %f) -> (%f, %f)\n", x, y, w, h);
+
+       cr = cairo_create (g->surface[1^g->displayed]);
+       cairo_translate (cr, x + w / 2., y + h / 2.);
+       cairo_scale (cr, w / 2., h / 2.);
+       cairo_arc (cr, 0., 0., 1., 0., 2 * G_PI);
+       cairo_fill(cr);
+       cairo_destroy(cr);
+#else
        int xx1, xx2, yy1, yy2;
 
-       xx1 = (int )rint (e->p.arc.dim.x + g->geom.x - g->wp.x);
-       xx2 = (int )e->p.arc.dim.width;
-       yy1 = (int )rint (g->geom.height-1 - e->p.arc.dim.y + g->geom.y - g->wp.y);
-       yy2 = (int )e->p.arc.dim.height;
+       xx1 = (int )rint (e->p.ellipse.dim.x + g->geom.x - g->wp.x);
+       xx2 = (int )e->p.ellipse.dim.width;
+       yy1 = (int )rint (g->geom.height-1 - e->p.ellipse.dim.y + g->geom.y - g->wp.y);
+       yy2 = (int )e->p.ellipse.dim.height;
        if (xx1<-xx2 || xx1>=g->wp.width || yy1<-yy2 || yy1>=g->wp.height)
                return;
-       debug(DBS_GRAPH_DRAWING) printf ("arc: (%d,%d)->(%d,%d)\n", xx1, yy1, xx2, yy2);
-       gdk_draw_arc (g->pixmap[1^g->displayed], e->gc, e->p.arc.filled, xx1,
-                                       yy1, xx2, yy2, e->p.arc.angle1, e->p.arc.angle2);
+       debug(DBS_GRAPH_DRAWING) printf ("ellipse: (%d,%d)->(%d,%d)\n", xx1, yy1, xx2, yy2);
+
+       gdk_draw_arc (g->pixmap[1^g->displayed], g->fg_gc, TRUE, xx1,
+                                       yy1, xx2, yy2, 0, 23040);
+#endif
+       /* NOTE the coordinates and angels needs to be recalculated as cairo_arc works differently */
 }
 
 static void axis_pixmaps_create (struct axis *axis)
 {
        debug(DBS_FENTRY) puts ("axis_pixmaps_create()");
+#if GTK_CHECK_VERSION(2,22,0)
+       if(axis->surface[0]){
+               cairo_surface_destroy (axis->surface[0]);
+               axis->surface[0] = NULL;
+       }
+       if(axis->surface[1]){
+               cairo_surface_destroy (axis->surface[1]);
+               axis->surface[1] = NULL;
+       }
+       axis->surface[0] = gdk_window_create_similar_surface (gtk_widget_get_window(axis->drawing_area),
+                       CAIRO_CONTENT_COLOR,
+                       axis->p.width,
+                       axis->p.height);
+
+       axis->surface[1] = gdk_window_create_similar_surface (gtk_widget_get_window(axis->drawing_area),
+                       CAIRO_CONTENT_COLOR,
+                       axis->p.width,
+                       axis->p.height);
+
+       axis->displayed = 0;
+#else
        if (axis->pixmap[0])
-               gdk_pixmap_unref (axis->pixmap[0]);
+               g_object_unref (axis->pixmap[0]);
        if (axis->pixmap[1])
-               gdk_pixmap_unref (axis->pixmap[1]);
+               g_object_unref (axis->pixmap[1]);
 
-       axis->pixmap[0] = gdk_pixmap_new (axis->drawing_area->window,
+       axis->pixmap[0] = gdk_pixmap_new (gtk_widget_get_window(axis->drawing_area),
                                                        axis->p.width, axis->p.height, -1);
-       axis->pixmap[1] = gdk_pixmap_new (axis->drawing_area->window,
+       axis->pixmap[1] = gdk_pixmap_new (gtk_widget_get_window(axis->drawing_area),
                                                        axis->p.width, axis->p.height, -1);
 
        axis->displayed = 0;
+#endif
 }
 
 static void axis_destroy (struct axis *axis)
 {
-       gdk_pixmap_unref (axis->pixmap[0]);
-       gdk_pixmap_unref (axis->pixmap[1]);
+#if GTK_CHECK_VERSION(2,22,0)
+       if(axis->surface[0]){
+               cairo_surface_destroy (axis->surface[0]);
+               axis->surface[0] = NULL;
+       }
+       if(axis->surface[1]){
+               cairo_surface_destroy (axis->surface[1]);
+               axis->surface[1] = NULL;
+       }
+#else
+       g_object_unref (axis->pixmap[0]);
+       g_object_unref (axis->pixmap[1]);
+#endif
        g_free ( (gpointer) (axis->label) );
 }
 
@@ -2204,6 +2393,7 @@ static void v_axis_pixmap_draw (struct axis *axis)
        int not_disp, rdigits, offset, imin, imax;
        double bottom, top, j, fl, corr;
         PangoLayout *layout;
+       cairo_t *cr;
 
        debug(DBS_FENTRY) puts ("v_axis_pixmap_draw()");
        bottom = (g->geom.height - (g->wp.height + g->wp.y + (-g->geom.y))) /
@@ -2223,12 +2413,30 @@ static void v_axis_pixmap_draw (struct axis *axis)
        }
 
        not_disp = 1 ^ axis->displayed;
-       gdk_draw_rectangle (axis->pixmap[not_disp], g->bg_gc, TRUE, 0, 0,
-                                       axis->p.width, axis->p.height);
+
+#if GTK_CHECK_VERSION(2,22,0)
+       cr = cairo_create (axis->surface[not_disp]);
+#else
+       cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
+       cairo_set_source_rgb (cr, 1, 1, 1);
+       cairo_rectangle (cr, 0, 0, axis->p.width, axis->p.height);
+       cairo_fill (cr);
+       cairo_destroy (cr);
+       cr = NULL;
+
        /* axis */
-       gdk_draw_line (axis->pixmap[not_disp], g->fg_gc, axis->p.width - 1,
-                       (gint) ((axis->p.height-axis->s.height)/2.0), axis->s.width - 1,
-                       axis->p.height);
+#if GTK_CHECK_VERSION(2,22,0)
+       cr = cairo_create (axis->surface[not_disp]);
+#else
+       cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
+       cairo_set_line_width (cr, 1.0);
+       cairo_move_to(cr, axis->p.width - 1.5, (axis->p.height-axis->s.height)/2.0);
+       cairo_line_to(cr, axis->s.width - 1.5, axis->p.height);
+       cairo_stroke(cr);
+       cairo_destroy(cr);
+       cr = NULL;
 
        offset = g->wp.y + (-g->geom.y);
        fl = floor (axis->min / axis->major) * axis->major;
@@ -2248,19 +2456,37 @@ static void v_axis_pixmap_draw (struct axis *axis)
                                                i*axis->major + fl, y);
                if (y < 0 || y > axis->p.height)
                        continue;
-               gdk_draw_line (axis->pixmap[not_disp], g->fg_gc,
-                               axis->s.width - 15, y, axis->s.width - 1, y);
+
+#if GTK_CHECK_VERSION(2,22,0)
+               cr = cairo_create (axis->surface[not_disp]);
+#else
+               cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
+               cairo_set_line_width (cr, 1.0);
+               cairo_move_to(cr, axis->p.width - 15, y+0.5);
+               cairo_line_to(cr, axis->s.width - 1, y+0.5);
+               cairo_stroke(cr);
+               cairo_destroy(cr);
+               cr = NULL;
+
                g_snprintf (desc, sizeof(desc), "%.*f", rdigits, i*axis->major + fl);
-                layout = gtk_widget_create_pango_layout(g->drawing_area, desc);
-                pango_layout_get_pixel_size(layout, &w, &h);
-                gdk_draw_layout(axis->pixmap[not_disp], g->fg_gc,
-                                axis->s.width-14-4-w, y - h/2, layout);
-                g_object_unref(G_OBJECT(layout));
+        layout = gtk_widget_create_pango_layout(g->drawing_area, desc);
+        pango_layout_get_pixel_size(layout, &w, &h);
+#if GTK_CHECK_VERSION(2,22,0)
+               cr = cairo_create (axis->surface[not_disp]);
+#else
+               cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
+               cairo_move_to (cr, axis->s.width-14-4-w, y - h/2);
+               pango_cairo_show_layout (cr, layout);
+               cairo_destroy (cr);
+               cr = NULL;
+        g_object_unref(G_OBJECT(layout));
        }
        /* minor ticks */
        if (axis->minor) {
                double minor_tick = axis->minor * g->zoom.y;
-               imin = (int) ((g->geom.height - offset + corr - g->wp.height)/minor_tick + 1);
+               imin = (int) ((g->geom.height - offset + corr - g->wp.height)/minor_tick + 1);
                imax = (int) ((g->geom.height - offset + corr) / minor_tick);
                for (i=imin; i <= imax; i++) {
                        int y = (int) (g->geom.height-1 - (int )rint (i*minor_tick) -
@@ -2268,22 +2494,35 @@ static void v_axis_pixmap_draw (struct axis *axis)
 
                        debug (DBS_AXES_DRAWING) printf ("%f @ %d\n", i*axis->minor+fl, y);
                        if (y > 0 && y < axis->p.height)
-                               gdk_draw_line (axis->pixmap[not_disp], g->fg_gc,
-                                               axis->s.width - 8, y,
-                                               axis->s.width - 1, y);
+#if GTK_CHECK_VERSION(2,22,0)
+                               cr = cairo_create (axis->surface[not_disp]);
+#else
+                               cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
+                               cairo_set_line_width (cr, 1.0);
+                               cairo_move_to(cr, axis->s.width - 8, y+0.5);
+                               cairo_line_to(cr, axis->s.width - 1, y+0.5);
+                               cairo_stroke(cr);
+                               cairo_destroy(cr);
+                               cr = NULL;
                }
        }
        for (i=0; axis->label[i]; i++) {
                gint w, h;
-                layout = gtk_widget_create_pango_layout(g->drawing_area,
-                                                        axis->label[i]);
-                pango_layout_get_pixel_size(layout, &w, &h);
-                gdk_draw_layout(axis->pixmap[not_disp], g->fg_gc,
-                                (axis->p.width - w)/2,
-                                TITLEBAR_HEIGHT-10 - i*(h+3) - h,
-                                layout);
-                g_object_unref(G_OBJECT(layout));
-       }
+        layout = gtk_widget_create_pango_layout(g->drawing_area,
+                                                axis->label[i]);
+        pango_layout_get_pixel_size(layout, &w, &h);
+#if GTK_CHECK_VERSION(2,22,0)
+               cr = cairo_create (axis->surface[not_disp]);
+#else
+        cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
+        cairo_move_to (cr, (axis->p.width - w)/2, TITLEBAR_HEIGHT-10 - i*(h+3) - h);
+        pango_cairo_show_layout (cr, layout);
+        cairo_destroy (cr);
+        cr = NULL;
+        g_object_unref(G_OBJECT(layout));
+    }
 }
 
 static void h_axis_pixmap_draw (struct axis *axis)
@@ -2294,6 +2533,7 @@ static void h_axis_pixmap_draw (struct axis *axis)
        int not_disp, rdigits, offset, imin, imax;
        double left, right, j, fl, corr;
         PangoLayout *layout;
+       cairo_t *cr;
 
        debug(DBS_FENTRY) puts ("h_axis_pixmap_draw()");
        left = (g->wp.x-g->geom.x) /
@@ -2313,11 +2553,31 @@ static void h_axis_pixmap_draw (struct axis *axis)
        }
 
        not_disp = 1 ^ axis->displayed;
-       gdk_draw_rectangle (axis->pixmap[not_disp], g->bg_gc, TRUE, 0, 0,
-                                       axis->p.width, axis->p.height);
+
+#if GTK_CHECK_VERSION(2,22,0)
+       cr = cairo_create (axis->surface[not_disp]);
+#else
+       cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
+       cairo_set_source_rgb (cr, 1, 1, 1);
+       cairo_rectangle (cr, 0, 0, axis->p.width, axis->p.height);
+       cairo_fill (cr);
+       cairo_destroy (cr);
+       cr = NULL;
+
        /* axis */
-       gdk_draw_line (axis->pixmap[not_disp], g->fg_gc, 0, 0,
-                                               (gint) (axis->s.width + (axis->p.width-axis->s.width)/2.0), 0);
+#if GTK_CHECK_VERSION(2,22,0)
+       cr = cairo_create (axis->surface[not_disp]);
+#else
+       cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
+       cairo_set_line_width (cr, 1.0);
+       cairo_move_to(cr, 0, 0.5);
+       cairo_line_to(cr, axis->s.width + (axis->p.width-axis->s.width)/2.0, 0.5);
+       cairo_stroke(cr);
+       cairo_destroy(cr);
+       cr = NULL;
+
        offset = g->wp.x - g->geom.x;
 
        fl = floor (axis->min / axis->major) * axis->major;
@@ -2335,13 +2595,32 @@ static void h_axis_pixmap_draw (struct axis *axis)
                /* printf ("%f @ %d\n", i*axis->major + fl, x); */
                if (x < 0 || x > axis->s.width)
                        continue;
-               gdk_draw_line (axis->pixmap[not_disp], g->fg_gc, x, 0, x, 15);
+#if GTK_CHECK_VERSION(2,22,0)
+               cr = cairo_create (axis->surface[not_disp]);
+#else
+               cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
+               cairo_set_line_width (cr, 1.0);
+               cairo_move_to(cr, x+0.5, 0);
+               cairo_line_to(cr, x+0.5, 15);
+               cairo_stroke(cr);
+               cairo_destroy(cr);
+               cr = NULL;
+
                g_snprintf (desc, sizeof(desc), "%.*f", rdigits, i*axis->major + fl);
-                layout = gtk_widget_create_pango_layout(g->drawing_area, desc);
-                pango_layout_get_pixel_size(layout, &w, &h);
-                gdk_draw_layout(axis->pixmap[not_disp], g->fg_gc,
-                                x - w/2, 15+4, layout);
-                g_object_unref(G_OBJECT(layout));
+        layout = gtk_widget_create_pango_layout(g->drawing_area, desc);
+        pango_layout_get_pixel_size(layout, &w, &h);
+#if GTK_CHECK_VERSION(2,22,0)
+               cr = cairo_create (axis->surface[not_disp]);
+#else
+               cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
+               cairo_move_to (cr,  x - w/2, 15+4);
+               pango_cairo_show_layout (cr, layout);
+               cairo_destroy (cr);
+               cr = NULL;
+
+        g_object_unref(G_OBJECT(layout));
        }
        if (axis->minor > 0) {
                /* minor ticks */
@@ -2350,19 +2629,36 @@ static void h_axis_pixmap_draw (struct axis *axis)
                imax = (int) ((offset + corr + g->wp.width) / minor_tick);
                for (i=imin; i <= imax; i++) {
                        int x = (int) (rint (i * minor_tick) - offset - corr);
-                       if (x > 0 && x < axis->s.width)
-                               gdk_draw_line (axis->pixmap[not_disp], g->fg_gc, x, 0, x, 8);
+                       if (x > 0 && x < axis->s.width){
+#if GTK_CHECK_VERSION(2,22,0)
+                               cr = cairo_create (axis->surface[not_disp]);
+#else
+                               cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
+                               cairo_set_line_width (cr, 1.0);
+                               cairo_move_to(cr, x+0.5, 0);
+                               cairo_line_to(cr, x+0.5, 8);
+                               cairo_stroke(cr);
+                               cairo_destroy(cr);
+                               cr = NULL;
+                       }
                }
        }
        for (i=0; axis->label[i]; i++) {
                gint w, h;
-                layout = gtk_widget_create_pango_layout(g->drawing_area,
-                                                        axis->label[i]);
-                pango_layout_get_pixel_size(layout, &w, &h);
-                gdk_draw_layout(axis->pixmap[not_disp], g->fg_gc,
-                                axis->s.width - w - 50, 15+h+15 + i*(h+3),
-                                layout);
-                g_object_unref(G_OBJECT(layout));
+        layout = gtk_widget_create_pango_layout(g->drawing_area,
+                                                axis->label[i]);
+        pango_layout_get_pixel_size(layout, &w, &h);
+#if GTK_CHECK_VERSION(2,22,0)
+               cr = cairo_create (axis->surface[not_disp]);
+#else
+               cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
+               cairo_move_to (cr,  axis->s.width - w - 50, 15+h+15 + i*(h+3));
+               pango_cairo_show_layout (cr, layout);
+               cairo_destroy (cr);
+               cr = NULL;
+        g_object_unref(G_OBJECT(layout));
        }
 }
 
@@ -2373,9 +2669,18 @@ static void axis_pixmaps_switch (struct axis *axis)
 
 static void axis_pixmap_display (struct axis *axis)
 {
-       gdk_draw_pixmap (axis->drawing_area->window, axis->g->fg_gc,
-                       axis->pixmap[axis->displayed], 0, 0, axis->p.x, axis->p.y,
-                       axis->p.width, axis->p.height);
+       cairo_t *cr;
+
+       cr = gdk_cairo_create (gtk_widget_get_window(axis->drawing_area));
+#if GTK_CHECK_VERSION(2,22,0)
+       cairo_set_source_surface (cr, axis->surface[axis->displayed], axis->p.x, axis->p.y);
+#else
+       gdk_cairo_set_source_pixmap (cr, axis->pixmap[axis->displayed], axis->p.x, axis->p.y);
+#endif
+       cairo_rectangle (cr, axis->p.x, axis->p.y, axis->p.width, axis->p.height);
+       cairo_fill (cr);
+       cairo_destroy (cr);
+
 }
 
 static void axis_compute_ticks (struct axis *axis, double x0, double xmax, int dir)
@@ -2547,7 +2852,7 @@ static void graph_select_segment (struct graph *g, int x, int y)
        x -= g->geom.x;
        y = g->geom.height-1 - (y - g->geom.y);
 
-       set_busy_cursor (g->drawing_area->window);
+       set_busy_cursor (gtk_widget_get_window(g->drawing_area));
 
        for (list=g->elists; list; list=list->next)
                for (e=list->elements; e->type != ELMT_NONE; e++) {
@@ -2559,8 +2864,8 @@ static void graph_select_segment (struct graph *g, int x, int y)
                                        num = e->parent->num;
                                }
                                break;
-                       case ELMT_ARC:
-                               if (arc_detect_collision (e, x, y)) {
+                       case ELMT_ELLIPSE:
+                               if (ellipse_detect_collision (e, x, y)) {
                                        num = e->parent->num;
                                }
                                break;
@@ -2573,7 +2878,7 @@ static void graph_select_segment (struct graph *g, int x, int y)
        if (num) {
                cf_goto_frame(&cfile, num);
        }
-       unset_busy_cursor (g->drawing_area->window);
+       unset_busy_cursor (gtk_widget_get_window(g->drawing_area));
 }
 
 static int line_detect_collision (struct element *e, int x, int y)
@@ -2603,16 +2908,16 @@ static int line_detect_collision (struct element *e, int x, int y)
                return FALSE;
 }
 
-static int arc_detect_collision (struct element *e, int x, int y)
+static int ellipse_detect_collision (struct element *e, int x, int y)
 {
        int xx1, yy1, xx2, yy2;
 
-       xx1 = (int )rint (e->p.arc.dim.x);
-       xx2 = (int )rint (e->p.arc.dim.x + e->p.arc.dim.width);
-       yy1 = (int )rint (e->p.arc.dim.y - e->p.arc.dim.height);
-       yy2 = (int )rint (e->p.arc.dim.y);
+       xx1 = (int )rint (e->p.ellipse.dim.x);
+       xx2 = (int )rint (e->p.ellipse.dim.x + e->p.ellipse.dim.width);
+       yy1 = (int )rint (e->p.ellipse.dim.y - e->p.ellipse.dim.height);
+       yy2 = (int )rint (e->p.ellipse.dim.y);
        /*
-       printf ("arc: (%d,%d)->(%d,%d), clicked: (%d,%d)\n", xx1, yy1, xx2, yy2, x, y);
+       printf ("ellipse: (%d,%d)->(%d,%d), clicked: (%d,%d)\n", xx1, yy1, xx2, yy2, x, y);
         */
        if (xx1<=x && x<=xx2 && yy1<=y && y<=yy2)
                return TRUE;
@@ -2622,13 +2927,43 @@ static int arc_detect_collision (struct element *e, int x, int y)
 
 static void cross_xor (struct graph *g, int x, int y)
 {
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkColor color_gray15 = {0x0, 0x2626, 0x2626, 0x2626};
+       cairo_t *cr;
+
+       /* XXX Fix me: lines do not disapere */
+       if (x > g->wp.x && x < g->wp.x+g->wp.width &&
+                               y >= g->wp.y && y < g->wp.y+g->wp.height) {
+               /* Draw horisontal line */
+               cr = gdk_cairo_create (gtk_widget_get_window(g->drawing_area));
+               cairo_set_operator (cr, CAIRO_OPERATOR_XOR);
+               gdk_cairo_set_source_color (cr, &color_gray15);
+               cairo_set_line_width (cr, 1.0);
+               cairo_move_to(cr,  g->wp.x, y);
+               cairo_line_to(cr,  g->wp.x + g->wp.width, y);
+               cairo_stroke(cr);
+               cairo_destroy(cr);
+               /* draw vertical line */
+               cr = gdk_cairo_create (gtk_widget_get_window(g->drawing_area));
+               cairo_set_operator (cr, CAIRO_OPERATOR_XOR);
+               gdk_cairo_set_source_color (cr, &color_gray15);
+               cairo_set_line_width (cr, 1.0);
+               cairo_move_to(cr,  x, g->wp.y);
+               cairo_line_to(cr,  x, g->wp.y + g->wp.height);
+               cairo_stroke(cr);
+               cairo_destroy(cr);
+       }
+
+#else
+
        if (x > g->wp.x && x < g->wp.x+g->wp.width &&
                                y >= g->wp.y && y < g->wp.y+g->wp.height) {
-               gdk_draw_line (g->drawing_area->window, xor_gc, g->wp.x,
+               gdk_draw_line (gtk_widget_get_window(g->drawing_area), xor_gc, g->wp.x,
                                                y, g->wp.x + g->wp.width, y);
-               gdk_draw_line (g->drawing_area->window, xor_gc, x,
+               gdk_draw_line (gtk_widget_get_window(g->drawing_area), xor_gc, x,
                                                g->wp.y, x, g->wp.y + g->wp.height);
        }
+#endif
 }
 
 static void cross_draw (struct graph *g, int x, int y)
@@ -2685,14 +3020,14 @@ static void magnify_create (struct graph *g, int x, int y)
        }
        graph_element_lists_make (mg);
 
-       gdk_window_get_position (GTK_WIDGET (g->toplevel)->window, &pos.x, &pos.y);
+       gdk_window_get_position (gtk_widget_get_window(GTK_WIDGET (g->toplevel)), &pos.x, &pos.y);
        g->magnify.x = pos.x + x - g->magnify.width/2;
        g->magnify.y = pos.y + y - g->magnify.height/2;
        offsetpos.x = g->magnify.x + g->magnify.offset.x;
        offsetpos.x = offsetpos.x >= 0 ? offsetpos.x : 0;
        offsetpos.y = g->magnify.y + g->magnify.offset.y;
        offsetpos.y = offsetpos.y >= 0 ? offsetpos.y : 0;
-       gtk_window_set_position (GTK_WINDOW(mg->drawing_area), GTK_WIN_POS_NONE);       
+       gtk_window_set_position (GTK_WINDOW(mg->drawing_area), GTK_WIN_POS_NONE);
        magnify_get_geom (g, x, y);
 
        gtk_widget_show (mg->drawing_area);
@@ -2710,7 +3045,11 @@ static void magnify_create (struct graph *g, int x, int y)
                }
        } while (e);
 
+#if GTK_CHECK_VERSION(2,22,0)
+       mg->surface[0] = mg->surface[1] = NULL;
+#else
        mg->pixmap[0] = mg->pixmap[1] = NULL;
+#endif /* GTK_CHECK_VERSION(2,22,0) */
        graph_pixmaps_create (mg);
        magnify_draw (g);
        g->magnify.active = 1;
@@ -2720,7 +3059,7 @@ static void magnify_move (struct graph *g, int x, int y)
 {
        struct ipoint pos, offsetpos;
 
-       gdk_window_get_position (GTK_WIDGET (g->toplevel)->window, &pos.x, &pos.y);
+       gdk_window_get_position (gtk_widget_get_window(GTK_WIDGET (g->toplevel)), &pos.x, &pos.y);
        g->magnify.x = pos.x + x - g->magnify.width/2;
        g->magnify.y = pos.y + y - g->magnify.height/2;
        offsetpos.x = g->magnify.x + g->magnify.offset.x;
@@ -2737,8 +3076,18 @@ static void magnify_destroy (struct graph *g)
        struct graph *mg = g->magnify.g;
 
        window_destroy (GTK_WIDGET (mg->drawing_area));
-       gdk_pixmap_unref (mg->pixmap[0]);
-       gdk_pixmap_unref (mg->pixmap[1]);
+
+#if GTK_CHECK_VERSION(2,22,0)
+       if(mg->surface[0]){
+                cairo_surface_destroy (mg->surface[0]);
+       }
+       if(mg->surface[1]){
+                cairo_surface_destroy (mg->surface[1]);
+       }
+#else
+       g_object_unref (mg->pixmap[0]);
+       g_object_unref (mg->pixmap[1]);
+#endif /* GTK_CHECK_VERSION(2,22,0) */
        for (list=mg->elists; list; list=list->next)
                g_free (list->elements);
 
@@ -2757,7 +3106,7 @@ static void magnify_get_geom (struct graph *g, int x, int y)
 {
        int posx, posy;
 
-       gdk_window_get_position (GTK_WIDGET (g->toplevel)->window, &posx, &posy);
+       gdk_window_get_position (gtk_widget_get_window(GTK_WIDGET (g->toplevel)), &posx, &posy);
 
        g->magnify.g->geom.x = g->geom.x;
        g->magnify.g->geom.y = g->geom.y;
@@ -2777,18 +3126,33 @@ static void magnify_get_geom (struct graph *g, int x, int y)
 
 static void magnify_draw (struct graph *g)
 {
+       cairo_t *cr;
        int not_disp = 1 ^ g->magnify.g->displayed;
 
        graph_pixmap_draw (g->magnify.g);
        /* graph pixmap is almost ready, just add border */
-       gdk_draw_line (g->magnify.g->pixmap[not_disp], g->fg_gc, 0, 0,
-                                               g->magnify.width - 1, 0);
-       gdk_draw_line (g->magnify.g->pixmap[not_disp], g->fg_gc,
-                       g->magnify.width - 1, 0, g->magnify.width - 1, g->magnify.height);
-       gdk_draw_line (g->magnify.g->pixmap[not_disp], g->fg_gc, 0, 0,
-                                               0, g->magnify.height - 1);
-       gdk_draw_line (g->magnify.g->pixmap[not_disp], g->fg_gc, 0,
-                       g->magnify.height - 1, g->magnify.width - 1, g->magnify.height - 1);
+#if GTK_CHECK_VERSION(2,22,0)
+       cr = cairo_create (g->magnify.g->surface[not_disp]);
+#else
+       cr = gdk_cairo_create (g->magnify.g->pixmap[not_disp]);
+#endif /* GTK_CHECK_VERSION(2,22,0) */
+       cairo_set_line_width (cr, 1.0);
+       cairo_move_to(cr, 0, 0);
+       cairo_line_to(cr, g->magnify.width - 1, 0);
+       cairo_stroke(cr);
+
+       cairo_move_to(cr, g->magnify.width - 1, 0);
+       cairo_line_to(cr, g->magnify.width - 1, g->magnify.height);
+       cairo_stroke(cr);
+
+       cairo_move_to(cr, 0, 0);
+       cairo_line_to(cr, 0,g->magnify.height - 1);
+       cairo_stroke(cr);
+
+       cairo_move_to(cr, 0, g->magnify.height - 1);
+       cairo_line_to(cr, g->magnify.width - 1, g->magnify.height - 1);
+       cairo_stroke(cr);
+       cairo_destroy(cr);
 
        graph_pixmaps_switch (g->magnify.g);
        graph_pixmap_display (g->magnify.g);
@@ -2856,7 +3220,8 @@ static gboolean configure_event (GtkWidget *widget, GdkEventConfigure *event, gp
 
 static gboolean expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data _U_)
 {
-        struct graph *g = (struct graph *) g_object_get_data(G_OBJECT(widget), "graph");
+    struct graph *g = (struct graph *) g_object_get_data(G_OBJECT(widget), "graph");
+    cairo_t *cr;
 
        debug(DBS_FENTRY) puts ("expose_event()");
 
@@ -2864,11 +3229,20 @@ static gboolean expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer
                return TRUE;
 
        /* lower left corner */
-       gdk_draw_rectangle (g->drawing_area->window, g->bg_gc, TRUE, 0,
-                       g->wp.y + g->wp.height, g->y_axis->p.width, g->x_axis->p.height);
+       cr = gdk_cairo_create (gtk_widget_get_window(g->drawing_area));
+       cairo_set_source_rgb (cr, 1, 1, 1);
+       cairo_rectangle (cr, 0, g->wp.y + g->wp.height, g->y_axis->p.width, g->x_axis->p.height);
+       cairo_fill (cr);
+       cairo_destroy(cr);
+       cr = NULL;
+
        /* right margin */
-       gdk_draw_rectangle (g->drawing_area->window, g->bg_gc, TRUE,
-                       g->wp.x + g->wp.width, g->wp.y, RMARGIN_WIDTH, g->wp.height);
+       cr = gdk_cairo_create (gtk_widget_get_window(g->drawing_area));
+       cairo_set_source_rgb (cr, 1, 1, 1);
+       cairo_rectangle (cr, g->wp.x + g->wp.width, g->wp.y, RMARGIN_WIDTH, g->wp.height);
+       cairo_fill (cr);
+       cairo_destroy(cr);
+       cr = NULL;
 
        graph_pixmap_display (g);
        graph_title_pixmap_display (g);
@@ -2947,7 +3321,7 @@ static void do_zoom_keyboard (struct graph *g)
        struct { double x, y; } factor;
        int pointer_x, pointer_y;
 
-       gdk_window_get_pointer (g->drawing_area->window, &pointer_x, &pointer_y, 0);
+       gdk_window_get_pointer (gtk_widget_get_window(g->drawing_area), &pointer_x, &pointer_y, 0);
 
        if (g->zoom.flags & ZOOM_OUT) {
                if (g->zoom.flags & ZOOM_HLOCK)
@@ -3025,7 +3399,7 @@ static void do_select_segment (struct graph *g)
 {
        int pointer_x, pointer_y;
 
-       gdk_window_get_pointer (g->drawing_area->window, &pointer_x, &pointer_y, 0);
+       gdk_window_get_pointer (gtk_widget_get_window(g->drawing_area), &pointer_x, &pointer_y, 0);
        graph_select_segment (g, pointer_x, pointer_y);
 }
 
@@ -3036,7 +3410,7 @@ static void do_wscale_graph (struct graph *g)
 
 static void do_rtt_graph (struct graph *g)
 {
-        gtk_toggle_button_set_active (g->gt.graph_rtt, TRUE); 
+        gtk_toggle_button_set_active (g->gt.graph_rtt, TRUE);
 }
 
 static void do_throughput_graph (struct graph *g)
@@ -3058,7 +3432,7 @@ static void do_magnify_create (struct graph *g)
 {
        int pointer_x, pointer_y;
 
-       gdk_window_get_pointer (g->drawing_area->window, &pointer_x, &pointer_y, 0);
+       gdk_window_get_pointer (gtk_widget_get_window(g->drawing_area), &pointer_x, &pointer_y, 0);
 
        magnify_create (g, (int )rint (pointer_x), (int )rint (pointer_y));
 }
@@ -3079,7 +3453,7 @@ static void do_key_motion (struct graph *g)
        axis_display (g->x_axis);
        if (g->cross.draw) {
                int pointer_x, pointer_y;
-               gdk_window_get_pointer (g->drawing_area->window, &pointer_x, &pointer_y, 0);
+               gdk_window_get_pointer (gtk_widget_get_window(g->drawing_area), &pointer_x, &pointer_y, 0);
                cross_draw (g, pointer_x, pointer_y);
        }
 }
@@ -3288,7 +3662,7 @@ static gboolean key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer
                do_key_motion_down (g, step);
                break;
        case GDK_F1:
-               callback_create_help (NULL, NULL);      
+               callback_create_help (NULL, NULL);
                break;
        default:
                break;
@@ -3326,7 +3700,7 @@ static gboolean enter_notify_event (GtkWidget *widget, GdkEventCrossing *event _
        /* graph_pixmap_display (g); */
        if (g->cross.draw) {
                int x, y;
-               gdk_window_get_pointer (g->drawing_area->window, &x, &y, 0);
+               gdk_window_get_pointer (gtk_widget_get_window(g->drawing_area), &x, &y, 0);
                cross_draw (g, x, y);
        }
        return TRUE;
@@ -3338,7 +3712,7 @@ static void toggle_crosshairs (struct graph *g)
 #if 0
        if (g->cross.draw) {
                int x, y;
-               gdk_window_get_pointer (g->drawing_area->window, &x, &y, 0);
+               gdk_window_get_pointer (gtk_widget_get_window(g->drawing_area), &x, &y, 0);
                cross_draw (g);
        } else if (g->cross.erase_needed) {
                cross_erase (g);
@@ -3605,16 +3979,12 @@ static void tseq_stevens_make_elmtlist (struct graph *g)
                secs = g->zoom.x * (tmp->rel_secs + tmp->rel_usecs / 1000000.0 - xx0);
                seqno = g->zoom.y * seq_cur;
 
-               e->type = ELMT_ARC;
+               e->type = ELMT_ELLIPSE;
                e->parent = tmp;
-               e->gc = g->fg_gc;
-               e->p.arc.dim.width = g->s.tseq_stevens.seq_width;
-               e->p.arc.dim.height = g->s.tseq_stevens.seq_height;
-               e->p.arc.dim.x = secs - g->s.tseq_stevens.seq_width/2.0;
-               e->p.arc.dim.y = seqno + g->s.tseq_stevens.seq_height/2.0;
-               e->p.arc.filled = TRUE;
-               e->p.arc.angle1 = 0;
-               e->p.arc.angle2 = 23040;
+               e->p.ellipse.dim.width = g->s.tseq_stevens.seq_width;
+               e->p.ellipse.dim.height = g->s.tseq_stevens.seq_height;
+               e->p.ellipse.dim.x = secs - g->s.tseq_stevens.seq_width/2.0;
+               e->p.ellipse.dim.y = seqno + g->s.tseq_stevens.seq_height/2.0;
                e++;
        }
        e->type = ELMT_NONE;
@@ -3647,59 +4017,26 @@ static void tseq_stevens_toggle_time_origin (struct graph *g)
 
 static void tseq_tcptrace_read_config (struct graph *g)
 {
-       GdkColormap *colormap;
-       GdkColor color;
+
+       /* Black */
+       g->s.tseq_tcptrace.seq_color.pixel=0;
+       g->s.tseq_tcptrace.seq_color.red=0;
+       g->s.tseq_tcptrace.seq_color.green=0;
+       g->s.tseq_tcptrace.seq_color.blue=0;
+
+       /* LightSlateGray */
+       g->s.tseq_tcptrace.ack_color[0].pixel=0;
+       g->s.tseq_tcptrace.ack_color[0].red=0x7777;
+       g->s.tseq_tcptrace.ack_color[0].green=0x8888;
+       g->s.tseq_tcptrace.ack_color[0].blue=0x9999;
+
+       /* LightGray */
+       g->s.tseq_tcptrace.ack_color[1].pixel=0;
+       g->s.tseq_tcptrace.ack_color[1].red=0xd3d3;
+       g->s.tseq_tcptrace.ack_color[1].green=0xd3d3;
+       g->s.tseq_tcptrace.ack_color[1].blue=0xd3d3;
 
        g->s.tseq_tcptrace.flags = 0;
-       g->s.tseq_tcptrace.gc_seq = gdk_gc_new (g->drawing_area->window);
-       g->s.tseq_tcptrace.gc_ack[0] = gdk_gc_new (g->drawing_area->window);
-       g->s.tseq_tcptrace.gc_ack[1] = gdk_gc_new (g->drawing_area->window);
-       colormap = gdk_window_get_colormap (g->drawing_area->window);
-       if (!gdk_color_parse ("black", &color)) {
-               /*
-                * XXX - do more than just warn.
-                */
-               simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
-                   "Could not parse color black.");
-       }
-       if (!gdk_colormap_alloc_color (colormap, &color, FALSE, TRUE)) {
-               /*
-                * XXX - do more than just warn.
-                */
-               simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
-                   "Could not allocate color black.");
-       }
-       gdk_gc_set_foreground (g->s.tseq_tcptrace.gc_seq, &color);
-       if (!gdk_color_parse ("LightSlateGray", &color)) {
-               /*
-                * XXX - do more than just warn.
-                */
-               simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
-                   "Could not parse color LightSlateGray.");
-       }
-       if (!gdk_colormap_alloc_color (colormap, &color, FALSE, TRUE)) {
-               /*
-                * XXX - do more than just warn.
-                */
-               simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
-                   "Could not allocate color LightSlateGray.");
-       }
-       gdk_gc_set_foreground (g->s.tseq_tcptrace.gc_ack[0], &color);
-       if (!gdk_color_parse ("LightGray", &color)) {
-               /*
-                * XXX - do more than just warn.
-                */
-               simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
-                   "Could not parse color LightGray.");
-       }
-       if (!gdk_colormap_alloc_color (colormap, &color, FALSE, TRUE)) {
-               /*
-                * XXX - do more than just warn.
-                */
-               simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
-                   "Could not allocate color LightGray.");
-       }
-       gdk_gc_set_foreground (g->s.tseq_tcptrace.gc_ack[1], &color);
 
        g->elists->next = (struct element_list * )
                                g_malloc (sizeof (struct element_list));
@@ -3774,21 +4111,24 @@ static void tseq_tcptrace_make_elmtlist (struct graph *g)
                        yy2 = g->zoom.y * (seq_cur + data);
                        e1->type = ELMT_LINE;
                        e1->parent = tmp;
-                       e1->gc = g->s.tseq_tcptrace.gc_seq;
+                       /* Set the drawing color */
+                       e1->elment_color_p = &g->s.tseq_tcptrace.seq_color;
                        e1->p.line.dim.x1 = e1->p.line.dim.x2 = x;
                        e1->p.line.dim.y1 = yy1;
                        e1->p.line.dim.y2 = yy2;
                        e1++;
                        e1->type = ELMT_LINE;
                        e1->parent = tmp;
-                       e1->gc = g->s.tseq_tcptrace.gc_seq;
+                       /* Set the drawing color */
+                       e1->elment_color_p = &g->s.tseq_tcptrace.seq_color;
                        e1->p.line.dim.x1 = x - 1;
                        e1->p.line.dim.x2 = x + 1;
                        e1->p.line.dim.y1 = e1->p.line.dim.y2 = yy1;
                        e1++;
                        e1->type = ELMT_LINE;
                        e1->parent = tmp;
-                       e1->gc = g->s.tseq_tcptrace.gc_seq;
+                       /* Set the drawing color */
+                       e1->elment_color_p = &g->s.tseq_tcptrace.seq_color;
                        e1->p.line.dim.x1 = x + 1;
                        e1->p.line.dim.x2 = x - 1;
                        e1->p.line.dim.y1 = e1->p.line.dim.y2 = yy2;
@@ -3807,7 +4147,8 @@ static void tseq_tcptrace_make_elmtlist (struct graph *g)
                        if (ack_seen == TRUE) { /* don't plot the first ack */
                                e0->type = ELMT_LINE;
                                e0->parent = tmp;
-                               e0->gc = g->s.tseq_tcptrace.gc_ack[toggle];
+                               /* Set the drawing color */
+                               e0->elment_color_p = &g->s.tseq_tcptrace.ack_color[toggle];
                                e0->p.line.dim.x1 = p_t;
                                e0->p.line.dim.y1 = p_ackno;
                                e0->p.line.dim.x2 = x;
@@ -3815,7 +4156,8 @@ static void tseq_tcptrace_make_elmtlist (struct graph *g)
                                e0++;
                                e0->type = ELMT_LINE;
                                e0->parent = tmp;
-                               e0->gc = g->s.tseq_tcptrace.gc_ack[toggle];
+                               /* Set the drawing color */
+                               e0->elment_color_p = &g->s.tseq_tcptrace.ack_color[toggle];
                                e0->p.line.dim.x1 = x;
                                e0->p.line.dim.y1 = p_ackno;
                                e0->p.line.dim.x2 = x;
@@ -3824,7 +4166,8 @@ static void tseq_tcptrace_make_elmtlist (struct graph *g)
                                /* window line */
                                e0->type = ELMT_LINE;
                                e0->parent = tmp;
-                               e0->gc = g->s.tseq_tcptrace.gc_ack[toggle];
+                               /* Set the drawing color */
+                               e0->elment_color_p = &g->s.tseq_tcptrace.ack_color[toggle];
                                e0->p.line.dim.x1 = p_t;
                                e0->p.line.dim.y1 = p_win + p_ackno;
                                e0->p.line.dim.x2 = x;
@@ -3832,7 +4175,8 @@ static void tseq_tcptrace_make_elmtlist (struct graph *g)
                                e0++;
                                e0->type = ELMT_LINE;
                                e0->parent = tmp;
-                               e0->gc = g->s.tseq_tcptrace.gc_ack[toggle];
+                               /* Set the drawing color */
+                               e0->elment_color_p = &g->s.tseq_tcptrace.ack_color[toggle];
                                e0->p.line.dim.x1 = x;
                                e0->p.line.dim.y1 = p_win + p_ackno;
                                e0->p.line.dim.x2 = x;
@@ -3900,16 +4244,12 @@ static void tput_make_elmtlist (struct graph *g)
                tput = sum / dtime;
                /* debug(DBS_TPUT_ELMTS) printf ("tput=%f\n", tput); */
 
-               e->type = ELMT_ARC;
+               e->type = ELMT_ELLIPSE;
                e->parent = tmp;
-               e->gc = g->fg_gc;
-               e->p.arc.dim.width = g->s.tput.width;
-               e->p.arc.dim.height = g->s.tput.height;
-               e->p.arc.dim.x = g->zoom.x*(time_val - g->bounds.x0) - g->s.tput.width/2.0;
-               e->p.arc.dim.y = g->zoom.y*tput + g->s.tput.height/2.0;
-               e->p.arc.filled = TRUE;
-               e->p.arc.angle1 = 0;
-               e->p.arc.angle2 = 23040;
+               e->p.ellipse.dim.width = g->s.tput.width;
+               e->p.ellipse.dim.height = g->s.tput.height;
+               e->p.ellipse.dim.x = g->zoom.x*(time_val - g->bounds.x0) - g->s.tput.width/2.0;
+               e->p.ellipse.dim.y = g->zoom.y*tput + g->s.tput.height/2.0;
                e++;
        }
        e->type = ELMT_NONE;
@@ -4172,16 +4512,12 @@ static void rtt_make_elmtlist (struct graph *g)
                                if (ackno > u->seqno) {
                                        double rtt = time_val - u->time;
 
-                                       e->type = ELMT_ARC;
+                                       e->type = ELMT_ELLIPSE;
                                        e->parent = tmp;
-                                       e->gc = g->fg_gc;
-                                       e->p.arc.dim.width = g->s.rtt.width;
-                                       e->p.arc.dim.height = g->s.rtt.height;
-                                       e->p.arc.dim.x = g->zoom.x * u->seqno - g->s.rtt.width/2.0;
-                                       e->p.arc.dim.y = g->zoom.y * rtt + g->s.rtt.height/2.0;
-                                       e->p.arc.filled = TRUE;
-                                       e->p.arc.angle1 = 0;
-                                       e->p.arc.angle2 = 23040;
+                                       e->p.ellipse.dim.width = g->s.rtt.width;
+                                       e->p.ellipse.dim.height = g->s.rtt.height;
+                                       e->p.ellipse.dim.x = g->zoom.x * u->seqno - g->s.rtt.width/2.0;
+                                       e->p.ellipse.dim.y = g->zoom.y * rtt + g->s.rtt.height/2.0;
                                        e++;
 
                                        v=u->next;
@@ -4226,7 +4562,7 @@ static void wscale_read_config(struct graph* g)
        g->x_axis->label[1] = NULL;
 }
 
-/* 
+/*
     (1) Find maximum and minimum values for Window-Size(scaled) and seconds
     (2) call function to define window related values
 */
@@ -4238,7 +4574,7 @@ static void wscale_initialize(struct graph* g)
        guint32 wsize_min = 0;
        gdouble sec_max = 0.0;
        gdouble sec_base = -1.0;
-       
+
        wscale_read_config (g);
 
        debug(DBS_FENTRY) puts ("wscale_initialize()");
@@ -4267,7 +4603,7 @@ static void wscale_initialize(struct graph* g)
                        if ( sec_max < sec )
                                sec_max = sec;
 
-               } 
+               }
 
        }
 
@@ -4297,10 +4633,10 @@ static void wscale_make_elmtlist(struct graph* g)
        {
                int n = 1 + get_num_dsegs(g);
                e = elements = (struct element*)g_malloc(n*sizeof(struct element));
-       } 
-       else 
+       }
+       else
                e = elements = g->elists->elements;
-       
+
 
        for ( segm = g->segments; segm; segm = segm->next )
        {
@@ -4321,18 +4657,14 @@ static void wscale_make_elmtlist(struct graph* g)
                        /* only data or ack segments */
                        if ( (flags & (TH_SYN|TH_RST)) == 0 )
                        {
-                               e->type = ELMT_ARC;
+                               e->type = ELMT_ELLIPSE;
                                e->parent = segm;
-                               e->gc = g->fg_gc;
-                               e->p.arc.dim.width = g->s.wscale.win_width;
-                               e->p.arc.dim.height = g->s.wscale.win_height;
-                               e->p.arc.dim.x = g->zoom.x * (sec - sec_base) - g->s.wscale.win_width / 2.0;
-                               e->p.arc.dim.y = g->zoom.y * wsize - g->s.wscale.win_height / 2.0;
-                               e->p.arc.filled = TRUE;
-                               e->p.arc.angle1 = 0;
-                               e->p.arc.angle2 = 0x5A00;
+                               e->p.ellipse.dim.width = g->s.wscale.win_width;
+                               e->p.ellipse.dim.height = g->s.wscale.win_height;
+                               e->p.ellipse.dim.x = g->zoom.x * (sec - sec_base) - g->s.wscale.win_width / 2.0;
+                               e->p.ellipse.dim.y = g->zoom.y * wsize - g->s.wscale.win_height / 2.0;
                                e++;
-                       } 
+                       }
                }
        }
        /* finished populating element list */
@@ -4357,8 +4689,12 @@ static int rint (double x)
 }
 #endif
 
-
-static gboolean tcp_graph_selected_packet_enabled(frame_data *current_frame, epan_dissect_t *edt, gpointer callback_data _U_)
+#ifdef MAIN_MENU_USE_UIMANAGER
+gboolean tcp_graph_selected_packet_enabled(frame_data *current_frame, epan_dissect_t *edt, gpointer callback_data _U_)
+#else
+static
+gboolean tcp_graph_selected_packet_enabled(frame_data *current_frame, epan_dissect_t *edt, gpointer callback_data _U_)
+#endif
 {
     return current_frame != NULL ? (edt->pi.ipproto == IP_PROTO_TCP) : FALSE;
 }