diff --git a/install/ui/vcsstatusbar.fbp b/install/ui/vcsstatusbar.fbp
new file mode 100644
index 0000000000..8f70988344
--- /dev/null
+++ b/install/ui/vcsstatusbar.fbp
@@ -0,0 +1,211 @@
+
+
+
+
+
diff --git a/install/ui/vcsstatusbar.xrc b/install/ui/vcsstatusbar.xrc
new file mode 100644
index 0000000000..7a1be4216a
--- /dev/null
+++ b/install/ui/vcsstatusbar.xrc
@@ -0,0 +1,48 @@
+
+
+
+
+
+ wxHORIZONTAL
+
+
+ wxALL
+ 1
+
+ 0
+ 2
+ 0
+ 6
+ 0,1
+
+
+
+ wxALIGN_CENTER_VERTICAL
+ 0
+
+
+ -1
+
+
+
+
+ wxEXPAND
+ 0
+
+ wxHORIZONTAL
+
+
+ wxALIGN_CENTER_VERTICAL
+ 0
+
+
+ -1
+
+
+
+
+
+
+
+
+
diff --git a/plugins/vcs/GitModule.cpp b/plugins/vcs/GitModule.cpp
index 3999f2489c..f45cb636a0 100644
--- a/plugins/vcs/GitModule.cpp
+++ b/plugins/vcs/GitModule.cpp
@@ -52,24 +52,10 @@ void GitModule::initialiseModule(const IApplicationContext& ctx)
_repository.reset();
}
-#if 0
- git_commit* commit;
- git_oid oid;
- git_reference_name_to_id(&oid, repository, "refs/heads/master");
-
- git_commit_lookup(&commit, repository, &oid);
-
- const auto* author = git_commit_author(commit);
- auto time = git_commit_time(commit);
- rMessage() << "Last commit author: " << author->name << " at " << ctime(&time) << std::endl;
-
- git_commit_free(commit);
-#endif
-
GlobalMainFrame().signal_MainFrameConstructed().connect([&]()
{
- _statusBarWidget = new ui::VcsStatus(GlobalStatusBarManager().getStatusBar());
- GlobalStatusBarManager().addElement(ui::VcsStatus::Name, _statusBarWidget,
+ _statusBarWidget = std::make_unique(GlobalStatusBarManager().getStatusBar());
+ GlobalStatusBarManager().addElement(ui::VcsStatus::Name, _statusBarWidget->getWidget(),
::ui::statusbar::StandardPosition::MapEditStopwatch + 10);
_statusBarWidget->setRepository(_repository);
@@ -80,12 +66,7 @@ void GitModule::shutdownModule()
{
rMessage() << getName() << "::shutdownModule called." << std::endl;
- if (_statusBarWidget)
- {
- _statusBarWidget->Destroy();
- _statusBarWidget = nullptr;
- }
-
+ _statusBarWidget.reset();
_repository.reset();
git_libgit2_shutdown();
diff --git a/plugins/vcs/GitModule.h b/plugins/vcs/GitModule.h
index 14bdc75421..b7b5dad528 100644
--- a/plugins/vcs/GitModule.h
+++ b/plugins/vcs/GitModule.h
@@ -18,7 +18,7 @@ class GitModule :
private:
std::shared_ptr _repository;
- ui::VcsStatus* _statusBarWidget = nullptr;
+ std::unique_ptr _statusBarWidget;
public:
// RegisterableModule implementation
diff --git a/plugins/vcs/ui/VcsStatus.cpp b/plugins/vcs/ui/VcsStatus.cpp
index 12bddca4a2..e9d9bf4e83 100644
--- a/plugins/vcs/ui/VcsStatus.cpp
+++ b/plugins/vcs/ui/VcsStatus.cpp
@@ -22,26 +22,15 @@ namespace ui
{
VcsStatus::VcsStatus(wxWindow* parent) :
- wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS, "VcsStatusBarPanel"),
+ _panel(loadNamedPanel(parent, "VcsStatusBar")),
_timer(this),
_fetchInProgress(false)
{
- SetSizer(new wxBoxSizer(wxVERTICAL));
-
- auto table = new wxFlexGridSizer(2);
- table->AddGrowableCol(0);
- table->AddGrowableCol(1);
- table->SetHGap(6);
- GetSizer()->Add(table, 0, wxALL | wxEXPAND, 1);
-
- _mapStatus = new wxStaticText(this, wxID_ANY, "");
- table->Add(_mapStatus, 0, wxLEFT, 6);
-
- _remoteStatus = new wxStaticText(this, wxID_ANY, _("Not under Version Control"));
- table->Add(_remoteStatus, 0, wxALIGN_RIGHT | wxRIGHT, 6);
+ _mapStatus = findNamedObject(_panel, "MapStatusLabel");
+ _remoteStatus = findNamedObject(_panel, "RemoteStatusLabel");
Bind(wxEVT_TIMER, &VcsStatus::onIntervalReached, this);
- Bind(wxEVT_IDLE, &VcsStatus::onIdle, this);
+ _panel->Bind(wxEVT_IDLE, &VcsStatus::onIdle, this);
GlobalRegistry().signalForKey(RKEY_AUTO_FETCH_ENABLED).connect(
sigc::mem_fun(this, &VcsStatus::restartTimer)
@@ -70,6 +59,13 @@ VcsStatus::~VcsStatus()
{
_mapFileTask.get(); // Wait for the thread to complete
}
+
+ _panel->Destroy();
+}
+
+wxWindow* VcsStatus::getWidget()
+{
+ return _panel;
}
void VcsStatus::setRepository(const std::shared_ptr& repository)
diff --git a/plugins/vcs/ui/VcsStatus.h b/plugins/vcs/ui/VcsStatus.h
index f70114ec8e..6d3bd04e16 100644
--- a/plugins/vcs/ui/VcsStatus.h
+++ b/plugins/vcs/ui/VcsStatus.h
@@ -9,6 +9,7 @@
#include "imap.h"
#include "../Repository.h"
+#include "wxutil/XmlResourceBasedWidget.h"
namespace vcs
{
@@ -17,10 +18,13 @@ namespace ui
{
class VcsStatus final :
- public wxPanel,
+ public wxEvtHandler,
+ public wxutil::XmlResourceBasedWidget,
public sigc::trackable
{
private:
+ wxPanel* _panel;
+
wxTimer _timer;
std::mutex _taskLock;
bool _fetchInProgress;
@@ -45,6 +49,8 @@ class VcsStatus final :
VcsStatus(wxWindow* parent);
~VcsStatus();
+ wxWindow* getWidget();
+
void setRepository(const std::shared_ptr& repository);
private: