Skip to content

Commit f654820

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 f654820

8 files changed

Lines changed: 395 additions & 7 deletions

File tree

eel/eel-theme-utils.c

Lines changed: 30 additions & 0 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,
@@ -174,6 +175,20 @@ is_known_supported_theme (const gchar *theme_name)
174175
return ret;
175176
}
176177

178+
static void
179+
check_desktop_support (const gchar *theme_name)
180+
{
181+
GtkCssProvider *provider;
182+
gchar *css;
183+
184+
provider = gtk_css_provider_get_named (theme_name, NULL);
185+
css = gtk_css_provider_to_string (provider);
186+
187+
theme_has_desktop_support = (g_strstr_len (css, -1, "nemo-desktop") != NULL);
188+
189+
g_free (css);
190+
}
191+
177192
static void
178193
process_theme (GtkSettings *gtk_settings)
179194
{
@@ -194,13 +209,28 @@ process_theme (GtkSettings *gtk_settings)
194209
add_fallback_mandatory_css_provider (theme_name);
195210
}
196211

212+
check_desktop_support (theme_name);
213+
197214
gtk_style_context_reset_widgets (gdk_screen_get_default ());
198215
g_free (theme_name);
199216
}
200217

218+
gboolean
219+
eel_theme_utils_theme_supports_desktop (void)
220+
{
221+
return theme_has_desktop_support;
222+
}
223+
201224
void
202225
eel_theme_utils_init_styles (void)
203226
{
227+
static gboolean initialized = FALSE;
228+
229+
if (initialized)
230+
return;
231+
232+
initialized = TRUE;
233+
204234
add_css_provider_at_priority ("/org/nemo/nemo-style-fallback.css",
205235
GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);
206236

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)