[gtk+/widget-padding-2: 5/12] add _gtk_widget_get_aux_info_or_defaults()
- From: Havoc Pennington <hp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/widget-padding-2: 5/12] add _gtk_widget_get_aux_info_or_defaults()
- Date: Sun, 12 Sep 2010 17:16:14 +0000 (UTC)
commit 6c780fa93b592dbca39207353204e873a0a98ad5
Author: Havoc Pennington <hp pobox com>
Date: Sun Sep 5 12:11:47 2010 -0400
add _gtk_widget_get_aux_info_or_defaults()
This is better than peeking aux info then testing != NULL
in several ways:
- it returns const aux info so if we don't create we can't write
- it ensures that the default we assume if aux_info is NULL is
the same as the default we set if we've created the aux info
- it avoids typing in != NULL checks
gtk/gtkwidget.c | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 77b37ec..cd6404a 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -359,6 +359,7 @@ static gint gtk_widget_event_internal (GtkWidget *widget,
GdkEvent *event);
static gboolean gtk_widget_real_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling);
+static const GtkWidgetAuxInfo* _gtk_widget_get_aux_info_or_defaults (GtkWidget *widget);
static void gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info);
static AtkObject* gtk_widget_real_get_accessible (GtkWidget *widget);
static void gtk_widget_accessible_interface_init (AtkImplementorIface *iface);
@@ -9555,6 +9556,10 @@ gtk_widget_propagate_state (GtkWidget *widget,
}
}
+static const GtkWidgetAuxInfo default_aux_info = {
+ -1, -1
+};
+
/*
* _gtk_widget_get_aux_info:
* @widget: a #GtkWidget
@@ -9576,8 +9581,7 @@ _gtk_widget_get_aux_info (GtkWidget *widget,
{
aux_info = g_slice_new0 (GtkWidgetAuxInfo);
- aux_info->width = -1;
- aux_info->height = -1;
+ *aux_info = default_aux_info;
g_object_set_qdata (G_OBJECT (widget), quark_aux_info, aux_info);
}
@@ -9585,6 +9589,21 @@ _gtk_widget_get_aux_info (GtkWidget *widget,
return aux_info;
}
+static const GtkWidgetAuxInfo*
+_gtk_widget_get_aux_info_or_defaults (GtkWidget *widget)
+{
+ GtkWidgetAuxInfo *aux_info;
+
+ aux_info = _gtk_widget_get_aux_info (widget, FALSE);
+ if (aux_info == NULL)
+ {
+ return &default_aux_info;
+ }
+ else
+ {
+ return aux_info;
+ }
+}
/*****************************************
* gtk_widget_aux_info_destroy:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]