[vte] drawing: Don't store the widget
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] drawing: Don't store the widget
- Date: Thu, 27 Mar 2014 18:47:26 +0000 (UTC)
commit 14e854fc0eaf0476c9dfc1423a97a20ac1067c98
Author: Christian Persch <chpe gnome org>
Date: Thu Mar 27 16:45:53 2014 +0100
drawing: Don't store the widget
And esp. not a reference to it! It's just needed when creating the font info,
so only pass it to set_text_font.
src/vte.c | 10 +++-------
src/vtedraw.c | 18 +++++++-----------
src/vtedraw.h | 3 ++-
3 files changed, 12 insertions(+), 19 deletions(-)
---
diff --git a/src/vte.c b/src/vte.c
index a97540b..53f5836 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -7331,6 +7331,7 @@ vte_terminal_ensure_font (VteTerminal *terminal)
gint width, height, ascent;
terminal->pvt->fontdirty = FALSE;
_vte_draw_set_text_font (terminal->pvt->draw,
+ &terminal->widget,
terminal->pvt->fontdesc);
_vte_draw_get_text_metrics (terminal->pvt->draw,
&width, &height, &ascent);
@@ -8033,8 +8034,8 @@ vte_terminal_init(VteTerminal *terminal)
sizeof(struct vte_match_regex));
vte_terminal_match_hilite_clear(terminal);
- /* Rendering data. Try everything. */
- pvt->draw = _vte_draw_new(&terminal->widget);
+ /* Rendering data */
+ pvt->draw = _vte_draw_new();
/* The font description. */
gtk_widget_ensure_style(&terminal->widget);
@@ -8546,11 +8547,6 @@ vte_terminal_realize(GtkWidget *widget)
terminal = VTE_TERMINAL(widget);
gtk_widget_get_allocation (widget, &allocation);
- /* Create the draw structure if we don't already have one. */
- if (terminal->pvt->draw == NULL) {
- terminal->pvt->draw = _vte_draw_new(&terminal->widget);
- }
-
/* Create the stock cursors. */
terminal->pvt->mouse_cursor_visible = TRUE;
terminal->pvt->mouse_default_cursor =
diff --git a/src/vtedraw.c b/src/vtedraw.c
index 73a0660..96d4110 100644
--- a/src/vtedraw.c
+++ b/src/vtedraw.c
@@ -741,13 +741,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");
@@ -780,10 +779,6 @@ _vte_draw_free (struct _vte_draw *draw)
}
}
- if (draw->widget != NULL) {
- g_object_unref (draw->widget);
- }
-
g_slice_free (struct _vte_draw, draw);
}
@@ -841,7 +836,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;
PangoFontDescription *italicdesc = NULL;
@@ -871,11 +867,11 @@ _vte_draw_set_text_font (struct _vte_draw *draw,
bolditalicdesc = pango_font_description_copy (bolddesc);
pango_font_description_set_style (bolditalicdesc, PANGO_STYLE_ITALIC);
- draw->fonts[VTE_DRAW_NORMAL] = font_info_create_for_widget (draw->widget, fontdesc);
- draw->fonts[VTE_DRAW_BOLD] = font_info_create_for_widget (draw->widget, bolddesc);
- draw->fonts[VTE_DRAW_ITALIC] = font_info_create_for_widget (draw->widget, italicdesc);
+ draw->fonts[VTE_DRAW_NORMAL] = font_info_create_for_widget (widget, fontdesc);
+ draw->fonts[VTE_DRAW_BOLD] = font_info_create_for_widget (widget, bolddesc);
+ draw->fonts[VTE_DRAW_ITALIC] = font_info_create_for_widget (widget, italicdesc);
draw->fonts[VTE_DRAW_ITALIC | VTE_DRAW_BOLD] =
- font_info_create_for_widget (draw->widget, bolditalicdesc);
+ font_info_create_for_widget (widget, bolditalicdesc);
pango_font_description_free (bolddesc);
pango_font_description_free (italicdesc);
pango_font_description_free (bolditalicdesc);
diff --git a/src/vtedraw.h b/src/vtedraw.h
index e3d5562..956215a 100644
--- a/src/vtedraw.h
+++ b/src/vtedraw.h
@@ -66,7 +66,7 @@ struct _vte_draw_text_request {
guint _vte_draw_get_style(gboolean bold, gboolean italic);
/* 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);
cairo_t *_vte_draw_get_context (struct _vte_draw *draw);
@@ -82,6 +82,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]