Finished connecting and some boilerplate code for the gui

This commit is contained in:
José Carlos Cuevas 2014-07-09 15:02:33 +02:00
parent 81d685e845
commit 82d970defb
2 changed files with 129 additions and 33 deletions

View file

@ -13,11 +13,6 @@
<property name="can_focus">False</property>
<property name="stock">gtk-properties</property>
</object>
<object class="GtkImage" id="GearsStockImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-execute</property>
</object>
<object class="GtkImage" id="GoToStockImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
@ -29,6 +24,20 @@
<property name="can_focus">False</property>
<property name="stock">gtk-media-play</property>
</object>
<object class="GtkAction" id="attach_action">
<property name="label" translatable="yes">Attach</property>
<property name="short_label" translatable="yes">Attach</property>
<property name="stock_id">gtk-jump-to</property>
<property name="always_show_image">True</property>
<signal name="activate" handler="on_attach_action_activate" swapped="no"/>
</object>
<object class="GtkAction" id="build_action">
<property name="label" translatable="yes">Build</property>
<property name="short_label" translatable="yes">Build</property>
<property name="stock_id">gtk-properties</property>
<property name="always_show_image">True</property>
<signal name="activate" handler="on_build_action_activate" swapped="no"/>
</object>
<object class="GtkAction" id="connect_action">
<property name="label" translatable="yes">Connect</property>
<property name="short_label" translatable="yes">Connect</property>
@ -36,6 +45,13 @@
<property name="always_show_image">True</property>
<signal name="activate" handler="on_connect_action_activate" swapped="no"/>
</object>
<object class="GtkAction" id="log_action">
<property name="label" translatable="yes">Log</property>
<property name="short_label" translatable="yes">Log</property>
<property name="stock_id">gtk-file</property>
<property name="always_show_image">True</property>
<signal name="activate" handler="on_log_action_activate" swapped="no"/>
</object>
<object class="GtkAction" id="preferences_action">
<property name="label" translatable="yes">Preferences</property>
<property name="short_label" translatable="yes">Preferences</property>
@ -51,13 +67,19 @@
<property name="always_show_image">True</property>
<signal name="activate" handler="on_refresh_action_activate" swapped="no"/>
</object>
<object class="GtkAction" id="run_action">
<object class="GtkAction" id="remove_image_action">
<property name="label" translatable="yes">Remove</property>
<property name="short_label" translatable="yes">Remove</property>
<property name="stock_id">gtk-delete</property>
<property name="always_show_image">True</property>
<signal name="activate" handler="on_remove_image_action_activate" swapped="no"/>
</object>
<object class="GtkAction" id="runimage_action">
<property name="label" translatable="yes">Run</property>
<property name="short_label" translatable="yes">Run</property>
<property name="tooltip" translatable="yes">Run a new container based off an image.</property>
<property name="stock_id">gtk-execute</property>
<property name="always_show_image">True</property>
<signal name="activate" handler="on_run_action_activate" swapped="no"/>
<signal name="activate" handler="on_runimage_action_activate" swapped="no"/>
</object>
<object class="GtkAction" id="start_action">
<property name="label" translatable="yes">Start</property>
@ -67,6 +89,13 @@
<property name="always_show_image">True</property>
<signal name="activate" handler="on_start_action_activate" swapped="no"/>
</object>
<object class="GtkAction" id="stop_action">
<property name="label" translatable="yes">Stop</property>
<property name="short_label" translatable="yes">Stop</property>
<property name="stock_id">gtk-media-stop</property>
<property name="always_show_image">True</property>
<signal name="activate" handler="on_stop_action_activate" swapped="no"/>
</object>
<object class="GtkWindow" id="MainWindow">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Stevedore</property>
@ -161,25 +190,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">5</property>
<child>
<object class="GtkButton" id="RunButton">
<property name="label">Run</property>
<property name="use_action_appearance">True</property>
<property name="related_action">run_action</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="action_name">run_action</property>
<property name="image">GearsStockImage</property>
<property name="yalign">0.55000001192092896</property>
<property name="always_show_image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="StartButton">
<property name="label" translatable="yes">Start</property>
@ -195,14 +205,14 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="StopButton">
<property name="label">gtk-media-stop</property>
<property name="use_action_appearance">True</property>
<property name="related_action"/>
<property name="related_action">stop_action</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -213,12 +223,14 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="AttachButton">
<property name="label" translatable="yes">Attach</property>
<property name="use_action_appearance">True</property>
<property name="related_action">attach_action</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -229,12 +241,14 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="LogButton">
<property name="label" translatable="yes">Log</property>
<property name="use_action_appearance">True</property>
<property name="related_action">log_action</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -245,7 +259,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
<property name="position">3</property>
</packing>
</child>
</object>
@ -309,11 +323,14 @@
<child>
<object class="GtkButton" id="BuildImageButton">
<property name="label" translatable="yes">Build</property>
<property name="use_action_appearance">True</property>
<property name="related_action">build_action</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="action_name">build_action</property>
<property name="image">GearStockImage</property>
<property name="yalign">0.61000001430511475</property>
<property name="always_show_image">True</property>
</object>
<packing>
@ -325,6 +342,8 @@
<child>
<object class="GtkButton" id="RemoveImageButton">
<property name="label">gtk-delete</property>
<property name="use_action_appearance">True</property>
<property name="related_action">remove_image_action</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -339,8 +358,10 @@
</packing>
</child>
<child>
<object class="GtkButton" id="button3">
<object class="GtkButton" id="RunImageButton">
<property name="label">gtk-execute</property>
<property name="use_action_appearance">True</property>
<property name="related_action">runimage_action</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>

View file

@ -47,10 +47,21 @@ class MainWindow(Gtk.Application):
self.add_window(self.window)
self.window.show()
def refresh_views(self):
"""
Refresh the docker interface object and the reload the ListViews
to get a fresh snapshot of the system
"""
print "Not Implemented: refresh_views"
# Events and "natural" callbacks
def on_MainWindow_delete_event(self, obj, event = None):
"on_MainWindow_delete_event activated"
print 'on_MainWindow_delete_event activated'
# Action callbacks
def on_connect_action_activate(self, obj, event = None):
"""
Connection action has been triggered
@ -65,6 +76,70 @@ class MainWindow(Gtk.Application):
print u"Error connecting to Docker Server: " + unicode(e)
self.docker = None
def on_preferences_action_activate(self, obj, event = None):
"""
We've been asked for the preferences window
"""
# TODO
print "Not implemented: on_preferences_action_activate"
def on_refresh_action_activate(self, obj, event = None):
"""
The user wants to reload the listings
"""
print "on_refresh_action_activate"
self.refresh_views()
def on_start_action_activate(self, obj, event = None):
"""
The user demands a certain container to be started
"""
print "Not implemented: on_start_action_activate"
def on_stop_action_activate(self, obj, event = None):
"""
The user wants to stop a certain container
"""
# TODO: Remember to show a warning and a yes-no choice before proceeding!
print "Not implemented: on_stop_action_activate"
def on_attach_action_activate(self, obj, event = None):
"""
Here we're requested to attach to a running container
"""
# TODO: We should launch $TERM with the attach command
# if the container is running. If not, we display an error or warning
# Maybe offer the option to start it and then attach?
print "Not implemented: on_attach_action_activate"
def on_log_action_activate(self, obj, event = None):
"""
User wants to see the log output of a certain container
"""
# TODO: We should launch $TERM with the log command and the -f option
# unless it is not running, where we remove the -f option and launch it
# anyway.
print "Not implemented: on_log_action_activate"
def on_build_action_activate(self, obj, event = None):
"""
Command for building new images from Dockerfiles
"""
# TODO: Open a OpenFileDialog and build the image.
print "Not implemented: on_build_action_activate"
def on_remove_image_action_activate(self, obj, event = None):
"""
We've been asked to remove an existing image
"""
print "Not implemented: on_remove_image_action_activate"
def on_runimage_action_activate(self, obj, event = None):
"""
Launch selected image into a running container
"""
print "Not implemented: on_runimage_action_activate"
# run main loop
def main():