25#include <wx/datetime.h>
27#include <wx/listctrl.h>
30#include <wx/splitter.h>
50 if( !lock.owns_lock() )
59 std::unique_lock<std::mutex> lock;
66 if( !lock.owns_lock() )
75 std::sort( aBranches.begin(), aBranches.end(),
78 if( aLeft.isCurrent != aRight.isCurrent )
79 return aLeft.isCurrent;
81 if( aLeft.isRemote != aRight.isRemote )
82 return !aLeft.isRemote;
84 if( aLeft.when.IsValid() != aRight.when.IsValid() )
85 return aLeft.when.IsValid();
87 if( aLeft.when.IsValid() && aLeft.when != aRight.when )
88 return aLeft.when > aRight.when;
90 return aLeft.name < aRight.name;
103 if( !aWhen.IsValid() )
104 return wxEmptyString;
106 wxTimeSpan diff = aNow - aWhen;
108 if( diff.GetSeconds() < 60 )
109 return _(
"just now" );
111 if(
int minutes = diff.GetMinutes(); minutes < 60 )
112 return wxString::Format( wxPLURAL(
"%d minute ago",
"%d minutes ago", minutes ), minutes );
114 if(
int hours = diff.GetHours(); hours < 24 )
115 return wxString::Format( wxPLURAL(
"%d hour ago",
"%d hours ago", hours ), hours );
117 if(
int days = diff.GetDays(); days < 30 )
118 return wxString::Format( wxPLURAL(
"%d day ago",
"%d days ago", days ), days );
120 return aWhen.FormatISODate();
126 if( !aSplitter->IsSplit() )
129 aSashPos = aSplitter->GetSashPosition();
130 aSplitter->Unsplit( aPane );
136 wxWindow*
detail = aSplitter->GetWindow2();
137 int detailMin =
detail->GetSizer()->CalcMin().x;
138 int frame = aSplitter->GetSashSize() + 2 * aSplitter->GetBorderSize();
140 detail->SetMinSize( wxSize( detailMin, -1 ) );
141 aSplitter->SetMinSize( wxSize( aSplitter->GetMinimumPaneSize() + frame + detailMin, -1 ) );
142 aSplitter->
SetPaneMinimums( aSplitter->GetMinimumPaneSize(), frame + detailMin );
153 aButton->SetLabelMarkup( wxString::Format( wxS(
"<span foreground='%s'>%s</span>" ),
154 colour.GetAsString( wxC2S_HTML_SYNTAX ), aButton->GetLabel() ) );
162 const size_t at = aEmail.find(
'@' );
164 if( at == wxString::npos || at == 0 || aEmail.find(
'@', at + 1 ) != wxString::npos )
167 const wxString domain = aEmail.Mid( at + 1 );
168 const size_t dot = domain.find(
'.' );
170 if( dot == wxString::npos || dot == 0 || dot + 1 == domain.length() )
173 for(
const wxUniChar& c : aEmail )
185 wxString
name = aName;
187 if(
name.Trim(
true ).Trim(
false ).IsEmpty() )
189 aError =
_(
"Enter your name. It is recorded as the author of your commits." );
195 aError =
_(
"Enter a valid email address. It is recorded as the author of your commits." );
205 long sel = aList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
208 return wxEmptyString;
210 return aList->GetItemText( sel, aColumn );
wxColour ToColour() const
The project's git session.
std::unique_lock< std::mutex > TryLockActionFor(std::chrono::milliseconds aWait)
TryLockAction that keeps trying for aWait before giving up.
static constexpr std::chrono::milliseconds ACTION_LOCK_WAIT
Long enough for a status read to finish, short enough that a window does not look hung.
std::unique_lock< std::mutex > TryLockAction()
void SetPaneMinimums(int aFirst, int aSecond)
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
This file is part of the common library.
static bool looksLikeAnEmailAddress(const wxString &aEmail)
void SortBranchesForDisplay(std::vector< KIGIT_BRANCH_INFO > &aBranches)
Put the current branch first, then local and remote branches with the newest tips first.
wxString BusyMessage()
What every caller says when it finds the session already busy.
std::unique_lock< std::mutex > WaitForActionLock(KIGIT_COMMON &aCommon, wxWindow *aParent)
TryLockAction that first waits a moment for a status read or fetch to let go.
void UnsplitKeepingSash(wxSplitterWindow *aSplitter, wxWindow *aPane, int &aSashPos)
Close a splitter's second pane, keeping the sash where the user left it for next time.
void ShowBusyMessage(wxWindow *aParent)
Show a busy message for a user action. UI thread only.
std::unique_lock< std::mutex > TryLockAction(KIGIT_COMMON &aCommon, wxWindow *aParent)
Try the action lock and show a busy message if it is unavailable.
bool ValidateIdentity(const wxString &aName, const wxString &aEmail, wxString &aError)
Check a name and email for recording commits. False leaves the reason in aError.
wxString SelectedText(wxListCtrl *aList, int aColumn)
The text of the selected row in a report list, or empty when nothing is selected.
wxString RelativeDate(const wxDateTime &aWhen)
"just now", "3 hours ago", or the ISO date once it is more than a month old.
void KeepDetailWidth(WX_SPLITTER_WINDOW *aSplitter)
Keep a split detail pane at the width its controls need, against both a narrow window and a dragged s...
void MarkDestructive(wxButton *aButton)
Paint a button's text the diff's red, for one that throws something away.
Diff colors with defaults for light backgrounds.
static DIFF_COLOR_THEME ForText(bool aDarkTheme)
Resolve change colors for UI text. Pass the desktop theme captured on the UI thread.