[gnome-software/wip/hughsie/drop-shadow] Don't apply drop shadow on stock symbolic icons
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/hughsie/drop-shadow] Don't apply drop shadow on stock symbolic icons
- Date: Mon, 15 Jul 2019 11:57:33 +0000 (UTC)
commit 659f205e0562264ba31188cfec0595447b04de8c
Author: Richard Hughes <richard hughsie com>
Date: Mon Jul 15 12:56:52 2019 +0100
Don't apply drop shadow on stock symbolic icons
Fixes https://gitlab.gnome.org/GNOME/gnome-software/issues/693
lib/gs-app.c | 27 +++++++++++++++++++++++++++
lib/gs-app.h | 1 +
src/gs-app-row.c | 5 +++++
src/gs-app-row.ui | 3 ---
4 files changed, 33 insertions(+), 3 deletions(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index 476ec62e..5f3c4798 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -1679,6 +1679,33 @@ gs_app_add_icon (GsApp *app, AsIcon *icon)
g_ptr_array_add (priv->icons, g_object_ref (icon));
}
+/**
+ * gs_app_get_use_drop_shadow:
+ * @app: a #GsApp
+ *
+ * Uses a heuristic to work out if the application pixbuf should have a drop
+ * shadow applied.
+ *
+ * Returns: %TRUE if a drop shadow should be applied
+ *
+ * Since: 3.34
+ **/
+gboolean
+gs_app_get_use_drop_shadow (GsApp *app)
+{
+ GsAppPrivate *priv = gs_app_get_instance_private (app);
+ AsIcon *ic;
+
+ /* guess */
+ if (priv->icons->len == 0)
+ return TRUE;
+
+ /* stock, and symbolic */
+ ic = g_ptr_array_index (priv->icons, 0);
+ return as_icon_get_kind (ic) != AS_ICON_KIND_STOCK ||
+ !g_str_has_suffix (as_icon_get_name (ic), "-symbolic");
+}
+
/**
* gs_app_get_agreement:
* @app: a #GsApp
diff --git a/lib/gs-app.h b/lib/gs-app.h
index 12cba966..6a67dcd5 100644
--- a/lib/gs-app.h
+++ b/lib/gs-app.h
@@ -283,6 +283,7 @@ void gs_app_set_pixbuf (GsApp *app,
GPtrArray *gs_app_get_icons (GsApp *app);
void gs_app_add_icon (GsApp *app,
AsIcon *icon);
+gboolean gs_app_get_use_drop_shadow (GsApp *app);
GFile *gs_app_get_local_file (GsApp *app);
void gs_app_set_local_file (GsApp *app,
GFile *local_file);
diff --git a/src/gs-app-row.c b/src/gs-app-row.c
index 5296fd62..fe1c9bd9 100644
--- a/src/gs-app-row.c
+++ b/src/gs-app-row.c
@@ -406,6 +406,11 @@ gs_app_row_refresh (GsAppRow *app_row)
else
gtk_style_context_remove_class (context, "dimmer-label");
+ if (gs_app_get_use_drop_shadow (priv->app))
+ gtk_style_context_add_class (context, "icon-dropshadow");
+ else
+ gtk_style_context_remove_class (context, "icon-dropshadow");
+
/* pending label */
switch (gs_app_get_state (priv->app)) {
case AS_APP_STATE_QUEUED_FOR_INSTALL:
diff --git a/src/gs-app-row.ui b/src/gs-app-row.ui
index 8499b2ad..7a59bcf1 100644
--- a/src/gs-app-row.ui
+++ b/src/gs-app-row.ui
@@ -25,9 +25,6 @@
<property name="pixel_size">64</property>
<property name="margin_start">24</property>
<property name="valign">center</property>
- <style>
- <class name="icon-dropshadow"/>
- </style>
</object>
</child>
<child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]