Exemplo n.º 1
0
void GitCommitDlg::OnCommitHistoryUI(wxUpdateUIEvent& event)
{
    clConfig conf("git.conf");
    GitEntry data;
    conf.ReadItem(&data);
    event.Enable(!data.GetRecentCommit().IsEmpty());
}
Exemplo n.º 2
0
GitCommitDlg::GitCommitDlg(wxWindow* parent)
    : GitCommitDlgBase(parent)
    , m_toggleChecks(false)
{
    // read the configuration
    clConfig conf("git.conf");
    GitEntry data;
    conf.ReadItem(&data);

    m_splitterInner->SetSashPosition(data.GetGitCommitDlgHSashPos());
    m_splitterMain->SetSashPosition(data.GetGitCommitDlgVSashPos());
    
    LexerConf::Ptr_t diffLexer = ColoursAndFontsManager::Get().GetLexer("diff");
    if(diffLexer) {
        diffLexer->Apply(m_stcDiff);
    }
    
    m_choiceRecentCommits->Append(data.GetRecentCommit());
    if(!data.GetRecentCommit().IsEmpty()) {
        m_choiceRecentCommits->SetSelection(0);
    }
    
    SetName("GitCommitDlg");
    WindowAttrManager::Load(this);
    LexerConf::Ptr_t lex = ColoursAndFontsManager::Get().GetLexer("text");
    lex->Apply(m_stcCommitMessage);
}
Exemplo n.º 3
0
void GitConsole::OnConfigurationChanged(wxCommandEvent& e)
{
    e.Skip();
    clConfig conf("git.conf");
    GitEntry data;
    conf.ReadItem(&data);
    m_isVerbose = (data.GetFlags() & GitEntry::Git_Verbose_Log);
}
Exemplo n.º 4
0
void GitCommitDlg::OnClearGitCommitHistory(wxCommandEvent& event)
{
    clConfig conf("git.conf");
    GitEntry data;
    conf.ReadItem(&data);

    data.GetRecentCommit().Clear();
    conf.WriteItem(&data);
}
Exemplo n.º 5
0
GitDiffDlg::~GitDiffDlg()
{
    WindowAttrManager::Save(this, wxT("GitDiffDlg"), NULL);
    clConfig conf("git.conf");
    GitEntry data;
    conf.ReadItem(&data);
    data.SetGitDiffDlgSashPos( m_splitter->GetSashPosition() );
    conf.WriteItem(&data);
}
Exemplo n.º 6
0
GitDiffDlg::GitDiffDlg(wxWindow* parent, const wxString& workingDir)
    : GitDiffDlgBase(parent)
    , m_workingDir(workingDir)
{
    clConfig conf("git.conf");
    GitEntry data;
    conf.ReadItem(&data);
    m_gitPath = data.GetGITExecutablePath();

    WindowAttrManager::Load(this, wxT("GitDiffDlg"), NULL);
    m_splitter->SetSashPosition( data.GetGitDiffDlgSashPos() );
}
Exemplo n.º 7
0
GitCommitDlg::~GitCommitDlg()
{
    // read the configuration
    clConfig conf("git.conf");
    GitEntry data;
    conf.ReadItem(&data);

    wxString message = m_stcCommitMessage->GetText();
    data.AddRecentCommit(message);
    data.SetGitCommitDlgHSashPos(m_splitterInner->GetSashPosition());
    data.SetGitCommitDlgVSashPos(m_splitterMain->GetSashPosition());
    conf.WriteItem(&data);
}
Exemplo n.º 8
0
GitCommitDlg::~GitCommitDlg()
{
    // read the configuration
    clConfig conf("git.conf");
    GitEntry data;
    conf.ReadItem( &data );
    
    data.SetGitCommitDlgHSashPos(m_splitterInner->GetSashPosition());
    data.SetGitCommitDlgVSashPos(m_splitterMain->GetSashPosition());
    conf.WriteItem( &data );
    
    WindowAttrManager::Save(this, wxT("GitCommitDlg"), NULL);
}
Exemplo n.º 9
0
void GitCommitDlg::OnCommitHistory(wxCommandEvent& event)
{
    clConfig conf("git.conf");
    GitEntry data;
    conf.ReadItem(&data);
    
    const wxArrayString& options = data.GetRecentCommit();
    
    clSingleChoiceDialog dlg(this, options);
    dlg.SetLabel(_("Choose a commit"));
    if(dlg.ShowModal() != wxID_OK) return;
    
    m_stcCommitMessage->SetText(dlg.GetSelection());
}
Exemplo n.º 10
0
GitCommitDlg::GitCommitDlg(wxWindow* parent, const wxString& repoDir)
    : GitCommitDlgBase(parent)
    , m_workingDir(repoDir)
{
    // read the configuration
    clConfig conf("git.conf");
    GitEntry data;
    conf.ReadItem( &data );
    
    m_splitterInner->SetSashPosition(data.GetGitCommitDlgHSashPos());
    m_splitterMain->SetSashPosition(data.GetGitCommitDlgVSashPos());
    
    WindowAttrManager::Load(this, wxT("GitCommitDlg"), NULL);
    LexerConf::Ptr_t lex = EditorConfigST::Get()->GetLexer("text");
    lex->Apply(m_stcCommitMessage);
}
Exemplo n.º 11
0
void GitConsole::DoOnDropdown(wxAuiToolBarEvent& e, const wxString& commandName, int id)
{

    if(!e.IsDropDownClicked()) {
        e.Skip();
        return;
    }

    GitEntry data;
    {
        clConfig conf("git.conf");
        conf.ReadItem(&data);
    } // Force conf out of scope, else its dtor clobbers the GitConsole::OnDropDownMenuEvent Save()
    GitCommandsEntries& ce = data.GetGitCommandsEntries(commandName);
    vGitLabelCommands_t entries = ce.GetCommands();
    int lastUsed = ce.GetLastUsedCommandIndex();

    wxArrayString arr;
    wxMenu menu;
    for(size_t n = 0; n < entries.size(); ++n) {
        wxMenuItem* item = menu.AppendRadioItem(n, entries.at(n).label);
        item->Check(n == (size_t)lastUsed);
        arr.Add(entries.at(n).command);
    }
    menu.Bind(wxEVT_COMMAND_MENU_SELECTED,
              wxCommandEventHandler(GitConsole::OnDropDownMenuEvent),
              this,
              0,
              arr.GetCount(),
              new GitCommandData(arr, commandName, id));

    wxAuiToolBar* auibar = dynamic_cast<wxAuiToolBar*>(e.GetEventObject());
    if(auibar) {
        clAuiToolStickness ts(auibar, e.GetToolId());
        wxRect rect = auibar->GetToolRect(e.GetId());
        wxPoint pt = auibar->ClientToScreen(rect.GetBottomLeft());
        pt = ScreenToClient(pt);
        PopupMenu(&menu, pt);
    }
    menu.Unbind(wxEVT_COMMAND_MENU_SELECTED,
                wxCommandEventHandler(GitConsole::OnDropDownMenuEvent),
                this,
                0,
                arr.GetCount(),
                new GitCommandData(arr, commandName, id));
}
Exemplo n.º 12
0
void GitConsole::OnDropDownMenuEvent(wxCommandEvent& event)
{
    int id = event.GetId();
    GitCommandData* userdata = static_cast<GitCommandData*>(event.GetEventUserData());
    wxCHECK_RET((int)userdata->arr.GetCount() > event.GetId(), "Out-of-range ID");
    event.SetString(userdata->arr.Item(id));
    event.SetId(userdata->id);

    wxPostEvent(m_git, event); // We've now populated the event object with useful data, so get GitPlugin to process it

    clConfig conf("git.conf");
    GitEntry data;
    conf.ReadItem(&data);
    GitCommandsEntries& ce = data.GetGitCommandsEntries(userdata->name);
    ce.SetLastUsedCommandIndex(id);
    conf.WriteItem(&data);
    conf.Save();
}
Exemplo n.º 13
0
GitConsole::~GitConsole()
{
    clConfig conf("git.conf");
    GitEntry data;
    conf.ReadItem(&data);
    data.SetGitConsoleSashPos(m_splitter->GetSashPosition());
    conf.WriteItem(&data);

    wxDELETE(m_bitmapLoader);
    EventNotifier::Get()->Disconnect(
        wxEVT_GIT_CONFIG_CHANGED, wxCommandEventHandler(GitConsole::OnConfigurationChanged), NULL, this);
    EventNotifier::Get()->Disconnect(
        wxEVT_WORKSPACE_CLOSED, wxCommandEventHandler(GitConsole::OnWorkspaceClosed), NULL, this);
    EventNotifier::Get()->Disconnect(
        wxEVT_CL_THEME_CHANGED, wxCommandEventHandler(GitConsole::OnEditorThemeChanged), NULL, this);

    Unbind(wxEVT_AUITOOLBAR_TOOL_DROPDOWN,
           wxAuiToolBarEventHandler(GitConsole::OnGitPullDropdown),
           this,
           XRCID("git_pull"));
}
Exemplo n.º 14
0
void GitSettingsDlg::OnOK(wxCommandEvent& event)
{
    GitEntry data;
    data.Load();

    data.SetGITExecutablePath(m_pathGIT->GetPath());
    data.SetGITKExecutablePath(m_pathGITK->GetPath());

    size_t flags = 0;
    if(m_checkBoxLog->IsChecked()) flags |= GitEntry::Git_Verbose_Log;

    if(m_checkBoxTerminal->IsChecked()) flags |= GitEntry::Git_Show_Terminal;

    if(m_checkBoxTrackTree->IsChecked()) flags |= GitEntry::Git_Colour_Tree_View;

    data.SetFlags(flags);
    data.Save();

    GitEntry::GitProperties props;
    props.global_email = m_textCtrlGlobalEmail->GetValue();
    props.global_username = m_textCtrlGlobalName->GetValue();
    props.local_email = m_textCtrlLocalEmail->GetValue();
    props.local_username = m_textCtrlLocalName->GetValue();
    GitEntry::WriteGitProperties(m_localRepoPath, props);

    // Notify about configuration changed
    wxCommandEvent evt(wxEVT_GIT_CONFIG_CHANGED);
    EventNotifier::Get()->AddPendingEvent(evt);

    EndModal(wxID_OK);
}
Exemplo n.º 15
0
GitCommitListDlg::GitCommitListDlg(wxWindow* parent, const wxString& workingDir, GitPlugin* git)
    : GitCommitListDlgBase(parent)
    , m_git(git)
    , m_workingDir(workingDir)
{
    LexerConf::Ptr_t lex = EditorConfigST::Get()->GetLexer("diff");
    if(lex) {
        lex->Apply(m_stcDiff, true);
    }

    LexerConf::Ptr_t textLex = EditorConfigST::Get()->GetLexer("text");
    textLex->Apply(m_stcCommitMessage, true);

    clConfig conf("git.conf");
    GitEntry data;
    conf.ReadItem(&data);
    m_gitPath = data.GetGITExecutablePath();
    m_gitPath.Trim().Trim(false);

    if(m_gitPath.IsEmpty()) {
        m_gitPath = "git";
    }
    SetName("GitCommitListDlg");
    WindowAttrManager::Load(this);

    m_dvListCtrlCommitList->Connect(ID_COPY_COMMIT_HASH,
                                    wxEVT_COMMAND_MENU_SELECTED,
                                    wxCommandEventHandler(GitCommitListDlg::OnCopyCommitHashToClipboard),
                                    NULL,
                                    this);
    m_dvListCtrlCommitList->Connect(ID_REVERT_COMMIT,
                                    wxEVT_COMMAND_MENU_SELECTED,
                                    wxCommandEventHandler(GitCommitListDlg::OnRevertCommit),
                                    NULL,
                                    this);
}
Exemplo n.º 16
0
GitSettingsDlg::GitSettingsDlg(wxWindow* parent, const wxString& localRepoPath)
    : GitSettingsDlgBase(parent)
    , m_localRepoPath(localRepoPath)
{
    GitEntry data;
    data.Load();

    m_pathGIT->SetPath(data.GetGITExecutablePath());
    m_pathGITK->SetPath(data.GetGITKExecutablePath());
    m_checkBoxLog->SetValue(data.GetFlags() & GitEntry::Git_Verbose_Log);
    m_checkBoxTerminal->SetValue(data.GetFlags() & GitEntry::Git_Show_Terminal);
    m_checkBoxTrackTree->SetValue(data.GetFlags() & GitEntry::Git_Colour_Tree_View);

    GitEntry::GitProperties props = GitEntry::ReadGitProperties(m_localRepoPath);

    m_textCtrlGlobalEmail->ChangeValue(props.global_email);
    m_textCtrlGlobalName->ChangeValue(props.global_username);
    m_textCtrlLocalEmail->ChangeValue(props.local_email);
    m_textCtrlLocalName->ChangeValue(props.local_username);
    
    SetName("GitSettingsDlg");
    WindowAttrManager::Load(this);
}
Exemplo n.º 17
0
GitConsole::GitConsole(wxWindow* parent, GitPlugin* git)
    : GitConsoleBase(parent)
    , m_git(git)
{
    // set the font to fit the C++ lexer default font
    LexerConf::Ptr_t lexCpp = EditorConfigST::Get()->GetLexer("c++");
    if(lexCpp) {
        wxFont font = lexCpp->GetFontForSyle(wxSTC_C_DEFAULT);
        for(int i = 0; i < wxSTC_STYLE_MAX; ++i) {
            m_stcLog->StyleSetFont(i, font);
        }
    }
    m_stcLog->SetReadOnly(true);

    m_bitmapLoader = new BitmapLoader();
    GitImages m_images;
    m_bitmaps = m_bitmapLoader->MakeStandardMimeMap();
    m_modifiedBmp = m_bitmapLoader->LoadBitmap("subversion/16/modified");
    m_untrackedBmp = m_bitmapLoader->LoadBitmap("subversion/16/unversioned");
    m_folderBmp = m_bitmapLoader->LoadBitmap("mime/16/folder");
    m_newBmp = m_images.Bitmap("gitFileAdd");
    m_deleteBmp = m_bitmapLoader->LoadBitmap("subversion/16/deleted");

    EventNotifier::Get()->Connect(
        wxEVT_GIT_CONFIG_CHANGED, wxCommandEventHandler(GitConsole::OnConfigurationChanged), NULL, this);
    EventNotifier::Get()->Connect(
        wxEVT_WORKSPACE_CLOSED, wxCommandEventHandler(GitConsole::OnWorkspaceClosed), NULL, this);
    EventNotifier::Get()->Connect(
        wxEVT_CL_THEME_CHANGED, wxCommandEventHandler(GitConsole::OnEditorThemeChanged), NULL, this);
    clConfig conf("git.conf");
    GitEntry data;
    conf.ReadItem(&data);
    m_isVerbose = (data.GetFlags() & GitEntry::Git_Verbose_Log);

    m_splitter->SetSashPosition(data.GetGitConsoleSashPos());
    m_auibar->AddTool(
        XRCID("git_reset_repository"), _("Reset"), m_images.Bitmap("gitResetRepo"), _("Reset repository"));
    m_auibar->AddSeparator();

    m_auibar->AddTool(XRCID("git_pull"), _("Pull"), m_images.Bitmap("gitPull"), _("Pull remote changes"));
    m_auibar->SetToolDropDown(XRCID("git_pull"), true);
    m_auibar->AddTool(XRCID("git_commit"), _("Commit"), m_images.Bitmap("gitCommitLocal"), _("Commit local changes"));
    m_auibar->AddTool(XRCID("git_push"), _("Push"), m_images.Bitmap("gitPush"), _("Push local changes"));
    m_auibar->AddTool(XRCID("git_rebase"), _("Rebase"), m_images.Bitmap("gitRebase"), _("Rebase"));
    m_auibar->SetToolDropDown(XRCID("git_rebase"), true);
    m_auibar->AddSeparator();
    m_auibar->AddTool(XRCID("git_commit_diff"), _("Diffs"), m_images.Bitmap("gitDiffs"), _("Show current diffs"));
    m_auibar->AddTool(
        XRCID("git_browse_commit_list"), _("Log"), m_images.Bitmap("gitCommitedFiles"), _("Browse commit history"));
#ifdef __WXMSW__
    m_auibar->AddSeparator();
    m_auibar->AddTool(XRCID("git_msysgit"),
                      _("Open MSYS Git"),
                      m_images.Bitmap("msysgit"),
                      _("Open MSYS Git at the current file location"));
#endif

    wxAuiToolBarItemArray append_items;
    PopulateAuiToolbarOverflow(append_items, m_images);
    m_auibar->AddSeparator();
    for(size_t i = 0; i < append_items.GetCount(); ++i) {
        const wxAuiToolBarItem& item = append_items.Item(i);
        m_auibar->AddTool(item.GetId(), item.GetLabel(), item.GetBitmap(), item.GetLabel(), (wxItemKind)item.GetKind());
    }
    m_auibar->Realize();

    Bind(wxEVT_AUITOOLBAR_TOOL_DROPDOWN,
         wxAuiToolBarEventHandler(GitConsole::OnGitPullDropdown),
         this,
         XRCID("git_pull"));
    Bind(wxEVT_AUITOOLBAR_TOOL_DROPDOWN,
         wxAuiToolBarEventHandler(GitConsole::OnGitRebaseDropdown),
         this,
         XRCID("git_rebase"));

    // Adjust the h-scrollbar of git log
    ::clRecalculateSTCHScrollBar(m_stcLog);
}