scrolledwindow: Add a child property

This commit is contained in:
Matthias Clasen 2020-05-02 00:17:25 -04:00
parent ee1f8d8d06
commit 54b613392b
3 changed files with 284 additions and 229 deletions

View File

@ -2204,6 +2204,8 @@ gtk_scrollbar_get_type
<TITLE>GtkScrolledWindow</TITLE> <TITLE>GtkScrolledWindow</TITLE>
GtkScrolledWindow GtkScrolledWindow
gtk_scrolled_window_new gtk_scrolled_window_new
gtk_scrolled_window_get_child
gtk_scrolled_window_set_child
gtk_scrolled_window_get_hadjustment gtk_scrolled_window_get_hadjustment
gtk_scrolled_window_set_hadjustment gtk_scrolled_window_set_hadjustment
gtk_scrolled_window_get_vadjustment gtk_scrolled_window_get_vadjustment

View File

@ -317,6 +317,7 @@ enum {
PROP_MAX_CONTENT_HEIGHT, PROP_MAX_CONTENT_HEIGHT,
PROP_PROPAGATE_NATURAL_WIDTH, PROP_PROPAGATE_NATURAL_WIDTH,
PROP_PROPAGATE_NATURAL_HEIGHT, PROP_PROPAGATE_NATURAL_HEIGHT,
PROP_CHILD,
NUM_PROPERTIES NUM_PROPERTIES
}; };
@ -697,6 +698,13 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
FALSE, FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY); GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
properties[PROP_CHILD] =
g_param_spec_object ("child",
P_("Child"),
P_("The child widget"),
GTK_TYPE_WIDGET,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, properties); g_object_class_install_properties (gobject_class, NUM_PROPERTIES, properties);
/** /**
@ -2679,6 +2687,9 @@ gtk_scrolled_window_set_property (GObject *object,
gtk_scrolled_window_set_propagate_natural_height (scrolled_window, gtk_scrolled_window_set_propagate_natural_height (scrolled_window,
g_value_get_boolean (value)); g_value_get_boolean (value));
break; break;
case PROP_CHILD:
gtk_scrolled_window_set_child (scrolled_window, g_value_get_object (value));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -2740,6 +2751,9 @@ gtk_scrolled_window_get_property (GObject *object,
case PROP_PROPAGATE_NATURAL_HEIGHT: case PROP_PROPAGATE_NATURAL_HEIGHT:
g_value_set_boolean (value, priv->propagate_natural_height); g_value_set_boolean (value, priv->propagate_natural_height);
break; break;
case PROP_CHILD:
g_value_set_object (value, gtk_scrolled_window_get_child (scrolled_window));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -4171,3 +4185,36 @@ gtk_scrolled_window_get_propagate_natural_height (GtkScrolledWindow *scrolled_wi
return priv->propagate_natural_height; return priv->propagate_natural_height;
} }
/**
* gtk_scrolled_window_set_child:
* @scrolled_window: a #GtkScrolledWindow
* @child: (allow-none): the child widget
*
* Sets the child widget of @scrolled_window.
*/
void
gtk_scrolled_window_set_child (GtkScrolledWindow *scrolled_window,
GtkWidget *child)
{
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
_gtk_bin_set_child (GTK_BIN (scrolled_window), child);
g_object_notify_by_pspec (G_OBJECT (scrolled_window), properties[PROP_CHILD]);
}
/**
* gtk_scrolled_window_get_child:
* @scrolled_window: a #GtkScrolledWindow
*
* Gets the child widget of @scrolled_window.
*
* Returns: (nullable) (transfer none): the child widget of @scrolled_window
*/
GtkWidget *
gtk_scrolled_window_get_child (GtkScrolledWindow *scrolled_window)
{
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), NULL);
return gtk_bin_get_child (GTK_BIN (scrolled_window));
}

View File

@ -182,6 +182,12 @@ void gtk_scrolled_window_set_propagate_natural_height (GtkScrolledWind
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
gboolean gtk_scrolled_window_get_propagate_natural_height (GtkScrolledWindow *scrolled_window); gboolean gtk_scrolled_window_get_propagate_natural_height (GtkScrolledWindow *scrolled_window);
GDK_AVAILABLE_IN_ALL
void gtk_scrolled_window_set_child (GtkScrolledWindow *scrolled_window,
GtkWidget *child);
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_scrolled_window_get_child (GtkScrolledWindow *scrolled_window);
G_END_DECLS G_END_DECLS