[recipes] Improve the error feedback
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Improve the error feedback
- Date: Mon, 15 May 2017 02:52:13 +0000 (UTC)
commit b6695ad8ab0c47fa42dde1c6d2e496cb6f543e5f
Author: Matthias Clasen <mclasen redhat com>
Date: Sun May 14 22:35:04 2017 -0400
Improve the error feedback
Show a popover with syntax hints when we flag an error.
src/gr-ingredients-viewer-row.c | 4 +++
src/gr-ingredients-viewer-row.ui | 48 ++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-ingredients-viewer-row.c b/src/gr-ingredients-viewer-row.c
index 00be91d..afe8535 100644
--- a/src/gr-ingredients-viewer-row.c
+++ b/src/gr-ingredients-viewer-row.c
@@ -46,6 +46,7 @@ struct _GrIngredientsViewerRow
GtkWidget *drag_handle;
GtkWidget *unit_event_box;
GtkWidget *ingredient_event_box;
+ GtkWidget *unit_help_popover;
char *amount;
char *unit;
@@ -358,6 +359,7 @@ static void
unit_text_changed (GrIngredientsViewerRow *row)
{
gtk_style_context_remove_class (gtk_widget_get_style_context (row->unit_entry), "error");
+ gtk_popover_popdown (GTK_POPOVER (row->unit_help_popover));
}
static gboolean
@@ -366,6 +368,7 @@ move_focus_back (gpointer data)
GrIngredientsViewerRow *row = data;
gtk_widget_grab_focus (row->unit_entry);
+ gtk_popover_popup (GTK_POPOVER (row->unit_help_popover));
return G_SOURCE_REMOVE;
}
@@ -525,6 +528,7 @@ gr_ingredients_viewer_row_class_init (GrIngredientsViewerRowClass *klass)
gtk_widget_class_bind_template_child (widget_class, GrIngredientsViewerRow, drag_handle);
gtk_widget_class_bind_template_child (widget_class, GrIngredientsViewerRow, unit_event_box);
gtk_widget_class_bind_template_child (widget_class, GrIngredientsViewerRow, ingredient_event_box);
+ gtk_widget_class_bind_template_child (widget_class, GrIngredientsViewerRow, unit_help_popover);
gtk_widget_class_bind_template_callback (widget_class, emit_delete);
gtk_widget_class_bind_template_callback (widget_class, edit_unit);
diff --git a/src/gr-ingredients-viewer-row.ui b/src/gr-ingredients-viewer-row.ui
index 72d1e84..2aaf86e 100644
--- a/src/gr-ingredients-viewer-row.ui
+++ b/src/gr-ingredients-viewer-row.ui
@@ -151,4 +151,52 @@
</object>
</child>
</template>
+ <object class="GtkPopover" id="unit_help_popover">
+ <property name="relative-to">unit_entry</property>
+ <property name="constrain-to">none</property>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">1</property>
+ <property name="margin">12</property>
+ <property name="column-spacing">20</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">1</property>
+ <property name="halign">center</property>
+ <property name="label" translatable="yes">Syntax</property>
+ <style>
+ <class name="heading"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">1</property>
+ <property name="xalign">0</property>
+ <property name="margin-bottom">10</property>
+ <property name="label" translatable="yes">Use a number, followed by an (optional)
unit.</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">1</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Examples: 1 kg, 2 1/2 pounds, 250 ml, 6</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]