wiget: Fix whitespace issues

Switch from tabs to spaces everywhere consistently and remove all
trailing whitespace.
This commit is contained in:
Timm Bäder 2020-12-27 13:10:35 +01:00
parent ebdf2989f8
commit f11f0da11c

View File

@ -8,7 +8,7 @@
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
@ -452,16 +452,11 @@
GTK_STATE_FLAG_ACTIVE) GTK_STATE_FLAG_ACTIVE)
typedef struct { typedef struct {
char *name; /* Name of the template automatic child */ char *name; /* Name of the template automatic child */
gboolean internal_child; /* Whether the automatic widget should be exported as an <internal-child> */ gboolean internal_child; /* Whether the automatic widget should be exported as an <internal-child> */
gssize offset; /* Instance private data offset where to set the automatic child (or 0) */ gssize offset; /* Instance private data offset where to set the automatic child (or 0) */
} AutomaticChildClass; } AutomaticChildClass;
typedef struct {
char *callback_name;
GCallback callback_symbol;
} CallbackSymbol;
enum { enum {
DESTROY, DESTROY,
SHOW, SHOW,
@ -521,70 +516,64 @@ enum {
PROP_ACCESSIBLE_ROLE PROP_ACCESSIBLE_ROLE
}; };
static GParamSpec *widget_props[NUM_PROPERTIES] = { NULL, };
typedef struct _GtkStateData GtkStateData; typedef struct
struct _GtkStateData
{ {
guint flags_to_set; guint flags_to_set;
guint flags_to_unset; guint flags_to_unset;
int old_scale_factor; int old_scale_factor;
}; } GtkStateData;
/* --- prototypes --- */
static void gtk_widget_base_class_init (gpointer g_class);
static void gtk_widget_class_init (GtkWidgetClass *klass);
static void gtk_widget_base_class_finalize (GtkWidgetClass *klass);
static void gtk_widget_init (GTypeInstance *instance,
gpointer g_class);
static void gtk_widget_dispose (GObject *object);
static void gtk_widget_finalize (GObject *object);
static void gtk_widget_real_destroy (GtkWidget *object);
static gboolean gtk_widget_real_focus (GtkWidget *widget,
GtkDirectionType direction);
static void gtk_widget_real_show (GtkWidget *widget);
static void gtk_widget_real_hide (GtkWidget *widget);
static void gtk_widget_real_map (GtkWidget *widget);
static void gtk_widget_real_unmap (GtkWidget *widget);
static void gtk_widget_real_realize (GtkWidget *widget);
static void gtk_widget_real_unrealize (GtkWidget *widget);
static void gtk_widget_real_direction_changed(GtkWidget *widget,
GtkTextDirection previous_direction);
static void gtk_widget_real_css_changed (GtkWidget *widget, static void gtk_widget_base_class_init (gpointer g_class);
GtkCssStyleChange *change); static void gtk_widget_class_init (GtkWidgetClass *klass);
static void gtk_widget_real_system_setting_changed (GtkWidget *widget, static void gtk_widget_base_class_finalize (GtkWidgetClass *klass);
GtkSystemSetting setting); static void gtk_widget_init (GTypeInstance *instance,
gpointer g_class);
static void gtk_widget_real_set_focus_child (GtkWidget *widget, static void gtk_widget_dispose (GObject *object);
GtkWidget *child); static void gtk_widget_finalize (GObject *object);
static void gtk_widget_real_move_focus (GtkWidget *widget, static void gtk_widget_real_destroy (GtkWidget *object);
GtkDirectionType direction); static gboolean gtk_widget_real_focus (GtkWidget *widget,
static gboolean gtk_widget_real_keynav_failed (GtkWidget *widget, GtkDirectionType direction);
GtkDirectionType direction); static void gtk_widget_real_show (GtkWidget *widget);
static void gtk_widget_real_hide (GtkWidget *widget);
static void gtk_widget_real_map (GtkWidget *widget);
static void gtk_widget_real_unmap (GtkWidget *widget);
static void gtk_widget_real_realize (GtkWidget *widget);
static void gtk_widget_real_unrealize (GtkWidget *widget);
static void gtk_widget_real_direction_changed (GtkWidget *widget,
GtkTextDirection previous_direction);
static void gtk_widget_real_css_changed (GtkWidget *widget,
GtkCssStyleChange *change);
static void gtk_widget_real_system_setting_changed (GtkWidget *widget,
GtkSystemSetting setting);
static void gtk_widget_real_set_focus_child (GtkWidget *widget,
GtkWidget *child);
static void gtk_widget_real_move_focus (GtkWidget *widget,
GtkDirectionType direction);
static gboolean gtk_widget_real_keynav_failed (GtkWidget *widget,
GtkDirectionType direction);
#ifdef G_ENABLE_CONSISTENCY_CHECKS #ifdef G_ENABLE_CONSISTENCY_CHECKS
static void gtk_widget_verify_invariants (GtkWidget *widget); static void gtk_widget_verify_invariants (GtkWidget *widget);
static void gtk_widget_push_verify_invariants (GtkWidget *widget); static void gtk_widget_push_verify_invariants (GtkWidget *widget);
static void gtk_widget_pop_verify_invariants (GtkWidget *widget); static void gtk_widget_pop_verify_invariants (GtkWidget *widget);
#else #else
#define gtk_widget_verify_invariants(widget) #define gtk_widget_verify_invariants(widget)
#define gtk_widget_push_verify_invariants(widget) #define gtk_widget_push_verify_invariants(widget)
#define gtk_widget_pop_verify_invariants(widget) #define gtk_widget_pop_verify_invariants(widget)
#endif #endif
static PangoContext* gtk_widget_peek_pango_context (GtkWidget *widget); static PangoContext* gtk_widget_peek_pango_context (GtkWidget *widget);
static void gtk_widget_update_pango_context (GtkWidget *widget); static void gtk_widget_update_pango_context (GtkWidget *widget);
static void gtk_widget_propagate_state (GtkWidget *widget, static void gtk_widget_propagate_state (GtkWidget *widget,
const GtkStateData *data); const GtkStateData *data);
static gboolean gtk_widget_real_mnemonic_activate (GtkWidget *widget, static gboolean gtk_widget_real_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling); gboolean group_cycling);
static void gtk_widget_accessible_interface_init (GtkAccessibleInterface *iface); static void gtk_widget_accessible_interface_init (GtkAccessibleInterface *iface);
static void gtk_widget_buildable_interface_init (GtkBuildableIface *iface); static void gtk_widget_buildable_interface_init (GtkBuildableIface *iface);
static void gtk_widget_buildable_set_id (GtkBuildable *buildable, static void gtk_widget_buildable_set_id (GtkBuildable *buildable,
const char *id); const char *id);
static const char * gtk_widget_buildable_get_id (GtkBuildable *buildable); static const char * gtk_widget_buildable_get_id (GtkBuildable *buildable);
static GObject * gtk_widget_buildable_get_internal_child (GtkBuildable *buildable, static GObject * gtk_widget_buildable_get_internal_child (GtkBuildable *buildable,
GtkBuilder *builder, GtkBuilder *builder,
const char *childname); const char *childname);
@ -606,16 +595,12 @@ static void gtk_widget_buildable_custom_finished (GtkBuildable
gpointer data); gpointer data);
static void gtk_widget_buildable_parser_finished (GtkBuildable *buildable, static void gtk_widget_buildable_parser_finished (GtkBuildable *buildable,
GtkBuilder *builder); GtkBuilder *builder);
static void gtk_widget_set_accessible_role (GtkWidget *self,
static void gtk_widget_set_accessible_role (GtkWidget *self,
GtkAccessibleRole role); GtkAccessibleRole role);
static GtkAccessibleRole gtk_widget_get_accessible_role (GtkWidget *self); static GtkAccessibleRole gtk_widget_get_accessible_role (GtkWidget *self);
static void gtk_widget_set_usize_internal (GtkWidget *widget,
static void template_data_free (GtkWidgetTemplate*template_data); int width,
int height);
static void gtk_widget_set_usize_internal (GtkWidget *widget,
int width,
int height);
static gboolean event_surface_is_still_viewable (GdkEvent *event); static gboolean event_surface_is_still_viewable (GdkEvent *event);
@ -627,21 +612,20 @@ static void gtk_widget_queue_compute_expand (GtkWidget *widget);
/* --- variables --- */
static int GtkWidget_private_offset = 0; static int GtkWidget_private_offset = 0;
static gpointer gtk_widget_parent_class = NULL; static gpointer gtk_widget_parent_class = NULL;
static guint widget_signals[LAST_SIGNAL] = { 0 }; static guint widget_signals[LAST_SIGNAL] = { 0 };
GtkTextDirection gtk_default_direction = GTK_TEXT_DIR_LTR; static GParamSpec *widget_props[NUM_PROPERTIES] = { NULL, };
GtkTextDirection gtk_default_direction = GTK_TEXT_DIR_LTR;
static GQuark quark_pango_context = 0; static GQuark quark_pango_context = 0;
static GQuark quark_mnemonic_labels = 0; static GQuark quark_mnemonic_labels = 0;
static GQuark quark_size_groups = 0; static GQuark quark_size_groups = 0;
static GQuark quark_auto_children = 0; static GQuark quark_auto_children = 0;
static GQuark quark_action_muxer = 0; static GQuark quark_action_muxer = 0;
static GQuark quark_font_options = 0; static GQuark quark_font_options = 0;
static GQuark quark_font_map = 0; static GQuark quark_font_map = 0;
/* --- functions --- */
GType GType
gtk_widget_get_type (void) gtk_widget_get_type (void)
{ {
@ -651,16 +635,16 @@ gtk_widget_get_type (void)
{ {
const GTypeInfo widget_info = const GTypeInfo widget_info =
{ {
sizeof (GtkWidgetClass), sizeof (GtkWidgetClass),
gtk_widget_base_class_init, gtk_widget_base_class_init,
(GBaseFinalizeFunc) gtk_widget_base_class_finalize, (GBaseFinalizeFunc) gtk_widget_base_class_finalize,
(GClassInitFunc) gtk_widget_class_init, (GClassInitFunc) gtk_widget_class_init,
NULL, /* class_finalize */ NULL, /* class_finalize */
NULL, /* class_init */ NULL, /* class_init */
sizeof (GtkWidget), sizeof (GtkWidget),
0, /* n_preallocs */ 0, /* n_preallocs */
gtk_widget_init, gtk_widget_init,
NULL, /* value_table */ NULL, /* value_table */
}; };
const GInterfaceInfo accessible_info = const GInterfaceInfo accessible_info =
@ -672,16 +656,16 @@ gtk_widget_get_type (void)
const GInterfaceInfo buildable_info = const GInterfaceInfo buildable_info =
{ {
(GInterfaceInitFunc) gtk_widget_buildable_interface_init, (GInterfaceInitFunc) gtk_widget_buildable_interface_init,
(GInterfaceFinalizeFunc) NULL, (GInterfaceFinalizeFunc) NULL,
NULL /* interface data */ NULL /* interface data */
}; };
const GInterfaceInfo constraint_target_info = const GInterfaceInfo constraint_target_info =
{ {
(GInterfaceInitFunc) NULL, (GInterfaceInitFunc) NULL,
(GInterfaceFinalizeFunc) NULL, (GInterfaceFinalizeFunc) NULL,
NULL /* interface data */ NULL /* interface data */
}; };
widget_type = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, g_intern_static_string ("GtkWidget"), widget_type = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, g_intern_static_string ("GtkWidget"),
@ -689,8 +673,7 @@ gtk_widget_get_type (void)
g_type_add_class_private (widget_type, sizeof (GtkWidgetClassPrivate)); g_type_add_class_private (widget_type, sizeof (GtkWidgetClassPrivate));
GtkWidget_private_offset = GtkWidget_private_offset = g_type_add_instance_private (widget_type, sizeof (GtkWidgetPrivate));
g_type_add_instance_private (widget_type, sizeof (GtkWidgetPrivate));
g_type_add_interface_static (widget_type, GTK_TYPE_ACCESSIBLE, g_type_add_interface_static (widget_type, GTK_TYPE_ACCESSIBLE,
&accessible_info); &accessible_info);
@ -772,7 +755,7 @@ gtk_widget_real_contains (GtkWidget *widget,
**/ **/
void void
_gtk_widget_grab_notify (GtkWidget *widget, _gtk_widget_grab_notify (GtkWidget *widget,
gboolean was_grabbed) gboolean was_grabbed)
{ {
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GList *l; GList *l;
@ -1642,12 +1625,12 @@ gtk_widget_class_init (GtkWidgetClass *klass)
*/ */
widget_signals[SHOW] = widget_signals[SHOW] =
g_signal_new (I_("show"), g_signal_new (I_("show"),
G_TYPE_FROM_CLASS (gobject_class), G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, show), G_STRUCT_OFFSET (GtkWidgetClass, show),
NULL, NULL, NULL, NULL,
NULL, NULL,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
/** /**
* GtkWidget::hide: * GtkWidget::hide:
@ -1658,12 +1641,12 @@ gtk_widget_class_init (GtkWidgetClass *klass)
*/ */
widget_signals[HIDE] = widget_signals[HIDE] =
g_signal_new (I_("hide"), g_signal_new (I_("hide"),
G_TYPE_FROM_CLASS (gobject_class), G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, hide), G_STRUCT_OFFSET (GtkWidgetClass, hide),
NULL, NULL, NULL, NULL,
NULL, NULL,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
/** /**
* GtkWidget::map: * GtkWidget::map:
@ -1680,12 +1663,12 @@ gtk_widget_class_init (GtkWidgetClass *klass)
*/ */
widget_signals[MAP] = widget_signals[MAP] =
g_signal_new (I_("map"), g_signal_new (I_("map"),
G_TYPE_FROM_CLASS (gobject_class), G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, map), G_STRUCT_OFFSET (GtkWidgetClass, map),
NULL, NULL, NULL, NULL,
NULL, NULL,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
/** /**
* GtkWidget::unmap: * GtkWidget::unmap:
@ -1700,12 +1683,12 @@ gtk_widget_class_init (GtkWidgetClass *klass)
*/ */
widget_signals[UNMAP] = widget_signals[UNMAP] =
g_signal_new (I_("unmap"), g_signal_new (I_("unmap"),
G_TYPE_FROM_CLASS (gobject_class), G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, unmap), G_STRUCT_OFFSET (GtkWidgetClass, unmap),
NULL, NULL, NULL, NULL,
NULL, NULL,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
/** /**
* GtkWidget::realize: * GtkWidget::realize:
@ -1717,12 +1700,12 @@ gtk_widget_class_init (GtkWidgetClass *klass)
*/ */
widget_signals[REALIZE] = widget_signals[REALIZE] =
g_signal_new (I_("realize"), g_signal_new (I_("realize"),
G_TYPE_FROM_CLASS (gobject_class), G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, realize), G_STRUCT_OFFSET (GtkWidgetClass, realize),
NULL, NULL, NULL, NULL,
NULL, NULL,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
/** /**
* GtkWidget::unrealize: * GtkWidget::unrealize:
@ -1735,12 +1718,12 @@ gtk_widget_class_init (GtkWidgetClass *klass)
*/ */
widget_signals[UNREALIZE] = widget_signals[UNREALIZE] =
g_signal_new (I_("unrealize"), g_signal_new (I_("unrealize"),
G_TYPE_FROM_CLASS (gobject_class), G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, unrealize), G_STRUCT_OFFSET (GtkWidgetClass, unrealize),
NULL, NULL, NULL, NULL,
NULL, NULL,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
/** /**
* GtkWidget::state-flags-changed: * GtkWidget::state-flags-changed:
@ -1770,13 +1753,13 @@ gtk_widget_class_init (GtkWidgetClass *klass)
*/ */
widget_signals[DIRECTION_CHANGED] = widget_signals[DIRECTION_CHANGED] =
g_signal_new (I_("direction-changed"), g_signal_new (I_("direction-changed"),
G_TYPE_FROM_CLASS (gobject_class), G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, direction_changed), G_STRUCT_OFFSET (GtkWidgetClass, direction_changed),
NULL, NULL, NULL, NULL,
NULL, NULL,
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
GTK_TYPE_TEXT_DIRECTION); GTK_TYPE_TEXT_DIRECTION);
/** /**
* GtkWidget::mnemonic-activate: * GtkWidget::mnemonic-activate:
@ -1791,13 +1774,13 @@ gtk_widget_class_init (GtkWidgetClass *klass)
*/ */
widget_signals[MNEMONIC_ACTIVATE] = widget_signals[MNEMONIC_ACTIVATE] =
g_signal_new (I_("mnemonic-activate"), g_signal_new (I_("mnemonic-activate"),
G_TYPE_FROM_CLASS (gobject_class), G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, mnemonic_activate), G_STRUCT_OFFSET (GtkWidgetClass, mnemonic_activate),
_gtk_boolean_handled_accumulator, NULL, _gtk_boolean_handled_accumulator, NULL,
_gtk_marshal_BOOLEAN__BOOLEAN, _gtk_marshal_BOOLEAN__BOOLEAN,
G_TYPE_BOOLEAN, 1, G_TYPE_BOOLEAN, 1,
G_TYPE_BOOLEAN); G_TYPE_BOOLEAN);
g_signal_set_va_marshaller (widget_signals[MNEMONIC_ACTIVATE], g_signal_set_va_marshaller (widget_signals[MNEMONIC_ACTIVATE],
G_TYPE_FROM_CLASS (gobject_class), G_TYPE_FROM_CLASS (gobject_class),
_gtk_marshal_BOOLEAN__BOOLEANv); _gtk_marshal_BOOLEAN__BOOLEANv);
@ -1872,16 +1855,16 @@ gtk_widget_class_init (GtkWidgetClass *klass)
*/ */
widget_signals[QUERY_TOOLTIP] = widget_signals[QUERY_TOOLTIP] =
g_signal_new (I_("query-tooltip"), g_signal_new (I_("query-tooltip"),
G_TYPE_FROM_CLASS (klass), G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, query_tooltip), G_STRUCT_OFFSET (GtkWidgetClass, query_tooltip),
_gtk_boolean_handled_accumulator, NULL, _gtk_boolean_handled_accumulator, NULL,
_gtk_marshal_BOOLEAN__INT_INT_BOOLEAN_OBJECT, _gtk_marshal_BOOLEAN__INT_INT_BOOLEAN_OBJECT,
G_TYPE_BOOLEAN, 4, G_TYPE_BOOLEAN, 4,
G_TYPE_INT, G_TYPE_INT,
G_TYPE_INT, G_TYPE_INT,
G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
GTK_TYPE_TOOLTIP); GTK_TYPE_TOOLTIP);
g_signal_set_va_marshaller (widget_signals[QUERY_TOOLTIP], g_signal_set_va_marshaller (widget_signals[QUERY_TOOLTIP],
G_TYPE_FROM_CLASS (klass), G_TYPE_FROM_CLASS (klass),
_gtk_marshal_BOOLEAN__INT_INT_BOOLEAN_OBJECTv); _gtk_marshal_BOOLEAN__INT_INT_BOOLEAN_OBJECTv);
@ -1890,11 +1873,31 @@ gtk_widget_class_init (GtkWidgetClass *klass)
gtk_widget_class_set_accessible_role (klass, GTK_ACCESSIBLE_ROLE_WIDGET); gtk_widget_class_set_accessible_role (klass, GTK_ACCESSIBLE_ROLE_WIDGET);
} }
static void
template_child_class_free (AutomaticChildClass *child_class)
{
if (child_class)
{
g_free (child_class->name);
g_slice_free (AutomaticChildClass, child_class);
}
}
static void static void
gtk_widget_base_class_finalize (GtkWidgetClass *klass) gtk_widget_base_class_finalize (GtkWidgetClass *klass)
{ {
GtkWidgetTemplate *template_data = klass->priv->template;
if (template_data)
{
g_bytes_unref (template_data->data);
g_slist_free_full (template_data->children, (GDestroyNotify)template_child_class_free);
g_object_unref (template_data->scope);
g_slice_free (GtkWidgetTemplate, template_data);
}
template_data_free (klass->priv->template);
g_object_unref (klass->priv->shortcuts); g_object_unref (klass->priv->shortcuts);
} }
@ -2690,7 +2693,7 @@ gtk_widget_hide (GtkWidget *widget)
parent = gtk_widget_get_parent (widget); parent = gtk_widget_get_parent (widget);
if (parent) if (parent)
gtk_widget_queue_resize (parent); gtk_widget_queue_resize (parent);
gtk_widget_queue_allocate (widget); gtk_widget_queue_allocate (widget);
@ -3494,12 +3497,10 @@ gtk_widget_queue_resize_internal (GtkWidget *widget)
groups = _gtk_widget_get_sizegroups (widget); groups = _gtk_widget_get_sizegroups (widget);
for (l = groups; l; l = l->next) for (l = groups; l; l = l->next)
{ {
for (widgets = gtk_size_group_get_widgets (l->data); widgets; widgets = widgets->next) for (widgets = gtk_size_group_get_widgets (l->data); widgets; widgets = widgets->next)
{
gtk_widget_queue_resize_internal (widgets->data); gtk_widget_queue_resize_internal (widgets->data);
} }
}
if (_gtk_widget_get_visible (widget)) if (_gtk_widget_get_visible (widget))
{ {
@ -3695,17 +3696,17 @@ adjust_for_align (GtkAlign align,
break; break;
case GTK_ALIGN_END: case GTK_ALIGN_END:
if (*allocated_size > natural_size) if (*allocated_size > natural_size)
{ {
*allocated_pos += (*allocated_size - natural_size); *allocated_pos += (*allocated_size - natural_size);
*allocated_size = natural_size; *allocated_size = natural_size;
} }
break; break;
case GTK_ALIGN_CENTER: case GTK_ALIGN_CENTER:
if (*allocated_size > natural_size) if (*allocated_size > natural_size)
{ {
*allocated_pos += (*allocated_size - natural_size) / 2; *allocated_pos += (*allocated_size - natural_size) / 2;
*allocated_size = MIN (*allocated_size, natural_size); *allocated_size = MIN (*allocated_size, natural_size);
} }
break; break;
} }
} }
@ -3992,7 +3993,7 @@ out:
**/ **/
GtkWidget * GtkWidget *
gtk_widget_common_ancestor (GtkWidget *widget_a, gtk_widget_common_ancestor (GtkWidget *widget_a,
GtkWidget *widget_b) GtkWidget *widget_b)
{ {
GtkWidget *parent_a; GtkWidget *parent_a;
GtkWidget *parent_b; GtkWidget *parent_b;
@ -4312,10 +4313,10 @@ gtk_widget_mnemonic_activate (GtkWidget *widget,
handled = TRUE; handled = TRUE;
else else
g_signal_emit (widget, g_signal_emit (widget,
widget_signals[MNEMONIC_ACTIVATE], widget_signals[MNEMONIC_ACTIVATE],
0, 0,
group_cycling, group_cycling,
&handled); &handled);
return handled; return handled;
} }
@ -4350,7 +4351,7 @@ gtk_widget_real_mnemonic_activate (GtkWidget *widget,
else else
{ {
g_warning ("widget '%s' isn't suitable for mnemonic activation", g_warning ("widget '%s' isn't suitable for mnemonic activation",
G_OBJECT_TYPE_NAME (widget)); G_OBJECT_TYPE_NAME (widget));
gtk_widget_error_bell (widget); gtk_widget_error_bell (widget);
} }
return TRUE; return TRUE;
@ -5191,7 +5192,7 @@ gtk_widget_is_focus (GtkWidget *widget)
**/ **/
void void
gtk_widget_set_focus_on_click (GtkWidget *widget, gtk_widget_set_focus_on_click (GtkWidget *widget,
gboolean focus_on_click) gboolean focus_on_click)
{ {
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
@ -5355,8 +5356,8 @@ _gtk_widget_set_has_grab (GtkWidget *widget,
* of alphanumeric symbols, dashes and underscores will suffice. * of alphanumeric symbols, dashes and underscores will suffice.
*/ */
void void
gtk_widget_set_name (GtkWidget *widget, gtk_widget_set_name (GtkWidget *widget,
const char *name) const char *name)
{ {
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
@ -6212,9 +6213,9 @@ gtk_widget_get_pango_context (GtkWidget *widget)
{ {
context = gtk_widget_create_pango_context (GTK_WIDGET (widget)); context = gtk_widget_create_pango_context (GTK_WIDGET (widget));
g_object_set_qdata_full (G_OBJECT (widget), g_object_set_qdata_full (G_OBJECT (widget),
quark_pango_context, quark_pango_context,
context, context,
g_object_unref); g_object_unref);
} }
return context; return context;
@ -6251,8 +6252,8 @@ update_pango_context (GtkWidget *widget,
pango_font_description_free (font_desc); pango_font_description_free (font_desc);
pango_context_set_base_dir (context, pango_context_set_base_dir (context,
_gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ? _gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ?
PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL); PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL);
pango_cairo_context_set_resolution (context, _gtk_css_number_value_get (style->core->dpi, 100)); pango_cairo_context_set_resolution (context, _gtk_css_number_value_get (style->core->dpi, 100));
@ -6434,8 +6435,8 @@ gtk_widget_create_pango_context (GtkWidget *widget)
* Returns: (transfer full): the new #PangoLayout * Returns: (transfer full): the new #PangoLayout
**/ **/
PangoLayout * PangoLayout *
gtk_widget_create_pango_layout (GtkWidget *widget, gtk_widget_create_pango_layout (GtkWidget *widget,
const char *text) const char *text)
{ {
PangoLayout *layout; PangoLayout *layout;
PangoContext *context; PangoContext *context;
@ -6501,17 +6502,17 @@ gtk_widget_set_child_visible (GtkWidget *widget,
root = _gtk_widget_get_root (widget); root = _gtk_widget_get_root (widget);
if (GTK_WIDGET (root) != widget && GTK_IS_WINDOW (root)) if (GTK_WIDGET (root) != widget && GTK_IS_WINDOW (root))
_gtk_window_unset_focus_and_default (GTK_WINDOW (root), widget); _gtk_window_unset_focus_and_default (GTK_WINDOW (root), widget);
} }
if (priv->parent && _gtk_widget_get_realized (priv->parent)) if (priv->parent && _gtk_widget_get_realized (priv->parent))
{ {
if (_gtk_widget_get_mapped (priv->parent) && if (_gtk_widget_get_mapped (priv->parent) &&
priv->child_visible && priv->child_visible &&
_gtk_widget_get_visible (widget)) _gtk_widget_get_visible (widget))
gtk_widget_map (widget); gtk_widget_map (widget);
else else
gtk_widget_unmap (widget); gtk_widget_unmap (widget);
} }
gtk_widget_verify_invariants (widget); gtk_widget_verify_invariants (widget);
@ -6721,7 +6722,7 @@ gtk_widget_keynav_failed (GtkWidget *widget,
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
g_signal_emit (widget, widget_signals[KEYNAV_FAILED], 0, g_signal_emit (widget, widget_signals[KEYNAV_FAILED], 0,
direction, &return_val); direction, &return_val);
return return_val; return return_val;
} }
@ -6762,9 +6763,9 @@ gtk_widget_error_bell (GtkWidget *widget)
} }
static void static void
gtk_widget_set_usize_internal (GtkWidget *widget, gtk_widget_set_usize_internal (GtkWidget *widget,
int width, int width,
int height) int height)
{ {
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
gboolean changed = FALSE; gboolean changed = FALSE;
@ -6904,7 +6905,7 @@ gtk_widget_has_size_request (GtkWidget *widget)
**/ **/
GtkWidget* GtkWidget*
gtk_widget_get_ancestor (GtkWidget *widget, gtk_widget_get_ancestor (GtkWidget *widget,
GType widget_type) GType widget_type)
{ {
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
@ -6952,7 +6953,7 @@ gtk_widget_get_settings (GtkWidget *widget)
**/ **/
gboolean gboolean
gtk_widget_is_ancestor (GtkWidget *widget, gtk_widget_is_ancestor (GtkWidget *widget,
GtkWidget *ancestor) GtkWidget *ancestor)
{ {
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
g_return_val_if_fail (ancestor != NULL, FALSE); g_return_val_if_fail (ancestor != NULL, FALSE);
@ -7108,11 +7109,11 @@ gtk_widget_set_default_direction (GtkTextDirection dir)
g_list_foreach (toplevels, (GFunc)g_object_ref, NULL); g_list_foreach (toplevels, (GFunc)g_object_ref, NULL);
while (tmp_list) while (tmp_list)
{ {
gtk_widget_set_default_direction_recurse (tmp_list->data, old_dir); gtk_widget_set_default_direction_recurse (tmp_list->data, old_dir);
g_object_unref (tmp_list->data); g_object_unref (tmp_list->data);
tmp_list = tmp_list->next; tmp_list = tmp_list->next;
} }
g_list_free (toplevels); g_list_free (toplevels);
} }
@ -7202,8 +7203,8 @@ typedef struct {
} FinalizeAssertion; } FinalizeAssertion;
static void static void
finalize_assertion_weak_ref (gpointer data, finalize_assertion_weak_ref (gpointer data,
GObject *where_the_object_was) GObject *where_the_object_was)
{ {
FinalizeAssertion *assertion = (FinalizeAssertion *)data; FinalizeAssertion *assertion = (FinalizeAssertion *)data;
assertion->did_finalize = TRUE; assertion->did_finalize = TRUE;
@ -7281,43 +7282,43 @@ gtk_widget_real_destroy (GtkWidget *object)
#ifdef G_ENABLE_CONSISTENCY_CHECKS #ifdef G_ENABLE_CONSISTENCY_CHECKS
for (l = assertions; l; l = l->next) for (l = assertions; l; l = l->next)
{ {
FinalizeAssertion *assertion = l->data; FinalizeAssertion *assertion = l->data;
if (!assertion->did_finalize) if (!assertion->did_finalize)
g_critical ("Automated component '%s' of class '%s' did not finalize in dispose()" g_critical ("Automated component '%s' of class '%s' did not finalize in dispose()"
"Current reference count is %d", "Current reference count is %d",
assertion->child_class->name, assertion->child_class->name,
g_type_name (assertion->widget_type), g_type_name (assertion->widget_type),
assertion->object->ref_count); assertion->object->ref_count);
g_slice_free (FinalizeAssertion, assertion); g_slice_free (FinalizeAssertion, assertion);
} }
g_slist_free (assertions); g_slist_free (assertions);
#endif /* G_ENABLE_CONSISTENCY_CHECKS */ #endif /* G_ENABLE_CONSISTENCY_CHECKS */
/* Set any automatic private data pointers to NULL */ /* Set any automatic private data pointers to NULL */
for (class = GTK_WIDGET_GET_CLASS (widget); for (class = GTK_WIDGET_GET_CLASS (widget);
GTK_IS_WIDGET_CLASS (class); GTK_IS_WIDGET_CLASS (class);
class = g_type_class_peek_parent (class)) class = g_type_class_peek_parent (class))
{ {
if (!class->priv->template) if (!class->priv->template)
continue; continue;
for (l = class->priv->template->children; l; l = l->next) for (l = class->priv->template->children; l; l = l->next)
{ {
AutomaticChildClass *child_class = l->data; AutomaticChildClass *child_class = l->data;
if (child_class->offset != 0) if (child_class->offset != 0)
{ {
gpointer field_p; gpointer field_p;
/* Nullify instance private data for internal children */ /* Nullify instance private data for internal children */
field_p = G_STRUCT_MEMBER_P (widget, child_class->offset); field_p = G_STRUCT_MEMBER_P (widget, child_class->offset);
(* (gpointer *) field_p) = NULL; (* (gpointer *) field_p) = NULL;
} }
} }
} }
} }
/* Callers of add_mnemonic_label() should disconnect on ::destroy */ /* Callers of add_mnemonic_label() should disconnect on ::destroy */
@ -7616,9 +7617,9 @@ _gtk_widget_list_devices (GtkWidget *widget,
*/ */
void void
_gtk_widget_synthesize_crossing (GtkWidget *from, _gtk_widget_synthesize_crossing (GtkWidget *from,
GtkWidget *to, GtkWidget *to,
GdkDevice *device, GdkDevice *device,
GdkCrossingMode mode) GdkCrossingMode mode)
{ {
GdkSurface *from_surface = NULL, *to_surface = NULL; GdkSurface *from_surface = NULL, *to_surface = NULL;
GtkCrossingData crossing; GtkCrossingData crossing;
@ -8321,7 +8322,7 @@ gtk_widget_buildable_interface_init (GtkBuildableIface *iface)
static void static void
gtk_widget_buildable_set_id (GtkBuildable *buildable, gtk_widget_buildable_set_id (GtkBuildable *buildable,
const char *id) const char *id)
{ {
g_object_set_qdata_full (G_OBJECT (buildable), quark_builder_set_id, g_object_set_qdata_full (G_OBJECT (buildable), quark_builder_set_id,
g_strdup (id), g_free); g_strdup (id), g_free);
@ -8335,8 +8336,8 @@ gtk_widget_buildable_get_id (GtkBuildable *buildable)
static GObject * static GObject *
gtk_widget_buildable_get_internal_child (GtkBuildable *buildable, gtk_widget_buildable_get_internal_child (GtkBuildable *buildable,
GtkBuilder *builder, GtkBuilder *builder,
const char *childname) const char *childname)
{ {
GtkWidgetClass *class; GtkWidgetClass *class;
GSList *l; GSList *l;
@ -8352,15 +8353,15 @@ gtk_widget_buildable_get_internal_child (GtkBuildable *buildable,
GtkWidgetTemplate *template = class->priv->template; GtkWidgetTemplate *template = class->priv->template;
if (!template) if (!template)
continue; continue;
for (l = template->children; l && internal_child_type == 0; l = l->next) for (l = template->children; l && internal_child_type == 0; l = l->next)
{ {
AutomaticChildClass *child_class = l->data; AutomaticChildClass *child_class = l->data;
if (child_class->internal_child && strcmp (childname, child_class->name) == 0) if (child_class->internal_child && strcmp (childname, child_class->name) == 0)
internal_child_type = G_OBJECT_CLASS_TYPE (class); internal_child_type = G_OBJECT_CLASS_TYPE (class);
} }
} }
/* Now return the 'internal-child' from the class which declared it, note /* Now return the 'internal-child' from the class which declared it, note
@ -8375,7 +8376,7 @@ gtk_widget_buildable_get_internal_child (GtkBuildable *buildable,
static void static void
gtk_widget_buildable_parser_finished (GtkBuildable *buildable, gtk_widget_buildable_parser_finished (GtkBuildable *buildable,
GtkBuilder *builder) GtkBuilder *builder)
{ {
} }
@ -9435,7 +9436,7 @@ gtk_widget_add_mnemonic_label (GtkWidget *widget,
new_list = g_slist_prepend (old_list, label); new_list = g_slist_prepend (old_list, label);
g_object_set_qdata_full (G_OBJECT (widget), quark_mnemonic_labels, g_object_set_qdata_full (G_OBJECT (widget), quark_mnemonic_labels,
new_list, (GDestroyNotify) g_slist_free); new_list, (GDestroyNotify) g_slist_free);
/* The ATContext takes ownership of the GList returned by list_mnemonic_labels(), /* The ATContext takes ownership of the GList returned by list_mnemonic_labels(),
* so we don't need to free it * so we don't need to free it
@ -9471,7 +9472,7 @@ gtk_widget_remove_mnemonic_label (GtkWidget *widget,
if (new_list) if (new_list)
g_object_set_qdata_full (G_OBJECT (widget), quark_mnemonic_labels, g_object_set_qdata_full (G_OBJECT (widget), quark_mnemonic_labels,
new_list, (GDestroyNotify) g_slist_free); new_list, (GDestroyNotify) g_slist_free);
if (new_list != NULL && new_list->data != NULL) if (new_list != NULL && new_list->data != NULL)
{ {
@ -10386,7 +10387,7 @@ gtk_widget_ensure_resize (GtkWidget *widget)
void void
_gtk_widget_add_sizegroup (GtkWidget *widget, _gtk_widget_add_sizegroup (GtkWidget *widget,
gpointer group) gpointer group)
{ {
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GSList *groups; GSList *groups;
@ -10400,7 +10401,7 @@ _gtk_widget_add_sizegroup (GtkWidget *widget,
void void
_gtk_widget_remove_sizegroup (GtkWidget *widget, _gtk_widget_remove_sizegroup (GtkWidget *widget,
gpointer group) gpointer group)
{ {
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GSList *groups; GSList *groups;
@ -10669,34 +10670,10 @@ template_child_class_new (const char *name,
return child_class; return child_class;
} }
static void
template_child_class_free (AutomaticChildClass *child_class)
{
if (child_class)
{
g_free (child_class->name);
g_slice_free (AutomaticChildClass, child_class);
}
}
static void
template_data_free (GtkWidgetTemplate *template_data)
{
if (template_data)
{
g_bytes_unref (template_data->data);
g_slist_free_full (template_data->children, (GDestroyNotify)template_child_class_free);
g_object_unref (template_data->scope);
g_slice_free (GtkWidgetTemplate, template_data);
}
}
static GHashTable * static GHashTable *
get_auto_child_hash (GtkWidget *widget, get_auto_child_hash (GtkWidget *widget,
GType type, GType type,
gboolean create) gboolean create)
{ {
GHashTable *auto_children; GHashTable *auto_children;
GHashTable *auto_child_hash; GHashTable *auto_child_hash;
@ -10709,7 +10686,7 @@ get_auto_child_hash (GtkWidget *widget,
auto_children = g_hash_table_new_full (g_direct_hash, auto_children = g_hash_table_new_full (g_direct_hash,
NULL, NULL,
NULL, (GDestroyNotify)g_hash_table_destroy); NULL, (GDestroyNotify)g_hash_table_destroy);
g_object_set_qdata_full (G_OBJECT (widget), g_object_set_qdata_full (G_OBJECT (widget),
quark_auto_children, quark_auto_children,
auto_children, auto_children,
@ -10722,13 +10699,13 @@ get_auto_child_hash (GtkWidget *widget,
if (!auto_child_hash && create) if (!auto_child_hash && create)
{ {
auto_child_hash = g_hash_table_new_full (g_str_hash, auto_child_hash = g_hash_table_new_full (g_str_hash,
g_str_equal, g_str_equal,
NULL, NULL,
(GDestroyNotify)g_object_unref); (GDestroyNotify)g_object_unref);
g_hash_table_insert (auto_children, g_hash_table_insert (auto_children,
GSIZE_TO_POINTER (type), GSIZE_TO_POINTER (type),
auto_child_hash); auto_child_hash);
} }
return auto_child_hash; return auto_child_hash;
@ -10748,7 +10725,7 @@ setup_template_child (GtkWidgetTemplate *template_data,
if (!object) if (!object)
{ {
g_critical ("Unable to retrieve object '%s' from class template for type '%s' while building a '%s'", g_critical ("Unable to retrieve object '%s' from class template for type '%s' while building a '%s'",
child_class->name, g_type_name (class_type), G_OBJECT_TYPE_NAME (widget)); child_class->name, g_type_name (class_type), G_OBJECT_TYPE_NAME (widget));
return FALSE; return FALSE;
} }
@ -10821,13 +10798,13 @@ gtk_widget_init_template (GtkWidget *widget)
* will validate that the template is created for the correct GType and assert that * will validate that the template is created for the correct GType and assert that
* there is no infinite recursion. * there is no infinite recursion.
*/ */
if (!gtk_builder_extend_with_template (builder, G_OBJECT (widget), class_type, if (!gtk_builder_extend_with_template (builder, G_OBJECT (widget), class_type,
(const char *)g_bytes_get_data (template->data, NULL), (const char *)g_bytes_get_data (template->data, NULL),
g_bytes_get_size (template->data), g_bytes_get_size (template->data),
&error)) &error))
{ {
g_critical ("Error building template class '%s' for an instance of type '%s': %s", g_critical ("Error building template class '%s' for an instance of type '%s': %s",
g_type_name (class_type), G_OBJECT_TYPE_NAME (object), error->message); g_type_name (class_type), G_OBJECT_TYPE_NAME (object), error->message);
g_error_free (error); g_error_free (error);
/* This should never happen, if the template XML cannot be built /* This should never happen, if the template XML cannot be built
@ -10848,14 +10825,14 @@ gtk_widget_init_template (GtkWidget *widget)
* invocations which may follow by reference in child classes. * invocations which may follow by reference in child classes.
*/ */
if (!setup_template_child (template, if (!setup_template_child (template,
class_type, class_type,
child_class, child_class,
widget, widget,
builder)) builder))
{ {
g_object_unref (builder); g_object_unref (builder);
return; return;
} }
} }
g_object_unref (builder); g_object_unref (builder);
@ -10876,7 +10853,7 @@ gtk_widget_init_template (GtkWidget *widget)
*/ */
void void
gtk_widget_class_set_template (GtkWidgetClass *widget_class, gtk_widget_class_set_template (GtkWidgetClass *widget_class,
GBytes *template_bytes) GBytes *template_bytes)
{ {
GBytes *data = NULL; GBytes *data = NULL;
@ -10918,7 +10895,7 @@ gtk_widget_class_set_template (GtkWidgetClass *widget_class,
*/ */
void void
gtk_widget_class_set_template_from_resource (GtkWidgetClass *widget_class, gtk_widget_class_set_template_from_resource (GtkWidgetClass *widget_class,
const char *resource_name) const char *resource_name)
{ {
GError *error = NULL; GError *error = NULL;
GBytes *bytes = NULL; GBytes *bytes = NULL;
@ -10938,7 +10915,7 @@ gtk_widget_class_set_template_from_resource (GtkWidgetClass *widget_class,
if (!bytes) if (!bytes)
{ {
g_critical ("Unable to load resource for composite template for type '%s': %s", g_critical ("Unable to load resource for composite template for type '%s': %s",
G_OBJECT_CLASS_NAME (widget_class), error->message); G_OBJECT_CLASS_NAME (widget_class), error->message);
g_error_free (error); g_error_free (error);
return; return;
} }
@ -11002,7 +10979,7 @@ gtk_widget_class_bind_template_callback_full (GtkWidgetClass *widget_class,
*/ */
void void
gtk_widget_class_set_template_scope (GtkWidgetClass *widget_class, gtk_widget_class_set_template_scope (GtkWidgetClass *widget_class,
GtkBuilderScope *scope) GtkBuilderScope *scope)
{ {
g_return_if_fail (GTK_IS_WIDGET_CLASS (widget_class)); g_return_if_fail (GTK_IS_WIDGET_CLASS (widget_class));
g_return_if_fail (widget_class->priv->template != NULL); g_return_if_fail (widget_class->priv->template != NULL);