[recipes] Use translated string APIs where suitable



commit a0cdd5dd45c68fde158e169627fdc25a9d901cf9
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jan 2 06:16:29 2017 -0500

    Use translated string APIs where suitable
    
    This also adds a few remaining cases of name<>id confusion
    in the search provider.

 src/gr-details-page.c          |   12 ++++++------
 src/gr-list-page.c             |    4 +---
 src/gr-recipe-exporter.c       |    3 ++-
 src/gr-recipe-printer.c        |    6 +++---
 src/gr-recipe-tile.c           |    2 +-
 src/gr-shell-search-provider.c |   10 +++++-----
 src/gr-window.c                |    4 ++--
 7 files changed, 20 insertions(+), 21 deletions(-)
---
diff --git a/src/gr-details-page.c b/src/gr-details-page.c
index 29c9e8b..d906f35 100644
--- a/src/gr-details-page.c
+++ b/src/gr-details-page.c
@@ -68,7 +68,7 @@ timer_complete (GrTimer *timer)
 
         store = gr_app_get_recipe_store (GR_APP (app));
         recipe = gr_recipe_store_get_recipe (store, id);
-        name = gr_recipe_get_name (recipe);
+        name = gr_recipe_get_translated_name (recipe);
 
         body = g_strdup_printf (_("Your cooking timer for ā€œ%sā€ has expired."), name);
 
@@ -183,7 +183,7 @@ timer_remaining_changed (GrTimer       *timer,
         guint hours, minutes, seconds;
         g_autofree char *buf = NULL;
 
-        if (strcmp (gr_timer_get_name (timer), gr_recipe_get_name (page->recipe)) != 0)
+        if (strcmp (gr_timer_get_name (timer), gr_recipe_get_id (page->recipe)) != 0)
                 return;
 
         remaining = gr_timer_get_remaining (timer);
@@ -806,9 +806,9 @@ gr_details_page_set_recipe (GrDetailsPage *page,
         prep_time = gr_recipe_get_prep_time (recipe);
         cook_time = gr_recipe_get_cook_time (recipe);
         ingredients = gr_recipe_get_ingredients (recipe);
-        instructions = gr_recipe_get_instructions (recipe);
         notes = gr_recipe_get_notes (recipe);
-        description = gr_recipe_get_description (recipe);
+        instructions = gr_recipe_get_translated_instructions (recipe);
+        description = gr_recipe_get_translated_description (recipe);
 
         g_object_get (recipe, "images", &images, NULL);
         gr_image_viewer_set_images (GR_IMAGE_VIEWER (page->recipe_image), images);
@@ -884,8 +884,8 @@ details_page_reload (GrDetailsPage *page,
         const char *name;
         const char *new_name;
 
-        name = gr_recipe_get_name (page->recipe);
-        new_name = gr_recipe_get_name (recipe);
+        name = gr_recipe_get_id (page->recipe);
+        new_name = gr_recipe_get_id (recipe);
         if (strcmp (name, new_name) == 0)
                 gr_details_page_set_recipe (page, recipe);
 }
diff --git a/src/gr-list-page.c b/src/gr-list-page.c
index 76de79b..81386cc 100644
--- a/src/gr-list-page.c
+++ b/src/gr-list-page.c
@@ -305,9 +305,7 @@ gr_list_page_populate_from_chef (GrListPage *self,
         gtk_widget_hide (self->diet_description);
 
         gtk_label_set_label (GTK_LABEL (self->chef_fullname), gr_chef_get_fullname (chef));
-        description = gr_chef_get_description (chef);
-        if (description[0] != '\0')
-                description = _(description);
+        description = gr_chef_get_translated_description (chef);
         gtk_label_set_markup (GTK_LABEL (self->chef_description), description);
 
         image_path = gr_chef_get_image (chef);
diff --git a/src/gr-recipe-exporter.c b/src/gr-recipe-exporter.c
index 5d36430..852dc78 100644
--- a/src/gr-recipe-exporter.c
+++ b/src/gr-recipe-exporter.c
@@ -191,7 +191,8 @@ prepare_export (GrRecipeExporter  *exporter,
         path = g_build_filename (exporter->dir, "recipes.db", NULL);
         keyfile = g_key_file_new ();
 
-        key = name = gr_recipe_get_name (exporter->recipe);
+        key = gr_recipe_get_id (exporter->recipe);
+        name = gr_recipe_get_name (exporter->recipe);
         author = gr_recipe_get_author (exporter->recipe);
         description = gr_recipe_get_description (exporter->recipe);
         serves = gr_recipe_get_serves (exporter->recipe);
diff --git a/src/gr-recipe-printer.c b/src/gr-recipe-printer.c
index 73dc49a..a8ff5ca 100644
--- a/src/gr-recipe-printer.c
+++ b/src/gr-recipe-printer.c
@@ -109,7 +109,7 @@ begin_print (GtkPrintOperation *operation,
         pango_layout_set_font_description (printer->title_layout, title_font);
 
         s = g_string_new ("");
-        g_string_append (s, gr_recipe_get_name (printer->recipe));
+        g_string_append (s, gr_recipe_get_translated_name (printer->recipe));
         g_string_append (s, "\n\n");
 
         pango_layout_set_text (printer->title_layout, s->str, s->len);
@@ -140,7 +140,7 @@ begin_print (GtkPrintOperation *operation,
         pango_layout_set_tabs (printer->bottom_layout, tabs);
         pango_tab_array_free (tabs);
 
-        g_string_append (s, gr_recipe_get_description (printer->recipe));
+        g_string_append (s, gr_recipe_get_translated_description (printer->recipe));
         g_string_append (s, "\n\n");
 
         attrs = pango_attr_list_new ();
@@ -211,7 +211,7 @@ begin_print (GtkPrintOperation *operation,
         pango_attr_list_insert (attrs, attr);
 
         g_string_append (s, "\n\n");
-        g_string_append (s, gr_recipe_get_instructions (printer->recipe));
+        g_string_append (s, gr_recipe_get_translated_instructions (printer->recipe));
 
         pango_layout_set_text (printer->bottom_layout, s->str, s->len);
         pango_layout_set_attributes (printer->bottom_layout, attrs);
diff --git a/src/gr-recipe-tile.c b/src/gr-recipe-tile.c
index aff9737..109f7cc 100644
--- a/src/gr-recipe-tile.c
+++ b/src/gr-recipe-tile.c
@@ -71,7 +71,7 @@ recipe_tile_set_recipe (GrRecipeTile *tile,
 
         store = gr_app_get_recipe_store (GR_APP (g_application_get_default ()));
 
-        name = gr_recipe_get_name (recipe);
+        name = gr_recipe_get_translated_name (recipe);
         author = gr_recipe_get_author (recipe);
         chef = gr_recipe_store_get_chef (store, author);
 
diff --git a/src/gr-shell-search-provider.c b/src/gr-shell-search-provider.c
index 16c32a7..ccd3e50 100644
--- a/src/gr-shell-search-provider.c
+++ b/src/gr-shell-search-provider.c
@@ -93,7 +93,7 @@ hits_added_cb (GrRecipeSearch *search,
         for (l = hits; l; l = l->next) {
                 GrRecipe *recipe = l->data;
 
-                pending_search->results = g_list_prepend (pending_search->results, 
(gpointer)gr_recipe_get_name (recipe));
+                pending_search->results = g_list_prepend (pending_search->results, 
(gpointer)gr_recipe_get_id (recipe));
         }
 }
 
@@ -209,14 +209,14 @@ handle_get_result_metas (GrShellSearchProvider2 *skeleton,
                 }
 
                 g_variant_builder_init (&meta, G_VARIANT_TYPE ("a{sv}"));
-                g_variant_builder_add (&meta, "{sv}", "id", g_variant_new_string (gr_recipe_get_name 
(recipe)));
-                g_variant_builder_add (&meta, "{sv}", "name", g_variant_new_string (gr_recipe_get_name 
(recipe)));
+                g_variant_builder_add (&meta, "{sv}", "id", g_variant_new_string (gr_recipe_get_id 
(recipe)));
+                g_variant_builder_add (&meta, "{sv}", "name", g_variant_new_string 
(gr_recipe_get_translated_name (recipe)));
                 pixbuf = gr_recipe_get_pixbuf (recipe);
                 if (pixbuf != NULL)
                         g_variant_builder_add (&meta, "{sv}", "icon", g_icon_serialize (G_ICON (pixbuf)));
-                g_variant_builder_add (&meta, "{sv}", "description", g_variant_new_string 
(gr_recipe_get_description (recipe)));
+                g_variant_builder_add (&meta, "{sv}", "description", g_variant_new_string 
(gr_recipe_get_translated_description (recipe)));
                 meta_variant = g_variant_builder_end (&meta);
-                g_hash_table_insert (self->metas_cache, g_strdup (gr_recipe_get_name (recipe)), 
g_variant_ref_sink (meta_variant));
+                g_hash_table_insert (self->metas_cache, g_strdup (gr_recipe_get_id (recipe)), 
g_variant_ref_sink (meta_variant));
 
         }
 
diff --git a/src/gr-window.c b/src/gr-window.c
index dab182a..9d51a5c 100644
--- a/src/gr-window.c
+++ b/src/gr-window.c
@@ -416,7 +416,7 @@ gr_window_show_recipe (GrWindow *window,
 
         gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (window->search_bar), FALSE);
 
-        gtk_header_bar_set_title (GTK_HEADER_BAR (window->header), gr_recipe_get_name (recipe));
+        gtk_header_bar_set_title (GTK_HEADER_BAR (window->header), gr_recipe_get_translated_name (recipe));
 
         gtk_stack_set_visible_child_name (GTK_STACK (window->header_start_stack), "back");
         gtk_stack_set_visible_child_name (GTK_STACK (window->header_title_stack), "title");
@@ -433,7 +433,7 @@ gr_window_edit_recipe (GrWindow *window,
 
         gr_edit_page_edit (GR_EDIT_PAGE (window->edit_page), recipe);
 
-        gtk_header_bar_set_title (GTK_HEADER_BAR (window->header), gr_recipe_get_name (recipe));
+        gtk_header_bar_set_title (GTK_HEADER_BAR (window->header), gr_recipe_get_translated_name (recipe));
 
         gtk_stack_set_visible_child_name (GTK_STACK (window->header_start_stack), "back");
         gtk_stack_set_visible_child_name (GTK_STACK (window->header_title_stack), "title");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]