Option to switch to the newly created branch

This commit is contained in:
Armandas Jarušauskas 2020-06-27 08:29:36 +00:00 committed by Alberto Fanjul
parent 73ffcae0c7
commit daaf84f8b0
4 changed files with 51 additions and 0 deletions

View File

@ -18,6 +18,7 @@
<schema gettext-domain="@GETTEXT_PACKAGE@" id="@APPLICATION_ID@.preferences" path="@SCHEMA_PATH@/preferences/">
<child name="main" schema="@APPLICATION_ID@.preferences.main" />
<child name="history" schema="@APPLICATION_ID@.preferences.history" />
<child name="branch" schema="@APPLICATION_ID@.preferences.branch" />
<child name="commit" schema="@APPLICATION_ID@.preferences.commit" />
<child name="diff" schema="@APPLICATION_ID@.preferences.diff" />
</schema>
@ -165,6 +166,15 @@
</description>
</key>
</schema>
<schema gettext-domain="@GETTEXT_PACKAGE@" id="@APPLICATION_ID@.preferences.branch" path="@SCHEMA_PATH@/preferences/branch/">
<key name="checkout-created-branch" type="b">
<default>true</default>
<summary>Switch to the new branch on creation</summary>
<description>
Setting that controls whether the newly created branch is checked out automatically.
</description>
</key>
</schema>
<schema gettext-domain="@GETTEXT_PACKAGE@" id="@APPLICATION_ID@.preferences.commit" path="@SCHEMA_PATH@/preferences/commit/">
<child name="message" schema="@APPLICATION_ID@.preferences.commit.message" />
<child name="diff" schema="@APPLICATION_ID@.preferences.commit.diff" />

View File

@ -81,6 +81,12 @@ class CommitActionCreateBranch : GitgExt.UIElement, GitgExt.Action, GitgExt.Comm
{
action_interface.add_ref((Gitg.Ref)branch);
}
if (dlg.checkout_created)
{
var checkout = new RefActionCheckout(application, action_interface, (Gitg.Ref)branch);
checkout.checkout.begin();
}
}
dlg.destroy();

View File

@ -29,8 +29,20 @@ class CreateBranchDialog : Gtk.Dialog
[GtkChild]
private Gtk.Entry d_entry_branch_name;
[GtkChild]
private Gtk.CheckButton d_checkout_created;
private Settings d_settings;
construct
{
d_settings = new Settings(Gitg.Config.APPLICATION_ID + ".preferences.branch");
d_settings.bind("checkout-created-branch",
d_checkout_created,
"active",
SettingsBindFlags.GET | SettingsBindFlags.SET);
d_entry_branch_name.changed.connect(() => {
d_button_create.sensitive = (new_branch_name.length != 0);
});
@ -56,6 +68,14 @@ class CreateBranchDialog : Gtk.Dialog
return d_entry_branch_name.text.strip();
}
}
public bool checkout_created
{
get
{
return d_checkout_created.active;
}
}
}
}

View File

@ -91,6 +91,21 @@
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="d_checkout_created">
<property name="label" translatable="yes">_Checkout the created branch</property>
<property name="use_underline">True</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="active">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>