[recipes/find-current-step] wip: write a quick function to find and parse the current step
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes/find-current-step] wip: write a quick function to find and parse the current step
- Date: Sun, 7 May 2017 19:24:15 +0000 (UTC)
commit dcb114e0f6080dcb0e29b9180e94162a0cd620bc
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Mar 19 23:00:25 2017 +0000
wip: write a quick function to find and parse the current step
src/gr-edit-page.c | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-edit-page.c b/src/gr-edit-page.c
index f2d2d34..d657da7 100644
--- a/src/gr-edit-page.c
+++ b/src/gr-edit-page.c
@@ -1214,8 +1214,37 @@ time_spin_activate (GtkEntry *entry, GrEditPage *self)
}
static void
+find_current_step (GrEditPage *self)
+{
+ GtkTextBuffer *buffer;
+ GtkTextIter iter;
+ GtkTextIter step_start;
+ GtkTextIter step_end;
+ GtkTextIter start;
+ GtkTextIter end;
+ g_autofree char *step;
+ g_autoptr(GPtrArray) steps = NULL;
+ GrRecipeStep *s;
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->instructions_field));
+ gtk_text_buffer_get_bounds (buffer, &start, &end);
+ gtk_text_buffer_get_selection_bounds (buffer, &iter, NULL);
+ if (!gtk_text_iter_backward_search (&iter, "\n\n", 0, NULL, &step_start, NULL))
+ step_start = start;
+ if (!gtk_text_iter_forward_search (&iter, "\n\n", 0, &step_end, NULL, NULL))
+ step_end = end;
+
+ step = gtk_text_buffer_get_text (buffer, &step_start, &step_end, FALSE);
+
+ steps = gr_recipe_parse_instructions (step, FALSE);
+ s = g_ptr_array_index (steps, 0);
+ g_print ("image %d timer %lu nick %s\n", s->image, s->timer, s->title);
+}
+
+static void
add_timer (GtkButton *button, GrEditPage *page)
{
+ find_current_step (page);
gtk_popover_popup (GTK_POPOVER (page->timer_popover));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]