[vte/vte-next: 56/114] Don't store the widget in _vte_draw struct



commit 8e728a42115c69011335b7b75925be2c093bf004
Author: Christian Persch <chpe gnome org>
Date:   Tue May 3 16:01:05 2011 +0200

    Don't store the widget in _vte_draw struct
    
    Esp. there's no need to reference it!

 src/vte.c     |    7 ++++---
 src/vtedraw.c |   16 +++++-----------
 src/vtedraw.h |    3 ++-
 3 files changed, 11 insertions(+), 15 deletions(-)
---
diff --git a/src/vte.c b/src/vte.c
index 6a8098c..3eab714 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -6983,7 +6983,8 @@ vte_terminal_ensure_font (VteTerminal *terminal)
 			gint width, height, ascent;
 			terminal->pvt->fontdirty = FALSE;
 			_vte_draw_set_text_font (terminal->pvt->draw,
-					terminal->pvt->fontdesc);
+                                                 GTK_WIDGET(terminal),
+                                                 terminal->pvt->fontdesc);
 			_vte_draw_get_text_metrics (terminal->pvt->draw,
 						    &width, &height, &ascent);
 			vte_terminal_apply_metrics(terminal,
@@ -7571,7 +7572,7 @@ vte_terminal_init(VteTerminal *terminal)
 	vte_terminal_match_hilite_clear(terminal);
 
 	/* Rendering data.  Try everything. */
-	pvt->draw = _vte_draw_new(&terminal->widget);
+	pvt->draw = _vte_draw_new();
 
 	/* The font description. */
 	gtk_widget_ensure_style(&terminal->widget);
@@ -8082,7 +8083,7 @@ vte_terminal_realize(GtkWidget *widget)
 
 	/* Create the draw structure if we don't already have one. */
 	if (terminal->pvt->draw == NULL) {
-		terminal->pvt->draw = _vte_draw_new(&terminal->widget);
+		terminal->pvt->draw = _vte_draw_new();
 	}
 
 	/* Create the stock cursors. */
diff --git a/src/vtedraw.c b/src/vtedraw.c
index 1e70249..310148b 100644
--- a/src/vtedraw.c
+++ b/src/vtedraw.c
@@ -720,8 +720,6 @@ font_info_get_unistr_info (struct font_info *info,
 }
 
 struct _vte_draw {
-	GtkWidget *widget;
-
 	struct font_info *font;
 	struct font_info *font_bold;
 	cairo_pattern_t *bg_pattern;
@@ -730,13 +728,12 @@ struct _vte_draw {
 };
 
 struct _vte_draw *
-_vte_draw_new (GtkWidget *widget)
+_vte_draw_new (void)
 {
 	struct _vte_draw *draw;
 
 	/* Create the structure. */
 	draw = g_slice_new0 (struct _vte_draw);
-	draw->widget = g_object_ref (widget);
 
 	_vte_debug_print (VTE_DEBUG_DRAW, "draw_new\n");
 
@@ -758,10 +755,6 @@ _vte_draw_free (struct _vte_draw *draw)
 		draw->font = NULL;
 	}
 
-	if (draw->widget != NULL) {
-		g_object_unref (draw->widget);
-	}
-
 	g_slice_free (struct _vte_draw, draw);
 }
 
@@ -833,7 +826,8 @@ _vte_draw_clear (struct _vte_draw *draw, gint x, gint y, gint width, gint height
 
 void
 _vte_draw_set_text_font (struct _vte_draw *draw,
-			const PangoFontDescription *fontdesc)
+                         GtkWidget *widget,
+                         const PangoFontDescription *fontdesc)
 {
 	PangoFontDescription *bolddesc = NULL;
 
@@ -842,13 +836,13 @@ _vte_draw_set_text_font (struct _vte_draw *draw,
 	if (draw->font_bold != draw->font)
 		font_info_destroy (draw->font_bold);
 	font_info_destroy (draw->font);
-	draw->font = font_info_create_for_widget (draw->widget, fontdesc);
+	draw->font = font_info_create_for_widget (widget, fontdesc);
 
 	/* calculate bold font desc */
 	bolddesc = pango_font_description_copy (fontdesc);
 	pango_font_description_set_weight (bolddesc, PANGO_WEIGHT_BOLD);
 
-	draw->font_bold = font_info_create_for_widget (draw->widget, bolddesc);
+	draw->font_bold = font_info_create_for_widget (widget, bolddesc);
 	pango_font_description_free (bolddesc);
 
 	/* Decide if we should keep this bold font face, per bug 54926:
diff --git a/src/vtedraw.h b/src/vtedraw.h
index d0d2be9..a50aff1 100644
--- a/src/vtedraw.h
+++ b/src/vtedraw.h
@@ -58,7 +58,7 @@ struct _vte_draw_text_request {
 };
 
 /* Create and destroy a draw structure. */
-struct _vte_draw *_vte_draw_new(GtkWidget *widget);
+struct _vte_draw *_vte_draw_new(void);
 void _vte_draw_free(struct _vte_draw *draw);
 
 void _vte_draw_set_cairo(struct _vte_draw *draw,
@@ -74,6 +74,7 @@ void _vte_draw_clear(struct _vte_draw *draw,
 		     gint x, gint y, gint width, gint height);
 
 void _vte_draw_set_text_font(struct _vte_draw *draw,
+                             GtkWidget *widget,
 			     const PangoFontDescription *fontdesc);
 void _vte_draw_get_text_metrics(struct _vte_draw *draw,
 				gint *width, gint *height, gint *ascent);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]