mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 14:31:10 +00:00
Bug 501730 – use GSlice for small allocs
* gtk/gtkmenuitem.c: * gtk/gtkmenu.c: Use the slice allocator for small allocations. Patch by Christian Persch. svn path=/trunk/; revision=20161
This commit is contained in:
parent
64d2764a04
commit
b0ea8e9f85
@ -1,3 +1,11 @@
|
||||
2008-05-25 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
Bug 501730 – use GSlice for small allocs
|
||||
|
||||
* gtk/gtkmenuitem.c:
|
||||
* gtk/gtkmenu.c: Use the slice allocator for small allocations.
|
||||
Patch by Christian Persch.
|
||||
|
||||
2008-05-25 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
Bug 523930 – sort -> search in gtktreeview.c
|
||||
|
@ -265,6 +265,12 @@ menu_queue_resize (GtkMenu *menu)
|
||||
gtk_widget_queue_resize (GTK_WIDGET (menu));
|
||||
}
|
||||
|
||||
static void
|
||||
attach_info_free (AttachInfo *info)
|
||||
{
|
||||
g_slice_free (AttachInfo, info);
|
||||
}
|
||||
|
||||
static AttachInfo *
|
||||
get_attach_info (GtkWidget *child)
|
||||
{
|
||||
@ -273,8 +279,8 @@ get_attach_info (GtkWidget *child)
|
||||
|
||||
if (!ai)
|
||||
{
|
||||
ai = g_new0 (AttachInfo, 1);
|
||||
g_object_set_data_full (object, I_(ATTACH_INFO_KEY), ai, g_free);
|
||||
ai = g_slice_new0 (AttachInfo);
|
||||
g_object_set_data_full (object, I_(ATTACH_INFO_KEY), ai, attach_info_free);
|
||||
}
|
||||
|
||||
return ai;
|
||||
@ -1024,7 +1030,7 @@ gtk_menu_attach_to_widget (GtkMenu *menu,
|
||||
|
||||
g_object_ref_sink (menu);
|
||||
|
||||
data = g_new (GtkMenuAttachData, 1);
|
||||
data = g_slice_new (GtkMenuAttachData);
|
||||
data->attach_widget = attach_widget;
|
||||
|
||||
g_signal_connect (attach_widget, "screen_changed",
|
||||
@ -1098,7 +1104,7 @@ gtk_menu_detach (GtkMenu *menu)
|
||||
if (GTK_WIDGET_REALIZED (menu))
|
||||
gtk_widget_unrealize (GTK_WIDGET (menu));
|
||||
|
||||
g_free (data);
|
||||
g_slice_free (GtkMenuAttachData, data);
|
||||
|
||||
/* Fallback title for menu comes from attach widget */
|
||||
gtk_menu_update_title (menu);
|
||||
@ -1644,12 +1650,15 @@ void
|
||||
gtk_menu_set_accel_path (GtkMenu *menu,
|
||||
const gchar *accel_path)
|
||||
{
|
||||
gchar *old_accel_path;
|
||||
|
||||
g_return_if_fail (GTK_IS_MENU (menu));
|
||||
if (accel_path)
|
||||
g_return_if_fail (accel_path[0] == '<' && strchr (accel_path, '/')); /* simplistic check */
|
||||
|
||||
g_free (menu->accel_path);
|
||||
old_accel_path = menu->accel_path;
|
||||
menu->accel_path = g_strdup (accel_path);
|
||||
g_free (old_accel_path);
|
||||
if (menu->accel_path)
|
||||
_gtk_menu_refresh_accel_paths (menu, FALSE);
|
||||
}
|
||||
|
@ -1076,6 +1076,12 @@ gtk_real_menu_item_toggle_size_allocate (GtkMenuItem *menu_item,
|
||||
menu_item->toggle_size = allocation;
|
||||
}
|
||||
|
||||
static void
|
||||
free_timeval (GTimeVal *val)
|
||||
{
|
||||
g_slice_free (GTimeVal, val);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_menu_item_real_popup_submenu (GtkWidget *widget,
|
||||
gboolean remember_exact_time)
|
||||
@ -1092,13 +1098,13 @@ gtk_menu_item_real_popup_submenu (GtkWidget *widget,
|
||||
|
||||
if (remember_exact_time)
|
||||
{
|
||||
GTimeVal *popup_time = g_new0 (GTimeVal, 1);
|
||||
GTimeVal *popup_time = g_slice_new0 (GTimeVal);
|
||||
|
||||
g_get_current_time (popup_time);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (menu_item->submenu),
|
||||
"gtk-menu-exact-popup-time", popup_time,
|
||||
(GDestroyNotify) g_free);
|
||||
(GDestroyNotify) free_timeval);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1603,6 +1609,7 @@ gtk_menu_item_set_accel_path (GtkMenuItem *menu_item,
|
||||
const gchar *accel_path)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
gchar *old_accel_path;
|
||||
|
||||
g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
|
||||
g_return_if_fail (accel_path == NULL ||
|
||||
@ -1611,8 +1618,9 @@ gtk_menu_item_set_accel_path (GtkMenuItem *menu_item,
|
||||
widget = GTK_WIDGET (menu_item);
|
||||
|
||||
/* store new path */
|
||||
g_free (menu_item->accel_path);
|
||||
old_accel_path = menu_item->accel_path;
|
||||
menu_item->accel_path = g_strdup (accel_path);
|
||||
g_free (old_accel_path);
|
||||
|
||||
/* forget accelerators associated with old path */
|
||||
gtk_widget_set_accel_path (widget, NULL, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user