Implemented the container removal action succesfully
This commit is contained in:
parent
19ed936f4b
commit
407d905590
2 changed files with 32 additions and 1 deletions
|
@ -238,6 +238,19 @@ class DockerInterface(object):
|
|||
else:
|
||||
raise DockerNotConnectedException()
|
||||
|
||||
def remove_container(self, container_id):
|
||||
'''
|
||||
Removes a container based on it's ID.
|
||||
|
||||
@param container_id: ID of the container to remove
|
||||
@type container_id: String
|
||||
'''
|
||||
if self.client is not None:
|
||||
self.client.remove_container(container_id)
|
||||
|
||||
else:
|
||||
raise DockerNotConnectedException()
|
||||
|
||||
|
||||
class DockerNotConnectedException(Exception):
|
||||
pass
|
||||
|
|
|
@ -213,7 +213,25 @@ class MainWindow(Gtk.Application):
|
|||
"""
|
||||
User wants to delete a selected container
|
||||
"""
|
||||
print "Not implemented: on_delete_container_action_activate"
|
||||
container_view = self.builder.get_object('ContainerListView')
|
||||
selection = container_view.get_selection()
|
||||
model, selected = selection.get_selected()
|
||||
# selection is a treeiter
|
||||
if selected is not None:
|
||||
selected_container_id = model[selected][4]
|
||||
container = self.docker.get_container_by_id(selected_container_id)
|
||||
|
||||
if container is not None:
|
||||
message_dialog = Gtk.MessageDialog(self.window, 0,
|
||||
Gtk.MessageType.QUESTION,
|
||||
Gtk.ButtonsType.YES_NO,
|
||||
"Are you sure you want to remove {name} container?".format(name = container.names[0]))
|
||||
response = message_dialog.run()
|
||||
if response == Gtk.ResponseType.YES:
|
||||
self.docker.remove_container(container.container_id)
|
||||
self.refresh_views()
|
||||
|
||||
message_dialog.destroy()
|
||||
|
||||
def on_build_action_activate(self, obj, event = None):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue