diff --git a/GitCommands/Settings/AppSettings.cs b/GitCommands/Settings/AppSettings.cs index e40eddf175d..8d30a851013 100644 --- a/GitCommands/Settings/AppSettings.cs +++ b/GitCommands/Settings/AppSettings.cs @@ -752,6 +752,15 @@ public enum PullAction Default } + /// + /// Gets or sets the default fetch action that is performed by the toolbar icon when it is clicked on. + /// + public static PullAction DefaultFetchAction + { + get => GetEnum("DefaultFetchAction", PullAction.Fetch); + set => SetEnum("DefaultFetchAction", value); + } + /// /// Gets or sets the default pull action that is performed by the toolbar icon when it is clicked on. /// diff --git a/GitUI/CommandsDialogs/FormBrowse.Designer.cs b/GitUI/CommandsDialogs/FormBrowse.Designer.cs index e44db7c73a4..05f5f590b6c 100644 --- a/GitUI/CommandsDialogs/FormBrowse.Designer.cs +++ b/GitUI/CommandsDialogs/FormBrowse.Designer.cs @@ -44,13 +44,15 @@ private void InitializeComponent() this.manageStashesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.createAStashToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripButtonCommit = new System.Windows.Forms.ToolStripButton(); - this.toolStripButtonPull = new System.Windows.Forms.ToolStripSplitButton(); - this.mergeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.rebaseToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripButtonFetch = new System.Windows.Forms.ToolStripSplitButton(); this.fetchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.pullToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.fetchAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.fetchPruneAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.setDefaultFetchButtonActionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.pullToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripButtonPull = new System.Windows.Forms.ToolStripSplitButton(); + this.mergeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.rebaseToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.setDefaultPullButtonActionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripButtonPush = new GitUI.CommandsDialogs.ToolStripPushButton(); this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); @@ -255,6 +257,7 @@ private void InitializeComponent() this._NO_TRANSLATE_WorkingDir, this.branchSelect, this.toolStripSeparator1, + this.toolStripButtonFetch, this.toolStripButtonPull, this.toolStripButtonPush, this.toolStripButtonCommit, @@ -398,80 +401,72 @@ private void InitializeComponent() this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25); // - // toolStripSplitStash - // - this.toolStripSplitStash.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.stashChangesToolStripMenuItem, - this.stashPopToolStripMenuItem, - this.toolStripSeparator9, - this.manageStashesToolStripMenuItem, - this.createAStashToolStripMenuItem}); - this.toolStripSplitStash.Image = global::GitUI.Properties.Images.Stash; - this.toolStripSplitStash.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripSplitStash.Name = "toolStripSplitStash"; - this.toolStripSplitStash.Size = new System.Drawing.Size(32, 22); - this.toolStripSplitStash.ToolTipText = "Manage stashes"; - this.toolStripSplitStash.ButtonClick += new System.EventHandler(this.ToolStripSplitStashButtonClick); - this.toolStripSplitStash.DropDownOpened += new System.EventHandler(this.toolStripSplitStash_DropDownOpened); - // - // stashChangesToolStripMenuItem + // toolStripButtonFetch // - this.stashChangesToolStripMenuItem.Name = "stashChangesToolStripMenuItem"; - this.stashChangesToolStripMenuItem.Size = new System.Drawing.Size(167, 22); - this.stashChangesToolStripMenuItem.Text = "Stash"; - this.stashChangesToolStripMenuItem.ToolTipText = "Stash changes"; - this.stashChangesToolStripMenuItem.Click += new System.EventHandler(this.StashChangesToolStripMenuItemClick); + this.toolStripButtonFetch.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonFetch.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.fetchToolStripMenuItem, + this.fetchAllToolStripMenuItem, + this.fetchPruneAllToolStripMenuItem, + toolStripSeparator11, + this.setDefaultFetchButtonActionToolStripMenuItem}); + this.toolStripButtonFetch.Image = global::GitUI.Properties.Images.Pull; + this.toolStripButtonFetch.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonFetch.Name = "toolStripButtonFetch"; + this.toolStripButtonFetch.Size = new System.Drawing.Size(32, 22); + this.toolStripButtonFetch.Text = "Fetch"; + this.toolStripButtonFetch.ButtonClick += new System.EventHandler(this.ToolStripButtonFetchClick); + this.toolStripButtonFetch.DropDownOpened += new System.EventHandler(this.ToolStripButtonFetch_DropDownOpened); // - // stashPopToolStripMenuItem + // fetchToolStripMenuItem // - this.stashPopToolStripMenuItem.Name = "stashPopToolStripMenuItem"; - this.stashPopToolStripMenuItem.Size = new System.Drawing.Size(167, 22); - this.stashPopToolStripMenuItem.Text = "Stash pop"; - this.stashPopToolStripMenuItem.ToolTipText = "Apply and drop single stash"; - this.stashPopToolStripMenuItem.Click += new System.EventHandler(this.StashPopToolStripMenuItemClick); + this.fetchToolStripMenuItem.Image = global::GitUI.Properties.Images.PullFetch; + this.fetchToolStripMenuItem.Name = "fetchToolStripMenuItem"; + this.fetchToolStripMenuItem.Size = new System.Drawing.Size(228, 22); + this.fetchToolStripMenuItem.Text = "Fetch"; + this.fetchToolStripMenuItem.ToolTipText = "Fetch branches and tags"; + this.fetchToolStripMenuItem.Click += new System.EventHandler(this.fetchToolStripMenuItem_Click); // - // toolStripSeparator9 + // fetchAllToolStripMenuItem // - this.toolStripSeparator9.Name = "toolStripSeparator9"; - this.toolStripSeparator9.Size = new System.Drawing.Size(164, 6); + this.fetchAllToolStripMenuItem.Image = global::GitUI.Properties.Images.PullFetchAll; + this.fetchAllToolStripMenuItem.Name = "fetchAllToolStripMenuItem"; + this.fetchAllToolStripMenuItem.Size = new System.Drawing.Size(228, 22); + this.fetchAllToolStripMenuItem.Text = "Fetch all"; + this.fetchAllToolStripMenuItem.ToolTipText = "Fetch branches and tags from all remote repositories"; + this.fetchAllToolStripMenuItem.Click += new System.EventHandler(this.fetchAllToolStripMenuItem_Click); // - // manageStashesToolStripMenuItem + // fetchPruneAllToolStripMenuItem // - this.manageStashesToolStripMenuItem.Name = "manageStashesToolStripMenuItem"; - this.manageStashesToolStripMenuItem.Size = new System.Drawing.Size(167, 22); - this.manageStashesToolStripMenuItem.Text = "Manage stashes..."; - this.manageStashesToolStripMenuItem.ToolTipText = "Manage stashes"; - this.manageStashesToolStripMenuItem.Click += new System.EventHandler(this.ManageStashesToolStripMenuItemClick); + this.fetchPruneAllToolStripMenuItem.Image = global::GitUI.Properties.Images.PullFetchPruneAll; + this.fetchPruneAllToolStripMenuItem.Name = "fetchPruneAllToolStripMenuItem"; + this.fetchPruneAllToolStripMenuItem.Size = new System.Drawing.Size(228, 22); + this.fetchPruneAllToolStripMenuItem.Text = "Fetch and prune all"; + this.fetchPruneAllToolStripMenuItem.ToolTipText = "Fetch branches and tags from all remote repositories also prune deleted refs"; + this.fetchPruneAllToolStripMenuItem.Click += new System.EventHandler(this.fetchPruneAllToolStripMenuItem_Click); // - // createAStashToolStripMenuItem + // setDefaultFetchButtonActionToolStripMenuItem // - this.createAStashToolStripMenuItem.Name = "createAStashToolStripMenuItem"; - this.createAStashToolStripMenuItem.Size = new System.Drawing.Size(167, 22); - this.createAStashToolStripMenuItem.Text = "Create a stash..."; - this.createAStashToolStripMenuItem.Click += new System.EventHandler(this.CreateStashToolStripMenuItemClick); + this.setDefaultFetchButtonActionToolStripMenuItem.Name = "setDefaultFetchButtonActionToolStripMenuItem"; + this.setDefaultFetchButtonActionToolStripMenuItem.Size = new System.Drawing.Size(228, 22); + this.setDefaultFetchButtonActionToolStripMenuItem.Text = "Set default Fetch button action"; // - // toolStripButtonCommit + // pullToolStripMenuItem1 // - this.toolStripButtonCommit.Image = global::GitUI.Properties.Images.RepoStateClean; - this.toolStripButtonCommit.ImageAlign = ContentAlignment.MiddleLeft; - this.toolStripButtonCommit.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButtonCommit.Name = "toolStripButtonCommit"; - this.toolStripButtonCommit.Size = new System.Drawing.Size(71, 22); - this.toolStripButtonCommit.Text = "Commit"; - this.toolStripButtonCommit.TextAlign = ContentAlignment.MiddleLeft; - this.toolStripButtonCommit.Click += new System.EventHandler(this.CommitToolStripMenuItemClick); + this.pullToolStripMenuItem1.Image = global::GitUI.Properties.Images.Pull; + this.pullToolStripMenuItem1.Name = "pullToolStripMenuItem1"; + this.pullToolStripMenuItem1.Size = new System.Drawing.Size(28, 25); + this.pullToolStripMenuItem1.Text = "Open pull dialog..."; + this.pullToolStripMenuItem1.ToolTipText = "Open pull dialog"; + this.pullToolStripMenuItem1.Click += new System.EventHandler(this.pullToolStripMenuItem1_Click); // // toolStripButtonPull // this.toolStripButtonPull.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButtonPull.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.pullToolStripMenuItem1, - toolStripSeparator11, this.mergeToolStripMenuItem, this.rebaseToolStripMenuItem1, - this.fetchToolStripMenuItem, - this.fetchAllToolStripMenuItem, - this.fetchPruneAllToolStripMenuItem, + this.pullToolStripMenuItem1, toolStripSeparator14, this.setDefaultPullButtonActionToolStripMenuItem}); this.toolStripButtonPull.Image = global::GitUI.Properties.Images.Pull; @@ -482,16 +477,11 @@ private void InitializeComponent() this.toolStripButtonPull.ButtonClick += new System.EventHandler(this.ToolStripButtonPullClick); this.toolStripButtonPull.DropDownOpened += new System.EventHandler(this.toolStripButtonPull_DropDownOpened); // - // toolStripSeparator11 - // - toolStripSeparator11.Name = "toolStripSeparator11"; - toolStripSeparator11.Size = new System.Drawing.Size(236, 6); - // // mergeToolStripMenuItem // this.mergeToolStripMenuItem.Image = global::GitUI.Properties.Images.PullMerge; this.mergeToolStripMenuItem.Name = "mergeToolStripMenuItem"; - this.mergeToolStripMenuItem.Size = new System.Drawing.Size(239, 22); + this.mergeToolStripMenuItem.Size = new System.Drawing.Size(228, 22); this.mergeToolStripMenuItem.Text = "Pull - merge"; this.mergeToolStripMenuItem.Click += new System.EventHandler(this.mergeToolStripMenuItem_Click); // @@ -499,49 +489,14 @@ private void InitializeComponent() // this.rebaseToolStripMenuItem1.Image = global::GitUI.Properties.Images.PullRebase; this.rebaseToolStripMenuItem1.Name = "rebaseToolStripMenuItem1"; - this.rebaseToolStripMenuItem1.Size = new System.Drawing.Size(239, 22); + this.rebaseToolStripMenuItem1.Size = new System.Drawing.Size(228, 22); this.rebaseToolStripMenuItem1.Text = "Pull - rebase"; this.rebaseToolStripMenuItem1.Click += new System.EventHandler(this.rebaseToolStripMenuItem1_Click); // - // fetchToolStripMenuItem - // - this.fetchToolStripMenuItem.Image = global::GitUI.Properties.Images.PullFetch; - this.fetchToolStripMenuItem.Name = "fetchToolStripMenuItem"; - this.fetchToolStripMenuItem.Size = new System.Drawing.Size(239, 22); - this.fetchToolStripMenuItem.Text = "Fetch"; - this.fetchToolStripMenuItem.ToolTipText = "Fetch branches and tags"; - this.fetchToolStripMenuItem.Click += new System.EventHandler(this.fetchToolStripMenuItem_Click); - // - // pullToolStripMenuItem1 - // - this.pullToolStripMenuItem1.Image = global::GitUI.Properties.Images.Pull; - this.pullToolStripMenuItem1.Name = "pullToolStripMenuItem1"; - this.pullToolStripMenuItem1.Size = new System.Drawing.Size(239, 22); - this.pullToolStripMenuItem1.Text = "Open pull dialog..."; - this.pullToolStripMenuItem1.Click += new System.EventHandler(this.pullToolStripMenuItem1_Click); - // - // fetchAllToolStripMenuItem - // - this.fetchAllToolStripMenuItem.Image = global::GitUI.Properties.Images.PullFetchAll; - this.fetchAllToolStripMenuItem.Name = "fetchAllToolStripMenuItem"; - this.fetchAllToolStripMenuItem.Size = new System.Drawing.Size(239, 22); - this.fetchAllToolStripMenuItem.Text = "Fetch all"; - this.fetchAllToolStripMenuItem.ToolTipText = "Fetch branches and tags from all remote repositories"; - this.fetchAllToolStripMenuItem.Click += new System.EventHandler(this.fetchAllToolStripMenuItem_Click); - // - // fetchPruneAllToolStripMenuItem - // - this.fetchPruneAllToolStripMenuItem.Image = global::GitUI.Properties.Images.PullFetchPruneAll; - this.fetchPruneAllToolStripMenuItem.Name = "fetchPruneAllToolStripMenuItem"; - this.fetchPruneAllToolStripMenuItem.Size = new System.Drawing.Size(239, 22); - this.fetchPruneAllToolStripMenuItem.Text = "Fetch and prune all"; - this.fetchPruneAllToolStripMenuItem.ToolTipText = "Fetch branches and tags from all remote repositories also prune deleted refs"; - this.fetchPruneAllToolStripMenuItem.Click += new System.EventHandler(this.fetchPruneAllToolStripMenuItem_Click); - // // setDefaultPullButtonActionToolStripMenuItem // this.setDefaultPullButtonActionToolStripMenuItem.Name = "setDefaultPullButtonActionToolStripMenuItem"; - this.setDefaultPullButtonActionToolStripMenuItem.Size = new System.Drawing.Size(239, 22); + this.setDefaultPullButtonActionToolStripMenuItem.Size = new System.Drawing.Size(228, 22); this.setDefaultPullButtonActionToolStripMenuItem.Text = "Set default Pull button action"; // // toolStripButtonPush @@ -554,6 +509,69 @@ private void InitializeComponent() this.toolStripButtonPush.Text = "Push"; this.toolStripButtonPush.Click += new System.EventHandler(this.ToolStripButtonPushClick); // + // toolStripButtonCommit + // + this.toolStripButtonCommit.Image = global::GitUI.Properties.Images.RepoStateClean; + this.toolStripButtonCommit.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.toolStripButtonCommit.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonCommit.Name = "toolStripButtonCommit"; + this.toolStripButtonCommit.Size = new System.Drawing.Size(71, 22); + this.toolStripButtonCommit.Text = "Commit"; + this.toolStripButtonCommit.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.toolStripButtonCommit.Click += new System.EventHandler(this.CommitToolStripMenuItemClick); + // + // toolStripSplitStash + // + this.toolStripSplitStash.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.stashChangesToolStripMenuItem, + this.stashPopToolStripMenuItem, + this.toolStripSeparator9, + this.manageStashesToolStripMenuItem, + this.createAStashToolStripMenuItem}); + this.toolStripSplitStash.Image = global::GitUI.Properties.Images.Stash; + this.toolStripSplitStash.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripSplitStash.Name = "toolStripSplitStash"; + this.toolStripSplitStash.Size = new System.Drawing.Size(32, 22); + this.toolStripSplitStash.ToolTipText = "Manage stashes"; + this.toolStripSplitStash.ButtonClick += new System.EventHandler(this.ToolStripSplitStashButtonClick); + this.toolStripSplitStash.DropDownOpened += new System.EventHandler(this.toolStripSplitStash_DropDownOpened); + // + // stashChangesToolStripMenuItem + // + this.stashChangesToolStripMenuItem.Name = "stashChangesToolStripMenuItem"; + this.stashChangesToolStripMenuItem.Size = new System.Drawing.Size(167, 22); + this.stashChangesToolStripMenuItem.Text = "Stash"; + this.stashChangesToolStripMenuItem.ToolTipText = "Stash changes"; + this.stashChangesToolStripMenuItem.Click += new System.EventHandler(this.StashChangesToolStripMenuItemClick); + // + // stashPopToolStripMenuItem + // + this.stashPopToolStripMenuItem.Name = "stashPopToolStripMenuItem"; + this.stashPopToolStripMenuItem.Size = new System.Drawing.Size(167, 22); + this.stashPopToolStripMenuItem.Text = "Stash pop"; + this.stashPopToolStripMenuItem.ToolTipText = "Apply and drop single stash"; + this.stashPopToolStripMenuItem.Click += new System.EventHandler(this.StashPopToolStripMenuItemClick); + // + // toolStripSeparator9 + // + this.toolStripSeparator9.Name = "toolStripSeparator9"; + this.toolStripSeparator9.Size = new System.Drawing.Size(164, 6); + // + // manageStashesToolStripMenuItem + // + this.manageStashesToolStripMenuItem.Name = "manageStashesToolStripMenuItem"; + this.manageStashesToolStripMenuItem.Size = new System.Drawing.Size(167, 22); + this.manageStashesToolStripMenuItem.Text = "Manage stashes..."; + this.manageStashesToolStripMenuItem.ToolTipText = "Manage stashes"; + this.manageStashesToolStripMenuItem.Click += new System.EventHandler(this.ManageStashesToolStripMenuItemClick); + // + // createAStashToolStripMenuItem + // + this.createAStashToolStripMenuItem.Name = "createAStashToolStripMenuItem"; + this.createAStashToolStripMenuItem.Size = new System.Drawing.Size(167, 22); + this.createAStashToolStripMenuItem.Text = "Create a stash..."; + this.createAStashToolStripMenuItem.Click += new System.EventHandler(this.CreateStashToolStripMenuItemClick); + // // toolStripSeparator2 // this.toolStripSeparator2.Name = "toolStripSeparator2"; @@ -979,7 +997,7 @@ private void InitializeComponent() // this.fileExplorerToolStripMenuItem.Image = global::GitUI.Properties.Images.BrowseFileExplorer; this.fileExplorerToolStripMenuItem.Name = "fileExplorerToolStripMenuItem"; - this.fileExplorerToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + this.fileExplorerToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) | System.Windows.Forms.Keys.O))); this.fileExplorerToolStripMenuItem.Size = new System.Drawing.Size(221, 22); this.fileExplorerToolStripMenuItem.Text = "File Explorer"; @@ -1929,11 +1947,7 @@ private void InitializeComponent() private ToolStripSplitButton toolStripButtonPull; private ToolStripMenuItem mergeToolStripMenuItem; private ToolStripMenuItem rebaseToolStripMenuItem1; - private ToolStripMenuItem fetchToolStripMenuItem; - private ToolStripMenuItem pullToolStripMenuItem1; private ToolStripMenuItem setDefaultPullButtonActionToolStripMenuItem; - private ToolStripMenuItem fetchAllToolStripMenuItem; - private ToolStripMenuItem fetchPruneAllToolStripMenuItem; private ToolStripMenuItem resetToolStripMenuItem; private ToolStripMenuItem reportAnIssueToolStripMenuItem; private ToolStripSeparator toolStripSeparator41; @@ -1966,5 +1980,11 @@ private void InitializeComponent() private ToolStripMenuItem tsmiTelemetryEnabled; private Panel RevisionGridContainer; private UserControls.InteractiveGitActionControl RevisionHeader; + private ToolStripSplitButton toolStripButtonFetch; + private ToolStripMenuItem fetchToolStripMenuItem; + private ToolStripMenuItem fetchAllToolStripMenuItem; + private ToolStripMenuItem fetchPruneAllToolStripMenuItem; + private ToolStripMenuItem setDefaultFetchButtonActionToolStripMenuItem; + private ToolStripMenuItem pullToolStripMenuItem1; } } diff --git a/GitUI/CommandsDialogs/FormBrowse.cs b/GitUI/CommandsDialogs/FormBrowse.cs index a682daab410..cbb808e3955 100644 --- a/GitUI/CommandsDialogs/FormBrowse.cs +++ b/GitUI/CommandsDialogs/FormBrowse.cs @@ -213,7 +213,7 @@ public FormBrowse([NotNull] GitUICommands commands, string filter, ObjectId sele UICommandsChanged += (a, e) => { var oldCommands = e.OldCommands; - RefreshDefaultPullAction(); + RefreshDefaultActions(); oldCommands.PostRepositoryChanged -= UICommands_PostRepositoryChanged; UICommands.PostRepositoryChanged += UICommands_PostRepositoryChanged; oldCommands.BrowseRepo = null; @@ -227,8 +227,9 @@ public FormBrowse([NotNull] GitUICommands commands, string filter, ObjectId sele fetchAllToolStripMenuItem.Tag = AppSettings.PullAction.FetchAll; fetchPruneAllToolStripMenuItem.Tag = AppSettings.PullAction.FetchPruneAll; + FillNextFetchActionAsDefaultToolStripMenuItems(); FillNextPullActionAsDefaultToolStripMenuItems(); - RefreshDefaultPullAction(); + RefreshDefaultActions(); UICommands.PostRepositoryChanged += UICommands_PostRepositoryChanged; UICommands.BrowseRepo = this; _controller = new FormBrowseController(new GitGpgController(() => Module), new RepositoryCurrentBranchNameProvider(), new InvalidRepositoryRemover()); @@ -449,9 +450,32 @@ Brush UpdateCommitButtonAndGetBrush(IReadOnlyList status, bool sh } } + private void FillNextFetchActionAsDefaultToolStripMenuItems() + { + FillNextActionAsDefaultToolStripMenuItems(toolStripButtonFetch, setDefaultFetchButtonActionToolStripMenuItem, + (object sender, EventArgs eventArgs) => + { + var clickedMenuItem = (ToolStripMenuItem)sender; + AppSettings.DefaultFetchAction = (AppSettings.PullAction)clickedMenuItem.Tag; + RefreshDefaultFetchAction(); + }); + } + private void FillNextPullActionAsDefaultToolStripMenuItems() { - var setDefaultPullActionDropDown = (ToolStripDropDownMenu)setDefaultPullButtonActionToolStripMenuItem.DropDown; + FillNextActionAsDefaultToolStripMenuItems(toolStripButtonPull, setDefaultPullButtonActionToolStripMenuItem, + (object sender, EventArgs eventArgs) => + { + var clickedMenuItem = (ToolStripMenuItem)sender; + AppSettings.DefaultPullAction = (AppSettings.PullAction)clickedMenuItem.Tag; + RefreshDefaultPullAction(); + }); + } + + private void FillNextActionAsDefaultToolStripMenuItems(ToolStripSplitButton buttonActionToolStripMenuItem, + ToolStripMenuItem defaultButtonActionToolStripMenuItem, EventHandler setDefaultPullActionMenuItemClick) + { + var setDefaultPullActionDropDown = (ToolStripDropDownMenu)defaultButtonActionToolStripMenuItem.DropDown; // Show both Check and Image margins in a menu setDefaultPullActionDropDown.ShowImageMargin = true; @@ -466,7 +490,7 @@ private void FillNextPullActionAsDefaultToolStripMenuItems() } }; - var setDefaultPullActionDropDownItems = toolStripButtonPull.DropDownItems + var setDefaultPullActionDropDownItems = buttonActionToolStripMenuItem.DropDownItems .OfType() .Where(tsmi => tsmi.Tag is AppSettings.PullAction) .Select(tsmi => @@ -480,19 +504,12 @@ private void FillNextPullActionAsDefaultToolStripMenuItems() Tag = tsmi.Tag }; - tsi.Click += SetDefaultPullActionMenuItemClick; + tsi.Click += setDefaultPullActionMenuItemClick; return tsi; }); setDefaultPullActionDropDown.Items.AddRange(setDefaultPullActionDropDownItems.ToArray()); - - void SetDefaultPullActionMenuItemClick(object sender, EventArgs eventArgs) - { - var clickedMenuItem = (ToolStripMenuItem)sender; - AppSettings.DefaultPullAction = (AppSettings.PullAction)clickedMenuItem.Tag; - RefreshDefaultPullAction(); - } } protected override void Dispose(bool disposing) @@ -1411,7 +1428,7 @@ private void OnShowSettingsClick(object sender, EventArgs e) _gitStatusMonitor.Active = NeedsGitStatusMonitor() && Module.IsValidGitWorkingDir(); - RefreshDefaultPullAction(); + RefreshDefaultActions(); } private void TagToolStripMenuItemClick(object sender, EventArgs e) @@ -2347,6 +2364,16 @@ private void pullToolStripMenuItem1_Click(object sender, EventArgs e) DoPull(pullAction: AppSettings.FormPullAction, isSilent: false); } + private void ToolStripButtonFetchClick(object sender, EventArgs e) + { + DoPull(pullAction: AppSettings.DefaultFetchAction, isSilent: true); + } + + private void ToolStripButtonFetch_DropDownOpened(object sender, EventArgs e) + { + PreventToolStripSplitButtonClosing(sender as ToolStripSplitButton); + } + private void mergeToolStripMenuItem_Click(object sender, EventArgs e) { DoPull(pullAction: AppSettings.PullAction.Merge, isSilent: true); @@ -2384,11 +2411,25 @@ private void DoPull(AppSettings.PullAction pullAction, bool isSilent) } } + private void RefreshDefaultActions() + { + RefreshDefaultFetchAction(); + RefreshDefaultPullAction(); + } + + private void RefreshDefaultFetchAction() + { + RefreshDefaultAction(setDefaultFetchButtonActionToolStripMenuItem, AppSettings.DefaultFetchAction); + } + private void RefreshDefaultPullAction() { - var defaultPullAction = AppSettings.DefaultPullAction; + RefreshDefaultAction(setDefaultPullButtonActionToolStripMenuItem, AppSettings.DefaultPullAction); + } - foreach (ToolStripMenuItem menuItem in setDefaultPullButtonActionToolStripMenuItem.DropDown.Items) + private void RefreshDefaultAction(ToolStripMenuItem toolStripMenuItem, AppSettings.PullAction defaultPullAction) + { + foreach (ToolStripMenuItem menuItem in toolStripMenuItem.DropDown.Items) { menuItem.Checked = (AppSettings.PullAction)menuItem.Tag == defaultPullAction; } @@ -2396,18 +2437,18 @@ private void RefreshDefaultPullAction() switch (defaultPullAction) { case AppSettings.PullAction.Fetch: - toolStripButtonPull.Image = Images.PullFetch.AdaptLightness(); - toolStripButtonPull.ToolTipText = _pullFetch.Text; + toolStripButtonFetch.Image = Images.PullFetch.AdaptLightness(); + toolStripButtonFetch.ToolTipText = _pullFetch.Text; break; case AppSettings.PullAction.FetchAll: - toolStripButtonPull.Image = Images.PullFetchAll.AdaptLightness(); - toolStripButtonPull.ToolTipText = _pullFetchAll.Text; + toolStripButtonFetch.Image = Images.PullFetchAll.AdaptLightness(); + toolStripButtonFetch.ToolTipText = _pullFetchAll.Text; break; case AppSettings.PullAction.FetchPruneAll: - toolStripButtonPull.Image = Images.PullFetchPruneAll.AdaptLightness(); - toolStripButtonPull.ToolTipText = _pullFetchPruneAll.Text; + toolStripButtonFetch.Image = Images.PullFetchPruneAll.AdaptLightness(); + toolStripButtonFetch.ToolTipText = _pullFetchPruneAll.Text; break; case AppSettings.PullAction.Merge: diff --git a/GitUI/GitUICommands.cs b/GitUI/GitUICommands.cs index aaece6e8778..6e5a71723fa 100644 --- a/GitUI/GitUICommands.cs +++ b/GitUI/GitUICommands.cs @@ -1833,7 +1833,7 @@ private static void UpdateSettingsBasedOnArguments(IReadOnlyDictionary Solve merge conflicts... + + Set default Fetch button action + + Set default Pull button action @@ -2519,6 +2523,10 @@ Do you want to continue? Commit + + Fetch + + Pull