[recipes] Stop using CSS for chef tiles



commit 64211000a46a64a20653b2e4b25f1397f3c4cde2
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Feb 26 21:06:11 2017 -0500

    Stop using CSS for chef tiles

 src/gr-chef-tile.c |   78 ++++++----------------------------------------------
 1 files changed, 9 insertions(+), 69 deletions(-)
---
diff --git a/src/gr-chef-tile.c b/src/gr-chef-tile.c
index 30360f9..6dd1d12 100644
--- a/src/gr-chef-tile.c
+++ b/src/gr-chef-tile.c
@@ -72,91 +72,31 @@ gr_chef_tile_class_init (GrChefTileClass *klass)
         gtk_widget_class_bind_template_child (widget_class, GrChefTile, image);
 }
 
-static void
-add_chef_css (GrChef  *chef,
-              GString *css)
-{
-        const char *id;
-        const char *image_path;
-
-        id = gr_chef_get_id (chef);
-        image_path = gr_chef_get_image (chef);
-
-        if (image_path != NULL && image_path[0] != '\0')
-                g_string_append_printf (css,
-                                       "image.chef.%s {\n"
-                                       "  background: url('%s');\n"
-                                       "  background-size: 64px;\n"
-                                       "  min-width: 64px;\n"
-                                       "  min-height: 64px;\n"
-                                       "}\n\n", id, image_path);
-        else
-                g_string_append_printf (css,
-                                       "image.chef.%s {\n"
-                                       "  background: rgb(%d,%d,%d);\n"
-                                       "  min-width: 64px;\n"
-                                       "  min-height: 64px;\n"
-                                       "}\n\n",
-                                       id,
-                                       g_random_int_range (0, 255),
-                                       g_random_int_range (0, 255),
-                                       g_random_int_range (0, 255));
-}
-
-static GtkCssProvider *provider = NULL;
-
 void
 gr_chef_tile_recreate_css (void)
 {
-        GrRecipeStore *store;
-        g_autofree char **keys = NULL;
-        guint length;
-        g_autoptr(GString) css = NULL;
-        int i;
-
-        store = gr_app_get_recipe_store (GR_APP (g_application_get_default ()));
-        keys = gr_recipe_store_get_chef_keys (store, &length);
-
-        css = g_string_new ("");
-
-        for (i = 0; i < length; i++) {
-                g_autoptr (GrChef) chef = NULL;
-                chef = gr_recipe_store_get_chef (store, keys[i]);
-                add_chef_css (chef, css);
-        }
-
-        if (provider == NULL) {
-                provider = gtk_css_provider_new ();
-                gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
-                                                           GTK_STYLE_PROVIDER (provider),
-                                                           GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-        }
-
-        gtk_css_provider_load_from_data (provider, css->str, css->len, NULL);
 }
 
 void
 gr_chef_tile_set_chef (GrChefTile *tile,
                        GrChef     *chef)
 {
-        if (tile->chef) {
-                const char *elem;
-
-                elem = gr_chef_get_id (tile->chef);
-                gtk_style_context_remove_class (gtk_widget_get_style_context (tile->image), elem);
-        }
-
         g_set_object (&tile->chef, chef);
 
         if (tile->chef) {
-                const char *elem;
                 const char *name;
-
-                elem = gr_chef_get_id (tile->chef);
-                gtk_style_context_add_class (gtk_widget_get_style_context (tile->image), elem);
+                const char *path;
 
                 name = gr_chef_get_fullname (chef);
                 gtk_label_set_label (GTK_LABEL (tile->label), name);
+
+                path = gr_chef_get_image (chef);
+                if (path && path[0]) {
+                        g_autoptr(GdkPixbuf) pixbuf = NULL;
+
+                        pixbuf = load_pixbuf_fill_size (path, 64, 64);
+                        gtk_image_set_from_pixbuf (GTK_IMAGE (tile->image), pixbuf);
+                }
         }
 }
 


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