[recipes] More tile rework
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] More tile rework
- Date: Mon, 27 Feb 2017 02:37:47 +0000 (UTC)
commit 23d6908ccc2b4b5c155bbc8787c665ffafc0216c
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Feb 26 21:29:23 2017 -0500
More tile rework
Drop the no-longer-needed function to recreate CSS for
chef tiles, and use images for it everywhere.
src/gr-chef-dialog.c | 3 ---
src/gr-chef-tile.c | 5 -----
src/gr-chef-tile.h | 3 ---
src/gr-list-page.c | 12 +++++++++++-
src/gr-recipe-importer.c | 3 ---
src/gr-recipe-small-tile.c | 28 +++++++++++++++++-----------
src/gr-recipes-page.c | 1 -
7 files changed, 28 insertions(+), 27 deletions(-)
---
diff --git a/src/gr-chef-dialog.c b/src/gr-chef-dialog.c
index 89ec414..b9ec120 100644
--- a/src/gr-chef-dialog.c
+++ b/src/gr-chef-dialog.c
@@ -232,9 +232,6 @@ save_chef_dialog (GrChefDialog *self,
ret = gr_recipe_store_add_chef (store, self->chef, error);
}
- if (ret)
- gr_chef_tile_recreate_css ();
-
return ret;
}
diff --git a/src/gr-chef-tile.c b/src/gr-chef-tile.c
index 6dd1d12..de8fc02 100644
--- a/src/gr-chef-tile.c
+++ b/src/gr-chef-tile.c
@@ -73,11 +73,6 @@ gr_chef_tile_class_init (GrChefTileClass *klass)
}
void
-gr_chef_tile_recreate_css (void)
-{
-}
-
-void
gr_chef_tile_set_chef (GrChefTile *tile,
GrChef *chef)
{
diff --git a/src/gr-chef-tile.h b/src/gr-chef-tile.h
index 20b7b48..88395a5 100644
--- a/src/gr-chef-tile.h
+++ b/src/gr-chef-tile.h
@@ -34,7 +34,4 @@ GrChef *gr_chef_tile_get_chef (GrChefTile *tile);
void gr_chef_tile_set_chef (GrChefTile *tile,
GrChef *chef);
-void gr_chef_tile_recreate_css (void);
-
-
G_END_DECLS
diff --git a/src/gr-list-page.c b/src/gr-list-page.c
index 5dbfb29..1fc406e 100644
--- a/src/gr-list-page.c
+++ b/src/gr-list-page.c
@@ -303,6 +303,7 @@ gr_list_page_populate_from_chef (GrListPage *self,
const char *name;
const char *fullname;
const char *description;
+ const char *path;
char *tmp;
g_autofree char *term = NULL;
@@ -314,8 +315,17 @@ gr_list_page_populate_from_chef (GrListPage *self,
name = gr_chef_get_name (chef) ? gr_chef_get_name (chef) : "";
fullname = gr_chef_get_fullname (chef) ? gr_chef_get_fullname (chef) : "";
description = gr_chef_get_translated_description (chef) ? gr_chef_get_translated_description (chef)
: "";
+ path = gr_chef_get_image (chef);
- gtk_style_context_add_class (gtk_widget_get_style_context (self->chef_image), id);
+ if (path && path[0]) {
+ g_autoptr(GdkPixbuf) pixbuf = NULL;
+
+ pixbuf = load_pixbuf_fill_size (path, 64, 64);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (self->chef_image), pixbuf);
+ }
+ else {
+ gtk_image_clear (GTK_IMAGE (self->chef_image));
+ }
gtk_widget_show (self->chef_grid);
gtk_widget_show (self->heading);
diff --git a/src/gr-recipe-importer.c b/src/gr-recipe-importer.c
index a655c7e..44ea301 100644
--- a/src/gr-recipe-importer.c
+++ b/src/gr-recipe-importer.c
@@ -439,9 +439,6 @@ next:
id = importer->recipe_ids[importer->current_recipe];
if (id == NULL) {
- // We're done!
- gr_chef_tile_recreate_css ();
-
g_signal_emit (importer, done_signal, 0, importer->recipes);
cleanup_import (importer);
return TRUE;
diff --git a/src/gr-recipe-small-tile.c b/src/gr-recipe-small-tile.c
index 2c78be0..4fb234d 100644
--- a/src/gr-recipe-small-tile.c
+++ b/src/gr-recipe-small-tile.c
@@ -82,24 +82,14 @@ recipe_small_tile_set_recipe (GrRecipeSmallTile *tile,
store = gr_app_get_recipe_store (GR_APP (g_application_get_default ()));
- if (tile->recipe) {
- const char *elem;
- elem = gr_recipe_get_id (tile->recipe);
- gtk_style_context_remove_class (gtk_widget_get_style_context (tile->box), elem);
- }
-
g_set_object (&tile->recipe, recipe);
if (tile->recipe) {
- const char *elem;
const char *name;
const char *author;
g_autoptr(GrChef) chef = NULL;
g_autofree char *tmp = NULL;
-
- elem = gr_recipe_get_id (tile->recipe);
- gtk_style_context_add_class (gtk_widget_get_style_context (tile->box), elem);
- gtk_style_context_add_class (gtk_widget_get_style_context (tile->image), elem);
+ g_autoptr(GArray) images = NULL;
name = gr_recipe_get_translated_name (recipe);
author = gr_recipe_get_author (recipe);
@@ -108,6 +98,22 @@ recipe_small_tile_set_recipe (GrRecipeSmallTile *tile,
gtk_label_set_label (GTK_LABEL (tile->label), name);
tmp = g_strdup_printf (_("by %s"), chef ? gr_chef_get_name (chef) : _("Anonymous"));
gtk_label_set_label (GTK_LABEL (tile->author), tmp);
+
+ g_object_get (recipe, "images", &images, NULL);
+ if (images->len > 0) {
+ int index;
+ GrImage *ri;
+ g_autoptr(GdkPixbuf) pixbuf = NULL;
+
+ index = gr_recipe_get_default_image (recipe);
+ if (index < 0 || index >= images->len)
+ index = 0;
+
+ ri = &g_array_index (images, GrImage, index);
+ pixbuf = load_pixbuf_fill_size (ri->path, 64, 64);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (tile->image), pixbuf);
+ }
+
}
}
diff --git a/src/gr-recipes-page.c b/src/gr-recipes-page.c
index b976af0..ad58ed9 100644
--- a/src/gr-recipes-page.c
+++ b/src/gr-recipes-page.c
@@ -144,7 +144,6 @@ gr_recipes_page_init (GrRecipesPage *page)
populate_shopping_from_store (page);
populate_categories_from_store (page);
populate_chefs_from_store (page);
- gr_chef_tile_recreate_css ();
connect_store_signals (page);
page->shopping_timeout = g_timeout_add_seconds (300, update_shopping_time, page);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]