summaryrefslogtreecommitdiff
path: root/gtk/gtkstyle.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2011-01-23 23:20:57 -0500
committerMatthias Clasen <mclasen@redhat.com>2011-01-23 23:20:57 -0500
commit3413438d374539df94554c070a1306f73190f584 (patch)
treea95283506d73f42aa3eaf719c1ad2d03df15aa2e /gtk/gtkstyle.c
parentd9fcc4c630f3668dd014c258c2deb22d61e438d0 (diff)
downloadgtk+-3413438d374539df94554c070a1306f73190f584.tar.gz
Don't leak CursorInfo structs
Diffstat (limited to 'gtk/gtkstyle.c')
-rw-r--r--gtk/gtkstyle.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index e7b87aa1ea..954cfacd57 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -3980,9 +3980,15 @@ struct _CursorInfo
GdkColor secondary;
};
+static void
+cursor_info_free (gpointer data)
+{
+ g_slice_free (CursorInfo, data);
+}
+
static const GdkColor *
get_insertion_cursor_color (GtkWidget *widget,
- gboolean is_primary)
+ gboolean is_primary)
{
CursorInfo *cursor_info;
GtkStyle *style;
@@ -3993,8 +3999,9 @@ get_insertion_cursor_color (GtkWidget *widget,
cursor_info = g_object_get_data (G_OBJECT (style), "gtk-style-cursor-info");
if (!cursor_info)
{
- cursor_info = g_new0 (CursorInfo, 1);
- g_object_set_data (G_OBJECT (style), I_("gtk-style-cursor-info"), cursor_info);
+ cursor_info = g_slice_new (CursorInfo);
+ g_object_set_data_full (G_OBJECT (style), I_("gtk-style-cursor-info"),
+ cursor_info, cursor_info_free);
cursor_info->for_type = G_TYPE_INVALID;
}
@@ -4009,7 +4016,8 @@ get_insertion_cursor_color (GtkWidget *widget,
cursor_info->for_type = G_OBJECT_TYPE (widget);
/* Cursors in text widgets are drawn only in NORMAL state,
- * so we can use text[GTK_STATE_NORMAL] as text color here */
+ * so we can use text[GTK_STATE_NORMAL] as text color here
+ */
gtk_widget_style_get (widget, "cursor-color", &cursor_color, NULL);
if (cursor_color)
{
@@ -4043,7 +4051,7 @@ get_insertion_cursor_color (GtkWidget *widget,
void
_gtk_widget_get_cursor_color (GtkWidget *widget,
- GdkColor *color)
+ GdkColor *color)
{
GdkColor *style_color;
@@ -4076,7 +4084,7 @@ _gtk_widget_get_cursor_color (GtkWidget *widget,
* but merely a convenience function for drawing the standard cursor shape.
*
* Since: 3.0
- **/
+ */
void
gtk_draw_insertion_cursor (GtkWidget *widget,
cairo_t *cr,
@@ -4090,7 +4098,7 @@ gtk_draw_insertion_cursor (GtkWidget *widget,
gint x, y;
gfloat cursor_aspect_ratio;
gint offset;
-
+
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (cr != NULL);
g_return_if_fail (location != NULL);
@@ -4103,7 +4111,7 @@ gtk_draw_insertion_cursor (GtkWidget *widget,
*/
gtk_widget_style_get (widget, "cursor-aspect-ratio", &cursor_aspect_ratio, NULL);
-
+
stem_width = location->height * cursor_aspect_ratio + 1;
arrow_width = stem_width + 1;
@@ -4112,8 +4120,8 @@ gtk_draw_insertion_cursor (GtkWidget *widget,
offset = stem_width / 2;
else
offset = stem_width - stem_width / 2;
-
- cairo_rectangle (cr,
+
+ cairo_rectangle (cr,
location->x - offset, location->y,
stem_width, location->height);
cairo_fill (cr);
@@ -4124,7 +4132,7 @@ gtk_draw_insertion_cursor (GtkWidget *widget,
{
x = location->x - offset - 1;
y = location->y + location->height - arrow_width * 2 - arrow_width + 1;
-
+
cairo_move_to (cr, x, y + 1);
cairo_line_to (cr, x - arrow_width, y + arrow_width);
cairo_line_to (cr, x, y + 2 * arrow_width);
@@ -4134,7 +4142,7 @@ gtk_draw_insertion_cursor (GtkWidget *widget,
{
x = location->x + stem_width - offset;
y = location->y + location->height - arrow_width * 2 - arrow_width + 1;
-
+
cairo_move_to (cr, x, y + 1);
cairo_line_to (cr, x + arrow_width, y + arrow_width);
cairo_line_to (cr, x, y + 2 * arrow_width);