From e83f587d095bb49c494e429fcfa43d4ee3b7e047 Mon Sep 17 00:00:00 2001 From: Alan Fitton Date: Mon, 9 Jul 2012 10:51:46 +0200 Subject: make the gtk3 graph build (this was supposed to be a branch but I forgot to checkout...). some more fixes needed here. --- src/trg-main-window.c | 4 ++++ src/trg-torrent-graph3.c | 28 +++++++++++++--------------- src/trg-torrent-graph3.h | 2 +- 3 files changed, 18 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/trg-main-window.c b/src/trg-main-window.c index ea3e342..74ae002 100644 --- a/src/trg-main-window.c +++ b/src/trg-main-window.c @@ -66,7 +66,11 @@ #include "trg-trackers-tree-view.h" #include "trg-trackers-model.h" #include "trg-state-selector.h" +#if GTK_CHECK_VERSION( 3, 0, 0 ) +#include "trg-torrent-graph3.h" +#else #include "trg-torrent-graph.h" +#endif #include "trg-torrent-move-dialog.h" #include "trg-torrent-props-dialog.h" #include "trg-torrent-add-url-dialog.h" diff --git a/src/trg-torrent-graph3.c b/src/trg-torrent-graph3.c index 85269bc..29b4c8e 100644 --- a/src/trg-torrent-graph3.c +++ b/src/trg-torrent-graph3.c @@ -137,10 +137,8 @@ void trg_torrent_graph_draw_background(TrgTorrentGraph * g) (int) (1.5 * priv->graph_delx) + GRAPH_FRAME_WIDTH; gtk_widget_get_allocation(priv->disp, &allocation); - priv->background = - gdk_pixmap_new(GDK_DRAWABLE(gtk_widget_get_window(priv->disp)), - allocation.width, allocation.height, -1); - cr = gdk_cairo_create(priv->background); + + cr = cairo_create(priv->background); gdk_cairo_set_source_color(cr, &priv->style->bg[GTK_STATE_NORMAL]); cairo_paint(cr); @@ -242,20 +240,20 @@ trg_torrent_graph_configure(GtkWidget * widget, trg_torrent_graph_clear_background(g); - trg_torrent_graph_draw(g); + trg_torrent_graph_queue_draw(g); return TRUE; } static gboolean -trg_torrent_graph_expose(GtkWidget * widget, - GdkEventExpose * event, gpointer data_ptr) +trg_torrent_graph_draw(GtkWidget * widget, + cairo_t *context, gpointer data_ptr) { TrgTorrentGraph *g = TRG_TORRENT_GRAPH(data_ptr); TrgTorrentGraphPrivate *priv = TRG_TORRENT_GRAPH_GET_PRIVATE(data_ptr); + GdkWindow *window = gtk_widget_get_window(priv->disp); GtkAllocation allocation; - GdkWindow *window; cairo_t *cr; guint i, j; @@ -263,13 +261,13 @@ trg_torrent_graph_expose(GtkWidget * widget, gdouble sample_width, x_offset; if (priv->background == NULL) { + cairo_pattern_t * pattern = NULL; trg_torrent_graph_draw_background(g); - cairo_pattern_t * pattern = cairo_pattern_create_for_surface(priv->background); + pattern = cairo_pattern_create_for_surface(priv->background); gdk_window_set_background_pattern (window, pattern); cairo_pattern_destroy (pattern); } - window = gtk_widget_get_window(priv->disp); gtk_widget_get_allocation(priv->disp, &allocation); /*gdk_draw_drawable(window, priv->gc, @@ -507,7 +505,7 @@ static GObject *trg_torrent_graph_constructor(GType type, priv->speed = 1000; priv->max = 1024; - hbox = gtk_hbox_new(FALSE, 0); + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); priv->label_in = gtk_label_new(NULL); priv->label_out = gtk_label_new(NULL); @@ -527,8 +525,8 @@ static GObject *trg_torrent_graph_constructor(GType type, gtk_box_set_homogeneous(GTK_BOX(object), FALSE); priv->disp = gtk_drawing_area_new(); - g_signal_connect(G_OBJECT(priv->disp), "expose_event", - G_CALLBACK(trg_torrent_graph_expose), object); + g_signal_connect(G_OBJECT(priv->disp), "draw", + G_CALLBACK(trg_torrent_graph_draw), object); g_signal_connect(G_OBJECT(priv->disp), "configure_event", G_CALLBACK(trg_torrent_graph_configure), object); @@ -573,7 +571,7 @@ TrgTorrentGraph *trg_torrent_graph_new(GtkStyle * style) return TRG_TORRENT_GRAPH(obj); } -void trg_torrent_graph_draw(TrgTorrentGraph * g) +void trg_torrent_graph_queue_draw(TrgTorrentGraph * g) { TrgTorrentGraphPrivate *priv = TRG_TORRENT_GRAPH_GET_PRIVATE(g); @@ -601,7 +599,7 @@ static gboolean trg_torrent_graph_update(gpointer user_data) trg_torrent_graph_update_net(g); if (priv->draw) - trg_torrent_graph_draw(g); + trg_torrent_graph_queue_draw(g); priv->render_counter++; diff --git a/src/trg-torrent-graph3.h b/src/trg-torrent-graph3.h index 35eef2d..404b29a 100644 --- a/src/trg-torrent-graph3.h +++ b/src/trg-torrent-graph3.h @@ -38,7 +38,7 @@ unsigned trg_torrent_graph_get_num_bars(TrgTorrentGraph * g); void trg_torrent_graph_clear_background(); -void trg_torrent_graph_draw(TrgTorrentGraph * g); +void trg_torrent_graph_queue_draw(TrgTorrentGraph * g); void trg_torrent_graph_start(TrgTorrentGraph * g); -- cgit v1.2.3