Skip to content

Commit

Permalink
Merge branch 'experimental'
Browse files Browse the repository at this point in the history
  • Loading branch information
tomolt committed May 27, 2015
2 parents 9636764 + 9f549d8 commit 33a36cb
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 20 deletions.
2 changes: 2 additions & 0 deletions GitBlocks.cbp
Expand Up @@ -62,6 +62,7 @@
<Unit filename="wxsmith/NewBranchDialog.wxs" />
<Unit filename="wxsmith/RemoveDialog.wxs" />
<Unit filename="wxsmith/RenameDialog.wxs" />
<Unit filename="wxsmith/SwitchBranchDialog.wxs" />
<Extensions>
<envvars />
<code_completion />
Expand All @@ -74,6 +75,7 @@
<wxDialog wxs="wxsmith/NewBranchDialog.wxs" src="src/NewBranchDialog.cpp" hdr="include/NewBranchDialog.h" fwddecl="0" i18n="1" name="NewBranchDialog" language="CPP" />
<wxDialog wxs="wxsmith/RemoveDialog.wxs" src="src/RemoveDialog.cpp" hdr="include/RemoveDialog.h" fwddecl="0" i18n="1" name="RemoveDialog" language="CPP" />
<wxDialog wxs="wxsmith/RenameDialog.wxs" src="src/RenameDialog.cpp" hdr="include/RenameDialog.h" fwddecl="0" i18n="1" name="RenameDialog" language="CPP" />
<wxDialog wxs="wxsmith/SwitchBranchDialog.wxs" src="src/SwitchBranchDialog.cpp" hdr="include/SwitchBranchDialog.h" fwddecl="0" i18n="1" name="SwitchBranchDialog" language="CPP" />
</resources>
</wxsmith>
<lib_finder disable_auto="1" />
Expand Down
2 changes: 2 additions & 0 deletions include/GitBlocks.h
Expand Up @@ -131,6 +131,8 @@ class GitBlocks : public cbPlugin
void Execute(wxString command, const wxString comment, wxString dir = wxEmptyString);
void ExecuteInTerminal(wxString command, const wxString comment, wxString dir = wxEmptyString);

wxArrayString ListBranches();

void Init(wxCommandEvent &event);
void Clone(wxCommandEvent &event);
void Destroy(wxCommandEvent &event);
Expand Down
6 changes: 3 additions & 3 deletions include/SwitchBranchDialog.h
Expand Up @@ -5,7 +5,7 @@
#include <wx/dialog.h>
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/choice.h>
//*)

class SwitchBranchDialog: public wxDialog
Expand All @@ -17,14 +17,14 @@ class SwitchBranchDialog: public wxDialog

//(*Declarations(SwitchBranchDialog)
wxStaticText* StaticText1;
wxTextCtrl* Name;
wxChoice* BranchChoice;
//*)

protected:

//(*Identifiers(SwitchBranchDialog)
static const long ID_STATICTEXT1;
static const long ID_NAME;
static const long ID_CHOICE1;
//*)

private:
Expand Down
2 changes: 1 addition & 1 deletion src/CommitDialog.cpp
Expand Up @@ -27,7 +27,7 @@ CommitDialog::CommitDialog(wxWindow* parent,wxWindowID id,const wxPoint& pos,con
wxBoxSizer* BoxSizer1;
wxStdDialogButtonSizer* StdDialogButtonSizer1;

Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("id"));
Create(parent, id, _("Commit"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("id"));
SetClientSize(wxDefaultSize);
Move(wxDefaultPosition);
BoxSizer1 = new wxBoxSizer(wxVERTICAL);
Expand Down
24 changes: 23 additions & 1 deletion src/GitBlocks.cpp
Expand Up @@ -134,6 +134,23 @@ void GitBlocks::ExecuteInTerminal(wxString command, const wxString comment, wxSt
Execute(newcmd, comment, dir);
}

wxArrayString GitBlocks::ListBranches()
{
wxString dir = Manager::Get()->GetProjectManager()->GetActiveProject()->GetBasePath();

wxArrayString output;

wxString ocwd = wxGetCwd();
wxSetWorkingDirectory(dir);
wxExecute(git + _T(" branch"), output);
wxSetWorkingDirectory(ocwd);

for(unsigned int i=0;i<output.size();i++)
output[i] = output[i].Mid(2);

return output;
}

void GitBlocks::Init(wxCommandEvent &event)
{
Execute(git + _T(" init"), _("Creating an empty git repository ..."));
Expand Down Expand Up @@ -258,8 +275,13 @@ void GitBlocks::NewBranch(wxCommandEvent &event)
void GitBlocks::SwitchBranch(wxCommandEvent &event)
{
SwitchBranchDialog dialog(Manager::Get()->GetAppWindow());

wxArrayString branches = ListBranches();
for(unsigned int i=0; i<branches.size(); i++)
dialog.BranchChoice->Append(branches[i]);

if(dialog.ShowModal() == wxID_OK)
Execute(git + _T(" checkout ") + dialog.Name->GetValue(), _("Switching branch ..."));
Execute(git + _T(" checkout ") + branches[dialog.BranchChoice->GetSelection()], _("Switching branch ..."));
}

void GitBlocks::DiffToIndex(wxCommandEvent &event)
Expand Down
4 changes: 2 additions & 2 deletions src/RemoveDialog.cpp
Expand Up @@ -33,12 +33,12 @@ RemoveDialog::RemoveDialog(wxWindow* parent,wxWindowID id,const wxPoint& pos,con
BoxSizer2->Add(StaticText1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FileChoice = new wxChoice(this, ID_CHOICE1, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE1"));
BoxSizer2->Add(FileChoice, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer1->Add(BoxSizer2, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer1->Add(BoxSizer2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StdDialogButtonSizer1 = new wxStdDialogButtonSizer();
StdDialogButtonSizer1->AddButton(new wxButton(this, wxID_OK, wxEmptyString));
StdDialogButtonSizer1->AddButton(new wxButton(this, wxID_CANCEL, wxEmptyString));
StdDialogButtonSizer1->Realize();
BoxSizer1->Add(StdDialogButtonSizer1, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer1->Add(StdDialogButtonSizer1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
SetSizer(BoxSizer1);
BoxSizer1->Fit(this);
BoxSizer1->SetSizeHints(this);
Expand Down
2 changes: 1 addition & 1 deletion src/RenameDialog.cpp
Expand Up @@ -16,7 +16,7 @@ END_EVENT_TABLE()
RenameDialog::RenameDialog(wxWindow* parent,wxWindowID id,const wxPoint& pos,const wxSize& size)
{
//(*Initialize(RenameDialog)
Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("id"));
Create(parent, id, _("Rename File"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("id"));
SetClientSize(wxDefaultSize);
Move(wxDefaultPosition);
//*)
Expand Down
14 changes: 7 additions & 7 deletions src/SwitchBranchDialog.cpp
Expand Up @@ -8,7 +8,7 @@

//(*IdInit(SwitchBranchDialog)
const long SwitchBranchDialog::ID_STATICTEXT1 = wxNewId();
const long SwitchBranchDialog::ID_NAME = wxNewId();
const long SwitchBranchDialog::ID_CHOICE1 = wxNewId();
//*)

BEGIN_EVENT_TABLE(SwitchBranchDialog,wxDialog)
Expand All @@ -23,21 +23,21 @@ SwitchBranchDialog::SwitchBranchDialog(wxWindow* parent,wxWindowID id,const wxPo
wxBoxSizer* BoxSizer1;
wxStdDialogButtonSizer* StdDialogButtonSizer1;

Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("id"));
Create(parent, id, _("Switch branch"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("id"));
SetClientSize(wxDefaultSize);
Move(wxDefaultPosition);
BoxSizer1 = new wxBoxSizer(wxVERTICAL);
BoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Name: "), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
BoxSizer2->Add(StaticText1, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
Name = new wxTextCtrl(this, ID_NAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_NAME"));
BoxSizer2->Add(Name, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Branch:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
BoxSizer2->Add(StaticText1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BranchChoice = new wxChoice(this, ID_CHOICE1, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE1"));
BoxSizer2->Add(BranchChoice, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer1->Add(BoxSizer2, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StdDialogButtonSizer1 = new wxStdDialogButtonSizer();
StdDialogButtonSizer1->AddButton(new wxButton(this, wxID_OK, wxEmptyString));
StdDialogButtonSizer1->AddButton(new wxButton(this, wxID_CANCEL, wxEmptyString));
StdDialogButtonSizer1->Realize();
BoxSizer1->Add(StdDialogButtonSizer1, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer1->Add(StdDialogButtonSizer1, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
SetSizer(BoxSizer1);
BoxSizer1->Fit(this);
BoxSizer1->SetSizeHints(this);
Expand Down
1 change: 1 addition & 0 deletions wxsmith/CommitDialog.wxs
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<wxsmith>
<object class="wxDialog" name="CommitDialog">
<title>Commit</title>
<pos_arg>1</pos_arg>
<size_arg>1</size_arg>
<object class="wxBoxSizer" variable="BoxSizer1" member="no">
Expand Down
2 changes: 1 addition & 1 deletion wxsmith/RemoveDialog.wxs
Expand Up @@ -16,7 +16,7 @@
<option>1</option>
</object>
<object class="sizeritem">
<object class="wxChoice" name="ID_CHOICE1" variable="Choice1" member="yes" />
<object class="wxChoice" name="ID_CHOICE1" variable="FileChoice" member="yes" />
<flag>wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
<border>5</border>
<option>1</option>
Expand Down
1 change: 1 addition & 0 deletions wxsmith/RenameDialog.wxs
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<wxsmith>
<object class="wxDialog" name="RenameDialog">
<title>Rename File</title>
<pos_arg>1</pos_arg>
<size_arg>1</size_arg>
</object>
Expand Down
10 changes: 6 additions & 4 deletions wxsmith/SwitchBranchDialog.wxs
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<wxsmith>
<object class="wxDialog" name="SwitchBranchDialog">
<title>Switch branch</title>
<pos_arg>1</pos_arg>
<size_arg>1</size_arg>
<object class="wxBoxSizer" variable="BoxSizer1" member="no">
Expand All @@ -9,14 +10,15 @@
<object class="wxBoxSizer" variable="BoxSizer2" member="no">
<object class="sizeritem">
<object class="wxStaticText" name="ID_STATICTEXT1" variable="StaticText1" member="yes">
<label>Name: </label>
<label>Branch:</label>
</object>
<flag>wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
<border>5</border>
<option>1</option>
</object>
<object class="sizeritem">
<object class="wxTextCtrl" name="ID_NAME" variable="Name" member="yes" />
<flag>wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
<object class="wxChoice" name="ID_CHOICE1" variable="BranchChoice" member="yes" />
<flag>wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
<border>5</border>
<option>1</option>
</object>
Expand All @@ -38,7 +40,7 @@
</object>
</object>
</object>
<flag>wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
<flag>wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
<border>5</border>
<option>1</option>
</object>
Expand Down

0 comments on commit 33a36cb

Please sign in to comment.