[gitg/gtk3: 16/20] Port to GtkWidget's new "draw" signal
- From: Garrett Regier <gregier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/gtk3: 16/20] Port to GtkWidget's new "draw" signal
- Date: Tue, 8 Feb 2011 16:26:45 +0000 (UTC)
commit 20a800418e5342794b76e06e113ad5e72e615e01
Author: Garrett Regier <alias301 gmail com>
Date: Sun Jan 2 21:37:32 2011 -0800
Port to GtkWidget's new "draw" signal
gitg/gitg-cell-renderer-path.c | 5 +--
gitg/gitg-diff-line-renderer.c | 91 +++++++++++++++++++---------------------
gitg/gitg-diff-view.c | 14 +++---
gitg/gitg-stat-view.c | 17 ++-----
4 files changed, 56 insertions(+), 71 deletions(-)
---
diff --git a/gitg/gitg-cell-renderer-path.c b/gitg/gitg-cell-renderer-path.c
index e4f7fd4..0560ecf 100644
--- a/gitg/gitg-cell-renderer-path.c
+++ b/gitg/gitg-cell-renderer-path.c
@@ -324,8 +324,6 @@ renderer_render(GtkCellRenderer *renderer, GdkDrawable *window, GtkWidget *widge
self->priv->last_height = area->height;
- cairo_t *cr = gdk_cairo_create(window);
-
gdk_cairo_rectangle (cr, area);
cairo_clip(cr);
@@ -336,13 +334,12 @@ renderer_render(GtkCellRenderer *renderer, GdkDrawable *window, GtkWidget *widge
/* draw labels */
draw_labels(self, widget, cr, area);
- cairo_destroy(cr);
area->x += total_width(self, widget);
cell_area->x += total_width(self, widget);
if (GTK_CELL_RENDERER_CLASS(parent_class)->render)
- GTK_CELL_RENDERER_CLASS(parent_class)->render(renderer, window, widget, area, cell_area, expose_area, flags);
+ GTK_CELL_RENDERER_CLASS(parent_class)->render(renderer, cr, widget, area, cell_area, flags);
}
static void
diff --git a/gitg/gitg-diff-line-renderer.c b/gitg/gitg-diff-line-renderer.c
index 796bc2a..7080fe2 100644
--- a/gitg/gitg-diff-line-renderer.c
+++ b/gitg/gitg-diff-line-renderer.c
@@ -122,7 +122,7 @@ darken_or_lighten (cairo_t *ctx,
static void
render_label (GitgDiffLineRenderer *lr,
- GdkDrawable *window,
+ cairo_t *ctx,
GtkWidget *widget,
GdkRectangle *background_area,
GdkRectangle *cell_area,
@@ -146,10 +146,7 @@ render_label (GitgDiffLineRenderer *lr,
style = gtk_widget_get_style (widget);
state = gtk_widget_get_state (widget);
- cairo_t *ctx = gdk_cairo_create (window);
- gdk_cairo_rectangle (ctx, expose_area);
- cairo_clip (ctx);
gdk_cairo_set_source_color (ctx, &(style->fg[state]));
@@ -175,23 +172,21 @@ render_label (GitgDiffLineRenderer *lr,
pango_cairo_show_layout (ctx, layout);
- cairo_destroy (ctx);
-
- /*gtk_paint_layout (style,
- window,
- state,
- FALSE,
- NULL,
- widget,
- NULL,
- cell_area->x + cell_area->width / 2,
- cell_area->y,
- layout);*/
+ /*gtk_draw_layout (style,
+ ctx,
+ state,
+ FALSE,
+ NULL,
+ widget,
+ NULL,
+ cell_area->x + cell_area->width / 2,
+ cell_area->y,
+ layout);*/
}
static void
render_lines (GitgDiffLineRenderer *lr,
- GdkDrawable *window,
+ cairo_t *ctx,
GtkWidget *widget,
GdkRectangle *background_area,
GdkRectangle *cell_area,
@@ -233,45 +228,45 @@ render_lines (GitgDiffLineRenderer *lr,
pango_layout_set_text (layout, old_str, -1);
style = gtk_widget_get_style (widget);
- gtk_paint_layout (style,
- window,
- gtk_widget_get_state (widget),
- FALSE,
- NULL,
- widget,
- NULL,
- cell_area->x + cell_area->width / 2 - 1 - xpad,
- cell_area->y,
- layout);
+ gtk_draw_layout (style,
+ ctx,
+ gtk_widget_get_state (widget),
+ FALSE,
+ NULL,
+ widget,
+ NULL,
+ cell_area->x + cell_area->width / 2 - 1 - xpad,
+ cell_area->y,
+ layout);
pango_layout_set_text (layout, new_str, -1);
- gtk_paint_layout (style,
- window,
- gtk_widget_get_state (widget),
- FALSE,
- NULL,
- widget,
- NULL,
- cell_area->x + cell_area->width - xpad,
- cell_area->y,
- layout);
-
- g_object_unref (layout);
-
- gtk_paint_vline (style,
- window,
+ gtk_draw_layout (style,
+ ctx,
gtk_widget_get_state (widget),
+ FALSE,
NULL,
widget,
NULL,
- background_area->y,
- background_area->y + background_area->height,
- background_area->x + background_area->width / 2);
+ cell_area->x + cell_area->width - xpad,
+ cell_area->y,
+ layout);
+
+ g_object_unref (layout);
+
+ gtk_draw_vline (style,
+ ctx,
+ gtk_widget_get_state (widget),
+ NULL,
+ widget,
+ NULL,
+ background_area->y,
+ background_area->y + background_area->height,
+ background_area->x + background_area->width / 2);
}
static void
gitg_diff_line_renderer_render_impl (GtkCellRenderer *cell,
- GdkDrawable *window,
+ cairo_t *ctx,
GtkWidget *widget,
GdkRectangle *background_area,
GdkRectangle *cell_area,
@@ -283,7 +278,7 @@ gitg_diff_line_renderer_render_impl (GtkCellRenderer *cell,
if (lr->priv->label)
{
render_label (lr,
- window,
+ ctx,
widget,
background_area,
cell_area,
@@ -293,7 +288,7 @@ gitg_diff_line_renderer_render_impl (GtkCellRenderer *cell,
else
{
render_lines (lr,
- window,
+ ctx,
widget,
background_area,
cell_area,
diff --git a/gitg/gitg-diff-view.c b/gitg/gitg-diff-view.c
index 847aa25..63d3695 100644
--- a/gitg/gitg-diff-view.c
+++ b/gitg/gitg-diff-view.c
@@ -145,7 +145,7 @@ struct _GitgDiffViewPrivate
G_DEFINE_TYPE (GitgDiffView, gitg_diff_view, GTK_TYPE_SOURCE_VIEW)
-static gboolean gitg_diff_view_expose (GtkWidget *widget, GdkEventExpose *event);
+static gboolean gitg_diff_view_draw (GtkWidget *widget, cairo_t *cr);
static guint diff_view_signals[NUM_SIGNALS] = {0,};
static void
@@ -314,7 +314,7 @@ gitg_diff_view_class_init (GitgDiffViewClass *klass)
object_class->constructed = gitg_diff_view_constructed;
- widget_class->expose_event = gitg_diff_view_expose;
+ widget_class->draw = gitg_diff_view_draw;
diff_view_signals[HEADER_ADDED] =
g_signal_new ("header-added",
@@ -855,20 +855,20 @@ line_renderer_data_func (GtkSourceGutter *gutter,
}
static gint
-gitg_diff_view_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gitg_diff_view_draw (GtkWidget *widget,
+ cairo_t *cr)
{
GitgDiffView *view = GITG_DIFF_VIEW (widget);
- /* Prepare for new round of expose on the line renderer */
+ /* Prepare for new round of draw on the line renderer */
view->priv->lines_current_region = NULL;
view->priv->lines_previous_line = -1;
view->priv->lines_counters[0] = 0;
view->priv->lines_counters[1] = 0;
- if (GTK_WIDGET_CLASS (gitg_diff_view_parent_class)->expose_event)
+ if (GTK_WIDGET_CLASS (gitg_diff_view_parent_class)->draw)
{
- return GTK_WIDGET_CLASS (gitg_diff_view_parent_class)->expose_event (widget, event);
+ return GTK_WIDGET_CLASS (gitg_diff_view_parent_class)->draw (widget, cr);
}
else
{
diff --git a/gitg/gitg-stat-view.c b/gitg/gitg-stat-view.c
index a04f9b2..d0b8662 100644
--- a/gitg/gitg-stat-view.c
+++ b/gitg/gitg-stat-view.c
@@ -254,9 +254,9 @@ draw_stat (GitgStatView *view,
}
static gboolean
-gitg_stat_view_expose (GtkWidget *widget, GdkEventExpose *event)
+gitg_stat_view_draw (GtkWidget *widget,
+ cairo_t *ctx)
{
- cairo_t *ctx;
GdkRectangle alloc;
guint added_width;
guint removed_width;
@@ -264,9 +264,9 @@ gitg_stat_view_expose (GtkWidget *widget, GdkEventExpose *event)
GitgStatView *view;
guint padding;
- if (GTK_WIDGET_CLASS (gitg_stat_view_parent_class)->expose_event)
+ if (GTK_WIDGET_CLASS (gitg_stat_view_parent_class)->draw)
{
- GTK_WIDGET_CLASS (gitg_stat_view_parent_class)->expose_event (widget, event);
+ GTK_WIDGET_CLASS (gitg_stat_view_parent_class)->draw (widget, ctx);
}
view = GITG_STAT_VIEW (widget);
@@ -286,11 +286,6 @@ gitg_stat_view_expose (GtkWidget *widget, GdkEventExpose *event)
padding = 2;
}
- ctx = gdk_cairo_create (event->window);
-
- gdk_cairo_rectangle (ctx, &event->area);
- cairo_clip (ctx);
-
gtk_widget_get_allocation (widget, &alloc);
update_gradients (view, &alloc);
@@ -328,8 +323,6 @@ gitg_stat_view_expose (GtkWidget *widget, GdkEventExpose *event)
alloc.height);
}
- cairo_destroy (ctx);
-
return TRUE;
}
@@ -412,8 +405,8 @@ gitg_stat_view_class_init (GitgStatViewClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->expose_event = gitg_stat_view_expose;
widget_class->style_set = gitg_stat_view_style_set;
+ widget_class->draw = gitg_stat_view_draw;
widget_class->realize = gitg_stat_view_realize;
widget_class->configure_event = gitg_stat_view_configure;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]