diff --git a/main.go b/main.go index 57e56d2..0950c7f 100644 --- a/main.go +++ b/main.go @@ -361,7 +361,7 @@ func (self *DockerGUI) create_menu_bar() { func (self *DockerGUI) show_context_menu(position *qt.QPoint) { context_menu := qt.NewQMenu2() - current_tab := self.tab_widget.CurrentWidget() + current_tab := self.tab_widget.CurrentIndex() // Add refresh action to context menu refresh_action := qt.NewQAction5("&Refresh", self.QObject) @@ -370,7 +370,7 @@ func (self *DockerGUI) show_context_menu(position *qt.QPoint) { context_menu.AddSeparator() - if current_tab == self.containers_tab { + if current_tab == ContainersTab { terminal_action := qt.NewQAction5("&Terminal", self.QObject) terminal_action.OnTriggered(func() { self.handle_action("Terminal") }) context_menu.AddAction(terminal_action) @@ -393,7 +393,9 @@ func (self *DockerGUI) show_context_menu(position *qt.QPoint) { remove_action.OnTriggered(func() { self.handle_action("Remove") }) context_menu.AddAction(remove_action) - } else if current_tab == self.images_tab { + context_menu.ExecWithPos(self.containers_tree.Viewport().MapToGlobalWithQPoint(position)) + + } else if current_tab == ImagesTab { pull_action := qt.NewQAction5("&Pull", self.QObject) pull_action.OnTriggered(self.pull_image) context_menu.AddAction(pull_action) @@ -404,19 +406,23 @@ func (self *DockerGUI) show_context_menu(position *qt.QPoint) { remove_action.OnTriggered(self.remove_image) context_menu.AddAction(remove_action) - } else if current_tab == self.networks_tab { + context_menu.ExecWithPos(self.images_tree.Viewport().MapToGlobalWithQPoint(position)) + + } else if current_tab == NetworksTab { remove_action := qt.NewQAction5("Remo&ve", self.QObject) remove_action.OnTriggered(func() { self.handle_action("Remove") }) context_menu.AddAction(remove_action) - } else if current_tab == self.volumes_tab { + context_menu.ExecWithPos(self.networks_tree.Viewport().MapToGlobalWithQPoint(position)) + + } else if current_tab == VolumesTab { remove_action := qt.NewQAction5("Remo&ve", self.QObject) remove_action.OnTriggered(func() { self.handle_action("Remove") }) context_menu.AddAction(remove_action) + context_menu.ExecWithPos(self.volumes_tree.Viewport().MapToGlobalWithQPoint(position)) } - context_menu.ExecWithPos(current_tab.MapToGlobalWithQPoint(position)) } func (self *DockerGUI) setup_auto_refresh() { @@ -441,9 +447,9 @@ func (self *DockerGUI) setup_auto_refresh() { } func (self *DockerGUI) handle_action(action string) { - current_tab := self.tab_widget.CurrentWidget() + current_tab := self.tab_widget.CurrentIndex() - if current_tab == self.containers_tab { + if current_tab == ContainersTab { selected_items := self.containers_tree.SelectedItems() if len(selected_items) == 0 { return @@ -460,7 +466,7 @@ func (self *DockerGUI) handle_action(action string) { exec.Command("docker", "rm", "-f", container_id).Run() } - } else if current_tab == self.networks_tab { + } else if current_tab == NetworksTab { selected_items := self.networks_tree.SelectedItems() if len(selected_items) == 0 { return @@ -471,7 +477,7 @@ func (self *DockerGUI) handle_action(action string) { exec.Command("docker", "network", "rm", network_id).Run() } - } else if current_tab == self.volumes_tab { + } else if current_tab == VolumesTab { selected_items := self.volumes_tree.SelectedItems() if len(selected_items) == 0 { return