[gnome-shell-extensions/wip/fmuellner/cleanups: 3/15] user-theme: Don't use concatenation to build filenames



commit 194e294d2c487df69a6023a25c923baac35266b6
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Jan 28 00:04:40 2019 +0100

    user-theme: Don't use concatenation to build filenames
    
    Since template strings were added in ES6, string concatenation is
    considered bad style. There's a catch though: xgettext currently
    has a nasty bug concerning the combination of backticks and slashes.
    Avoid that issue by building filenames with the corresponding GLib
    helper function.
    
    https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/49

 extensions/user-theme/extension.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/extensions/user-theme/extension.js b/extensions/user-theme/extension.js
index e0c2d57..a3e382b 100644
--- a/extensions/user-theme/extension.js
+++ b/extensions/user-theme/extension.js
@@ -36,7 +36,9 @@ class ThemeManager {
         let _themeName = this._settings.get_string(SETTINGS_KEY);
 
         if (_themeName) {
-            let _userCssStylesheet = GLib.get_home_dir() + '/.themes/' + _themeName + 
'/gnome-shell/gnome-shell.css';
+            let _userCssStylesheet = GLib.build_filenamev([
+                GLib.get_home_dir(), '.themes', _themeName, 'gnome-shell', 'gnome-shell.css'
+            ]);
             let file = Gio.file_new_for_path(_userCssStylesheet);
             if (file.query_exists(null))
                 _stylesheet = _userCssStylesheet;
@@ -44,7 +46,9 @@ class ThemeManager {
                 let sysdirs = GLib.get_system_data_dirs();
                 sysdirs.unshift(GLib.get_user_data_dir());
                 for (let i = 0; i < sysdirs.length; i++) {
-                    _userCssStylesheet = sysdirs[i] + '/themes/' + _themeName + 
'/gnome-shell/gnome-shell.css';
+                    _userCssStylesheet = GLib.build_filenamev([
+                        sysdirs[i], 'themes', _themeName, 'gnome-shell', 'gnome-shell.css'
+                    ]);
                     let file = Gio.file_new_for_path(_userCssStylesheet);
                     if (file.query_exists(null)) {
                         _stylesheet = _userCssStylesheet;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]