[nautilus/gtk4-preparation-trunk: 13/64] list-view: Drop libgd usage
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/gtk4-preparation-trunk: 13/64] list-view: Drop libgd usage
- Date: Thu, 23 Dec 2021 02:10:15 +0000 (UTC)
commit 48367c38611c0a4277639b24633373651482f9c4
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 | 18 ++++++++++--------
src/resources/css/Adwaita.css | 8 --------
2 files changed, 10 insertions(+), 16 deletions(-)
---
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 8ab527624..242a45490 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
@@ -78,6 +77,9 @@ struct SelectionForeachData
/* We wait two seconds after row is collapsed to unload the subdirectory */
#define COLLAPSE_TO_UNLOAD_DELAY 2
+/* According to Pango docs, alpha is a guint16 value between 0 and 65535. */
+#define ALPHA_55_PERCENT ((guint16) (0.55 * 0xffff))
+
static GdkCursor *hand_cursor = NULL;
static GList *nautilus_list_view_get_selection (NautilusFilesView *view);
@@ -2211,18 +2213,18 @@ 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 ();
+
+ 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 65800eed2..7d82463d4 100644
--- a/src/resources/css/Adwaita.css
+++ b/src/resources/css/Adwaita.css
@@ -8,14 +8,6 @@
opacity: 0.50;
}
-.nautilus-list-dim-label {
- color: mix (@theme_fg_color, @theme_bg_color, 0.50);
-}
-
-.nautilus-list-dim-label:selected {
- color: mix (@theme_selected_fg_color, @theme_selected_bg_color, 0.20);
-}
-
/* Toolbar */
/* Here we use the .button background-image colors from Adwaita, but ligthen them,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]