[gtk/matthiasc/for-master: 8/8] widget-factory: Add more error states
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 8/8] widget-factory: Add more error states
- Date: Thu, 13 Aug 2020 11:50:55 +0000 (UTC)
commit e9afb63a01bc0605aee0f17463e397ebc8003f06
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Aug 12 13:41:53 2020 -0400
widget-factory: Add more error states
Add a label with the .error style class in the
configuration dialog, also add another entry validation
here, to have it in one place.
demos/widget-factory/widget-factory.c | 19 +++++++++++++++++++
demos/widget-factory/widget-factory.ui | 21 +++++++++++++++++++++
2 files changed, 40 insertions(+)
---
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index d4afff17b2..0b17ed05d4 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -1878,6 +1878,24 @@ age_entry_changed (GtkEntry *entry,
}
}
+static void
+validate_more_details (GtkEntry *entry,
+ GParamSpec *pspec,
+ GtkEntry *details)
+{
+ if (strlen (gtk_editable_get_text (GTK_EDITABLE (entry))) > 0 &&
+ strlen (gtk_editable_get_text (GTK_EDITABLE (details))) == 0)
+ {
+ gtk_widget_set_tooltip_text (GTK_WIDGET (entry), "Must have details first");
+ gtk_widget_add_css_class (GTK_WIDGET (entry), "error");
+ }
+ else
+ {
+ gtk_widget_set_tooltip_text (GTK_WIDGET (entry), "");
+ gtk_widget_remove_css_class (GTK_WIDGET (entry), "error");
+ }
+}
+
static void
activate (GApplication *app)
{
@@ -1959,6 +1977,7 @@ activate (GApplication *app)
"reset_icon_size", (GCallback)reset_icon_size,
"osd_frame_pressed", (GCallback)osd_frame_pressed,
"age_entry_changed", (GCallback)age_entry_changed,
+ "validate_more_details", (GCallback)validate_more_details,
NULL);
gtk_builder_set_scope (builder, scope);
g_object_unref (scope);
diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui
index 8e962e4e9f..6ee4a6c742 100644
--- a/demos/widget-factory/widget-factory.ui
+++ b/demos/widget-factory/widget-factory.ui
@@ -2812,6 +2812,7 @@ microphone-sensitivity-medium-symbolic</property>
<property name="hexpand">1</property>
<property name="show-emoji-icon">1</property>
<property name="placeholder-text" translatable="yes">Ageā¦</property>
+ <signal name="notify::text" handler="age_entry_changed"/>
</object>
</child>
<style>
@@ -3022,6 +3023,7 @@ bad things might happen.</property>
<layout>
<property name="column">1</property>
<property name="row">0</property>
+ <property name="column-span">2</property>
</layout>
</object>
</child>
@@ -3044,9 +3046,11 @@ bad things might happen.</property>
<child>
<object class="GtkEntry" id="more_details_entry">
<property name="valign">baseline</property>
+ <signal name="notify::text" handler="validate_more_details" object="details_entry"
swapped="no"/>
<layout>
<property name="column">1</property>
<property name="row">1</property>
+ <property name="column-span">2</property>
</layout>
</object>
</child>
@@ -3074,6 +3078,7 @@ bad things might happen.</property>
<layout>
<property name="column">1</property>
<property name="row">2</property>
+ <property name="column-span">2</property>
</layout>
</object>
</child>
@@ -3103,6 +3108,22 @@ bad things might happen.</property>
</layout>
</object>
</child>
+ <child>
+ <object class="GtkLabel" id="switch_error">
+ <property name="visible">0</property>
+ <property name="halign">start</property>
+ <property name="valign">baseline</property>
+ <property name="label">Error!</property>
+ <property name="visible" bind-source="mode_switch" bind-property="active"></property>
+ <style>
+ <class name="error"/>
+ </style>
+ <layout>
+ <property name="column">2</property>
+ <property name="row">3</property>
+ </layout>
+ </object>
+ </child>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]