gtk+ r19382 - in trunk: . gtk tests
- From: hasselmm svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk+ r19382 - in trunk: . gtk tests
- Date: Thu, 17 Jan 2008 16:42:05 +0000 (GMT)
Author: hasselmm
Date: Thu Jan 17 16:42:04 2008
New Revision: 19382
URL: http://svn.gnome.org/viewvc/gtk+?rev=19382&view=rev
Log:
Change GtkCalendarDetailFunc to return newly allocated string. (#339540)
* gtk/gtkcalendar.c: Release the memory returned by the detail_func.
* gtk/gtkcalendar.h: Remove G_CONST_RETURN from GtkCalendarDetailFunc.
* tests/testcalendar.c: Duplicate calendar details before returning.
Modified:
trunk/ChangeLog
trunk/gtk/gtkcalendar.c
trunk/gtk/gtkcalendar.h
trunk/tests/testcalendar.c
Modified: trunk/gtk/gtkcalendar.c
==============================================================================
--- trunk/gtk/gtkcalendar.c (original)
+++ trunk/gtk/gtkcalendar.c Thu Jan 17 16:42:04 2008
@@ -1672,7 +1672,7 @@
(* GTK_WIDGET_CLASS (gtk_calendar_parent_class)->unrealize) (widget);
}
-static G_CONST_RETURN gchar*
+static gchar*
gtk_calendar_get_detail (GtkCalendar *calendar,
gint row,
gint column)
@@ -1709,7 +1709,7 @@
{
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget);
GtkCalendar *calendar = GTK_CALENDAR (widget);
- const gchar *detail = NULL;
+ gchar *detail = NULL;
GdkRectangle day_rect;
if (priv->main_win)
@@ -1736,6 +1736,8 @@
gtk_tooltip_set_tip_area (tooltip, &day_rect);
gtk_tooltip_set_markup (tooltip, detail);
+ g_free (detail);
+
return TRUE;
}
@@ -1914,7 +1916,7 @@
for (r = 0; r < 6; r++)
for (c = 0; c < 7; c++)
{
- const gchar *detail = gtk_calendar_get_detail (calendar, r, c);
+ gchar *detail = gtk_calendar_get_detail (calendar, r, c);
if (detail)
{
@@ -1935,6 +1937,7 @@
max_detail_height = MAX (max_detail_height, logical_rect.height);
g_free (markup);
+ g_free (detail);
}
}
}
@@ -2429,7 +2432,7 @@
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar);
cairo_t *cr;
GdkColor *text_color;
- const gchar *detail;
+ gchar *detail;
gchar buffer[32];
gint day;
gint x_loc, y_loc;
@@ -2619,6 +2622,7 @@
g_object_unref (layout);
cairo_destroy (cr);
+ g_free (detail);
}
static void
Modified: trunk/gtk/gtkcalendar.h
==============================================================================
--- trunk/gtk/gtkcalendar.h (original)
+++ trunk/gtk/gtkcalendar.h Thu Jan 17 16:42:04 2008
@@ -89,13 +89,14 @@
*
* Since: 2.16
*
- * Return value: Pango markup with details for the specified day, or %NULL.
+ * Return value: Newly allocated string with Pango markup with details
+ * for the specified day, or %NULL.
*/
-typedef G_CONST_RETURN gchar* (*GtkCalendarDetailFunc) (GtkCalendar *calendar,
- guint year,
- guint month,
- guint day,
- gpointer user_data);
+typedef gchar* (*GtkCalendarDetailFunc) (GtkCalendar *calendar,
+ guint year,
+ guint month,
+ guint day,
+ gpointer user_data);
struct _GtkCalendar
{
Modified: trunk/tests/testcalendar.c
==============================================================================
--- trunk/tests/testcalendar.c (original)
+++ trunk/tests/testcalendar.c Thu Jan 17 16:42:04 2008
@@ -85,7 +85,7 @@
g_hash_table_replace (data->details_table, key, detail);
}
-static G_CONST_RETURN gchar*
+static gchar*
calendar_get_detail (CalendarData *data,
guint year,
guint month,
@@ -98,7 +98,7 @@
detail = g_hash_table_lookup (data->details_table, key);
g_free (key);
- return detail;
+ return (detail ? g_strdup (detail) : NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]