[gnome-software/wip/hughsie/category-colorful] Remove the now-unused code that supported the colorful category buttons



commit e4ced0a688f9f85b1017445674a210e416b8580a
Author: Richard Hughes <richard hughsie com>
Date:   Mon Jan 13 18:16:55 2020 +0000

    Remove the now-unused code that supported the colorful category buttons

 lib/gs-category.c                           | 39 --------------------
 lib/gs-category.h                           |  3 --
 plugins/core/gs-desktop-common.c            | 20 +++++------
 plugins/core/gs-desktop-common.h            |  1 -
 plugins/core/gs-plugin-desktop-categories.c |  3 --
 src/gs-category-tile.c                      | 55 -----------------------------
 src/gs-category-tile.h                      |  3 --
 src/gs-overview-page.c                      |  1 -
 8 files changed, 10 insertions(+), 115 deletions(-)
---
diff --git a/lib/gs-category.c b/lib/gs-category.c
index dc16a9f0..5ff4051e 100644
--- a/lib/gs-category.c
+++ b/lib/gs-category.c
@@ -29,7 +29,6 @@ struct _GsCategory
        gchar           *name;
        gchar           *icon;
        gint             score;
-       GPtrArray       *key_colors;
        GPtrArray       *desktop_groups;
        GsCategory      *parent;
        guint            size;
@@ -66,8 +65,6 @@ gs_category_to_string (GsCategory *category)
        }
        g_string_append_printf (str, "  size: %u\n",
                                category->size);
-       g_string_append_printf (str, "  key-colors: %u\n",
-                               category->key_colors->len);
        g_string_append_printf (str, "  desktop-groups: %u\n",
                                category->desktop_groups->len);
        if (category->parent != NULL) {
@@ -288,40 +285,6 @@ gs_category_set_score (GsCategory *category, gint score)
        category->score = score;
 }
 
-/**
- * gs_category_get_key_colors:
- * @category: a #GsCategory
- *
- * Gets the list of key colors for the category.
- *
- * Returns: (element-type GdkRGBA) (transfer none): An array
- *
- * Since: 3.22
- **/
-GPtrArray *
-gs_category_get_key_colors (GsCategory *category)
-{
-       g_return_val_if_fail (GS_IS_CATEGORY (category), NULL);
-       return category->key_colors;
-}
-
-/**
- * gs_category_add_key_color:
- * @category: a #GsCategory
- * @key_color: a #GdkRGBA
- *
- * Adds a key color to the category.
- *
- * Since: 3.22
- **/
-void
-gs_category_add_key_color (GsCategory *category, const GdkRGBA *key_color)
-{
-       g_return_if_fail (GS_IS_CATEGORY (category));
-       g_return_if_fail (key_color != NULL);
-       g_ptr_array_add (category->key_colors, gdk_rgba_copy (key_color));
-}
-
 /**
  * gs_category_get_desktop_groups:
  * @category: a #GsCategory
@@ -521,7 +484,6 @@ gs_category_finalize (GObject *object)
                g_object_remove_weak_pointer (G_OBJECT (category->parent),
                                              (gpointer *) &category->parent);
        g_ptr_array_unref (category->children);
-       g_ptr_array_unref (category->key_colors);
        g_ptr_array_unref (category->desktop_groups);
        g_free (category->id);
        g_free (category->name);
@@ -541,7 +503,6 @@ static void
 gs_category_init (GsCategory *category)
 {
        category->children = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
-       category->key_colors = g_ptr_array_new_with_free_func ((GDestroyNotify) gdk_rgba_free);
        category->desktop_groups = g_ptr_array_new_with_free_func (g_free);
 }
 
diff --git a/lib/gs-category.h b/lib/gs-category.h
index 0dad2e9b..b1588939 100644
--- a/lib/gs-category.h
+++ b/lib/gs-category.h
@@ -31,9 +31,6 @@ void           gs_category_set_icon           (GsCategory     *category,
 gint            gs_category_get_score          (GsCategory     *category);
 void            gs_category_set_score          (GsCategory     *category,
                                                 gint            score);
-GPtrArray      *gs_category_get_key_colors     (GsCategory     *category);
-void            gs_category_add_key_color      (GsCategory     *category,
-                                                const GdkRGBA  *key_color);
 
 GPtrArray      *gs_category_get_desktop_groups (GsCategory     *category);
 gboolean        gs_category_has_desktop_group  (GsCategory     *category,
diff --git a/plugins/core/gs-desktop-common.c b/plugins/core/gs-desktop-common.c
index f2c09222..17ed029d 100644
--- a/plugins/core/gs-desktop-common.c
+++ b/plugins/core/gs-desktop-common.c
@@ -297,34 +297,34 @@ static const GsDesktopMap map_reference[] = {
 static const GsDesktopData msdata[] = {
        /* TRANSLATORS: this is the menu spec main category for Audio & Video */
        { "audio-video",        map_audiovisual,        N_("Audio & Video"),
-                               "folder-music-symbolic", "#215d9c", 100 },
+                               "folder-music-symbolic", 100 },
        /* TRANSLATORS: this is the menu spec main category for Development */
        { "developer-tools",    map_developertools,     N_("Developer Tools"),
-                               "applications-engineering-symbolic", "#d3d7c7", 40 },
+                               "applications-engineering-symbolic", 40 },
        /* TRANSLATORS: this is the menu spec main category for Education & Science */
        { "education-science",          map_education_science,  N_("Education & Science"),
-                               "system-help-symbolic", "#d3d7c7", 30 },
+                               "system-help-symbolic", 30 },
        /* TRANSLATORS: this is the menu spec main category for Game */
        { "games",              map_games,              N_("Games"),
-                               "applications-games-symbolic", "#c4a000", 70 },
+                               "applications-games-symbolic", 70 },
        /* TRANSLATORS: this is the menu spec main category for Graphics */
        { "graphics",           map_graphics,           N_("Graphics & Photography"),
-                               "applications-graphics-symbolic", "#75507b", 60 },
+                               "applications-graphics-symbolic", 60 },
        /* TRANSLATORS: this is the menu spec main category for Office */
        { "productivity",       map_productivity,       N_("Productivity"),
-                               "text-editor-symbolic", "#cc0000", 80 },
+                               "text-editor-symbolic", 80 },
        /* TRANSLATORS: this is the menu spec main category for Add-ons */
        { "addons",             map_addons,             N_("Add-ons"),
-                               "application-x-addon-symbolic", "#4e9a06", 50 },
+                               "application-x-addon-symbolic", 50 },
        /* TRANSLATORS: this is the menu spec main category for Communication */
        { "communication",      map_communication,      N_("Communication & News"),
-                               "user-available-symbolic", "#729fcf", 90 },
+                               "user-available-symbolic", 90 },
        /* TRANSLATORS: this is the menu spec main category for Reference */
        { "reference",          map_reference,          N_("Reference"),
-                               "view-dual-symbolic", "#d3d7c7", 0 },
+                               "view-dual-symbolic", 0 },
        /* TRANSLATORS: this is the menu spec main category for Utilities */
        { "utilities",          map_utilities,          N_("Utilities"),
-                               "applications-utilities-symbolic", "#d3d7c7", 10 },
+                               "applications-utilities-symbolic", 10 },
        { NULL }
 };
 
diff --git a/plugins/core/gs-desktop-common.h b/plugins/core/gs-desktop-common.h
index 6fde5025..6da04dbb 100644
--- a/plugins/core/gs-desktop-common.h
+++ b/plugins/core/gs-desktop-common.h
@@ -22,7 +22,6 @@ typedef struct {
        const GsDesktopMap *mapping;
        const gchar     *name;
        const gchar     *icon;
-       const gchar     *key_colors;
        gint             score;
 } GsDesktopData;
 
diff --git a/plugins/core/gs-plugin-desktop-categories.c b/plugins/core/gs-plugin-desktop-categories.c
index d6a1686b..7e6ff51c 100644
--- a/plugins/core/gs-plugin-desktop-categories.c
+++ b/plugins/core/gs-plugin-desktop-categories.c
@@ -37,7 +37,6 @@ gs_plugin_add_categories (GsPlugin *plugin,
 
        msdata = gs_desktop_get_data ();
        for (i = 0; msdata[i].id != NULL; i++) {
-               GdkRGBA key_color;
                GsCategory *category;
                g_autofree gchar *msgctxt = NULL;
 
@@ -46,8 +45,6 @@ gs_plugin_add_categories (GsPlugin *plugin,
                gs_category_set_icon (category, msdata[i].icon);
                gs_category_set_name (category, gettext (msdata[i].name));
                gs_category_set_score (category, msdata[i].score);
-               if (gdk_rgba_parse (&key_color, msdata[i].key_colors))
-                       gs_category_add_key_color (category, &key_color);
                g_ptr_array_add (list, category);
                msgctxt = g_strdup_printf ("Menu of %s", msdata[i].name);
 
diff --git a/src/gs-category-tile.c b/src/gs-category-tile.c
index 8788607b..14de7438 100644
--- a/src/gs-category-tile.c
+++ b/src/gs-category-tile.c
@@ -10,9 +10,6 @@
 #include "gs-category-tile.h"
 #include "gs-common.h"
 
-#define COLORFUL_TILE_CLASS "colorful"
-#define COLORFUL_TILE_PROVIDER_KEY "GnomeSoftware::colorful-tile-provider"
-
 struct _GsCategoryTile
 {
        GtkButton        parent_instance;
@@ -20,7 +17,6 @@ struct _GsCategoryTile
        GsCategory      *cat;
        GtkWidget       *label;
        GtkWidget       *image;
-       gboolean         colorful;
 };
 
 G_DEFINE_TYPE (GsCategoryTile, gs_category_tile, GTK_TYPE_BUTTON)
@@ -36,48 +32,12 @@ gs_category_tile_get_category (GsCategoryTile *tile)
 static void
 gs_category_tile_refresh (GsCategoryTile *tile)
 {
-       GPtrArray *key_colors;
-       GtkStyleContext *context;
-
-       /* get the style context */
-       context = gtk_widget_get_style_context (GTK_WIDGET (tile));
-
        /* set labels */
        gtk_label_set_label (GTK_LABEL (tile->label),
                             gs_category_get_name (tile->cat));
        gtk_image_set_from_icon_name (GTK_IMAGE (tile->image),
                                      gs_category_get_icon (tile->cat),
                                      GTK_ICON_SIZE_MENU);
-
-       /* set custom CSS for colorful tiles */
-       key_colors = gs_category_get_key_colors (tile->cat);
-       if (tile->colorful && key_colors->len > 0) {
-               GdkRGBA *tmp = g_ptr_array_index (key_colors, 0);
-               g_autoptr(GtkCssProvider) provider = NULL;
-               g_autofree gchar *css = NULL;
-               g_autofree gchar *color = gdk_rgba_to_string (tmp);
-
-               css = g_strdup_printf ("@define-color gs_tile_color %s;", color);
-
-               provider = gtk_css_provider_new ();
-               gtk_css_provider_load_from_data (provider, css, -1, NULL);
-
-               gtk_style_context_add_class (context, COLORFUL_TILE_CLASS);
-               gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (provider),
-                                               GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-
-               g_object_set_data_full (G_OBJECT (tile),
-                                       COLORFUL_TILE_PROVIDER_KEY,
-                                       g_object_ref (provider),
-                                       g_object_unref);
-       } else {
-               GtkStyleProvider *provider = g_object_get_data (G_OBJECT (tile),
-                                                               COLORFUL_TILE_PROVIDER_KEY);
-               if (provider) {
-                       gtk_style_context_remove_class (context, COLORFUL_TILE_CLASS);
-                       gtk_style_context_remove_provider (context, provider);
-               }
-       }
 }
 
 void
@@ -90,21 +50,6 @@ gs_category_tile_set_category (GsCategoryTile *tile, GsCategory *cat)
        gs_category_tile_refresh (tile);
 }
 
-gboolean
-gs_category_tile_get_colorful (GsCategoryTile *tile)
-{
-       g_return_val_if_fail (GS_IS_CATEGORY_TILE (tile), FALSE);
-       return tile->colorful;
-}
-
-void
-gs_category_tile_set_colorful (GsCategoryTile *tile, gboolean colorful)
-{
-       g_return_if_fail (GS_IS_CATEGORY_TILE (tile));
-       tile->colorful = colorful;
-       gs_category_tile_refresh (tile);
-}
-
 static void
 gs_category_tile_destroy (GtkWidget *widget)
 {
diff --git a/src/gs-category-tile.h b/src/gs-category-tile.h
index 3d2fdd73..0904f54d 100644
--- a/src/gs-category-tile.h
+++ b/src/gs-category-tile.h
@@ -21,8 +21,5 @@ GtkWidget     *gs_category_tile_new                   (GsCategory *cat);
 GsCategory      *gs_category_tile_get_category         (GsCategoryTile *tile);
 void            gs_category_tile_set_category          (GsCategoryTile *tile,
                                                         GsCategory     *cat);
-gboolean        gs_category_tile_get_colorful          (GsCategoryTile *tile);
-void            gs_category_tile_set_colorful          (GsCategoryTile *tile,
-                                                        gboolean        colorful);
 
 G_END_DECLS
diff --git a/src/gs-overview-page.c b/src/gs-overview-page.c
index a3720462..f4584437 100644
--- a/src/gs-overview-page.c
+++ b/src/gs-overview-page.c
@@ -537,7 +537,6 @@ gs_overview_page_get_categories_cb (GObject *source_object,
                tile = gs_category_tile_new (cat);
                g_signal_connect (tile, "clicked",
                                  G_CALLBACK (category_tile_clicked), self);
-               gs_category_tile_set_colorful (GS_CATEGORY_TILE (tile), TRUE);
                flowbox = GTK_FLOW_BOX (priv->flowbox_categories);
                gtk_flow_box_insert (flowbox, tile, -1);
                gtk_widget_set_can_focus (gtk_widget_get_parent (tile), FALSE);


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