[recipes/image-links: 2/3] Support links for switching the image in the instructions.
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes/image-links: 2/3] Support links for switching the image in the instructions.
- Date: Tue, 3 Jan 2017 21:29:55 +0000 (UTC)
commit 1b497a0aea06a62e328cf6ee343dc521e6310a45
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jan 3 16:28:52 2017 -0500
Support links for switching the image in the instructions.
src/gr-details-page.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-details-page.c b/src/gr-details-page.c
index 26c6aac..77b3ef5 100644
--- a/src/gr-details-page.c
+++ b/src/gr-details-page.c
@@ -787,6 +787,23 @@ populate_ingredients (GrDetailsPage *page,
}
}
+static gboolean
+activate_link (GtkLabel *label,
+ const char *uri,
+ GrDetailsPage *page)
+{
+ if (g_str_has_prefix (uri, "image:")) {
+ int idx;
+
+ idx = (int)g_ascii_strtoll (uri + strlen ("image:"), NULL, 10);
+ gr_image_viewer_show_image (GR_IMAGE_VIEWER (page->recipe_image), idx);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
void
gr_details_page_set_recipe (GrDetailsPage *page,
GrRecipe *recipe)
@@ -837,6 +854,8 @@ gr_details_page_set_recipe (GrDetailsPage *page,
else
gtk_label_set_label (GTK_LABEL (page->cook_time_label), _(cook_time));
gtk_label_set_label (GTK_LABEL (page->instructions_label), instructions);
+ gtk_label_set_use_markup (GTK_LABEL (page->instructions_label), TRUE);
+ g_signal_connect (page->instructions_label, "activate-link", G_CALLBACK (activate_link), page);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (page->serves_spin), serves);
gtk_widget_set_sensitive (page->serves_spin, ing != NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]