[gtk/bin-removal: 45/83] popover: Add a child property
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/bin-removal: 45/83] popover: Add a child property
- Date: Mon, 4 May 2020 16:48:54 +0000 (UTC)
commit 1f3f0ab1f17d549e7994618cc1f9723e22ff86de
Author: Matthias Clasen <mclasen redhat com>
Date: Fri May 1 18:24:15 2020 -0400
popover: Add a child property
docs/reference/gtk/gtk4-sections.txt | 2 ++
gtk/gtkpopover.c | 51 ++++++++++++++++++++++++++++++++++++
gtk/gtkpopover.h | 6 +++++
3 files changed, 59 insertions(+)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 3aca633fde..0cfe918849 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -5774,6 +5774,8 @@ GtkPopover
gtk_popover_new
gtk_popover_popup
gtk_popover_popdown
+gtk_popover_set_child
+gtk_popover_get_child
gtk_popover_set_pointing_to
gtk_popover_get_pointing_to
gtk_popover_set_position
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index 70a15ea3d9..820a6abd1f 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -174,6 +174,7 @@ enum {
PROP_DEFAULT_WIDGET,
PROP_HAS_ARROW,
PROP_MNEMONICS_VISIBLE,
+ PROP_CHILD,
NUM_PROPERTIES
};
@@ -1545,6 +1546,10 @@ gtk_popover_set_property (GObject *object,
gtk_popover_set_mnemonics_visible (popover, g_value_get_boolean (value));
break;
+ case PROP_CHILD:
+ gtk_popover_set_child (popover, g_value_get_object (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1586,6 +1591,10 @@ gtk_popover_get_property (GObject *object,
g_value_set_boolean (value, priv->mnemonics_visible);
break;
+ case PROP_CHILD:
+ g_value_set_object (value, gtk_popover_get_child (popover));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1720,6 +1729,13 @@ gtk_popover_class_init (GtkPopoverClass *klass)
FALSE,
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 (object_class, NUM_PROPERTIES, properties);
signals[CLOSED] =
@@ -1775,6 +1791,41 @@ gtk_popover_new (void)
return g_object_new (GTK_TYPE_POPOVER, NULL);
}
+/**
+ * gtk_popover_set_child:
+ * @popover: a #GtkPopover
+ * @child: (allow-none): the child widget
+ *
+ * Sets the child widget of @popover.
+ */
+void
+gtk_popover_set_child (GtkPopover *popover,
+ GtkWidget *child)
+{
+ g_return_if_fail (GTK_IS_POPOVER (popover));
+ g_return_if_fail (child == NULL || GTK_IS_WIDGET (child));
+
+ _gtk_bin_set_child (GTK_BIN (popover), child);
+ g_object_notify_by_pspec (G_OBJECT (popover), properties[PROP_CHILD]);
+}
+
+/**
+ * gtk_popover_get_child:
+ * @popover: a #GtkPopover
+ *
+ * Gets the child widget of @popover.
+ *
+ * Returns: (nullable) (transfer none): the child widget of @popover
+ */
+GtkWidget *
+gtk_popover_get_child (GtkPopover *popover)
+{
+ g_return_val_if_fail (GTK_IS_POPOVER (popover), NULL);
+
+ return gtk_bin_get_child (GTK_BIN (popover));
+}
+
+
/**
* gtk_popover_set_default_widget:
* @popover: a #GtkPopover
diff --git a/gtk/gtkpopover.h b/gtk/gtkpopover.h
index 7f90714278..a9b9d8e1d6 100644
--- a/gtk/gtkpopover.h
+++ b/gtk/gtkpopover.h
@@ -62,6 +62,12 @@ GType gtk_popover_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkWidget * gtk_popover_new (void);
+GDK_AVAILABLE_IN_ALL
+void gtk_popover_set_child (GtkPopover *popover,
+ GtkWidget *child);
+GDK_AVAILABLE_IN_ALL
+GtkWidget * gtk_popover_get_child (GtkPopover *popover);
+
GDK_AVAILABLE_IN_ALL
void gtk_popover_set_pointing_to (GtkPopover *popover,
const GdkRectangle *rect);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]