app/display/gimpcanvas.c free the cached PangoLayouts in

2007-11-14  Michael Natterer  <mitch@gimp.org>

	* 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
This commit is contained in:
Michael Natterer 2007-11-14 14:42:05 +00:00 committed by Michael Natterer
parent 614932021c
commit 10ccddfb93
6 changed files with 84 additions and 26 deletions

View File

@ -1,3 +1,17 @@
2007-11-14 Michael Natterer <mitch@gimp.org>
* 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 <mitch@gimp.org>
* app/widgets/gimpcolorframe.[ch]: replaced the number label with

View File

@ -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,

View File

@ -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

View File

@ -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)

View File

@ -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 *

View File

@ -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);