[gtk/wip/matthiasc/shortcut-4: 130/139] popover: Add a mnemonics-visible property
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/shortcut-4: 130/139] popover: Add a mnemonics-visible property
- Date: Thu, 26 Mar 2020 02:47:47 +0000 (UTC)
commit f9e24d4118ff4d84da4dc48abb3705ca33de0ad2
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Mar 24 12:29:26 2020 -0400
popover: Add a mnemonics-visible property
This will be handled separately for popovers, so we
need our own property for it.
gtk/gtkpopover.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
gtk/gtkpopover.h | 6 ++++++
2 files changed, 65 insertions(+)
---
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;
+}
diff --git a/gtk/gtkpopover.h b/gtk/gtkpopover.h
index c89d2a1aca..7f90714278 100644
--- a/gtk/gtkpopover.h
+++ b/gtk/gtkpopover.h
@@ -86,6 +86,12 @@ void gtk_popover_set_has_arrow (GtkPopover *popover,
GDK_AVAILABLE_IN_ALL
gboolean gtk_popover_get_has_arrow (GtkPopover *popover);
+GDK_AVAILABLE_IN_ALL
+void gtk_popover_set_mnemonics_visible (GtkPopover *popover,
+ gboolean mnemonics_visible);
+GDK_AVAILABLE_IN_ALL
+gboolean gtk_popover_get_mnemonics_visible (GtkPopover *popover);
+
GDK_AVAILABLE_IN_ALL
void gtk_popover_popup (GtkPopover *popover);
GDK_AVAILABLE_IN_ALL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]