ui: preserve scroll changes that occur during docker refresh

This commit is contained in:
mappu 2025-01-06 19:08:36 +13:00
parent 6f8a984f3c
commit 5c5f2007f4

32
main.go
View File

@ -525,15 +525,15 @@ func (self *DockerGUI) refresh_data() {
} }
func (self *DockerGUI) refresh_containers() { func (self *DockerGUI) refresh_containers() {
scroll_position := self.containers_tree.VerticalScrollBar().Value()
selected_items := self.get_selected_items(self.containers_tree)
self.containers_tree.Clear()
output, err := dockerCommand("ps", "-a", "--format", "{{.ID}}\\t{{.Names}}\\t{{.Image}}\\t{{.Status}}\\t{{.Ports}}").Output() output, err := dockerCommand("ps", "-a", "--format", "{{.ID}}\\t{{.Names}}\\t{{.Image}}\\t{{.Status}}\\t{{.Ports}}").Output()
if err != nil { if err != nil {
panic(err) panic(err)
} }
scroll_position := self.containers_tree.VerticalScrollBar().Value()
selected_items := self.get_selected_items(self.containers_tree)
self.containers_tree.Clear()
containers := strings.Split(strings.TrimSpace(string(output)), "\n") containers := strings.Split(strings.TrimSpace(string(output)), "\n")
for _, container := range containers { for _, container := range containers {
parts := strings.Split(container, "\t") parts := strings.Split(container, "\t")
@ -563,15 +563,15 @@ func (self *DockerGUI) refresh_containers() {
} }
func (self *DockerGUI) refresh_images() { func (self *DockerGUI) refresh_images() {
scroll_position := self.images_tree.VerticalScrollBar().Value()
selected_items := self.get_selected_items(self.images_tree)
self.images_tree.Clear()
output, err := dockerCommand("images", "--format", "{{.ID}}\\t{{.Repository}}\\t{{.Tag}}\\t{{.Size}}").Output() output, err := dockerCommand("images", "--format", "{{.ID}}\\t{{.Repository}}\\t{{.Tag}}\\t{{.Size}}").Output()
if err != nil { if err != nil {
panic(err) panic(err)
} }
scroll_position := self.images_tree.VerticalScrollBar().Value()
selected_items := self.get_selected_items(self.images_tree)
self.images_tree.Clear()
images := strings.Split(strings.TrimSpace(string(output)), "\n") images := strings.Split(strings.TrimSpace(string(output)), "\n")
for _, image := range images { for _, image := range images {
parts := strings.Split(image, "\t") parts := strings.Split(image, "\t")
@ -595,15 +595,15 @@ func (self *DockerGUI) refresh_images() {
} }
func (self *DockerGUI) refresh_networks() { func (self *DockerGUI) refresh_networks() {
scroll_position := self.networks_tree.VerticalScrollBar().Value()
selected_items := self.get_selected_items(self.networks_tree)
self.networks_tree.Clear()
output, err := dockerCommand("network", "ls", "--format", "{{.ID}}\\t{{.Name}}\\t{{.Driver}}").Output() output, err := dockerCommand("network", "ls", "--format", "{{.ID}}\\t{{.Name}}\\t{{.Driver}}").Output()
if err != nil { if err != nil {
panic(err) panic(err)
} }
scroll_position := self.networks_tree.VerticalScrollBar().Value()
selected_items := self.get_selected_items(self.networks_tree)
self.networks_tree.Clear()
networks := strings.Split(strings.TrimSpace(string(output)), "\n") networks := strings.Split(strings.TrimSpace(string(output)), "\n")
for _, network := range networks { for _, network := range networks {
parts := strings.Split(network, "\t") parts := strings.Split(network, "\t")
@ -625,15 +625,15 @@ func (self *DockerGUI) refresh_networks() {
} }
func (self *DockerGUI) refresh_volumes() { func (self *DockerGUI) refresh_volumes() {
scroll_position := self.volumes_tree.VerticalScrollBar().Value()
selected_items := self.get_selected_items(self.volumes_tree)
self.volumes_tree.Clear()
output, err := dockerCommand("volume", "ls", "--format", "{{.Name}}\\t{{.Driver}}\\t{{.Mountpoint}}").Output() output, err := dockerCommand("volume", "ls", "--format", "{{.Name}}\\t{{.Driver}}\\t{{.Mountpoint}}").Output()
if err != nil { if err != nil {
panic(err) panic(err)
} }
scroll_position := self.volumes_tree.VerticalScrollBar().Value()
selected_items := self.get_selected_items(self.volumes_tree)
self.volumes_tree.Clear()
volumes := strings.Split(strings.TrimSpace(string(output)), "\n") volumes := strings.Split(strings.TrimSpace(string(output)), "\n")
for _, volume := range volumes { for _, volume := range volumes {
parts := strings.Split(volume, "\t") parts := strings.Split(volume, "\t")