summaryrefslogtreecommitdiff
path: root/gtk/gtkpopover.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-03-24 12:29:26 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-03-25 23:14:45 -0400
commit2de4fc3ec0e4be84ebc93f17a1eda7259c1e519f (patch)
tree1bacf1e5f415b11a469f6619656a3e4eed098cbb /gtk/gtkpopover.c
parentb2ac42e576e50fe60651609e9215fc21b4e4f604 (diff)
downloadgtk+-2de4fc3ec0e4be84ebc93f17a1eda7259c1e519f.tar.gz
popover: Add a mnemonics-visible property
This will be handled separately for popovers, so we need our own property for it.
Diffstat (limited to 'gtk/gtkpopover.c')
-rw-r--r--gtk/gtkpopover.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index ae4d818be6..88426dd7a7 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -146,6 +146,7 @@ typedef struct {
GtkPositionType position;
gboolean autohide;
gboolean has_arrow;
+ gboolean mnemonics_visible;
GtkWidget *contents_widget;
GtkCssNode *arrow_node;
@@ -170,6 +171,7 @@ enum {
PROP_AUTOHIDE,
PROP_DEFAULT_WIDGET,
PROP_HAS_ARROW,
+ PROP_MNEMONICS_VISIBLE,
NUM_PROPERTIES
};
@@ -1382,6 +1384,10 @@ gtk_popover_set_property (GObject *object,
gtk_popover_set_has_arrow (popover, g_value_get_boolean (value));
break;
+ case PROP_MNEMONICS_VISIBLE:
+ gtk_popover_set_mnemonics_visible (popover, g_value_get_boolean (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1419,6 +1425,10 @@ gtk_popover_get_property (GObject *object,
g_value_set_boolean (value, priv->has_arrow);
break;
+ case PROP_MNEMONICS_VISIBLE:
+ g_value_set_boolean (value, priv->mnemonics_visible);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1546,6 +1556,13 @@ gtk_popover_class_init (GtkPopoverClass *klass)
TRUE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+ properties[PROP_MNEMONICS_VISIBLE] =
+ g_param_spec_boolean ("mnemonics-visible",
+ P_("Mnemonics visible"),
+ P_("Whether mnemonics are currently visible in this popover"),
+ FALSE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
signals[CLOSED] =
@@ -1898,3 +1915,45 @@ gtk_popover_get_has_arrow (GtkPopover *popover)
return priv->has_arrow;
}
+
+/**
+ * gtk_popover_set_mnemonics_visible:
+ * @popover: a #GtkPopover
+ * @mnemonics_visible: the new value
+ *
+ * Sets the #GtkPopover:mnemonics-visible property.
+ */
+void
+gtk_popover_set_mnemonics_visible (GtkPopover *popover,
+ gboolean mnemonics_visible)
+{
+ GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
+
+ g_return_if_fail (GTK_IS_POPOVER (popover));
+
+ if (priv->mnemonics_visible == mnemonics_visible)
+ return;
+
+ priv->mnemonics_visible = mnemonics_visible;
+
+ g_object_notify_by_pspec (G_OBJECT (popover), properties[PROP_MNEMONICS_VISIBLE]);
+ gtk_widget_queue_resize (GTK_WIDGET (popover));
+}
+
+/**
+ * gtk_popover_get_mnemonics_visible:
+ * @popover: a #GtkPopover
+ *
+ * Gets the value of the #GtkPopover:mnemonics-visible property.
+ *
+ * Returns: %TRUE if mnemonics are supposed to be visible in this popover
+ */
+gboolean
+gtk_popover_get_mnemonics_visible (GtkPopover *popover)
+{
+ GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
+
+ g_return_val_if_fail (GTK_IS_POPOVER (popover), FALSE);
+
+ return priv->mnemonics_visible;
+}