Fixed some warnings
[TortoiseGit.git] / src / TortoiseProc / DeleteRemoteTagDlg.cpp
blobee9eceaa62d15463bd4efa9fdcf4d609f1bf43cf
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2012 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "stdafx.h"
22 #include "Git.h"
23 #include "AppUtils.h"
24 #include "TortoiseProc.h"
25 #include "DeleteRemoteTagDlg.h"
26 #include "Messagebox.h"
28 IMPLEMENT_DYNAMIC(CDeleteRemoteTagDlg, CHorizontalResizableStandAloneDialog)
30 CDeleteRemoteTagDlg::CDeleteRemoteTagDlg(CWnd* pParent /*=NULL*/)
31 : CHorizontalResizableStandAloneDialog(CDeleteRemoteTagDlg::IDD, pParent)
35 CDeleteRemoteTagDlg::~CDeleteRemoteTagDlg()
39 void CDeleteRemoteTagDlg::DoDataExchange(CDataExchange* pDX)
41 CDialog::DoDataExchange(pDX);
42 DDX_Control(pDX, IDC_COMBOBOXEX_TAGS, m_ctrlTags);
45 BEGIN_MESSAGE_MAP(CDeleteRemoteTagDlg, CHorizontalResizableStandAloneDialog)
46 ON_BN_CLICKED(IDOK, OnBnClickedOk)
47 ON_CBN_SELCHANGE(IDC_COMBOBOXEX_TAGS, OnCbnSelchangeTags)
48 END_MESSAGE_MAP()
50 BOOL CDeleteRemoteTagDlg::OnInitDialog()
52 CHorizontalResizableStandAloneDialog::OnInitDialog();
53 CAppUtils::MarkWindowAsUnpinnable(m_hWnd);
55 AddAnchor(IDC_COMBOBOXEX_TAGS, TOP_LEFT, BOTTOM_RIGHT);
56 AddAnchor(IDOK, BOTTOM_RIGHT);
57 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
59 this->AddOthersToAnchor();
61 AdjustControlSize(IDC_STATIC);
63 Refresh();
65 EnableSaveRestore(_T("DeleteRemoteTagDlg"));
67 return TRUE;
70 void CDeleteRemoteTagDlg::Refresh()
72 m_ctrlTags.SetMaxHistoryItems(0x0FFFFFFF);
73 m_ctrlTags.Reset();
75 STRING_VECTOR list;
76 g_Git.GetRemoteTags(m_sRemote, list);
77 m_ctrlTags.AddString(list);
79 m_ctrlTags.SetCurSel(-1);
80 DialogEnableWindow(IDOK, FALSE);
83 void CDeleteRemoteTagDlg::OnBnClickedOk()
85 this->UpdateData(TRUE);
87 CString msg;
88 msg.Format(IDS_PROC_DELETEBRANCHTAG, m_ctrlTags.GetString());
89 if (CMessageBox::Show(m_hWnd, msg, _T("TortoiseGit"), 2, IDI_QUESTION, CString(MAKEINTRESOURCE(IDS_DELETEBUTTON)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON))) == 1)
91 CString cmd, out;
92 cmd.Format(_T("git.exe push %s :refs/tags/%s"), m_sRemote, m_ctrlTags.GetString());
93 if (g_Git.Run(cmd, &out, CP_UTF8))
95 MessageBox(out, _T("TortoiseGit"), MB_ICONERROR);
96 return;
98 m_ctrlTags.RemoveSelectedItem();
99 m_ctrlTags.SetCurSel(-1);
100 DialogEnableWindow(IDOK, FALSE);
104 void CDeleteRemoteTagDlg::OnCbnSelchangeTags()
106 DialogEnableWindow(IDOK, m_ctrlTags.GetCurSel() != 1);
109 BOOL CDeleteRemoteTagDlg::PreTranslateMessage(MSG* pMsg)
111 if (pMsg->message == WM_KEYDOWN)
113 switch (pMsg->wParam)
115 case VK_F5:
117 Refresh();
119 break;
123 return CHorizontalResizableStandAloneDialog::PreTranslateMessage(pMsg);