[nautilus/wip/antoniof/gtk4-preparation-drop-libgd: 6/11] list-view: Drop libgd usage
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/gtk4-preparation-drop-libgd: 6/11] list-view: Drop libgd usage
- Date: Sun, 26 Dec 2021 18:12:44 +0000 (UTC)
commit 7b251f09455ff72a65ee811bba3ca9f112abcc6d
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 | 6 ++----
2 files changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index b8248e0bc..23619e57b 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);
@@ -2230,18 +2232,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 03acabd4a..4bc40e21b 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]