Skip to content

Commit 9cba095

Browse files
committed
Added current repo to the window title
Fixes #302
1 parent 771feae commit 9cba095

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/main/kotlin/com/jetpackduba/gitnuro/App.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import com.jetpackduba.gitnuro.ui.AppTab
4848
import com.jetpackduba.gitnuro.ui.TabsManager
4949
import com.jetpackduba.gitnuro.ui.components.RepositoriesTabPanel
5050
import com.jetpackduba.gitnuro.ui.components.TabInformation
51+
import com.jetpackduba.gitnuro.ui.components.TabInformation.Companion.NEW_TAB_DEFAULT_NAME
5152
import com.jetpackduba.gitnuro.ui.context_menu.AppPopupMenu
5253
import com.jetpackduba.gitnuro.ui.dialogs.settings.ProxyType
5354
import kotlinx.coroutines.launch
@@ -64,6 +65,7 @@ import javax.inject.Inject
6465

6566

6667
private const val TAG = "App"
68+
private const val MAX_CHARS_CURRENT_TAB_NAME = 250
6769

6870

6971
class App {
@@ -145,9 +147,13 @@ class App {
145147
// Save window state for next time the Window is started
146148
appSettingsRepository.windowPlacement = windowState.placement.preferenceValue
147149

150+
val currentTab = tabsManager.currentTab.collectAsState().value
151+
152+
val currentTabName = (currentTab?.tabName?.value ?: NEW_TAB_DEFAULT_NAME).take(MAX_CHARS_CURRENT_TAB_NAME)
153+
148154
if (isOpen) {
149155
Window(
150-
title = System.getenv("title") ?: AppConstants.APP_NAME,
156+
title = "${System.getenv("title") ?: AppConstants.APP_NAME} - $currentTabName",
151157
onCloseRequest = {
152158
isOpen = false
153159
},

src/main/kotlin/com/jetpackduba/gitnuro/ui/TabsManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class TabsManager @Inject constructor(
136136
}
137137

138138
private fun newAppTab(
139-
tabName: MutableState<String> = mutableStateOf(TabInformation.DEFAULT_NAME),
139+
tabName: MutableState<String> = mutableStateOf(TabInformation.NEW_TAB_DEFAULT_NAME),
140140
path: String? = null,
141141
): TabInformation {
142142
return TabInformation(

src/main/kotlin/com/jetpackduba/gitnuro/ui/components/RepositoriesTabPanel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class TabInformation(
272272
this.path = newPath
273273

274274
if (newPath == null) {
275-
tabName.value = DEFAULT_NAME
275+
tabName.value = NEW_TAB_DEFAULT_NAME
276276
} else {
277277
tabName.value = Path(newPath).name
278278
appStateManager.repositoryTabChanged(newPath)
@@ -290,7 +290,7 @@ class TabInformation(
290290
}
291291

292292
companion object {
293-
const val DEFAULT_NAME = "New tab"
293+
const val NEW_TAB_DEFAULT_NAME = "New tab"
294294
}
295295
}
296296

0 commit comments

Comments
 (0)