This commit is contained in:
Gergely Polonkai 2016-06-09 18:22:45 +02:00
parent e53541fbb2
commit 862030ab58
2 changed files with 25 additions and 3 deletions

View File

@ -125,6 +125,7 @@ class GitSoundWindow(object):
self.builder = self.Gtk.Builder()
self.builder.add_from_file('git-sound.ui')
self.win = self.builder.get_object('main-window')
self.play_button = self.builder.get_object('play-button')
self.stop_button = self.builder.get_object('stop-button')
@ -233,6 +234,9 @@ class GitSoundWindow(object):
self.Gtk.main_iteration_do(False)
def update_play_pos(self):
if self.gitmidi is None:
return
position = self.gitmidi.get_play_pos()
if position is None:
@ -263,6 +267,23 @@ class GitSoundWindow(object):
if self.gitmidi is not None:
self.gitmidi.stop()
def __save(self, dialog, response_id):
if response_id == self.Gtk.ResponseType.OK:
save_file = dialog.get_file().get_path()
dialog.destroy()
self.gitmidi.export_file(save_file)
def save_midi(self):
dialog = self.Gtk.FileChooserDialog(
u"Save As…",
self.win,
self.Gtk.FileChooserAction.SAVE,
("Save", self.Gtk.ResponseType.OK))
dialog.set_do_overwrite_confirmation(True)
dialog.connect('response', self.__save)
dialog.run()
def start(self):
program_store = self.builder.get_object('program-list')
self.program_combo = self.builder.get_object('program-combo')
@ -296,13 +317,13 @@ class GitSoundWindow(object):
'generate_repo': lambda button: self.generate_repo(button),
'play_midi': lambda button: self.play_midi(),
'stop_midi': lambda button: self.stop_midi(),
'save_midi': lambda button: self.save_midi(),
})
self.progressbar = self.builder.get_object('generate-progress')
win = self.builder.get_object('main-window')
win.connect("delete-event", self.Gtk.main_quit)
win.show_all()
self.win.connect("delete-event", self.Gtk.main_quit)
self.win.show_all()
self.Gtk.main()
sys.exit(0)

View File

@ -142,6 +142,7 @@
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
<signal name="clicked" handler="save_midi" swapped="no"/>
</object>
<packing>
<property name="left_attach">3</property>