Remove run_after_async

This commit is contained in:
Jesse van den Kieboom 2013-12-27 20:10:15 +01:00
parent bdcecc96b1
commit 0129670140
2 changed files with 30 additions and 21 deletions

View file

@ -74,7 +74,7 @@ namespace Gitg
} }
} }
public override void run_after_async() protected override InputStream? run_async(Cancellable? cancellable)
{ {
var selected_commit = (Gitg.Commit) d_commit; var selected_commit = (Gitg.Commit) d_commit;
string commit_subject = selected_commit.get_subject(); string commit_subject = selected_commit.get_subject();
@ -97,6 +97,13 @@ namespace Gitg
commit_subject = ""; commit_subject = "";
} }
// Show file chooser and finish create patch in idle.
Idle.add(() => {
if (cancellable.is_cancelled())
{
return false;
}
var chooser = new Gtk.FileChooserDialog(_("Save Patch File"), null, var chooser = new Gtk.FileChooserDialog(_("Save Patch File"), null,
Gtk.FileChooserAction.SAVE, Gtk.FileChooserAction.SAVE,
_("_Cancel"), _("_Cancel"),
@ -109,11 +116,18 @@ namespace Gitg
chooser.show(); chooser.show();
chooser.response.connect((dialog, id) => { chooser.response.connect((dialog, id) => {
if (id != -6) { if (!cancellable.is_cancelled() && id != -6)
{
create_patch (selected_commit, chooser.get_file()); create_patch (selected_commit, chooser.get_file());
} }
chooser.destroy(); chooser.destroy();
}); });
return false;
});
return null;
} }
} }
} }

View file

@ -86,9 +86,6 @@ namespace Gitg
return null; return null;
} }
protected virtual void run_after_async()
{}
private async InputStream? run_impl(Cancellable? cancellable) throws GLib.Error private async InputStream? run_impl(Cancellable? cancellable) throws GLib.Error
{ {
SourceFunc callback = run_impl.callback; SourceFunc callback = run_impl.callback;
@ -107,8 +104,6 @@ namespace Gitg
return null; return null;
}); });
run_after_async();
// Wait for it to finish, yield to caller // Wait for it to finish, yield to caller
yield; yield;