[gtk/kill-containers: 27/76] expander: Add a child property
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/kill-containers: 27/76] expander: Add a child property
- Date: Sat, 9 May 2020 04:41:42 +0000 (UTC)
commit 3d9bb474f8d706edb32e58b77e14a49a63947751
Author: Matthias Clasen <mclasen redhat com>
Date: Thu May 7 00:02:42 2020 -0400
expander: Add a child property
docs/reference/gtk/gtk4-sections.txt | 2 ++
gtk/gtkexpander.c | 58 +++++++++++++++++++++++++++++++++++-
gtk/gtkexpander.h | 11 +++++--
3 files changed, 68 insertions(+), 3 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 2614c38e5a..6373dafbf2 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -1032,6 +1032,8 @@ gtk_expander_set_label_widget
gtk_expander_get_label_widget
gtk_expander_set_resize_toplevel
gtk_expander_get_resize_toplevel
+gtk_expander_set_child
+gtk_expander_get_child
<SUBSECTION Standard>
GTK_TYPE_EXPANDER
GTK_EXPANDER_CLASS
diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c
index c4d9cb139c..6ebbed5f76 100644
--- a/gtk/gtkexpander.c
+++ b/gtk/gtkexpander.c
@@ -140,7 +140,8 @@ enum
PROP_USE_UNDERLINE,
PROP_USE_MARKUP,
PROP_LABEL_WIDGET,
- PROP_RESIZE_TOPLEVEL
+ PROP_RESIZE_TOPLEVEL,
+ PROP_CHILD
};
typedef struct _GtkExpanderClass GtkExpanderClass;
@@ -355,6 +356,14 @@ gtk_expander_class_init (GtkExpanderClass *klass)
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
+ g_object_class_install_property (gobject_class,
+ PROP_CHILD,
+ g_param_spec_object ("child",
+ P_("Child"),
+ P_("The child widget"),
+ GTK_TYPE_WIDGET,
+ GTK_PARAM_READWRITE));
+
widget_class->activate_signal =
g_signal_new (I_("activate"),
G_TYPE_FROM_CLASS (gobject_class),
@@ -462,6 +471,9 @@ gtk_expander_set_property (GObject *object,
case PROP_RESIZE_TOPLEVEL:
gtk_expander_set_resize_toplevel (expander, g_value_get_boolean (value));
break;
+ case PROP_CHILD:
+ gtk_expander_set_child (expander, g_value_get_object (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -498,6 +510,9 @@ gtk_expander_get_property (GObject *object,
case PROP_RESIZE_TOPLEVEL:
g_value_set_boolean (value, gtk_expander_get_resize_toplevel (expander));
break;
+ case PROP_CHILD:
+ g_value_set_object (value, gtk_expander_get_child (expander));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1189,3 +1204,44 @@ gtk_expander_get_resize_toplevel (GtkExpander *expander)
return expander->resize_toplevel;
}
+
+/**
+ * gtk_expander_set_child:
+ * @expander: a #GtkExpander
+ * @child: (allow-none): the child widget
+ *
+ * Sets the child widget of @expander.
+ */
+void
+gtk_expander_set_child (GtkExpander *expander,
+ GtkWidget *child)
+{
+ g_return_if_fail (GTK_IS_EXPANDER (expander));
+ g_return_if_fail (child == NULL || GTK_IS_WIDGET (child));
+
+ g_clear_pointer (&expander->child, gtk_widget_unparent);
+
+ expander->child = child;
+
+ if (expander->child)
+ gtk_widget_set_parent (expander->child, GTK_WIDGET (expander));
+
+ g_object_notify (G_OBJECT (expander), "child");
+}
+
+/**
+ * gtk_expander_get_child:
+ * @expander: a #GtkExpander
+ *
+ * Gets the child widget of @expander.
+ *
+ * Returns: (nullable) (transfer none): the child widget of @expander
+ */
+GtkWidget *
+gtk_expander_get_child (GtkExpander *expander)
+{
+ g_return_val_if_fail (GTK_IS_EXPANDER (expander), NULL);
+
+ return expander->child;
+}
+
diff --git a/gtk/gtkexpander.h b/gtk/gtkexpander.h
index e1e7afef3f..1737816058 100644
--- a/gtk/gtkexpander.h
+++ b/gtk/gtkexpander.h
@@ -16,7 +16,7 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors:
- * Mark McLoughlin <mark skynet ie>
+ * Mark McLoughlin <mark skynet ie>
*/
#ifndef __GTK_EXPANDER_H__
@@ -70,7 +70,7 @@ gboolean gtk_expander_get_use_markup (GtkExpander *expander);
GDK_AVAILABLE_IN_ALL
void gtk_expander_set_label_widget (GtkExpander *expander,
- GtkWidget *label_widget);
+ GtkWidget *label_widget);
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_expander_get_label_widget (GtkExpander *expander);
GDK_AVAILABLE_IN_ALL
@@ -79,6 +79,13 @@ void gtk_expander_set_resize_toplevel (GtkExpander *expander,
GDK_AVAILABLE_IN_ALL
gboolean gtk_expander_get_resize_toplevel (GtkExpander *expander);
+GDK_AVAILABLE_IN_ALL
+void gtk_expander_set_child (GtkExpander *expander,
+ GtkWidget *child);
+GDK_AVAILABLE_IN_ALL
+GtkWidget * gtk_expander_get_child (GtkExpander *expander);
+
+
G_END_DECLS
#endif /* __GTK_EXPANDER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]