Do not close dialogs on errors

This is still not ideal, as errors are not in dialog and there's no clue of error but an improvement
This commit is contained in:
Alberto Fanjul 2023-12-19 00:20:09 +01:00
parent 479cdf5515
commit 4c690fdc13
2 changed files with 47 additions and 43 deletions

View File

@ -109,38 +109,40 @@ class AddRemoteAction : GitgExt.UIElement, GitgExt.Action, Object
dlg.remote_url = remote_url;
dlg.response.connect((d, resp) => {
if (resp == Gtk.ResponseType.OK)
if (resp != Gtk.ResponseType.OK)
{
Ggit.Remote? remote = null;
d_remote = null;
repo = application.repository;
remote_name = dlg.remote_name;
remote_url = dlg.remote_url;
try
{
remote = repo.create_remote(remote_name,
remote_url);
}
catch (Error e)
{
add_remote(remote_name, remote_url);
application.show_infobar(_("Failed to add remote"),
e.message,
Gtk.MessageType.ERROR);
}
d_remote = application.remote_lookup.lookup(remote_name);
if (remote != null)
{
fetch.begin((obj,res) => {
fetch.end(res);
});
}
dlg.destroy();
return;
}
Ggit.Remote? remote = null;
d_remote = null;
repo = application.repository;
remote_name = dlg.remote_name;
remote_url = dlg.remote_url;
try
{
remote = repo.create_remote(remote_name,
remote_url);
}
catch (Error e)
{
application.show_infobar(_("Failed to add remote"),
e.message,
Gtk.MessageType.ERROR);
return;
}
d_remote = application.remote_lookup.lookup(remote_name);
if (remote != null)
{
fetch.begin((obj,res) => {
fetch.end(res);
});
}
dlg.destroy();
});

View File

@ -143,23 +143,25 @@ class RefActionCheckout : GitgExt.UIElement, GitgExt.Action, GitgExt.RefAction,
}
private void on_checkout_remote_branch_dialog_response(Gitg.CheckoutRemoteBranchDialog dialog, int response_id) {
if (response_id == Gtk.ResponseType.OK)
if (response_id != Gtk.ResponseType.OK)
{
string? remote_branch_name = dialog.track_remote ? dialog.remote_branch_name : null;
create_branch.begin(reference, dialog.new_branch_name, remote_branch_name, (obj, res) => {
var branch_ref = create_branch.end(res) as Gitg.Ref;
if (branch_ref != null)
{
action_interface.add_ref(branch_ref);
reference = branch_ref;
checkout.begin();
}
});
dialog.destroy();
return;
}
dialog.destroy();
string? remote_branch_name = dialog.track_remote ? dialog.remote_branch_name : null;
create_branch.begin(reference, dialog.new_branch_name, remote_branch_name, (obj, res) => {
var branch_ref = create_branch.end(res) as Gitg.Ref;
if (branch_ref != null)
{
action_interface.add_ref(branch_ref);
reference = branch_ref;
checkout.begin();
dialog.destroy();
}
});
}
private async Ggit.Branch? create_branch(Ggit.Ref reference, string new_branch_name, string? remote_branch_name)