[nautilus/wip/antoniof/gtk4-preparation-drop-libgd: 1/8] list-view: Drop libgd usage




commit 4783d001b2fc50db85054ea9816fc9d56c7eb311
Author: António Fernandes <antoniof gnome org>
Date:   Mon Nov 1 10:28:05 2021 +0000

    list-view: Drop libgd usage
    
    We want the text of all columns to be dimmed, except for the filename
    column. For that purpose, we use GdStyledTextRenderer, which extends
    GtkCellRendererText with support for CSS classes.
    
    However, it can't actually use the standard .dim-label style, because
    opacity is ignored, so we end up shipping an ugly css hack instead.
    
    Also, GTK 4 makes GtkCellRendererText a final class, which should not
    be subclassed.
    
    So, achieve the desired result using pango alpha attribute, which
    actually works well. (Note the final color is slightly different, but
    it's actually more faithful to the dim-label style class, so I
    believe it to be an improvement; it can be tweaked later in any case.)

 src/nautilus-list-view.c      | 16 ++++++++--------
 src/resources/css/Adwaita.css |  6 ++----
 2 files changed, 10 insertions(+), 12 deletions(-)
---
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 0ee93f640..6b6d20e9c 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -30,7 +30,6 @@
 #include <gdk/gdkkeysyms.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
-#include <libgd/gd.h>
 #include <string.h>
 
 #define DEBUG_FLAG NAUTILUS_DEBUG_LIST_VIEW
@@ -2338,18 +2337,19 @@ create_and_set_up_tree_view (NautilusListView *view)
             }
             else
             {
-                /* We need to use libgd */
-                cell = gd_styled_text_renderer_new ();
-                /* FIXME: should be just dim-label.
-                 * See https://bugzilla.gnome.org/show_bug.cgi?id=744397
-                 */
-                gd_styled_text_renderer_add_class (GD_STYLED_TEXT_RENDERER (cell),
-                                                   "nautilus-list-dim-label");
+                PangoAttrList *attr_list = pango_attr_list_new ();
+                const guint16 alpha_55_percent = (guint16)(0.55 * 0xffff);
+
+                cell = gtk_cell_renderer_text_new ();
 
                 column = gtk_tree_view_column_new_with_attributes (label,
                                                                    cell,
                                                                    "text", column_num,
                                                                    NULL);
+
+                pango_attr_list_insert (attr_list, pango_attr_foreground_alpha_new (alpha_55_percent));
+                g_object_set (cell, "attributes", attr_list, NULL);
+                pango_attr_list_unref (attr_list);
             }
 
             gtk_tree_view_column_set_alignment (column, xalign);
diff --git a/src/resources/css/Adwaita.css b/src/resources/css/Adwaita.css
index 68c3e424c..726f4e76b 100644
--- a/src/resources/css/Adwaita.css
+++ b/src/resources/css/Adwaita.css
@@ -12,13 +12,11 @@
     border-radius: 5px;
 }
 
-.nautilus-canvas-item.dim-label,
-.nautilus-list-dim-label {
+.nautilus-canvas-item.dim-label {
     color: mix (@theme_fg_color, @theme_bg_color, 0.50);
 }
 
-.nautilus-canvas-item.dim-label:selected,
-.nautilus-list-dim-label:selected {
+.nautilus-canvas-item.dim-label:selected {
     color: mix (@theme_selected_fg_color, @theme_selected_bg_color, 0.20);
 }
 


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