@@ -69,23 +69,14 @@ static void detectGTKFromDConf(FFinstance* instance, FFGTKResult* result)
6969 cursorTheme = ffSettingsGet (instance , "/org/mate/peripherals-mouse/cursor-theme" , "org.mate.peripherals-mouse" , NULL , "cursor-theme" , FF_VARIANT_TYPE_STRING ).strValue ;
7070 cursorSize = ffSettingsGet (instance , "/org/mate/peripherals-mouse/cursor-size" , "org.mate.peripherals-mouse" , NULL , "cursor-size" , FF_VARIANT_TYPE_INT ).intValue ;
7171 }
72-
73- //Fallback + Gnome impl
74-
75- if (themeName == NULL )
72+ else if (ffStrbufIgnCaseCompS (& wmde -> dePrettyName , "Gnome" ) == 0 )
73+ {
7674 themeName = ffSettingsGet (instance , "/org/gnome/desktop/interface/gtk-theme" , "org.gnome.desktop.interface" , NULL , "gtk-theme" , FF_VARIANT_TYPE_STRING ).strValue ;
77-
78- if (iconsName == NULL )
7975 iconsName = ffSettingsGet (instance , "/org/gnome/desktop/interface/icon-theme" , "org.gnome.desktop.interface" , NULL , "icon-theme" , FF_VARIANT_TYPE_STRING ).strValue ;
80-
81- if (fontName == NULL )
8276 fontName = ffSettingsGet (instance , "/org/gnome/desktop/interface/font-name" , "org.gnome.desktop.interface" , NULL , "font-name" , FF_VARIANT_TYPE_STRING ).strValue ;
83-
84- if (cursorTheme == NULL )
8577 cursorTheme = ffSettingsGet (instance , "/org/gnome/desktop/interface/cursor-theme" , "org.gnome.desktop.interface" , NULL , "cursor-theme" , FF_VARIANT_TYPE_STRING ).strValue ;
86-
87- if (cursorSize <= 0 )
8878 cursorSize = ffSettingsGet (instance , "/org/gnome/desktop/interface/cursor-size" , "org.gnome.desktop.interface" , NULL , "cursor-size" , FF_VARIANT_TYPE_INT ).intValue ;
79+ }
8980
9081 pthread_mutex_unlock (& mutex );
9182 applyGTKDConfSettings (result , themeName , iconsName , fontName , cursorTheme , cursorSize );
@@ -146,41 +137,8 @@ static void detectGTKFromConfigDir(FFstrbuf* configDir, const char* version, FFG
146137 ffStrbufSubstrBefore (configDir , configDirLength );
147138}
148139
149- static void detectGTK (FFinstance * instance , const char * version , const char * envVariable , FFGTKResult * result )
140+ static void detectGTK (FFinstance * instance , const char * version , FFGTKResult * result )
150141{
151- FFstrbuf buffer ;
152- ffStrbufInitA (& buffer , 128 );
153-
154- // From ENV: GTK*_RC_FILES
155-
156- ffStrbufSetS (& buffer , getenv (envVariable ));
157- uint32_t startIndex = 0 ;
158- while (startIndex < buffer .length )
159- {
160- uint32_t colonIndex = ffStrbufNextIndexC (& buffer , startIndex , ':' );
161- buffer .chars [colonIndex ] = '\0' ;
162-
163- detectGTKFromConfigFile (buffer .chars + startIndex , result );
164- if (allPropertiesSet (result ))
165- {
166- ffStrbufDestroy (& buffer );
167- return ;
168- }
169-
170- startIndex = colonIndex + 1 ;
171- }
172-
173- //From DConf / GSettings
174-
175- detectGTKFromDConf (instance , result );
176- if (allPropertiesSet (result ))
177- {
178- ffStrbufDestroy (& buffer );
179- return ;
180- }
181-
182- //From config dirs
183-
184142 //We need to do this because we use multiple threads on configDirs
185143 FFstrbuf baseDirCopy ;
186144 ffStrbufInitA (& baseDirCopy , 64 );
@@ -191,14 +149,20 @@ static void detectGTK(FFinstance* instance, const char* version, const char* env
191149 ffStrbufSet (& baseDirCopy , baseDir );
192150 detectGTKFromConfigDir (& baseDirCopy , version , result );
193151 if (allPropertiesSet (result ))
194- break ;
152+ {
153+ ffStrbufDestroy (& baseDirCopy );
154+ return ;
155+ }
195156 }
196157
197158 ffStrbufDestroy (& baseDirCopy );
198- ffStrbufDestroy (& buffer );
159+
160+ //Mate, Cinnamon and Gnome use dconf to save theme config
161+ //On other DEs, this will do nothing
162+ detectGTKFromDConf (instance , result );
199163}
200164
201- #define FF_CALCULATE_GTK_IMPL (version ) \
165+ #define FF_DETECT_GTK_IMPL (version ) \
202166 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; \
203167 static FFGTKResult result; \
204168 static bool init = false; \
@@ -213,23 +177,23 @@ static void detectGTK(FFinstance* instance, const char* version, const char* env
213177 ffStrbufInit(&result.font); \
214178 ffStrbufInit(&result.cursor); \
215179 ffStrbufInit(&result.cursorSize); \
216- detectGTK(instance, #version, "GTK"#version"_RC_FILES", &result); \
180+ detectGTK(instance, #version, &result); \
217181 pthread_mutex_unlock(&mutex); \
218182 return &result;
219183
220184const FFGTKResult * ffDetectGTK2 (FFinstance * instance )
221185{
222- FF_CALCULATE_GTK_IMPL (2 )
186+ FF_DETECT_GTK_IMPL (2 )
223187}
224188
225189const FFGTKResult * ffDetectGTK3 (FFinstance * instance )
226190{
227- FF_CALCULATE_GTK_IMPL (3 )
191+ FF_DETECT_GTK_IMPL (3 )
228192}
229193
230194const FFGTKResult * ffDetectGTK4 (FFinstance * instance )
231195{
232- FF_CALCULATE_GTK_IMPL (4 )
196+ FF_DETECT_GTK_IMPL (4 )
233197}
234198
235199#undef FF_CALCULATE_GTK_IMPL
0 commit comments