Skip to content

Commit

Permalink
Git blame: added new icon to the "Git blame" functionality
Browse files Browse the repository at this point in the history
Git blame: it is now possible to call "git blame" from the file's context menu (from the workspace view or from the explorer view)
  • Loading branch information
eranif committed Oct 24, 2016
1 parent a0724ac commit 1085df1
Show file tree
Hide file tree
Showing 13 changed files with 685 additions and 657 deletions.
1 change: 0 additions & 1 deletion Plugin/builder_gnumake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,6 @@ BuilderGnuMake::CreateTargets(const wxString& type, BuildConfigPtr bldConf, wxSt
// know that a re-link is required
if(bldConf->IsLinkerRequired() && markRebuilt) {
text << wxT("\t@$(MakeDirCommand) \"") << DoGetMarkerFileDir(wxEmptyString) << wxT("\"\n");

text << wxT("\t@echo rebuilt > ") << DoGetMarkerFileDir(projName) << wxT("\n");
}
}
Expand Down
Binary file modified Runtime/codelite-bitmaps.zip
Binary file not shown.
Binary file added bitmaps/16-finger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bitmaps/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bitmaps/24-finger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bitmaps/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 24 additions & 4 deletions git/git.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ GitPlugin::GitPlugin(IManager* manager)
wxCommandEventHandler(GitPlugin::OnFileResetSelected), NULL, this);
m_eventHandler->Connect(XRCID("git_diff_file"), wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(GitPlugin::OnFileDiffSelected), NULL, this);

m_eventHandler->Bind(wxEVT_MENU, &GitPlugin::OnFileGitBlame, this, XRCID("git_blame_file"));

// Add the console
m_console = new GitConsole(m_mgr->GetOutputPaneNotebook(), this);
m_mgr->GetOutputPaneNotebook()->AddPage(m_console, _("Git"), false, m_mgr->GetStdIcons()->LoadBitmap("git"));
Expand Down Expand Up @@ -243,7 +244,7 @@ void GitPlugin::CreatePluginMenu(wxMenu* pluginsMenu)
m_pluginMenu->Append(item);
item =
new wxMenuItem(m_pluginMenu, XRCID("git_blame"), _("Show git blame"), _("Show blame"), wxITEM_NORMAL);
//item->SetBitmap(bmps->LoadBitmap("diff")); TODO:
item->SetBitmap(bmps->LoadBitmap("finger"));
m_pluginMenu->Append(item);
item = new wxMenuItem(m_pluginMenu, XRCID("git_apply_patch"), _("Apply Patch"), _("Apply Patch"), wxITEM_NORMAL);
item->SetBitmap(bmps->LoadBitmap("patch"));
Expand Down Expand Up @@ -419,7 +420,8 @@ void GitPlugin::UnPlug()
XRCID("git_refresh"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(GitPlugin::OnRefresh), NULL, this);
m_eventHandler->Disconnect(XRCID("git_garbage_collection"), wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(GitPlugin::OnGarbageColletion), NULL, this);

m_eventHandler->Unbind(wxEVT_MENU, &GitPlugin::OnFileGitBlame, this, XRCID("git_blame_file"));

/*SYSTEM*/
EventNotifier::Get()->Disconnect(wxEVT_INIT_DONE, wxCommandEventHandler(GitPlugin::OnInitDone), NULL, this);
EventNotifier::Get()->Disconnect(wxEVT_FILE_SAVED, clCommandEventHandler(GitPlugin::OnFileSaved), NULL, this);
Expand Down Expand Up @@ -2363,7 +2365,12 @@ void GitPlugin::OnFileMenu(clContextMenuEvent& event)
item = new wxMenuItem(menu, XRCID("git_diff_file"), _("Show file diff"));
item->SetBitmap(bmps->LoadBitmap("diff"));
menu->Append(item);


menu->AppendSeparator();
item = new wxMenuItem(menu, XRCID("git_blame_file"), _("Show Git Blame"));
item->SetBitmap(bmps->LoadBitmap("finger"));
menu->Append(item);

item = new wxMenuItem(parentMenu, wxID_ANY, _("Git"), "", wxITEM_NORMAL, menu);
item->SetBitmap(bmps->LoadBitmap("git"));
parentMenu->AppendSeparator();
Expand Down Expand Up @@ -2654,3 +2661,16 @@ void GitPlugin::FetchNextCommits(int skip)
m_gitActionQueue.push_back(ga);
ProcessGitActionQueue();
}

void GitPlugin::OnFileGitBlame(wxCommandEvent& event)
{
// Sanity
if(m_filesSelected.IsEmpty() || m_repositoryDirectory.empty()) return;

// We need to be symlink-aware here on Linux, so use CLRealPath
wxString realfilepath = CLRealPath(m_filesSelected.Item(0));
wxFileName fn(realfilepath);
fn.MakeRelativeTo(CLRealPath(m_repositoryDirectory));

DoGitBlame(fn.GetFullPath());
}
24 changes: 13 additions & 11 deletions git/git.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class GitPlugin : public IPlugin
{
friend class GitConsole;
friend class GitCommitListDlg;

typedef std::map<int, int> IntMap_t;
enum {
gitNone = 0,
Expand Down Expand Up @@ -249,6 +249,7 @@ class GitPlugin : public IPlugin
void OnGarbageColletion(wxCommandEvent& e);
void OnOpenMSYSGit(wxCommandEvent& e);
void OnActiveProjectChanged(clProjectSettingsEvent& event);
void OnFileGitBlame(wxCommandEvent& event);

#if 0
void OnBisectStart(wxCommandEvent& e);
Expand All @@ -270,17 +271,17 @@ class GitPlugin : public IPlugin
public:
GitPlugin(IManager* manager);
~GitPlugin();

void StoreWorkspaceRepoDetails();
void WorkspaceClosed();
/**

/**
* @brief fetch the next 100 commits (skip 'skip' first commits)
* and show them in the commit list dialog
* @param skip number of first commits to skip
* and show them in the commit list dialog
* @param skip number of first commits to skip
*/
void FetchNextCommits(int skip);

GitConsole* GetConsole() { return m_console; }
const wxString& GetRepositoryDirectory() const { return m_repositoryDirectory; }
IProcess* GetProcess() { return m_process; }
Expand All @@ -300,11 +301,12 @@ class GitPlugin : public IPlugin
void UndoAddFiles(const wxArrayString& files);

void RefreshFileListView();
void DoGitBlame(const wxString& args); // Called by OnGitBlame or the git blame dialog

void DoGitBlame(const wxString& args); // Called by OnGitBlame or the git blame dialog
wxString GetEditorRelativeFilepath() const; // Called by OnGitBlame or the git blame dialog
void OnGitBlameRevList(const wxString& arg, const wxString& filepath, const wxString& commit=""); // Called by the git blame dialog
void OnGitBlameLog(const wxString& commit); // Called by the git blame dialog
void OnGitBlameRevList(
const wxString& arg, const wxString& filepath, const wxString& commit = ""); // Called by the git blame dialog
void OnGitBlameLog(const wxString& commit); // Called by the git blame dialog

/**
* @brief simple git command executioin completed. Display its output etc
Expand Down
1 change: 1 addition & 0 deletions git/gitBlameDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ void GitBlameDlg::OnForwardUpdateUI(wxUpdateUIEvent& event) { event.Enable(m_com

void GitBlameDlg::OnHistoryItemSelected(wxCommandEvent& event)
{
wxBusyCursor bc;
int sel = event.GetSelection();
wxString str = event.GetString();
wxString commit = m_commitStore.GetCommit(sel);
Expand Down
38 changes: 17 additions & 21 deletions git/gitui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1896,43 +1896,39 @@ GitBlameDlgBase::GitBlameDlgBase(wxWindow* parent, wxWindowID id, const wxString
wxBoxSizer* boxSizer374 = new wxBoxSizer(wxVERTICAL);
this->SetSizer(boxSizer374);

wxBoxSizer* boxSizer378 = new wxBoxSizer(wxVERTICAL);
m_auibar436 = new wxAuiToolBar(this, wxID_ANY, wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1,-1)), wxAUI_TB_PLAIN_BACKGROUND|wxAUI_TB_DEFAULT_STYLE);
m_auibar436->SetToolBitmapSize(wxSize(16,16));

boxSizer374->Add(boxSizer378, 1, wxALL|wxEXPAND, WXC_FROM_DIP(5));
boxSizer374->Add(m_auibar436, 0, wxEXPAND, WXC_FROM_DIP(5));

m_toolbar389 = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1,-1)), wxTB_NODIVIDER|wxTB_FLAT);
m_toolbar389->SetToolBitmapSize(wxSize(16,16));
m_auibar436->AddTool(XRCID("m_tbBack"), _("Previous"), wxXmlResource::Get()->LoadBitmap(wxT("24-back")), wxNullBitmap, wxITEM_NORMAL, _("Go backwards to earlier commit's blame"), _("Show earlier commit's blame"), NULL);

boxSizer378->Add(m_toolbar389, 0, wxALL|wxEXPAND, WXC_FROM_DIP(5));

m_toolbar389->AddTool(XRCID("m_tbBack"), _("Previous"), wxXmlResource::Get()->LoadBitmap(wxT("24-back")), wxNullBitmap, wxITEM_NORMAL, _("Go backwards to earlier commit's blame"), _("Show earlier commit's blame"), NULL);

m_toolbar389->AddTool(XRCID("m_tbForward"), _("Next"), wxXmlResource::Get()->LoadBitmap(wxT("24-forward")), wxNullBitmap, wxITEM_NORMAL, _("Go forward to more-recent commit's blame"), _("Show next-seen commit's blame"), NULL);
m_auibar436->AddTool(XRCID("m_tbForward"), _("Next"), wxXmlResource::Get()->LoadBitmap(wxT("24-forward")), wxNullBitmap, wxITEM_NORMAL, _("Go forward to more-recent commit's blame"), _("Show next-seen commit's blame"), NULL);

wxArrayString m_choiceHistoryArr;
m_choiceHistoryArr.Add(wxT("abcd4444 (HEAD)"));
m_choiceHistory = new wxChoice(m_toolbar389, XRCID("m_choiceHistory"), wxDefaultPosition, wxDLG_UNIT(m_toolbar389, wxSize(-1,-1)), m_choiceHistoryArr, 0);
m_choiceHistory = new wxChoice(m_auibar436, XRCID("m_choiceHistory"), wxDefaultPosition, wxDLG_UNIT(m_auibar436, wxSize(-1,-1)), m_choiceHistoryArr, 0);
m_choiceHistory->SetToolTip(_("Previously-visited commits. Note that these are listed in the order that you visited them, not commit-date order."));
m_toolbar389->AddControl(m_choiceHistory);
m_auibar436->AddControl(m_choiceHistory);

m_staticText414 = new wxStaticText(m_toolbar389, wxID_ANY, _(" Extra arguments:"), wxDefaultPosition, wxDLG_UNIT(m_toolbar389, wxSize(-1,-1)), 0);
m_toolbar389->AddControl(m_staticText414);
m_staticText414 = new wxStaticText(m_auibar436, wxID_ANY, _(" Extra arguments:"), wxDefaultPosition, wxDLG_UNIT(m_auibar436, wxSize(-1,-1)), 0);
m_auibar436->AddControl(m_staticText414);

wxArrayString m_comboExtraArgsArr;
m_comboExtraArgsArr.Add(wxT("-L 123,130 foo bar"));
m_comboExtraArgs = new wxComboBox(m_toolbar389, XRCID("m_comboExtraArgs"), wxT(""), wxDefaultPosition, wxDLG_UNIT(m_toolbar389, wxSize(-1,-1)), m_comboExtraArgsArr, wxTE_PROCESS_ENTER);
m_comboExtraArgs = new wxComboBox(m_auibar436, XRCID("m_comboExtraArgs"), wxT(""), wxDefaultPosition, wxDLG_UNIT(m_auibar436, wxSize(-1,-1)), m_comboExtraArgsArr, wxTE_PROCESS_ENTER);
m_comboExtraArgs->SetToolTip(_("Optional extra arguments that you wish passed to git blame.\nAn example might be: -L 100,130\nNote that this is _not_ sanity-checked, it's added just as it is."));
#if wxVERSION_NUMBER >= 3000
m_comboExtraArgs->SetHint(wxT(""));
#endif
m_toolbar389->AddControl(m_comboExtraArgs);
m_auibar436->AddControl(m_comboExtraArgs);

m_toolbar389->AddTool(XRCID("m_toolbarItemRefresh"), _("Refresh"), wxXmlResource::Get()->LoadBitmap(wxT("24-debugger_restart")), wxNullBitmap, wxITEM_NORMAL, _("Redo the current commit's blame"), _("Redo the current commit's blame"), NULL);
m_auibar436->AddTool(XRCID("m_toolbarItemRefresh"), _("Refresh"), wxXmlResource::Get()->LoadBitmap(wxT("24-debugger_restart")), wxNullBitmap, wxITEM_NORMAL, _("Redo the current commit's blame"), _("Redo the current commit's blame"), NULL);

m_toolbar389->AddStretchableSpace();
m_auibar436->AddStretchSpacer(1);

m_toolbar389->AddTool(XRCID("m_toolbarItemSettings"), _("Settings"), wxXmlResource::Get()->LoadBitmap(wxT("24-cog")), wxNullBitmap, wxITEM_NORMAL, _("Settings"), wxT(""), NULL);
m_toolbar389->Realize();
m_auibar436->AddTool(XRCID("m_toolbarItemSettings"), _("Settings"), wxXmlResource::Get()->LoadBitmap(wxT("24-cog")), wxNullBitmap, wxITEM_NORMAL, _("Settings"), wxT(""), NULL);
m_auibar436->Realize();

m_stcBlame = new wxStyledTextCtrl(this, wxID_ANY, wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1,-1)), 0);
// Configure the fold margin
Expand Down Expand Up @@ -1970,7 +1966,7 @@ GitBlameDlgBase::GitBlameDlgBase(wxWindow* parent, wxWindowID id, const wxString
m_stcBlame->SetKeyWords(3, wxT(""));
m_stcBlame->SetKeyWords(4, wxT(""));

boxSizer378->Add(m_stcBlame, 1, wxALL|wxEXPAND, WXC_FROM_DIP(5));
boxSizer374->Add(m_stcBlame, 1, wxALL|wxEXPAND, WXC_FROM_DIP(5));

m_stdBtnSizer306 = new wxStdDialogButtonSizer();

Expand Down Expand Up @@ -2069,7 +2065,7 @@ GitBlameSettingsDlgBase::GitBlameSettingsDlgBase(wxWindow* parent, wxWindowID id

m_stdBtnSizer429 = new wxStdDialogButtonSizer();

boxSizer420->Add(m_stdBtnSizer429, 0, wxALL, WXC_FROM_DIP(5));
boxSizer420->Add(m_stdBtnSizer429, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, WXC_FROM_DIP(10));

m_button431 = new wxButton(this, wxID_OK, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
m_stdBtnSizer429->AddButton(m_button431);
Expand Down
4 changes: 2 additions & 2 deletions git/gitui.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class GitConsoleBase : public wxPanel
class GitBlameDlgBase : public wxDialog
{
protected:
wxToolBar* m_toolbar389;
wxAuiToolBar* m_auibar436;
wxChoice* m_choiceHistory;
wxStaticText* m_staticText414;
wxComboBox* m_comboExtraArgs;
Expand All @@ -411,7 +411,7 @@ class GitBlameDlgBase : public wxDialog
wxChoice* GetChoiceHistory() { return m_choiceHistory; }
wxStaticText* GetStaticText414() { return m_staticText414; }
wxComboBox* GetComboExtraArgs() { return m_comboExtraArgs; }
wxToolBar* GetToolbar389() { return m_toolbar389; }
wxAuiToolBar* GetAuibar436() { return m_auibar436; }
wxStyledTextCtrl* GetStcBlame() { return m_stcBlame; }
GitBlameDlgBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Git Blame"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(-1,-1), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);
virtual ~GitBlameDlgBase();
Expand Down
Loading

0 comments on commit 1085df1

Please sign in to comment.