From 10ccddfb9372c82ab43c01ccd99618de8d4f3893 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Wed, 14 Nov 2007 14:42:05 +0000 Subject: [PATCH] app/display/gimpcanvas.c free the cached PangoLayouts in 2007-11-14 Michael Natterer * app/display/gimpcanvas.c * app/widgets/gimpcurveview.c: free the cached PangoLayouts in GtkWidget::style_set(). * app/widgets/gimppaletteview.c: draw the focus rectangle in hardcoded black/white since we also hardcode the grid color to black. * app/display/gimpstatusbar.c * app/widgets/gimpdockable.c: small cleanups while reviewing layout code. svn path=/trunk/; revision=24156 --- ChangeLog | 14 +++++++++++++ app/display/gimpcanvas.c | 39 ++++++++++++++++++++++++++--------- app/display/gimpstatusbar.c | 5 ++--- app/widgets/gimpcurveview.c | 38 +++++++++++++++++++++++++++------- app/widgets/gimpdockable.c | 6 +++--- app/widgets/gimppaletteview.c | 8 ++++--- 6 files changed, 84 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8bd68a8883..642cb548c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2007-11-14 Michael Natterer + + * app/display/gimpcanvas.c + * app/widgets/gimpcurveview.c: free the cached PangoLayouts in + GtkWidget::style_set(). + + * app/widgets/gimppaletteview.c: draw the focus rectangle in + hardcoded black/white since we also hardcode the grid color to + black. + + * app/display/gimpstatusbar.c + * app/widgets/gimpdockable.c: small cleanups while reviewing + layout code. + 2007-11-14 Michael Natterer * app/widgets/gimpcolorframe.[ch]: replaced the number label with diff --git a/app/display/gimpcanvas.c b/app/display/gimpcanvas.c index 833f8ffd55..46022c35a0 100644 --- a/app/display/gimpcanvas.c +++ b/app/display/gimpcanvas.c @@ -42,17 +42,19 @@ enum /* local function prototypes */ -static void gimp_canvas_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); -static void gimp_canvas_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); +static void gimp_canvas_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void gimp_canvas_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); -static void gimp_canvas_realize (GtkWidget *widget); -static void gimp_canvas_unrealize (GtkWidget *widget); +static void gimp_canvas_realize (GtkWidget *widget); +static void gimp_canvas_unrealize (GtkWidget *widget); +static void gimp_canvas_style_set (GtkWidget *widget, + GtkStyle *prev_style); static GdkGC * gimp_canvas_gc_new (GimpCanvas *canvas, GimpCanvasStyle style); @@ -159,6 +161,7 @@ gimp_canvas_class_init (GimpCanvasClass *klass) widget_class->realize = gimp_canvas_realize; widget_class->unrealize = gimp_canvas_unrealize; + widget_class->style_set = gimp_canvas_style_set; g_object_class_install_property (object_class, PROP_GIMP, g_param_spec_object ("gimp", NULL, NULL, @@ -262,6 +265,22 @@ gimp_canvas_unrealize (GtkWidget *widget) GTK_WIDGET_CLASS (parent_class)->unrealize (widget); } +static void +gimp_canvas_style_set (GtkWidget *widget, + GtkStyle *prev_style) +{ + GimpCanvas *canvas = GIMP_CANVAS (widget); + + if (GTK_WIDGET_CLASS (parent_class)->style_set) + GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style); + + if (canvas->layout) + { + g_object_unref (canvas->layout); + canvas->layout = NULL; + } +} + /* Returns: %TRUE if the XOR color is not white */ static gboolean gimp_canvas_get_xor_color (GimpCanvas *canvas, diff --git a/app/display/gimpstatusbar.c b/app/display/gimpstatusbar.c index 120d89d6ec..fdbbf6b5ec 100644 --- a/app/display/gimpstatusbar.c +++ b/app/display/gimpstatusbar.c @@ -1086,10 +1086,9 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell, /* one static layout for all displays should be fine */ if (! layout) - layout = gtk_widget_create_pango_layout (statusbar->cursor_label, text); - else - pango_layout_set_text (layout, text, -1); + layout = gtk_widget_create_pango_layout (statusbar->cursor_label, NULL); + pango_layout_set_text (layout, text, -1); pango_layout_get_pixel_size (layout, &width, NULL); /* find out how many pixels the label's parent frame is bigger than diff --git a/app/widgets/gimpcurveview.c b/app/widgets/gimpcurveview.c index 91b426fff3..e80c631a8e 100644 --- a/app/widgets/gimpcurveview.c +++ b/app/widgets/gimpcurveview.c @@ -52,6 +52,8 @@ static void gimp_curve_view_get_property (GObject *object, GValue *value, GParamSpec *pspec); +static void gimp_curve_view_style_set (GtkWidget *widget, + GtkStyle *prev_style); static gboolean gimp_curve_view_expose (GtkWidget *widget, GdkEventExpose *event); static gboolean gimp_curve_view_button_press (GtkWidget *widget, @@ -84,6 +86,7 @@ gimp_curve_view_class_init (GimpCurveViewClass *klass) object_class->set_property = gimp_curve_view_set_property; object_class->get_property = gimp_curve_view_get_property; + widget_class->style_set = gimp_curve_view_style_set; widget_class->expose_event = gimp_curve_view_expose; widget_class->button_press_event = gimp_curve_view_button_press; widget_class->button_release_event = gimp_curve_view_button_release; @@ -157,10 +160,10 @@ gimp_curve_view_dispose (GObject *object) } static void -gimp_curve_view_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) +gimp_curve_view_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) { GimpCurveView *view = GIMP_CURVE_VIEW (object); @@ -200,6 +203,28 @@ gimp_curve_view_get_property (GObject *object, } } +static void +gimp_curve_view_style_set (GtkWidget *widget, + GtkStyle *prev_style) +{ + GimpCurveView *view = GIMP_CURVE_VIEW (widget); + + if (GTK_WIDGET_CLASS (parent_class)->style_set) + GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style); + + if (view->xpos_layout) + { + g_object_unref (view->xpos_layout); + view->xpos_layout = NULL; + } + + if (view->cursor_layout) + { + g_object_unref (view->cursor_layout); + view->cursor_layout = NULL; + } +} + static void gimp_curve_view_draw_grid (GimpCurveView *view, GtkStyle *style, @@ -381,10 +406,9 @@ gimp_curve_view_expose (GtkWidget *widget, g_snprintf (buf, sizeof (buf), "x:%d", view->xpos); if (! view->xpos_layout) - view->xpos_layout = gtk_widget_create_pango_layout (widget, buf); - else - pango_layout_set_text (view->xpos_layout, buf, -1); + view->xpos_layout = gtk_widget_create_pango_layout (widget, NULL); + pango_layout_set_text (view->xpos_layout, buf, -1); pango_layout_get_pixel_size (view->xpos_layout, &x, &y); if (view->xpos < 127) diff --git a/app/widgets/gimpdockable.c b/app/widgets/gimpdockable.c index 96c02e8c0a..9de0491aa3 100644 --- a/app/widgets/gimpdockable.c +++ b/app/widgets/gimpdockable.c @@ -430,6 +430,9 @@ gimp_dockable_style_set (GtkWidget *widget, GimpDockable *dockable = GIMP_DOCKABLE (widget); gint content_border; + if (GTK_WIDGET_CLASS (parent_class)->style_set) + GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style); + gtk_widget_style_get (widget, "content-border", &content_border, NULL); @@ -441,9 +444,6 @@ gimp_dockable_style_set (GtkWidget *widget, g_object_unref (dockable->title_layout); dockable->title_layout = NULL; } - - if (GTK_WIDGET_CLASS (parent_class)->style_set) - GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style); } static PangoLayout * diff --git a/app/widgets/gimppaletteview.c b/app/widgets/gimppaletteview.c index 9f49adc2ae..66f00d8f24 100644 --- a/app/widgets/gimppaletteview.c +++ b/app/widgets/gimppaletteview.c @@ -188,8 +188,8 @@ gimp_palette_view_expose (GtkWidget *widget, gdk_cairo_region (cr, eevent->region); cairo_clip (cr); + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); cairo_set_line_width (cr, 1.0); - gdk_cairo_set_source_color (cr, &widget->style->base[GTK_STATE_NORMAL]); cairo_rectangle (cr, widget->allocation.x + col * renderer->cell_width + 0.5, @@ -218,10 +218,12 @@ gimp_palette_view_expose (GtkWidget *widget, total_length += dash_list[i]; } - gdk_cairo_set_source_color (cr, &widget->style->text[GTK_STATE_NORMAL]); + cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); cairo_set_dash (cr, dashes, n_dashes, 0.5); - cairo_stroke (cr); + g_free (dashes); + + cairo_stroke (cr); } g_free (dash_list);