Skip to content

Commit 0bfc2dd

Browse files
committed
nemo-desktop: Allow adjustment to label shadow.
Add two settings: - desktop-text-shadow: Three levels of shadow (normal, darker, darkest) - normal being the traditional amount. - desktop-text-shadow-use-theme: If true, and if the theme supports it, allow the GTK theme to control desktop style, including text shadow. Nemo has always checked for theme support at startup and during theme changes, to ensure custom widgets/features worked correctly for users (such as inactive-pane shading). We add another check for 'nemo-desktop' there. If the theme lacks any support, nemo provides it like before, using the shadow-level setting.
1 parent 2e5ad2c commit 0bfc2dd

8 files changed

Lines changed: 401 additions & 9 deletions

File tree

eel/eel-theme-utils.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "eel-string.h"
33

44
static GtkCssProvider *mandatory_css_provider = NULL;
5+
static gboolean theme_has_desktop_support = FALSE;
56

67
static gboolean
78
css_provider_load_from_resource (GtkCssProvider *provider,
@@ -96,8 +97,6 @@ add_fallback_mandatory_css_provider (const gchar *theme_name)
9697
goto out;
9798
}
9899

99-
/* Our fallback uses @theme_ prefixed names for colors. If the active theme does also, skip
100-
* to apply */
101100
if (g_strstr_len (css, -1, "theme_selected_bg_color")) {
102101
final_fallback_css = g_strdup (init_fallback_css);
103102

@@ -126,6 +125,7 @@ add_fallback_mandatory_css_provider (const gchar *theme_name)
126125
if (error) {
127126
g_warning ("Failed to create a fallback provider: %s", error->message);
128127
g_clear_error (&error);
128+
g_clear_object (&mandatory_css_provider);
129129
goto out;
130130
}
131131

@@ -174,6 +174,20 @@ is_known_supported_theme (const gchar *theme_name)
174174
return ret;
175175
}
176176

177+
static void
178+
check_desktop_support (const gchar *theme_name)
179+
{
180+
GtkCssProvider *provider;
181+
gchar *css;
182+
183+
provider = gtk_css_provider_get_named (theme_name, NULL);
184+
css = gtk_css_provider_to_string (provider);
185+
186+
theme_has_desktop_support = (g_strstr_len (css, -1, "nemo-desktop") != NULL);
187+
188+
g_free (css);
189+
}
190+
177191
static void
178192
process_theme (GtkSettings *gtk_settings)
179193
{
@@ -194,13 +208,28 @@ process_theme (GtkSettings *gtk_settings)
194208
add_fallback_mandatory_css_provider (theme_name);
195209
}
196210

211+
check_desktop_support (theme_name);
212+
197213
gtk_style_context_reset_widgets (gdk_screen_get_default ());
198214
g_free (theme_name);
199215
}
200216

217+
gboolean
218+
eel_theme_utils_theme_supports_desktop (void)
219+
{
220+
return theme_has_desktop_support;
221+
}
222+
201223
void
202224
eel_theme_utils_init_styles (void)
203225
{
226+
static gboolean initialized = FALSE;
227+
228+
if (initialized)
229+
return;
230+
231+
initialized = TRUE;
232+
204233
add_css_provider_at_priority ("/org/nemo/nemo-style-fallback.css",
205234
GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);
206235

eel/eel-theme-utils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <gtk/gtk.h>
55

6-
void eel_theme_utils_init_styles (void);
6+
void eel_theme_utils_init_styles (void);
7+
gboolean eel_theme_utils_theme_supports_desktop (void);
78

89
#endif /* EEL_THEME_UTILS_H */

gresources/nemo-desktop-preferences.glade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@
516516
<object class="GtkFrame">
517517
<property name="visible">True</property>
518518
<property name="can_focus">False</property>
519-
<property name="margin_bottom">2</property>
519+
<property name="margin_bottom">10</property>
520520
<property name="label_xalign">0</property>
521521
<property name="label_yalign">0</property>
522522
<property name="shadow_type">in</property>

gresources/nemo-style-application.css

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,57 @@ NemoDesktopWindow GtkPaned {
2323
-NemoIconContainer-activate-prelight-icon-label: true;
2424
}
2525

26-
.nemo-desktop.nemo-canvas-item {
26+
/* Shadow variant: Normal (traditional nemo default) */
27+
.nemo-desktop.nemo-canvas-item.shadow-normal {
2728
color: #eeeeee;
2829
text-shadow: 1px 1px alpha(black, 0.8);
2930
}
3031

31-
.nemo-desktop.nemo-canvas-item:hover {
32+
/* Shadow variant: Darker */
33+
.nemo-desktop.nemo-canvas-item.shadow-darker {
34+
color: #eeeeee;
35+
text-shadow: 1px 1px black;
36+
}
37+
38+
/* Shadow variant: Darkest */
39+
.nemo-desktop.nemo-canvas-item.shadow-darkest {
40+
color: #eeeeee;
41+
text-shadow: 1px 1px black, 1px 0px alpha(black, 0.6), 0px 1px alpha(black, 0.6);
42+
}
43+
44+
/* Hover for shadow modes */
45+
.nemo-desktop.nemo-canvas-item.shadow-normal:hover,
46+
.nemo-desktop.nemo-canvas-item.shadow-darker:hover,
47+
.nemo-desktop.nemo-canvas-item.shadow-darkest:hover {
3248
background-color: alpha(black, 0.5);
3349
background-image: none;
3450
text-shadow: none;
3551
}
3652

37-
.nemo-desktop.nemo-canvas-item:selected {
53+
/* Selected for shadow modes */
54+
.nemo-desktop.nemo-canvas-item.shadow-normal:selected,
55+
.nemo-desktop.nemo-canvas-item.shadow-darker:selected,
56+
.nemo-desktop.nemo-canvas-item.shadow-darkest:selected {
3857
background-color: alpha(@theme_selected_bg_color, 0.8);
3958
background-image: none;
4059
text-shadow: none;
4160
color: #f5f5f5;
4261
}
4362

63+
/* "Use current theme" hover/selected — provide highlight feedback
64+
without forcing text color or shadow. Lower specificity (2 classes)
65+
than shadow variants above (3 classes), so only applies when no
66+
shadow class is set. */
67+
.nemo-desktop.nemo-canvas-item:hover {
68+
background-color: alpha(black, 0.5);
69+
background-image: none;
70+
}
71+
72+
.nemo-desktop.nemo-canvas-item:selected {
73+
background-color: alpha(@theme_selected_bg_color, 0.8);
74+
background-image: none;
75+
}
76+
4477
/* EelEditableLabel (icon labels) */
4578
.nemo-desktop.view .entry,
4679
.nemo-desktop.view .entry:active,

0 commit comments

Comments
 (0)