diff --git a/lib/constants.dart b/lib/constants.dart index 28ee24f..8de7162 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -62,6 +62,7 @@ const _webDirPath = 'web'; // ? Linux const _linuxDirPath = 'linux'; +const _linuxRunnerDirPath = '$_linuxDirPath/runner'; // ? Windows const _windowsDirPath = 'windows'; @@ -101,6 +102,8 @@ const _webManifestFilePath = '$_webDirPath/$_manifestJsonFileName'; // ? Linux const _linuxCMakeListsFilePath = '$_linuxDirPath/$_cMakeListsFileName'; const _linuxMyApplicationFilePath = '$_linuxDirPath/$_myApplicationFileName'; +const _linuxRunnerMyApplicationFilePath = + '$_linuxRunnerDirPath/$_myApplicationFileName'; // ? Windows const _windowsCMakeListsFilePath = '$_windowsDirPath/$_cMakeListsFileName'; diff --git a/lib/messages.dart b/lib/messages.dart index 208d957..f5803f5 100644 --- a/lib/messages.dart +++ b/lib/messages.dart @@ -115,9 +115,9 @@ const _linuxCMakeListsNotFoundMessage = ''' '''; const _linuxMyApplicationNotFoundMessage = ''' -╔══════════════════════════════════════════════╗ -║ my_application.cc not found in `linux/`. ║ -╚══════════════════════════════════════════════╝ +╔══════════════════════════════════════════════════════════════════╗ +║ my_application.cc not found in `linux/` and `linux/runner/`. ║ +╚══════════════════════════════════════════════════════════════════╝ '''; const _invalidWindowsConfigMessage = ''' diff --git a/lib/platforms/linux.dart b/lib/platforms/linux.dart index 903f16e..10118ac 100644 --- a/lib/platforms/linux.dart +++ b/lib/platforms/linux.dart @@ -30,22 +30,43 @@ void _setLinuxAppName(dynamic appName) { if (appName is! String) throw _PackageRenameErrors.invalidAppName; final myAppFile = File(_linuxMyApplicationFilePath); - if (!myAppFile.existsSync()) { + final runnerMyAppFile = File(_linuxRunnerMyApplicationFilePath); + + final doesMyAppFileExist = myAppFile.existsSync(); + final doesRunnerMyAppFileExist = runnerMyAppFile.existsSync(); + + if (!doesMyAppFileExist && !doesRunnerMyAppFileExist) { throw _PackageRenameErrors.linuxMyApplicationNotFound; } - final myAppString = myAppFile.readAsStringSync(); - final newTitleMyAppString = myAppString - .replaceAll( - RegExp(r'gtk_header_bar_set_title\(header_bar, "(.*)"\);'), - 'gtk_header_bar_set_title(header_bar, "$appName");', - ) - .replaceAll( - RegExp(r'gtk_window_set_title\(window, "(.*)"\);'), - 'gtk_window_set_title(window, "$appName");', - ); - - myAppFile.writeAsStringSync(newTitleMyAppString); + if (doesMyAppFileExist) { + final myAppString = myAppFile.readAsStringSync(); + final newTitleMyAppString = myAppString + .replaceAll( + RegExp(r'gtk_header_bar_set_title\(header_bar, "(.*)"\);'), + 'gtk_header_bar_set_title(header_bar, "$appName");', + ) + .replaceAll( + RegExp(r'gtk_window_set_title\(window, "(.*)"\);'), + 'gtk_window_set_title(window, "$appName");', + ); + + myAppFile.writeAsStringSync(newTitleMyAppString); + } + if (doesRunnerMyAppFileExist) { + final runnerMyAppString = runnerMyAppFile.readAsStringSync(); + final newTitleRunnerMyAppString = runnerMyAppString + .replaceAll( + RegExp(r'gtk_header_bar_set_title\(header_bar, "(.*)"\);'), + 'gtk_header_bar_set_title(header_bar, "$appName");', + ) + .replaceAll( + RegExp(r'gtk_window_set_title\(window, "(.*)"\);'), + 'gtk_window_set_title(window, "$appName");', + ); + + runnerMyAppFile.writeAsStringSync(newTitleRunnerMyAppString); + } _logger.i('Linux app title set to: `$appName` (my_application.cc)'); } on _PackageRenameException catch (e) {