Commit 29c799a1 authored by Matthias Clasen's avatar Matthias Clasen

Use g_object_get_qdata instead of g_object_get_data

This is less expensive.
parent 66f0bdee
......@@ -366,6 +366,8 @@ static const GdkColor gtk_default_insensitive_bg = { 0, GTK_GRAY };
static const GdkColor gtk_default_selected_base = { 0, GTK_BLUE };
static const GdkColor gtk_default_active_base = { 0, GTK_VERY_DARK_GRAY };
static GQuark quark_default_style;
/* --- signals --- */
static guint realize_signal = 0;
static guint unrealize_signal = 0;
......@@ -507,6 +509,8 @@ gtk_style_class_init (GtkStyleClass *klass)
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
quark_default_style = g_quark_from_static_string ("gtk-legacy-default-style");
}
static void
......@@ -4015,14 +4019,14 @@ gtk_widget_get_default_style_for_screen (GdkScreen *screen)
{
GtkStyle *default_style;
default_style = g_object_get_data (G_OBJECT (screen), "gtk-legacy-default-style");
default_style = g_object_get_qdata (G_OBJECT (screen), quark_default_style);
if (default_style == NULL)
{
default_style = gtk_style_new ();
g_object_set_data_full (G_OBJECT (screen),
I_("gtk-legacy-default-style"),
default_style,
g_object_unref);
g_object_set_qdata_full (G_OBJECT (screen),
quark_default_style,
default_style,
g_object_unref);
}
return default_style;
......
......@@ -52,6 +52,8 @@ enum {
static guint cssnode_signals[LAST_SIGNAL] = { 0 };
static GParamSpec *cssnode_properties[NUM_PROPERTIES];
static GQuark quark_global_cache;
static GtkStyleProviderPrivate *
gtk_css_node_get_style_provider_or_null (GtkCssNode *cssnode)
{
......@@ -214,7 +216,7 @@ lookup_in_global_parent_cache (GtkCssNode *node,
!may_use_global_parent_cache (node))
return NULL;
cache = g_object_get_data (G_OBJECT (parent), "gtk-global-cache");
cache = g_object_get_qdata (G_OBJECT (parent), quark_global_cache);
if (cache == NULL)
return NULL;
......@@ -289,14 +291,17 @@ store_in_global_parent_cache (GtkCssNode *node,
if (!may_be_stored_in_parent_cache (style))
return;
cache = g_object_get_data (G_OBJECT (parent), "gtk-global-cache");
cache = g_object_get_qdata (G_OBJECT (parent), quark_global_cache);
if (cache == NULL)
{
cache = g_hash_table_new_full (gtk_global_parent_cache_hash,
gtk_global_parent_cache_equal,
gtk_global_parent_cache_free,
g_object_unref);
g_object_set_data_full (G_OBJECT (parent), "gtk-global-cache", cache, (GDestroyNotify) g_hash_table_destroy);
g_object_set_qdata_full (G_OBJECT (parent),
quark_global_cache,
cache,
(GDestroyNotify) g_hash_table_destroy);
}
g_hash_table_insert (cache,
......@@ -522,6 +527,8 @@ gtk_css_node_class_init (GtkCssNodeClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
quark_global_cache = g_quark_from_static_string ("gtk-global-cache");
object_class->get_property = gtk_css_node_get_property;
object_class->set_property = gtk_css_node_set_property;
object_class->dispose = gtk_css_node_dispose;
......
......@@ -364,6 +364,12 @@ static GParamSpec *label_props[NUM_PROPERTIES] = { NULL, };
static guint signals[LAST_SIGNAL] = { 0 };
static GQuark quark_shortcuts_connected;
static GQuark quark_mnemonic_menu;
static GQuark quark_mnemonics_visible_connected;
static GQuark quark_gtk_signal;
static GQuark quark_link;
static void gtk_label_set_property (GObject *object,
guint prop_id,
const GValue *value,
......@@ -700,7 +706,7 @@ gtk_label_class_init (GtkLabelClass *class)
* Since: 2.18
*/
signals[ACTIVATE_CURRENT_LINK] =
g_signal_new_class_handler ("activate-current-link",
g_signal_new_class_handler (I_("activate-current-link"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_CALLBACK (gtk_label_activate_current_link),
......@@ -722,7 +728,7 @@ gtk_label_class_init (GtkLabelClass *class)
* Since: 2.18
*/
signals[ACTIVATE_LINK] =
g_signal_new ("activate-link",
g_signal_new (I_("activate-link"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkLabelClass, activate_link),
......@@ -1139,6 +1145,12 @@ gtk_label_class_init (GtkLabelClass *class)
"activate-current-link", 0);
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_LABEL_ACCESSIBLE);
quark_shortcuts_connected = g_quark_from_static_string ("gtk-label-shortcuts-connected");
quark_mnemonic_menu = g_quark_from_static_string ("gtk-mnemonic-menu");
quark_mnemonics_visible_connected = g_quark_from_static_string ("gtk-label-mnemonics-visible-connected");
quark_gtk_signal = g_quark_from_static_string ("gtk-signal");
quark_link = g_quark_from_static_string ("link");
}
static void
......@@ -1795,7 +1807,7 @@ gtk_label_setup_mnemonic (GtkLabel *label,
GtkWidget *toplevel;
GtkWidget *mnemonic_menu;
mnemonic_menu = g_object_get_data (G_OBJECT (label), "gtk-mnemonic-menu");
mnemonic_menu = g_object_get_qdata (G_OBJECT (label), quark_mnemonic_menu);
if (last_key != GDK_KEY_VoidSymbol)
{
......@@ -1846,7 +1858,7 @@ gtk_label_setup_mnemonic (GtkLabel *label,
}
done:
g_object_set_data (G_OBJECT (label), I_("gtk-mnemonic-menu"), mnemonic_menu);
g_object_set_qdata (G_OBJECT (label), quark_mnemonic_menu, mnemonic_menu);
}
static void
......@@ -1965,8 +1977,7 @@ gtk_label_screen_changed (GtkWidget *widget,
settings = gtk_widget_get_settings (widget);
shortcuts_connected =
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (settings),
"gtk-label-shortcuts-connected"));
GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (settings), quark_shortcuts_connected));
if (! shortcuts_connected)
{
......@@ -1977,7 +1988,7 @@ gtk_label_screen_changed (GtkWidget *widget,
G_CALLBACK (label_shortcut_setting_changed),
NULL);
g_object_set_data (G_OBJECT (settings), "gtk-label-shortcuts-connected",
g_object_set_qdata (G_OBJECT (settings), quark_shortcuts_connected,
GINT_TO_POINTER (TRUE));
}
......@@ -5027,8 +5038,7 @@ connect_mnemonics_visible_notify (GtkLabel *label)
gtk_window_get_mnemonics_visible (GTK_WINDOW (toplevel));
connected =
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (toplevel),
"gtk-label-mnemonics-visible-connected"));
GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (toplevel), quark_mnemonics_visible_connected));
if (!connected)
{
......@@ -5036,9 +5046,9 @@ connect_mnemonics_visible_notify (GtkLabel *label)
"notify::mnemonics-visible",
G_CALLBACK (label_mnemonics_visible_changed),
label);
g_object_set_data (G_OBJECT (toplevel),
"gtk-label-mnemonics-visible-connected",
GINT_TO_POINTER (1));
g_object_set_qdata (G_OBJECT (toplevel),
quark_mnemonics_visible_connected,
GINT_TO_POINTER (1));
}
}
......@@ -6440,7 +6450,7 @@ static void
activate_cb (GtkWidget *menuitem,
GtkLabel *label)
{
const gchar *signal = g_object_get_data (G_OBJECT (menuitem), "gtk-signal");
const gchar *signal = g_object_get_qdata (G_OBJECT (menuitem), quark_gtk_signal);
g_signal_emit_by_name (label, signal);
}
......@@ -6453,7 +6463,7 @@ append_action_signal (GtkLabel *label,
{
GtkWidget *menuitem = gtk_menu_item_new_with_mnemonic (text);
g_object_set_data (G_OBJECT (menuitem), I_("gtk-signal"), (char *)signal);
g_object_set_qdata (G_OBJECT (menuitem), quark_gtk_signal, (char *)signal);
g_signal_connect (menuitem, "activate",
G_CALLBACK (activate_cb), label);
......@@ -6518,7 +6528,7 @@ open_link_activate_cb (GtkMenuItem *menuitem,
{
GtkLabelLink *link;
link = g_object_get_data (G_OBJECT (menuitem), "link");
link = g_object_get_qdata (G_OBJECT (menuitem), quark_link);
emit_activate_link (label, link);
}
......@@ -6529,7 +6539,7 @@ copy_link_activate_cb (GtkMenuItem *menuitem,
GtkLabelLink *link;
GtkClipboard *clipboard;
link = g_object_get_data (G_OBJECT (menuitem), "link");
link = g_object_get_qdata (G_OBJECT (menuitem), quark_link);
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (label), GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_text (clipboard, link->uri, -1);
}
......@@ -6581,7 +6591,7 @@ gtk_label_do_popup (GtkLabel *label,
{
/* Open Link */
menuitem = gtk_menu_item_new_with_mnemonic (_("_Open Link"));
g_object_set_data (G_OBJECT (menuitem), "link", link);
g_object_set_qdata (G_OBJECT (menuitem), quark_link, link);
gtk_widget_show (menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
......@@ -6590,7 +6600,7 @@ gtk_label_do_popup (GtkLabel *label,
/* Copy Link Address */
menuitem = gtk_menu_item_new_with_mnemonic (_("Copy _Link Address"));
g_object_set_data (G_OBJECT (menuitem), "link", link);
g_object_set_qdata (G_OBJECT (menuitem), quark_link, link);
gtk_widget_show (menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
......
......@@ -269,6 +269,7 @@ static const gchar default_color_palette[] =
/* --- variables --- */
static GQuark quark_property_parser = 0;
static GQuark quark_gtk_settings = 0;
static GSList *object_list = NULL;
static guint class_n_properties = 0;
......@@ -367,6 +368,8 @@ gtk_settings_class_init (GtkSettingsClass *class)
gobject_class->notify = gtk_settings_notify;
quark_property_parser = g_quark_from_static_string ("gtk-rc-property-parser");
quark_gtk_settings = g_quark_from_static_string ("gtk-settings");
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-double-click-time",
P_("Double Click Time"),
......@@ -1849,7 +1852,7 @@ gtk_settings_get_for_screen (GdkScreen *screen)
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
settings = g_object_get_data (G_OBJECT (screen), "gtk-settings");
settings = g_object_get_qdata (G_OBJECT (screen), quark_gtk_settings);
if (!settings)
{
#ifdef GDK_WINDOWING_QUARTZ
......@@ -1874,8 +1877,10 @@ gtk_settings_get_for_screen (GdkScreen *screen)
#endif
settings = g_object_new (GTK_TYPE_SETTINGS, NULL);
settings->priv->screen = screen;
g_object_set_data_full (G_OBJECT (screen), I_("gtk-settings"),
settings, g_object_unref);
g_object_set_qdata_full (G_OBJECT (screen),
quark_gtk_settings,
settings,
g_object_unref);
settings_init_style (settings);
settings_update_modules (settings);
......@@ -2231,7 +2236,7 @@ settings_install_property_parser (GtkSettingsClass *class,
priv->property_values[class_n_properties - 1].source = GTK_SETTINGS_SOURCE_DEFAULT;
g_object_notify_by_pspec (G_OBJECT (settings), pspec);
qvalue = g_datalist_get_data (&priv->queued_settings, pspec->name);
qvalue = g_datalist_id_dup_data (&priv->queued_settings, g_param_spec_get_name_quark (pspec), NULL, NULL);
if (qvalue)
apply_queued_setting (settings, pspec, qvalue);
}
......@@ -2343,7 +2348,7 @@ gtk_settings_set_property_value_internal (GtkSettings *settings,
name_quark = g_quark_from_string (name);
g_free (name);
qvalue = g_datalist_id_get_data (&priv->queued_settings, name_quark);
qvalue = g_datalist_id_dup_data (&priv->queued_settings, name_quark, NULL, NULL);
if (!qvalue)
{
qvalue = g_slice_new0 (GtkSettingsValuePrivate);
......
......@@ -150,6 +150,7 @@ static void gtk_tooltip_display_closed (GdkDisplay *display,
static void gtk_tooltip_set_last_window (GtkTooltip *tooltip,
GdkWindow *window);
static GQuark quark_current_tooltip;
G_DEFINE_TYPE (GtkTooltip, gtk_tooltip, G_TYPE_OBJECT);
......@@ -161,6 +162,8 @@ gtk_tooltip_class_init (GtkTooltipClass *klass)
object_class = G_OBJECT_CLASS (klass);
object_class->dispose = gtk_tooltip_dispose;
quark_current_tooltip = g_quark_from_static_string ("gdk-display-current-tooltip");
}
static void
......@@ -868,6 +871,7 @@ static gint
tooltip_browse_mode_expired (gpointer data)
{
GtkTooltip *tooltip;
GdkDisplay *display;
tooltip = GTK_TOOLTIP (data);
......@@ -875,8 +879,8 @@ tooltip_browse_mode_expired (gpointer data)
tooltip->browse_mode_timeout_id = 0;
/* destroy tooltip */
g_object_set_data (G_OBJECT (gtk_widget_get_display (tooltip->window)),
"gdk-display-current-tooltip", NULL);
display = gtk_widget_get_display (tooltip->window);
g_object_set_qdata (G_OBJECT (display), quark_current_tooltip, NULL);
return FALSE;
}
......@@ -886,7 +890,7 @@ gtk_tooltip_display_closed (GdkDisplay *display,
gboolean was_error,
GtkTooltip *tooltip)
{
g_object_set_data (G_OBJECT (display), "gdk-display-current-tooltip", NULL);
g_object_set_qdata (G_OBJECT (display), quark_current_tooltip, NULL);
}
static void
......@@ -1209,8 +1213,7 @@ gtk_tooltip_show_tooltip (GdkDisplay *display)
GtkTooltip *tooltip;
gboolean return_value = FALSE;
tooltip = g_object_get_data (G_OBJECT (display),
"gdk-display-current-tooltip");
tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
if (tooltip->keyboard_mode_enabled)
{
......@@ -1338,8 +1341,7 @@ tooltip_popup_timeout (gpointer data)
GtkTooltip *tooltip;
display = GDK_DISPLAY (data);
tooltip = g_object_get_data (G_OBJECT (display),
"gdk-display-current-tooltip");
tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
/* This usually does not happen. However, it does occur in language
* bindings were reference counting of objects behaves differently.
......@@ -1360,8 +1362,7 @@ gtk_tooltip_start_delay (GdkDisplay *display)
guint timeout;
GtkTooltip *tooltip;
tooltip = g_object_get_data (G_OBJECT (display),
"gdk-display-current-tooltip");
tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
if (!tooltip || GTK_TOOLTIP_VISIBLE (tooltip))
return;
......@@ -1392,8 +1393,7 @@ _gtk_tooltip_focus_in (GtkWidget *widget)
/* Get current tooltip for this display */
display = gtk_widget_get_display (widget);
tooltip = g_object_get_data (G_OBJECT (display),
"gdk-display-current-tooltip");
tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
/* Check if keyboard mode is enabled at this moment */
if (!tooltip || !tooltip->keyboard_mode_enabled)
......@@ -1444,8 +1444,7 @@ _gtk_tooltip_focus_out (GtkWidget *widget)
/* Get current tooltip for this display */
display = gtk_widget_get_display (widget);
tooltip = g_object_get_data (G_OBJECT (display),
"gdk-display-current-tooltip");
tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
if (!tooltip || !tooltip->keyboard_mode_enabled)
return;
......@@ -1466,15 +1465,15 @@ _gtk_tooltip_toggle_keyboard_mode (GtkWidget *widget)
GtkTooltip *tooltip;
display = gtk_widget_get_display (widget);
tooltip = g_object_get_data (G_OBJECT (display),
"gdk-display-current-tooltip");
tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
if (!tooltip)
{
tooltip = g_object_new (GTK_TYPE_TOOLTIP, NULL);
g_object_set_data_full (G_OBJECT (display),
"gdk-display-current-tooltip",
tooltip, g_object_unref);
g_object_set_qdata_full (G_OBJECT (display),
quark_current_tooltip,
tooltip,
g_object_unref);
g_signal_connect (display, "closed",
G_CALLBACK (gtk_tooltip_display_closed),
tooltip);
......@@ -1506,8 +1505,7 @@ _gtk_tooltip_hide (GtkWidget *widget)
GtkTooltip *tooltip;
display = gtk_widget_get_display (widget);
tooltip = g_object_get_data (G_OBJECT (display),
"gdk-display-current-tooltip");
tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
if (!tooltip || !GTK_TOOLTIP_VISIBLE (tooltip) || !tooltip->tooltip_widget)
return;
......@@ -1550,8 +1548,7 @@ _gtk_tooltip_handle_event (GdkEvent *event)
/* Returns coordinates relative to has_tooltip_widget's allocation. */
has_tooltip_widget = find_topmost_widget_coords_from_event (event, &x, &y);
display = gdk_window_get_display (event->any.window);
current_tooltip = g_object_get_data (G_OBJECT (display),
"gdk-display-current-tooltip");
current_tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
if (current_tooltip)
{
......@@ -1657,9 +1654,10 @@ _gtk_tooltip_handle_event (GdkEvent *event)
{
/* Need a new tooltip for this display */
current_tooltip = g_object_new (GTK_TYPE_TOOLTIP, NULL);
g_object_set_data_full (G_OBJECT (display),
"gdk-display-current-tooltip",
current_tooltip, g_object_unref);
g_object_set_qdata_full (G_OBJECT (display),
quark_current_tooltip,
current_tooltip,
g_object_unref);
g_signal_connect (display, "closed",
G_CALLBACK (gtk_tooltip_display_closed),
current_tooltip);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment