[recipes] More precise error handling
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] More precise error handling
- Date: Wed, 17 May 2017 01:28:20 +0000 (UTC)
commit 71f547569e835d14d8900a5d8afdc0a4675fd004
Author: Matthias Clasen <mclasen redhat com>
Date: Tue May 16 21:17:04 2017 -0400
More precise error handling
Jump to the field that needs fixing when correcting
an invalid ingredient row.
src/gr-ingredients-viewer-row.c | 12 ++++++++++++
src/gr-ingredients-viewer-row.h | 2 ++
src/gr-ingredients-viewer.c | 10 ++++++++--
3 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/src/gr-ingredients-viewer-row.c b/src/gr-ingredients-viewer-row.c
index fea3432..fd18523 100644
--- a/src/gr-ingredients-viewer-row.c
+++ b/src/gr-ingredients-viewer-row.c
@@ -809,3 +809,15 @@ setup_editable_row (GrIngredientsViewerRow *self)
gtk_entry_set_completion (GTK_ENTRY (self->unit_entry), NULL);
}
}
+
+GtkWidget *
+gr_ingredients_viewer_row_has_error (GrIngredientsViewerRow *row)
+{
+ if (row->amount == NULL || row->amount[0] == '\0')
+ return gtk_widget_get_parent (row->unit_label);
+
+ if (row->ingredient == NULL || row->ingredient[0] == '\0')
+ return gtk_widget_get_parent (row->ingredient_label);
+
+ return NULL;
+}
diff --git a/src/gr-ingredients-viewer-row.h b/src/gr-ingredients-viewer-row.h
index 317037e..1083cc9 100644
--- a/src/gr-ingredients-viewer-row.h
+++ b/src/gr-ingredients-viewer-row.h
@@ -28,4 +28,6 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GrIngredientsViewerRow, gr_ingredients_viewer_row, GR, INGREDIENTS_VIEWER_ROW,
GtkListBoxRow)
+GtkWidget *gr_ingredients_viewer_row_has_error (GrIngredientsViewerRow *row);
+
G_END_DECLS
diff --git a/src/gr-ingredients-viewer.c b/src/gr-ingredients-viewer.c
index 3902d4e..cd581b2 100644
--- a/src/gr-ingredients-viewer.c
+++ b/src/gr-ingredients-viewer.c
@@ -170,19 +170,25 @@ gr_ingredients_viewer_has_error (GrIngredientsViewer *viewer)
children = gtk_container_get_children (GTK_CONTAINER (viewer->list));
for (l = children; l; l = l->next) {
GtkWidget *row = l->data;
+ GtkWidget *error_field;
+
+#if 0
g_autofree char *amount = NULL;
- g_autofree char *unit = NULL;
g_autofree char *ingredient = NULL;
g_object_get (row,
"amount", &amount,
- "unit", &unit,
"ingredient", &ingredient,
NULL);
if (amount == NULL || amount[0] == '\0' ||
ingredient == NULL || ingredient[0] == '\0')
return row;
+#else
+ error_field = gr_ingredients_viewer_row_has_error (row);
+ if (error_field)
+ return error_field;
+#endif
}
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]