[gnome-photos] Change how the preview button for the currently active filter is marked



commit 6fffcb881c9ffe7e20f4c23b151f570930a686c3
Author: Jakub Steiner <jimmac gmail com>
Date:   Thu Jan 10 15:27:43 2019 +0100

    Change how the preview button for the currently active filter is marked
    
    Instead of shading the entire preview thumbnail, put a shadow around
    the overlaid object-select-symbolic icon, and re-colour the button with
    the theme's selection colour. As a nice side-effect, this replaces a
    lot of C code with a few lines of CSS and a custom style class.

 data/Adwaita.css                |   6 ++
 src/Makefile.am                 |   2 -
 src/meson.build                 |   1 -
 src/photos-tool-filter-button.c |  10 +-
 src/photos-widget-shader.c      | 220 ----------------------------------------
 src/photos-widget-shader.h      |  36 -------
 6 files changed, 9 insertions(+), 266 deletions(-)
---
diff --git a/data/Adwaita.css b/data/Adwaita.css
index 835996a1..0aeebb2d 100644
--- a/data/Adwaita.css
+++ b/data/Adwaita.css
@@ -45,3 +45,9 @@ GdMainIconView.content-view.cell:active {
     background-color: @photos_collection_bg;
     border-radius: 8px;
 }
+
+button.photos-filter-preview:checked {
+    background: @theme_selected_bg_color;
+    color: @theme_selected_fg_color;
+    -gtk-icon-shadow: 0 3px 3px shade(@theme_selected_bg_color,0.7);
+}
diff --git a/src/Makefile.am b/src/Makefile.am
index 744249e9..6e1969fe 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -336,8 +336,6 @@ gnome_photos_SOURCES = \
        photos-utils.h \
        photos-view-container.c \
        photos-view-container.h \
-       photos-widget-shader.c \
-       photos-widget-shader.h \
        photos-zoom-controls.c \
        photos-zoom-controls.h \
        photos-main.c \
diff --git a/src/meson.build b/src/meson.build
index 645b1d73..1ce52d06 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -219,7 +219,6 @@ sources = common_sources + files(
   'photos-update-mtime-job.c',
   'photos-utils.c',
   'photos-view-container.c',
-  'photos-widget-shader.c',
   'photos-zoom-controls.c',
   'photos-main.c',
 )
diff --git a/src/photos-tool-filter-button.c b/src/photos-tool-filter-button.c
index 11bf21bb..ab884768 100644
--- a/src/photos-tool-filter-button.c
+++ b/src/photos-tool-filter-button.c
@@ -26,7 +26,6 @@
 #include "photos-application.h"
 #include "photos-tool-filter-button.h"
 #include "photos-utils.h"
-#include "photos-widget-shader.h"
 
 
 struct _PhotosToolFilterButton
@@ -106,8 +105,8 @@ photos_tool_filter_button_constructed (GObject *object)
   PhotosToolFilterButton *self = PHOTOS_TOOL_FILTER_BUTTON (object);
   GApplication *app;
   g_autoptr (GdkPixbuf) preview_icon = NULL;
+  GtkStyleContext *context;
   GtkWidget *image;
-  PhotosWidgetShader *shader;
   cairo_surface_t *preview_icon_surface = NULL; /* TODO: use g_autoptr */
   gint scale;
 
@@ -121,7 +120,6 @@ photos_tool_filter_button_constructed (GObject *object)
 
   image = gtk_image_new_from_surface (preview_icon_surface);
   gtk_container_add (GTK_CONTAINER (self->overlay), image);
-  shader = photos_widget_shader_new (image);
   gtk_widget_show (image);
 
   self->button = gtk_radio_button_new_with_label_from_widget (self->group, self->label);
@@ -130,8 +128,9 @@ photos_tool_filter_button_constructed (GObject *object)
   gtk_button_set_image_position (GTK_BUTTON (self->button), GTK_POS_TOP);
   gtk_button_set_relief (GTK_BUTTON (self->button), GTK_RELIEF_NONE);
   gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (self->button), FALSE);
+  context = gtk_widget_get_style_context (self->button);
+  gtk_style_context_add_class (context, "photos-filter-preview");
   gtk_container_add (GTK_CONTAINER (self), self->button);
-  g_object_bind_property (self->button, "active", shader, "active", G_BINDING_SYNC_CREATE);
   g_signal_connect_swapped (self->button, "toggled", G_CALLBACK (photos_tool_filter_button_toggled), self);
   photos_tool_filter_button_toggled (self);
 
@@ -303,7 +302,6 @@ photos_tool_filter_button_set_active (PhotosToolFilterButton *self, gboolean is_
 void
 photos_tool_filter_button_set_image (PhotosToolFilterButton *self, GtkWidget *image)
 {
-  PhotosWidgetShader *shader;
   GtkWidget *old_image;
 
   old_image = gtk_bin_get_child (GTK_BIN (self->overlay));
@@ -312,7 +310,5 @@ photos_tool_filter_button_set_image (PhotosToolFilterButton *self, GtkWidget *im
 
   gtk_widget_destroy (old_image);
   gtk_container_add (GTK_CONTAINER (self->overlay), image);
-  shader = photos_widget_shader_new (image);
-  g_object_bind_property (self->button, "active", shader, "active", G_BINDING_SYNC_CREATE);
   gtk_widget_show (image);
 }


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