summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2006-01-04 07:06:12 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2006-01-04 07:06:12 +0000
commit04eceaf621aec4388bc37e10b63a49da4d2a6942 (patch)
treebddf2cd7704e2174c2cfba8bb1d65036b2a72801 /gtk
parentf827de4ec41b5f5bba304f2a062b8d67690542d6 (diff)
downloadgtk+-04eceaf621aec4388bc37e10b63a49da4d2a6942.tar.gz
Use the slice allocator for many small allocations.
2006-01-04 Matthias Clasen <mclasen@redhat.com> * gtk/gtkaccelmap.c: * gtk/gtkactiongroup.c: * gtk/gtkdialog.c: * gtk/gtkfilesystemunix.c: * gtk/gtkgc.c: * gtk/gtkkeyhash.c: * gtk/gtkplug.c: * gtk/gtktextiter.c: * gtk/gtktextlayout.c: * gtk/gtkuimanager.c: * gtk/gtkwidget.c: * gtk/gtkwindow.c: * gtk/gtkxembed.c: Use the slice allocator for many small allocations. * gtk/gtkcolorsel.c: * gtk/gtktreeview.c: Use IPN. * gtk/gtkwidget.c: Remove an unused field from the AccelPath struct.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkaccelmap.c8
-rw-r--r--gtk/gtkactiongroup.c6
-rw-r--r--gtk/gtkcolorsel.c14
-rw-r--r--gtk/gtkdialog.c10
-rw-r--r--gtk/gtkfilesystemunix.c4
-rw-r--r--gtk/gtkgc.c16
-rw-r--r--gtk/gtkkeyhash.c4
-rw-r--r--gtk/gtkplug.c10
-rw-r--r--gtk/gtktextiter.c4
-rw-r--r--gtk/gtktextlayout.c4
-rw-r--r--gtk/gtktreesortable.c1
-rw-r--r--gtk/gtktreeview.c9
-rw-r--r--gtk/gtkuimanager.c12
-rw-r--r--gtk/gtkwidget.c26
-rw-r--r--gtk/gtkwindow.c82
-rw-r--r--gtk/gtkxembed.c5
16 files changed, 120 insertions, 95 deletions
diff --git a/gtk/gtkaccelmap.c b/gtk/gtkaccelmap.c
index c95fbcfc8e..d096f85600 100644
--- a/gtk/gtkaccelmap.c
+++ b/gtk/gtkaccelmap.c
@@ -57,8 +57,8 @@ typedef struct {
guint accel_mods;
guint std_accel_key;
guint std_accel_mods;
- guint changed : 1;
- guint lock_count;
+ guint changed : 1;
+ guint lock_count : 15;
GSList *groups;
} AccelEntry;
@@ -179,8 +179,8 @@ gtk_accel_map_add_entry (const gchar *accel_path,
}
else
{
- entry = g_new0 (AccelEntry, 1);
- entry->accel_path = g_quark_to_string (g_quark_from_string (accel_path));
+ entry = g_slice_new0 (AccelEntry);
+ entry->accel_path = g_intern_string (accel_path);
entry->std_accel_key = accel_key;
entry->std_accel_mods = accel_mods;
entry->accel_key = accel_key;
diff --git a/gtk/gtkactiongroup.c b/gtk/gtkactiongroup.c
index 7910644d60..b852079fd5 100644
--- a/gtk/gtkactiongroup.c
+++ b/gtk/gtkactiongroup.c
@@ -714,7 +714,7 @@ shared_data_unref (gpointer data)
if (shared_data->destroy)
(*shared_data->destroy) (shared_data->data);
- g_free (shared_data);
+ g_slice_free (SharedData, shared_data);
}
}
@@ -748,7 +748,7 @@ gtk_action_group_add_actions_full (GtkActionGroup *action_group,
g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
- shared_data = g_new0 (SharedData, 1);
+ shared_data = g_slice_new0 (SharedData);
shared_data->ref_count = 1;
shared_data->data = user_data;
shared_data->destroy = destroy;
@@ -844,7 +844,7 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_gro
g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
- shared_data = g_new0 (SharedData, 1);
+ shared_data = g_slice_new0 (SharedData);
shared_data->ref_count = 1;
shared_data->data = user_data;
shared_data->destroy = destroy;
diff --git a/gtk/gtkcolorsel.c b/gtk/gtkcolorsel.c
index a94401c6cc..b7a7346415 100644
--- a/gtk/gtkcolorsel.c
+++ b/gtk/gtkcolorsel.c
@@ -108,6 +108,7 @@ struct _ColorSelectionPrivate
guint changing : 1;
guint default_set : 1;
guint default_alpha_set : 1;
+ guint has_grab : 1;
gdouble color[COLORSEL_NUM_CHANNELS];
gdouble old_color[COLORSEL_NUM_CHANNELS];
@@ -140,7 +141,6 @@ struct _ColorSelectionPrivate
/* Window for grabbing on */
GtkWidget *dropper_grab_widget;
guint32 grab_time;
- gboolean has_grab;
/* Connection to settings */
gulong settings_connection;
@@ -1907,6 +1907,8 @@ gtk_color_selection_class_init (GtkColorSelectionClass *klass)
P_("Palette to use in the color selector"),
default_colors,
GTK_PARAM_READWRITE));
+
+ g_type_class_add_private (gobject_class, sizeof (ColorSelectionPrivate));
}
/* widget functions */
@@ -1925,7 +1927,7 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
gtk_widget_push_composite_child ();
- priv = colorsel->private_data = g_new0 (ColorSelectionPrivate, 1);
+ priv = colorsel->private_data = G_TYPE_INSTANCE_GET_PRIVATE (colorsel, GTK_TYPE_COLOR_SELECTION, ColorSelectionPrivate);
priv->changing = FALSE;
priv->default_set = FALSE;
priv->default_alpha_set = FALSE;
@@ -2118,14 +2120,6 @@ gtk_color_selection_destroy (GtkObject *object)
static void
gtk_color_selection_finalize (GObject *object)
{
- GtkColorSelection *cselection = GTK_COLOR_SELECTION (object);
-
- if (cselection->private_data)
- {
- g_free (cselection->private_data);
- cselection->private_data = NULL;
- }
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c
index 6ed9952aa0..a04be42029 100644
--- a/gtk/gtkdialog.c
+++ b/gtk/gtkdialog.c
@@ -532,6 +532,12 @@ gtk_dialog_new_with_buttons (const gchar *title,
return GTK_WIDGET (dialog);
}
+static void
+response_data_free (gpointer data)
+{
+ g_slice_free (ResponseData, data);
+}
+
static ResponseData*
get_response_data (GtkWidget *widget,
gboolean create)
@@ -541,12 +547,12 @@ get_response_data (GtkWidget *widget,
if (ad == NULL && create)
{
- ad = g_new (ResponseData, 1);
+ ad = g_slice_new (ResponseData);
g_object_set_data_full (G_OBJECT (widget),
I_("gtk-dialog-response-data"),
ad,
- g_free);
+ response_data_free);
}
return ad;
diff --git a/gtk/gtkfilesystemunix.c b/gtk/gtkfilesystemunix.c
index 55865201a0..0dfdcd0783 100644
--- a/gtk/gtkfilesystemunix.c
+++ b/gtk/gtkfilesystemunix.c
@@ -702,7 +702,7 @@ icon_cache_element_free (IconCacheElement *element)
{
if (element->pixbuf)
g_object_unref (element->pixbuf);
- g_free (element);
+ g_slice_free (IconCacheElement, element);
}
static void
@@ -744,7 +744,7 @@ get_cached_icon (GtkWidget *widget,
element = g_hash_table_lookup (cache, name);
if (!element)
{
- element = g_new0 (IconCacheElement, 1);
+ element = g_slice_new0 (IconCacheElement);
g_hash_table_insert (cache, g_strdup (name), element);
}
diff --git a/gtk/gtkgc.c b/gtk/gtkgc.c
index a2cf6e4c05..867d446b02 100644
--- a/gtk/gtkgc.c
+++ b/gtk/gtkgc.c
@@ -64,7 +64,7 @@ static gint gtk_gc_drawable_equal (GtkGCDrawable *a,
static gint initialize = TRUE;
static GCache *gc_cache = NULL;
-
+static GQuark quark_gtk_gc_drawable_ht = 0;
GdkGC*
gtk_gc_get (gint depth,
@@ -102,21 +102,21 @@ free_gc_drawable (gpointer data)
{
GtkGCDrawable *drawable = data;
g_object_unref (drawable->drawable);
- g_free (drawable);
+ g_slice_free (GtkGCDrawable, drawable);
}
static GHashTable*
gtk_gc_get_drawable_ht (GdkScreen *screen)
{
- GHashTable *ht = g_object_get_data (G_OBJECT (screen), "gtk-gc-drawable-ht");
+ GHashTable *ht = g_object_get_qdata (G_OBJECT (screen), quark_gtk_gc_drawable_ht);
if (!ht)
{
ht = g_hash_table_new_full ((GHashFunc) gtk_gc_drawable_hash,
(GEqualFunc) gtk_gc_drawable_equal,
NULL, free_gc_drawable);
- g_object_set_data_full (G_OBJECT (screen),
- I_("gtk-gc-drawable-ht"), ht,
- (GDestroyNotify)g_hash_table_destroy);
+ g_object_set_qdata_full (G_OBJECT (screen),
+ quark_gtk_gc_drawable_ht, ht,
+ (GDestroyNotify)g_hash_table_destroy);
}
return ht;
@@ -127,6 +127,8 @@ gtk_gc_init (void)
{
initialize = FALSE;
+ quark_gtk_gc_drawable_ht = g_quark_from_static_string ("gtk-gc-drawable-ht");
+
gc_cache = g_cache_new ((GCacheNewFunc) gtk_gc_new,
(GCacheDestroyFunc) gtk_gc_destroy,
(GCacheDupFunc) gtk_gc_key_dup,
@@ -170,7 +172,7 @@ gtk_gc_new (gpointer key)
drawable = g_hash_table_lookup (ht, &keyval->depth);
if (!drawable)
{
- drawable = g_new (GtkGCDrawable, 1);
+ drawable = g_slice_new (GtkGCDrawable);
drawable->depth = keyval->depth;
drawable->drawable = gdk_pixmap_new (gdk_screen_get_root_window (screen),
1, 1, drawable->depth);
diff --git a/gtk/gtkkeyhash.c b/gtk/gtkkeyhash.c
index 12648e050d..7265daa3c8 100644
--- a/gtk/gtkkeyhash.c
+++ b/gtk/gtkkeyhash.c
@@ -147,7 +147,7 @@ key_hash_free_entry (GtkKeyHash *key_hash,
(*key_hash->destroy_notify) (entry->value);
g_free (entry->keys);
- g_free (entry);
+ g_slice_free (GtkKeyHashEntry, entry);
}
static void
@@ -202,7 +202,7 @@ _gtk_key_hash_add_entry (GtkKeyHash *key_hash,
GdkModifierType modifiers,
gpointer value)
{
- GtkKeyHashEntry *entry = g_new (GtkKeyHashEntry, 1);
+ GtkKeyHashEntry *entry = g_slice_new (GtkKeyHashEntry);
entry->value = value;
entry->keyval = keyval;
diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c
index 352b03db66..962ded6d66 100644
--- a/gtk/gtkplug.c
+++ b/gtk/gtkplug.c
@@ -802,7 +802,7 @@ keys_foreach (GtkWindow *window,
gpointer data)
{
GHashTable *new_grabbed_keys = data;
- GrabbedKey *key = g_new (GrabbedKey, 1);
+ GrabbedKey *key = g_slice_new (GrabbedKey);
key->accelerator_key = keyval;
key->accelerator_mods = modifiers;
@@ -811,12 +811,18 @@ keys_foreach (GtkWindow *window,
}
static void
+grabbed_key_free (gpointer data)
+{
+ g_slice_free (GrabbedKey, data);
+}
+
+static void
gtk_plug_keys_changed (GtkWindow *window)
{
GHashTable *new_grabbed_keys, *old_grabbed_keys;
GtkPlug *plug = GTK_PLUG (window);
- new_grabbed_keys = g_hash_table_new_full (grabbed_key_hash, grabbed_key_equal, (GDestroyNotify)g_free, NULL);
+ new_grabbed_keys = g_hash_table_new_full (grabbed_key_hash, grabbed_key_equal, (GDestroyNotify)grabbed_key_free, NULL);
_gtk_window_keys_foreach (window, keys_foreach, new_grabbed_keys);
if (plug->socket_window)
diff --git a/gtk/gtktextiter.c b/gtk/gtktextiter.c
index c919f386dc..31e3d6b84c 100644
--- a/gtk/gtktextiter.c
+++ b/gtk/gtktextiter.c
@@ -441,7 +441,7 @@ gtk_text_iter_copy (const GtkTextIter *iter)
g_return_val_if_fail (iter != NULL, NULL);
- new_iter = g_new (GtkTextIter, 1);
+ new_iter = g_slice_new (GtkTextIter);
*new_iter = *iter;
@@ -462,7 +462,7 @@ gtk_text_iter_free (GtkTextIter *iter)
{
g_return_if_fail (iter != NULL);
- g_free (iter);
+ g_slice_free (GtkTextIter, iter);
}
GType
diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c
index 84f4e5cdeb..a73533fe6e 100644
--- a/gtk/gtktextlayout.c
+++ b/gtk/gtktextlayout.c
@@ -1323,7 +1323,7 @@ gtk_text_attr_appearance_destroy (PangoAttribute *attr)
if (appearance->fg_stipple)
g_object_unref (appearance->fg_stipple);
- g_free (attr);
+ g_slice_free (GtkTextAttrAppearance, attr);
}
static gboolean
@@ -1369,7 +1369,7 @@ gtk_text_attr_appearance_new (const GtkTextAppearance *appearance)
klass.type = gtk_text_attr_appearance_type =
pango_attr_type_register ("GtkTextAttrAppearance");
- result = g_new (GtkTextAttrAppearance, 1);
+ result = g_slice_new (GtkTextAttrAppearance);
result->attr.klass = &klass;
result->appearance = *appearance;
diff --git a/gtk/gtktreesortable.c b/gtk/gtktreesortable.c
index d72ef22b53..4961e903af 100644
--- a/gtk/gtktreesortable.c
+++ b/gtk/gtktreesortable.c
@@ -170,6 +170,7 @@ gtk_tree_sortable_set_sort_func (GtkTreeSortable *sortable,
GtkTreeSortableIface *iface;
g_return_if_fail (GTK_IS_TREE_SORTABLE (sortable));
+ g_return_if_fail (sort_func != NULL);
iface = GTK_TREE_SORTABLE_GET_IFACE (sortable);
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 48b0637537..4de65e394f 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -1151,12 +1151,15 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
gtk_binding_entry_add_signal (binding_set, GDK_f, GDK_CONTROL_MASK, "start_interactive_search", 0);
gtk_binding_entry_add_signal (binding_set, GDK_F, GDK_CONTROL_MASK, "start_interactive_search", 0);
+
+ g_type_class_add_private (o_class, sizeof (GtkTreeViewPrivate));
}
static void
gtk_tree_view_init (GtkTreeView *tree_view)
{
- tree_view->priv = g_new0 (GtkTreeViewPrivate, 1);
+ tree_view->priv = G_TYPE_INSTANCE_GET_PRIVATE (tree_view, GTK_TYPE_TREE_VIEW, GtkTreeViewPrivate);
+
GTK_WIDGET_SET_FLAGS (tree_view, GTK_CAN_FOCUS);
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (tree_view), FALSE);
@@ -1316,10 +1319,6 @@ gtk_tree_view_get_property (GObject *object,
static void
gtk_tree_view_finalize (GObject *object)
{
- GtkTreeView *tree_view = (GtkTreeView *) object;
-
- g_free (tree_view->priv);
-
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
diff --git a/gtk/gtkuimanager.c b/gtk/gtkuimanager.c
index c07b193f30..4a7b1715d6 100644
--- a/gtk/gtkuimanager.c
+++ b/gtk/gtkuimanager.c
@@ -980,12 +980,18 @@ get_node (GtkUIManager *self,
return node;
}
+static void
+node_ui_reference_free (gpointer data)
+{
+ g_slice_free (NodeUIReference, data);
+}
+
static gboolean
free_node (GNode *node)
{
Node *info = NODE_INFO (node);
- g_list_foreach (info->uifiles, (GFunc) g_free, NULL);
+ g_list_foreach (info->uifiles, (GFunc) node_ui_reference_free, NULL);
g_list_free (info->uifiles);
if (info->action)
@@ -1032,7 +1038,7 @@ node_prepend_ui_reference (GNode *gnode,
reference = node->uifiles->data;
else
{
- reference = g_new (NodeUIReference, 1);
+ reference = g_slice_new (NodeUIReference);
node->uifiles = g_list_prepend (node->uifiles, reference);
}
@@ -1058,7 +1064,7 @@ node_remove_ui_reference (GNode *gnode,
if (p == node->uifiles)
mark_node_dirty (gnode);
node->uifiles = g_list_delete_link (node->uifiles, p);
- g_free (reference);
+ g_slice_free (NodeUIReference, reference);
break;
}
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index fc01393cdf..ac936d240c 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -3340,7 +3340,6 @@ gtk_widget_list_accel_closures (GtkWidget *widget)
typedef struct {
GQuark path_quark;
- GtkWidget *widget;
GtkAccelGroup *accel_group;
GClosure *closure;
} AccelPath;
@@ -3355,7 +3354,7 @@ destroy_accel_path (gpointer data)
/* closures_destroy takes care of unrefing the closure */
g_object_unref (apath->accel_group);
- g_free (apath);
+ g_slice_free (AccelPath, apath);
}
@@ -3399,11 +3398,10 @@ gtk_widget_set_accel_path (GtkWidget *widget,
g_return_if_fail (_gtk_accel_path_is_valid (accel_path));
gtk_accel_map_add_entry (accel_path, 0, 0);
- apath = g_new (AccelPath, 1);
- apath->widget = widget;
+ apath = g_slice_new (AccelPath);
apath->accel_group = g_object_ref (accel_group);
apath->path_quark = g_quark_from_string (accel_path);
- apath->closure = widget_new_accel_closure (apath->widget, GTK_WIDGET_GET_CLASS (apath->widget)->activate_signal);
+ apath->closure = widget_new_accel_closure (widget, GTK_WIDGET_GET_CLASS (widget)->activate_signal);
}
else
apath = NULL;
@@ -5920,14 +5918,14 @@ gtk_widget_set_events (GtkWidget *widget,
if (events)
{
if (!eventp)
- eventp = g_new (gint, 1);
+ eventp = g_slice_new (gint);
*eventp = events;
g_object_set_qdata (G_OBJECT (widget), quark_event_mask, eventp);
}
else if (eventp)
{
- g_free (eventp);
+ g_slice_free (gint, eventp);
g_object_set_qdata (G_OBJECT (widget), quark_event_mask, NULL);
}
@@ -5983,7 +5981,7 @@ gtk_widget_add_events (GtkWidget *widget,
{
if (!eventp)
{
- eventp = g_new (gint, 1);
+ eventp = g_slice_new (gint);
*eventp = 0;
}
@@ -5992,7 +5990,7 @@ gtk_widget_add_events (GtkWidget *widget,
}
else if (eventp)
{
- g_free (eventp);
+ g_slice_free (gint, eventp);
g_object_set_qdata (G_OBJECT (widget), quark_event_mask, NULL);
}
@@ -6033,7 +6031,7 @@ gtk_widget_set_extension_events (GtkWidget *widget,
modep = g_object_get_qdata (G_OBJECT (widget), quark_extension_event_mode);
if (!modep)
- modep = g_new (GdkExtensionMode, 1);
+ modep = g_slice_new (GdkExtensionMode);
*modep = mode;
g_object_set_qdata (G_OBJECT (widget), quark_extension_event_mode, modep);
@@ -6695,11 +6693,11 @@ gtk_widget_finalize (GObject *object)
events = g_object_get_qdata (G_OBJECT (widget), quark_event_mask);
if (events)
- g_free (events);
+ g_slice_free (gint, events);
mode = g_object_get_qdata (G_OBJECT (widget), quark_extension_event_mode);
if (mode)
- g_free (mode);
+ g_slice_free (GdkExtensionMode, mode);
accessible = g_object_get_qdata (G_OBJECT (widget), quark_accessible_object);
if (accessible)
@@ -6973,7 +6971,7 @@ static void
gtk_widget_shape_info_destroy (GtkWidgetShapeInfo *info)
{
g_object_unref (info->shape_mask);
- g_free (info);
+ g_slice_free (GtkWidgetShapeInfo, info);
}
/**
@@ -7012,7 +7010,7 @@ gtk_widget_shape_combine_mask (GtkWidget *widget,
{
GTK_PRIVATE_SET_FLAG (widget, GTK_HAS_SHAPE_MASK);
- shape_info = g_new (GtkWidgetShapeInfo, 1);
+ shape_info = g_slice_new (GtkWidgetShapeInfo);
g_object_set_qdata_full (G_OBJECT (widget), quark_shape_info, shape_info,
(GDestroyNotify) gtk_widget_shape_info_destroy);
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 4fbcab3df9..520f03eb68 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -289,6 +289,11 @@ static guint default_icon_serial = 0;
static gboolean disable_startup_notification = FALSE;
static gboolean sent_startup_notification = FALSE;
+static GQuark quark_gtk_embedded = 0;
+static GQuark quark_gtk_window_key_hash = 0;
+static GQuark quark_gtk_window_default_icon_pixmap = 0;
+static GQuark quark_gtk_window_icon_info = 0;
+
static void gtk_window_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -376,6 +381,11 @@ gtk_window_class_init (GtkWindowClass *klass)
parent_class = g_type_class_peek_parent (klass);
+ quark_gtk_embedded = g_quark_from_static_string ("gtk-embedded");
+ quark_gtk_window_key_hash = g_quark_from_static_string ("gtk-window-key-hash");
+ quark_gtk_window_default_icon_pixmap = g_quark_from_static_string ("gtk-window-default-icon-pixmap");
+ quark_gtk_window_icon_info = g_quark_from_static_string ("gtk-window-icon-info");
+
gobject_class->dispose = gtk_window_dispose;
gobject_class->finalize = gtk_window_finalize;
@@ -1726,17 +1736,16 @@ gtk_window_add_embedded_xid (GtkWindow *window, guint xid)
g_return_if_fail (GTK_IS_WINDOW (window));
- embedded_windows = g_object_get_data (G_OBJECT (window), "gtk-embedded");
+ embedded_windows = g_object_get_qdata (G_OBJECT (window), quark_gtk_embedded);
if (embedded_windows)
- g_object_steal_qdata (G_OBJECT (window),
- g_quark_from_static_string ("gtk-embedded"));
+ g_object_steal_qdata (G_OBJECT (window), quark_gtk_embedded);
embedded_windows = g_list_prepend (embedded_windows,
GUINT_TO_POINTER (xid));
- g_object_set_data_full (G_OBJECT (window), I_("gtk-embedded"),
- embedded_windows,
- embedded_windows ?
- (GDestroyNotify) g_list_free : NULL);
+ g_object_set_qdata_full (G_OBJECT (window), quark_gtk_embedded,
+ embedded_windows,
+ embedded_windows ?
+ (GDestroyNotify) g_list_free : NULL);
}
void
@@ -1747,10 +1756,9 @@ gtk_window_remove_embedded_xid (GtkWindow *window, guint xid)
g_return_if_fail (GTK_IS_WINDOW (window));
- embedded_windows = g_object_get_data (G_OBJECT (window), "gtk-embedded");
+ embedded_windows = g_object_get_qdata (G_OBJECT (window), quark_gtk_embedded);
if (embedded_windows)
- g_object_steal_qdata (G_OBJECT (window),
- g_quark_from_static_string ("gtk-embedded"));
+ g_object_steal_qdata (G_OBJECT (window), quark_gtk_embedded);
node = g_list_find (embedded_windows, GUINT_TO_POINTER (xid));
if (node)
@@ -1759,10 +1767,10 @@ gtk_window_remove_embedded_xid (GtkWindow *window, guint xid)
g_list_free_1 (node);
}
- g_object_set_data_full (G_OBJECT (window), I_("gtk-embedded"),
- embedded_windows,
- embedded_windows ?
- (GDestroyNotify) g_list_free : NULL);
+ g_object_set_qdata_full (G_OBJECT (window), quark_gtk_embedded,
+ embedded_windows,
+ embedded_windows ?
+ (GDestroyNotify) g_list_free : NULL);
}
void
@@ -2538,15 +2546,14 @@ gtk_window_get_deletable (GtkWindow *window)
static GtkWindowIconInfo*
get_icon_info (GtkWindow *window)
{
- return g_object_get_data (G_OBJECT (window),
- "gtk-window-icon-info");
+ return g_object_get_qdata (G_OBJECT (window), quark_gtk_window_icon_info);
}
static void
free_icon_info (GtkWindowIconInfo *info)
{
g_free (info->icon_name);
- g_free (info);
+ g_slice_free (GtkWindowIconInfo, info);
}
@@ -2559,9 +2566,9 @@ ensure_icon_info (GtkWindow *window)
if (info == NULL)
{
- info = g_new0 (GtkWindowIconInfo, 1);
- g_object_set_data_full (G_OBJECT (window),
- I_("gtk-window-icon-info"),
+ info = g_slice_new0 (GtkWindowIconInfo);
+ g_object_set_qdata_full (G_OBJECT (window),
+ quark_gtk_window_icon_info,
info,
(GDestroyNotify)free_icon_info);
}
@@ -2578,12 +2585,13 @@ typedef struct {
static ScreenIconInfo *
get_screen_icon_info (GdkScreen *screen)
{
- ScreenIconInfo *info = g_object_get_data (G_OBJECT (screen),
- "gtk-window-default-icon-pixmap");
+ ScreenIconInfo *info = g_object_get_qdata (G_OBJECT (screen),
+ quark_gtk_window_default_icon_pixmap);
if (!info)
{
- info = g_new0 (ScreenIconInfo, 1);
- g_object_set_data (G_OBJECT (screen), I_("gtk-window-default-icon-pixmap"), info);
+ info = g_slice_new0 (ScreenIconInfo);
+ g_object_set_qdata (G_OBJECT (screen),
+ quark_gtk_window_default_icon_pixmap, info);
}
if (info->serial != default_icon_serial)
@@ -4775,7 +4783,7 @@ send_client_message_to_embedded_windows (GtkWidget *widget,
{
GList *embedded_windows;
- embedded_windows = g_object_get_data (G_OBJECT (widget), "gtk-embedded");
+ embedded_windows = g_object_get_qdata (G_OBJECT (widget), quark_gtk_embedded);
if (embedded_windows)
{
GdkEvent *send_event = gdk_event_new (GDK_CLIENT_EVENT);
@@ -7490,9 +7498,15 @@ struct _GtkWindowKeyEntry
{
guint keyval;
guint modifiers;
- gboolean is_mnemonic;
+ guint is_mnemonic : 1;
};
+static void
+window_key_entry_destroy (gpointer data)
+{
+ g_slice_free (GtkWindowKeyEntry, data);
+}
+
static void
add_to_key_hash (GtkWindow *window,
guint keyval,
@@ -7502,7 +7516,7 @@ add_to_key_hash (GtkWindow *window,
{
GtkKeyHash *key_hash = data;
- GtkWindowKeyEntry *entry = g_new (GtkWindowKeyEntry, 1);
+ GtkWindowKeyEntry *entry = g_slice_new (GtkWindowKeyEntry);
entry->keyval = keyval;
entry->modifiers = modifiers;
@@ -7526,15 +7540,15 @@ static GtkKeyHash *
gtk_window_get_key_hash (GtkWindow *window)
{
GdkScreen *screen = gtk_window_check_screen (window);
- GtkKeyHash *key_hash = g_object_get_data (G_OBJECT (window), "gtk-window-key-hash");
+ GtkKeyHash *key_hash = g_object_get_qdata (G_OBJECT (window), quark_gtk_window_key_hash);
if (key_hash)
return key_hash;
key_hash = _gtk_key_hash_new (gdk_keymap_get_for_display (gdk_screen_get_display (screen)),
- (GDestroyNotify)g_free);
+ (GDestroyNotify)window_key_entry_destroy);
_gtk_window_keys_foreach (window, add_to_key_hash, key_hash);
- g_object_set_data (G_OBJECT (window), I_("gtk-window-key-hash"), key_hash);
+ g_object_set_qdata (G_OBJECT (window), quark_gtk_window_key_hash, key_hash);
return key_hash;
}
@@ -7542,11 +7556,11 @@ gtk_window_get_key_hash (GtkWindow *window)
static void
gtk_window_free_key_hash (GtkWindow *window)
{
- GtkKeyHash *key_hash = g_object_get_data (G_OBJECT (window), "gtk-window-key-hash");
+ GtkKeyHash *key_hash = g_object_get_qdata (G_OBJECT (window), quark_gtk_window_key_hash);
if (key_hash)
{
_gtk_key_hash_free (key_hash);
- g_object_set_data (G_OBJECT (window), "gtk-window-key-hash", NULL);
+ g_object_set_qdata (G_OBJECT (window), quark_gtk_window_key_hash, NULL);
}
}
@@ -7566,13 +7580,13 @@ gboolean
gtk_window_activate_key (GtkWindow *window,
GdkEventKey *event)
{
- GtkKeyHash *key_hash = g_object_get_data (G_OBJECT (window), "gtk-window-key-hash");
+ GtkKeyHash *key_hash = g_object_get_qdata (G_OBJECT (window), quark_gtk_window_key_hash);
GtkWindowKeyEntry *found_entry = NULL;
if (!key_hash)
{
gtk_window_keys_changed (window);
- key_hash = g_object_get_data (G_OBJECT (window), "gtk-window-key-hash");
+ key_hash = g_object_get_qdata (G_OBJECT (window), quark_gtk_window_key_hash);
}
if (key_hash)
diff --git a/gtk/gtkxembed.c b/gtk/gtkxembed.c
index 164b4c2bb7..d4718b0ad9 100644
--- a/gtk/gtkxembed.c
+++ b/gtk/gtkxembed.c
@@ -47,7 +47,7 @@ static GSList *current_messages;
void
_gtk_xembed_push_message (XEvent *xevent)
{
- GtkXEmbedMessage *message = g_new (GtkXEmbedMessage, 1);
+ GtkXEmbedMessage *message = g_slice_new (GtkXEmbedMessage);
message->time = xevent->xclient.data.l[0];
message->message = xevent->xclient.data.l[1];
@@ -68,8 +68,7 @@ _gtk_xembed_pop_message (void)
{
GtkXEmbedMessage *message = current_messages->data;
current_messages = g_slist_delete_link (current_messages, current_messages);
-
- g_free (message);
+ g_slice_free (GtkXEmbedMessage, message);
}
/**