mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-09 02:10:10 +00:00
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.
This commit is contained in:
parent
3a0fdffe5e
commit
e9afb63a01
@ -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);
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user