[libadwaita] entry-row: Add :activates-default
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita] entry-row: Add :activates-default
- Date: Fri, 5 Aug 2022 19:12:48 +0000 (UTC)
commit 94909f0081608d64334a9cc4fc6f0a3db081a1df
Author: Gleb Smirnov <glebsmirnov0708 gmail com>
Date: Wed Jul 13 09:07:47 2022 +0300
entry-row: Add :activates-default
src/adw-entry-row.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++
src/adw-entry-row.h | 6 +++++
2 files changed, 76 insertions(+)
---
diff --git a/src/adw-entry-row.c b/src/adw-entry-row.c
index 851446c1..bf329f39 100644
--- a/src/adw-entry-row.c
+++ b/src/adw-entry-row.c
@@ -80,6 +80,7 @@ typedef struct
gboolean show_apply_button;
gboolean text_changed;
gboolean show_indicator;
+ gboolean activates_default;
} AdwEntryRowPrivate;
static void adw_entry_row_editable_init (GtkEditableInterface *iface);
@@ -99,6 +100,7 @@ enum {
PROP_INPUT_PURPOSE,
PROP_ATTRIBUTES,
PROP_ENABLE_EMOJI_COMPLETION,
+ PROP_ACTIVATES_DEFAULT,
PROP_LAST_PROP,
};
@@ -246,6 +248,9 @@ text_activated_cb (AdwEntryRow *self)
if (gtk_widget_get_visible (priv->apply_button)) {
apply_button_clicked_cb (self);
} else {
+ if (priv->activates_default)
+ gtk_widget_activate_default (GTK_WIDGET (self));
+
g_signal_emit (self, signals[SIGNAL_ENTRY_ACTIVATED], 0);
}
}
@@ -367,6 +372,9 @@ adw_entry_row_get_property (GObject *object,
case PROP_ENABLE_EMOJI_COMPLETION:
g_value_set_boolean (value, adw_entry_row_get_enable_emoji_completion (self));
break;
+ case PROP_ACTIVATES_DEFAULT:
+ g_value_set_boolean (value, adw_entry_row_get_activates_default (self));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -407,6 +415,9 @@ adw_entry_row_set_property (GObject *object,
case PROP_ENABLE_EMOJI_COMPLETION:
adw_entry_row_set_enable_emoji_completion (self, g_value_get_boolean (value));
break;
+ case PROP_ACTIVATES_DEFAULT:
+ adw_entry_row_set_activates_default (self, g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -521,6 +532,18 @@ adw_entry_row_class_init (AdwEntryRowClass *klass)
FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+ /**
+ * AdwEntryRow:activates-default: (attributes org.gtk.Property.get=adw_entry_row_get_activates_default
org.gtk.Property.set=adw_entry_row_set_activates_default)
+ *
+ * Whether activating the embedded entry can activate the default widget.
+ *
+ * Since: 1.2
+ */
+ props[PROP_ACTIVATES_DEFAULT] =
+ g_param_spec_boolean ("activates-default", NULL, NULL,
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
gtk_editable_install_properties (object_class, PROP_LAST_PROP);
@@ -1018,6 +1041,53 @@ adw_entry_row_set_enable_emoji_completion (AdwEntryRow *self,
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_ENABLE_EMOJI_COMPLETION]);
}
+/**
+ * adw_entry_row_get_activates_default: (attributes org.gtk.Method.get_property=activates-default)
+ * @self: an entry row
+ *
+ * Gets whether activating the embedded entry can activate the default widget.
+ *
+ * Returns: whether to activate the default widget
+ */
+gboolean
+adw_entry_row_get_activates_default (AdwEntryRow *self)
+{
+ AdwEntryRowPrivate *priv;
+
+ g_return_val_if_fail (ADW_IS_ENTRY_ROW (self), FALSE);
+
+ priv = adw_entry_row_get_instance_private (self);
+
+ return priv->activates_default;
+}
+
+/**
+ * adw_entry_row_set_activates_default: (attributes org.gtk.Method.set_property=activates-default)
+ * @self: an entry row
+ * @activates: whether to activate the default widget
+ *
+ * Sets whether activating the embedded entry can activate the default widget.
+ *
+ * Since: 1.2
+ */
+void
+adw_entry_row_set_activates_default (AdwEntryRow *self,
+ gboolean activates)
+{
+ AdwEntryRowPrivate *priv;
+
+ g_return_if_fail (ADW_IS_ENTRY_ROW (self));
+
+ priv = adw_entry_row_get_instance_private (self);
+
+ if (priv->activates_default == activates)
+ return;
+
+ priv->activates_default = activates;
+
+ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_ACTIVATES_DEFAULT]);
+}
+
void
adw_entry_row_set_indicator_icon_name (AdwEntryRow *self,
const char *icon_name)
diff --git a/src/adw-entry-row.h b/src/adw-entry-row.h
index 705be13a..c76d85c0 100644
--- a/src/adw-entry-row.h
+++ b/src/adw-entry-row.h
@@ -74,4 +74,10 @@ ADW_AVAILABLE_IN_1_2
void adw_entry_row_set_attributes (AdwEntryRow *self,
PangoAttrList *attributes);
+ADW_AVAILABLE_IN_1_2
+gboolean adw_entry_row_get_activates_default (AdwEntryRow *self);
+ADW_AVAILABLE_IN_1_2
+void adw_entry_row_set_activates_default (AdwEntryRow *self,
+ gboolean activates);
+
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]