summaryrefslogtreecommitdiff
path: root/RealtimeSync
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:23:48 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:23:48 +0200
commitee1c8c5c25d25dfa42120125a8a45dc9831ee412 (patch)
tree67aa287157db954e0cadeee05b4aad331eb2ecf2 /RealtimeSync
parent5.13 (diff)
downloadFreeFileSync-ee1c8c5c25d25dfa42120125a8a45dc9831ee412.tar.gz
FreeFileSync-ee1c8c5c25d25dfa42120125a8a45dc9831ee412.tar.bz2
FreeFileSync-ee1c8c5c25d25dfa42120125a8a45dc9831ee412.zip
5.14
Diffstat (limited to 'RealtimeSync')
-rw-r--r--RealtimeSync/application.cpp59
-rw-r--r--RealtimeSync/application.h2
-rw-r--r--RealtimeSync/gui_generated.cpp123
-rw-r--r--RealtimeSync/gui_generated.h12
-rw-r--r--RealtimeSync/main_dlg.cpp10
-rw-r--r--RealtimeSync/main_dlg.h1
-rw-r--r--RealtimeSync/makefile25
-rw-r--r--RealtimeSync/resources.cpp14
-rw-r--r--RealtimeSync/resources.h7
-rw-r--r--RealtimeSync/tray_menu.cpp32
-rw-r--r--RealtimeSync/watcher.cpp2
11 files changed, 134 insertions, 153 deletions
diff --git a/RealtimeSync/application.cpp b/RealtimeSync/application.cpp
index 1d7640df..1efed1a1 100644
--- a/RealtimeSync/application.cpp
+++ b/RealtimeSync/application.cpp
@@ -7,6 +7,7 @@
#include "application.h"
#include "main_dlg.h"
#include <zen/file_handling.h>
+#include <zen/thread.h>
#include <wx/event.h>
#include <wx/log.h>
#include <wx/msgdlg.h>
@@ -20,8 +21,12 @@
#ifdef FFS_WIN
#include <zen/win_ver.h>
+
#elif defined FFS_LINUX
#include <gtk/gtk.h>
+
+#elif defined FFS_MAC
+#include <ApplicationServices/ApplicationServices.h>
#endif
using namespace zen;
@@ -29,67 +34,67 @@ using namespace zen;
IMPLEMENT_APP(Application);
-#ifdef FFS_WIN
namespace
{
-const DWORD mainThreadId = ::GetCurrentThreadId();
+boost::thread::id mainThreadId = boost::this_thread::get_id();
void onTerminationRequested()
{
- std::wstring msg = ::GetCurrentThreadId() == mainThreadId ?
+ std::wstring msg = boost::this_thread::get_id() == mainThreadId ?
L"Termination requested in main thread!\n\n" :
L"Termination requested in worker thread!\n\n";
msg += L"Please take a screenshot and file a bug report at: http://sourceforge.net/projects/freefilesync";
- ::MessageBox(0, msg.c_str(), _("An exception occurred!").c_str(), 0);
+ wxSafeShowMessage(_("An exception occurred!"), msg);
std::abort();
}
#ifdef _MSC_VER
void crtInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved) { assert(false); }
#endif
+
+const wxEventType EVENT_ENTER_EVENT_LOOP = wxNewEventType();
}
-#endif
bool Application::OnInit()
{
-#ifdef FFS_WIN
std::set_terminate(onTerminationRequested); //unlike wxWidgets uncaught exception handling, this works for all worker threads
- assert(!win8OrLater()); //another breadcrumb: test and add new OS entry to "compatibility" in application manifest
+
+#ifdef FFS_WIN
#ifdef _MSC_VER
_set_invalid_parameter_handler(crtInvalidParameterHandler); //see comment in <zen/time.h>
#endif
+ //Quote: "Best practice is that all applications call the process-wide SetErrorMode function with a parameter of
+ //SEM_FAILCRITICALERRORS at startup. This is to prevent error mode dialogs from hanging the application."
+ ::SetErrorMode(SEM_FAILCRITICALERRORS);
+
+#elif defined FFS_LINUX
+ ::gtk_rc_parse((zen::getResourceDir() + "styles.gtk_rc").c_str()); //remove inner border from bitmap buttons
+
+#elif defined FFS_MAC
+ ProcessSerialNumber psn = { 0, kCurrentProcess };
+ ::TransformProcessType(&psn, kProcessTransformToForegroundApplication); //behave like an application bundle, even when the app is not packaged (yet)
#endif
+ warn_static("fix")
+ SetAppName(L"FreeFileSync"); //abuse FFS's name, to have "GetUserDataDir()" return the same directory
+
//do not call wxApp::OnInit() to avoid using default commandline parser
- //Note: initialization is done in the FIRST idle event instead of OnInit. Reason: Commandline mode requires the wxApp eventhandler to be established
- //for UI update events. This is not the case at the time of OnInit().
- Connect(wxEVT_IDLE, wxIdleEventHandler(Application::OnStartApplication), nullptr, this);
+ //Note: app start is deferred: -> see FreeFileSync
+ Connect(EVENT_ENTER_EVENT_LOOP, wxEventHandler(Application::onEnterEventLoop), nullptr, this);
+ wxCommandEvent scrollEvent(EVENT_ENTER_EVENT_LOOP);
+ AddPendingEvent(scrollEvent);
- return true;
+ return true; //true: continue processing; false: exit immediately.
}
-void Application::OnStartApplication(wxIdleEvent& event)
+void Application::onEnterEventLoop(wxEvent& event)
{
- Disconnect(wxEVT_IDLE, wxIdleEventHandler(Application::OnStartApplication), nullptr, this);
-
- warn_static("fix")
-
- //if appname is not set, the default is the executable's name!
- SetAppName(L"FreeFileSync"); //abuse FFS's name, to have "GetUserDataDir()" return the same directory
-
-#ifdef FFS_WIN
- //Quote: "Best practice is that all applications call the process-wide SetErrorMode function with a parameter of
- //SEM_FAILCRITICALERRORS at startup. This is to prevent error mode dialogs from hanging the application."
- ::SetErrorMode(SEM_FAILCRITICALERRORS);
-#elif defined FFS_LINUX
- ::gtk_rc_parse((zen::getResourceDir() + "styles.gtk_rc").c_str()); //remove inner border from bitmap buttons
-#endif
+ Disconnect(EVENT_ENTER_EVENT_LOOP, wxEventHandler(Application::onEnterEventLoop), nullptr, this);
- //set program language
try
{
setLanguage(rts::getProgramLanguage()); //throw FileError
diff --git a/RealtimeSync/application.h b/RealtimeSync/application.h
index 3b9c58e2..b3c302d7 100644
--- a/RealtimeSync/application.h
+++ b/RealtimeSync/application.h
@@ -17,7 +17,7 @@ public:
virtual bool OnExceptionInMainLoop() { throw; } //just re-throw and avoid display of additional messagebox: it will be caught in OnRun()
private:
- void OnStartApplication(wxIdleEvent& event);
+ void onEnterEventLoop(wxEvent& event);
//virtual wxLayoutDirection GetLayoutDirection() const { return wxLayout_LeftToRight; }
};
diff --git a/RealtimeSync/gui_generated.cpp b/RealtimeSync/gui_generated.cpp
index ca891fc9..d388e40d 100644
--- a/RealtimeSync/gui_generated.cpp
+++ b/RealtimeSync/gui_generated.cpp
@@ -14,6 +14,7 @@
MainDlgGenerated::MainDlgGenerated( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxSize( 420,350 ), wxDefaultSize );
+ this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
m_menubar1 = new wxMenuBar( 0 );
m_menuFile = new wxMenu();
@@ -49,22 +50,10 @@ MainDlgGenerated::MainDlgGenerated( wxWindow* parent, wxWindowID id, const wxStr
bSizerMain = new wxBoxSizer( wxVERTICAL );
- m_panelMain = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
- m_panelMain->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
-
- wxBoxSizer* bSizer1;
- bSizer1 = new wxBoxSizer( wxVERTICAL );
-
- m_panel5 = new wxPanel( m_panelMain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
- m_panel5->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
-
- wxBoxSizer* bSizer17;
- bSizer17 = new wxBoxSizer( wxVERTICAL );
-
wxBoxSizer* bSizer16;
bSizer16 = new wxBoxSizer( wxHORIZONTAL );
- m_staticText9 = new wxStaticText( m_panel5, wxID_ANY, _("Usage:"), wxDefaultPosition, wxDefaultSize, 0 );
+ m_staticText9 = new wxStaticText( this, wxID_ANY, _("Usage:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText9->Wrap( -1 );
m_staticText9->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
@@ -73,15 +62,15 @@ MainDlgGenerated::MainDlgGenerated( wxWindow* parent, wxWindowID id, const wxStr
wxBoxSizer* bSizer15;
bSizer15 = new wxBoxSizer( wxVERTICAL );
- m_staticText3 = new wxStaticText( m_panel5, wxID_ANY, _("1. Select folders to watch."), wxDefaultPosition, wxDefaultSize, 0 );
+ m_staticText3 = new wxStaticText( this, wxID_ANY, _("1. Select folders to watch."), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText3->Wrap( -1 );
bSizer15->Add( m_staticText3, 0, wxLEFT, 10 );
- m_staticText4 = new wxStaticText( m_panel5, wxID_ANY, _("2. Enter a command line."), wxDefaultPosition, wxDefaultSize, 0 );
+ m_staticText4 = new wxStaticText( this, wxID_ANY, _("2. Enter a command line."), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText4->Wrap( -1 );
bSizer15->Add( m_staticText4, 0, wxLEFT, 10 );
- m_staticText5 = new wxStaticText( m_panel5, wxID_ANY, _("3. Press 'Start'."), wxDefaultPosition, wxDefaultSize, 0 );
+ m_staticText5 = new wxStaticText( this, wxID_ANY, _("3. Press 'Start'."), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText5->Wrap( -1 );
bSizer15->Add( m_staticText5, 0, wxLEFT, 10 );
@@ -89,22 +78,22 @@ MainDlgGenerated::MainDlgGenerated( wxWindow* parent, wxWindowID id, const wxStr
bSizer16->Add( bSizer15, 0, wxTOP|wxLEFT, 5 );
- bSizer17->Add( bSizer16, 0, 0, 5 );
+ bSizerMain->Add( bSizer16, 0, 0, 5 );
- m_staticText811 = new wxStaticText( m_panel5, wxID_ANY, _("To get started just import a .ffs_batch file."), wxDefaultPosition, wxDefaultSize, 0 );
+ m_staticText811 = new wxStaticText( this, wxID_ANY, _("To get started just import a .ffs_batch file."), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText811->Wrap( -1 );
m_staticText811->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
- bSizer17->Add( m_staticText811, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
+ bSizerMain->Add( m_staticText811, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
+ m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
+ bSizerMain->Add( m_staticline2, 0, wxEXPAND, 5 );
- m_panel5->SetSizer( bSizer17 );
- m_panel5->Layout();
- bSizer17->Fit( m_panel5 );
- bSizer1->Add( m_panel5, 0, wxEXPAND, 5 );
+ m_panelMain = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
+ m_panelMain->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
- m_staticline2 = new wxStaticLine( m_panelMain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
- bSizer1->Add( m_staticline2, 0, wxEXPAND, 5 );
+ wxBoxSizer* bSizer1;
+ bSizer1 = new wxBoxSizer( wxVERTICAL );
m_staticText7 = new wxStaticText( m_panelMain, wxID_ANY, _("Folders to watch"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText7->Wrap( -1 );
@@ -205,38 +194,20 @@ MainDlgGenerated::MainDlgGenerated( wxWindow* parent, wxWindowID id, const wxStr
bSizer1->Add( m_textCtrlCommand, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
- m_staticline5 = new wxStaticLine( m_panelMain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
- bSizer1->Add( m_staticline5, 0, wxEXPAND, 5 );
-
- m_panel4 = new wxPanel( m_panelMain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
- m_panel4->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
-
- wxBoxSizer* bSizer141;
- bSizer141 = new wxBoxSizer( wxHORIZONTAL );
+ m_panelMain->SetSizer( bSizer1 );
+ m_panelMain->Layout();
+ bSizer1->Fit( m_panelMain );
+ bSizerMain->Add( m_panelMain, 1, wxEXPAND, 5 );
- bSizer141->Add( 0, 0, 1, wxEXPAND, 5 );
+ m_staticline5 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
+ bSizerMain->Add( m_staticline5, 0, wxEXPAND, 5 );
- m_buttonStart = new zen::BitmapButton( m_panel4, wxID_OK, _("Start"), wxDefaultPosition, wxSize( -1,-1 ), 0 );
+ m_buttonStart = new zen::BitmapButton( this, wxID_OK, _("Start"), wxDefaultPosition, wxSize( -1,-1 ), 0 );
m_buttonStart->SetDefault();
m_buttonStart->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
- bSizer141->Add( m_buttonStart, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
-
-
- bSizer141->Add( 0, 0, 1, wxEXPAND, 5 );
-
-
- m_panel4->SetSizer( bSizer141 );
- m_panel4->Layout();
- bSizer141->Fit( m_panel4 );
- bSizer1->Add( m_panel4, 0, wxEXPAND, 5 );
-
-
- m_panelMain->SetSizer( bSizer1 );
- m_panelMain->Layout();
- bSizer1->Fit( m_panelMain );
- bSizerMain->Add( m_panelMain, 1, wxEXPAND, 5 );
+ bSizerMain->Add( m_buttonStart, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
this->SetSizer( bSizerMain );
@@ -247,7 +218,7 @@ MainDlgGenerated::MainDlgGenerated( wxWindow* parent, wxWindowID id, const wxStr
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( MainDlgGenerated::OnClose ) );
this->Connect( m_menuItem13->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainDlgGenerated::OnConfigLoad ) );
this->Connect( m_menuItem14->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainDlgGenerated::OnConfigSave ) );
- this->Connect( m_menuItem4->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainDlgGenerated::OnQuit ) );
+ this->Connect( m_menuItem4->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainDlgGenerated::OnMenuQuit ) );
this->Connect( m_menuItemContent->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainDlgGenerated::OnShowHelp ) );
this->Connect( m_menuItemAbout->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainDlgGenerated::OnMenuAbout ) );
m_bpButtonAddFolder->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDlgGenerated::OnAddFolder ), NULL, this );
@@ -261,7 +232,7 @@ MainDlgGenerated::~MainDlgGenerated()
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( MainDlgGenerated::OnClose ) );
this->Disconnect( wxID_OPEN, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainDlgGenerated::OnConfigLoad ) );
this->Disconnect( wxID_SAVEAS, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainDlgGenerated::OnConfigSave ) );
- this->Disconnect( wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainDlgGenerated::OnQuit ) );
+ this->Disconnect( wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainDlgGenerated::OnMenuQuit ) );
this->Disconnect( wxID_HELP, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainDlgGenerated::OnShowHelp ) );
this->Disconnect( wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainDlgGenerated::OnMenuAbout ) );
m_bpButtonAddFolder->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDlgGenerated::OnAddFolder ), NULL, this );
@@ -302,58 +273,54 @@ FolderGenerated::~FolderGenerated()
ErrorDlgGenerated::ErrorDlgGenerated( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxSize( 300,160 ), wxDefaultSize );
- this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
+ this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
wxBoxSizer* bSizer24;
bSizer24 = new wxBoxSizer( wxVERTICAL );
+ m_panel3 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
+ m_panel3->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
+
+ wxBoxSizer* bSizer16;
+ bSizer16 = new wxBoxSizer( wxVERTICAL );
- bSizer24->Add( 0, 10, 0, wxEXPAND, 5 );
+
+ bSizer16->Add( 0, 10, 0, wxEXPAND, 5 );
wxBoxSizer* bSizer26;
bSizer26 = new wxBoxSizer( wxHORIZONTAL );
- m_bitmap10 = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), 0 );
- bSizer26->Add( m_bitmap10, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
+ m_bitmap10 = new wxStaticBitmap( m_panel3, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), 0 );
+ bSizer26->Add( m_bitmap10, 0, wxRIGHT|wxLEFT, 5 );
- m_textCtrl8 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 400,150 ), wxTE_MULTILINE|wxTE_READONLY|wxNO_BORDER );
+ m_textCtrl8 = new wxTextCtrl( m_panel3, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 400,150 ), wxTE_MULTILINE|wxTE_READONLY|wxNO_BORDER );
m_textCtrl8->SetMaxLength( 0 );
bSizer26->Add( m_textCtrl8, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
- bSizer24->Add( bSizer26, 1, wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
+ bSizer16->Add( bSizer26, 1, wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
+
+
+ m_panel3->SetSizer( bSizer16 );
+ m_panel3->Layout();
+ bSizer16->Fit( m_panel3 );
+ bSizer24->Add( m_panel3, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 );
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizer24->Add( m_staticline2, 0, wxEXPAND, 5 );
- m_panel3 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
- m_panel3->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
-
wxBoxSizer* bSizer13;
bSizer13 = new wxBoxSizer( wxHORIZONTAL );
-
- bSizer13->Add( 0, 0, 1, wxEXPAND, 5 );
-
- m_buttonRetry = new wxButton( m_panel3, wxID_RETRY, _("&Retry"), wxDefaultPosition, wxSize( -1,30 ), 0 );
+ m_buttonRetry = new wxButton( this, wxID_RETRY, _("&Retry"), wxDefaultPosition, wxSize( -1,30 ), 0 );
m_buttonRetry->SetDefault();
- m_buttonRetry->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
-
bSizer13->Add( m_buttonRetry, 0, wxTOP|wxBOTTOM|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
- m_buttonAbort = new wxButton( m_panel3, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxSize( -1,30 ), 0 );
- m_buttonAbort->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
-
+ m_buttonAbort = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxSize( -1,30 ), 0 );
bSizer13->Add( m_buttonAbort, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
- bSizer13->Add( 0, 0, 1, wxEXPAND, 5 );
-
-
- m_panel3->SetSizer( bSizer13 );
- m_panel3->Layout();
- bSizer13->Fit( m_panel3 );
- bSizer24->Add( m_panel3, 0, wxEXPAND, 5 );
+ bSizer24->Add( bSizer13, 0, wxALIGN_RIGHT, 5 );
this->SetSizer( bSizer24 );
diff --git a/RealtimeSync/gui_generated.h b/RealtimeSync/gui_generated.h
index 6426b2d2..9a19bf63 100644
--- a/RealtimeSync/gui_generated.h
+++ b/RealtimeSync/gui_generated.h
@@ -24,11 +24,11 @@ namespace zen { class BitmapButton; }
#include <wx/settings.h>
#include <wx/stattext.h>
#include <wx/sizer.h>
-#include <wx/panel.h>
#include <wx/statline.h>
#include <wx/bmpbuttn.h>
#include <wx/button.h>
#include <wx/textctrl.h>
+#include <wx/panel.h>
#include <wx/scrolwin.h>
#include <wx/spinctrl.h>
#include <wx/frame.h>
@@ -52,14 +52,13 @@ protected:
wxMenu* m_menuHelp;
wxMenuItem* m_menuItemAbout;
wxBoxSizer* bSizerMain;
- wxPanel* m_panelMain;
- wxPanel* m_panel5;
wxStaticText* m_staticText9;
wxStaticText* m_staticText3;
wxStaticText* m_staticText4;
wxStaticText* m_staticText5;
wxStaticText* m_staticText811;
wxStaticLine* m_staticline2;
+ wxPanel* m_panelMain;
wxStaticText* m_staticText7;
wxPanel* m_panelMainFolder;
wxStaticText* m_staticTextFinalPath;
@@ -76,14 +75,13 @@ protected:
wxStaticText* m_staticText6;
wxTextCtrl* m_textCtrlCommand;
wxStaticLine* m_staticline5;
- wxPanel* m_panel4;
zen::BitmapButton* m_buttonStart;
// Virtual event handlers, overide them in your derived class
virtual void OnClose( wxCloseEvent& event ) { event.Skip(); }
virtual void OnConfigLoad( wxCommandEvent& event ) { event.Skip(); }
virtual void OnConfigSave( wxCommandEvent& event ) { event.Skip(); }
- virtual void OnQuit( wxCommandEvent& event ) { event.Skip(); }
+ virtual void OnMenuQuit( wxCommandEvent& event ) { event.Skip(); }
virtual void OnShowHelp( wxCommandEvent& event ) { event.Skip(); }
virtual void OnMenuAbout( wxCommandEvent& event ) { event.Skip(); }
virtual void OnAddFolder( wxCommandEvent& event ) { event.Skip(); }
@@ -113,7 +111,7 @@ public:
wxBitmapButton* m_bpButtonRemoveFolder;
wxTextCtrl* m_txtCtrlDirectory;
- FolderGenerated( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL );
+ FolderGenerated( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = 0 );
~FolderGenerated();
};
@@ -126,10 +124,10 @@ class ErrorDlgGenerated : public wxDialog
private:
protected:
+ wxPanel* m_panel3;
wxStaticBitmap* m_bitmap10;
wxTextCtrl* m_textCtrl8;
wxStaticLine* m_staticline2;
- wxPanel* m_panel3;
wxButton* m_buttonRetry;
wxButton* m_buttonAbort;
diff --git a/RealtimeSync/main_dlg.cpp b/RealtimeSync/main_dlg.cpp
index 758babd5..1dbeb5e0 100644
--- a/RealtimeSync/main_dlg.cpp
+++ b/RealtimeSync/main_dlg.cpp
@@ -52,7 +52,7 @@ MainDialog::MainDialog(wxDialog* dlg, const wxString& cfgFileName)
#endif
wxWindowUpdateLocker dummy(this); //avoid display distortion
- SetIcon(GlobalResources::instance().programIcon); //set application icon
+ SetIcon(GlobalResources::instance().programIcon); //set application icon
setRelativeFontSize(*m_buttonStart, 1.5);
m_buttonStart->setInnerBorderSize(8);
@@ -60,9 +60,9 @@ MainDialog::MainDialog(wxDialog* dlg, const wxString& cfgFileName)
m_bpButtonRemoveTopFolder->Hide();
m_panelMainFolder->Layout();
- m_bpButtonAddFolder ->SetBitmapLabel(GlobalResources::getImage(L"item_add"));
- m_bpButtonRemoveTopFolder->SetBitmapLabel(GlobalResources::getImage(L"item_delete"));
- m_buttonStart ->setBitmapFront(GlobalResources::getImage(L"startRts"), 5);
+ m_bpButtonAddFolder ->SetBitmapLabel(getResourceImage(L"item_add"));
+ m_bpButtonRemoveTopFolder->SetBitmapLabel(getResourceImage(L"item_delete"));
+ m_buttonStart ->setBitmapFront(getResourceImage(L"startRts"), 5);
//register key event
Connect(wxEVT_CHAR_HOOK, wxKeyEventHandler(MainDialog::OnKeyPressed), nullptr, this);
@@ -384,7 +384,7 @@ void MainDialog::addFolder(const std::vector<wxString>& newFolders, bool addFron
{
//add new folder pair
DirectoryPanel* newFolder = new DirectoryPanel(m_scrolledWinFolders);
- newFolder->m_bpButtonRemoveFolder->SetBitmapLabel(GlobalResources::getImage(L"item_delete"));
+ newFolder->m_bpButtonRemoveFolder->SetBitmapLabel(getResourceImage(L"item_delete"));
//get size of scrolled window
folderHeight = newFolder->GetSize().GetHeight();
diff --git a/RealtimeSync/main_dlg.h b/RealtimeSync/main_dlg.h
index 50f074e4..f5fed970 100644
--- a/RealtimeSync/main_dlg.h
+++ b/RealtimeSync/main_dlg.h
@@ -39,6 +39,7 @@ private:
virtual void OnStart (wxCommandEvent& event);
virtual void OnConfigSave (wxCommandEvent& event);
virtual void OnConfigLoad (wxCommandEvent& event);
+ virtual void OnMenuQuit (wxCommandEvent& event) { Close(); }
void onFilesDropped(zen::FileDropEvent& event);
void setConfiguration(const xmlAccess::XmlRealConfig& cfg);
diff --git a/RealtimeSync/makefile b/RealtimeSync/makefile
index b1c78f61..aee2d43c 100644
--- a/RealtimeSync/makefile
+++ b/RealtimeSync/makefile
@@ -1,8 +1,10 @@
+BLAH_BLUBB_123=
+#for some buggy reason the first row in the make file has no effect on Suse Linux! => make sure there's no important command
APPNAME = RealtimeSync
prefix = /usr
BINDIR = $(DESTDIR)$(prefix)/bin
-CPPFLAGS = -std=c++11 -Wall -pipe -O3 -DNDEBUG -DwxUSE_UNICODE -DZEN_PLATFORM_OTHER -DWXINTL_NO_GETTEXT_MACRO -I.. -include "zen/i18n.h" -include "zen/warn_static.h"
+CXXFLAGS = -std=c++11 -Wall -pipe -O3 -DNDEBUG -DwxUSE_UNICODE -DZEN_PLATFORM_OTHER -DWXINTL_NO_GETTEXT_MACRO -I.. -include "zen/i18n.h" -include "zen/warn_static.h"
LINKFLAGS =
#distinguish Linux/Mac builds
@@ -11,23 +13,23 @@ OPERATING_SYSTEM_NAME := $(shell uname)
#################### Linux ############################
ifeq ($(OPERATING_SYSTEM_NAME), Linux)
COMPILER_BIN=g++ -pthread
-CPPFLAGS += -DFFS_LINUX
+CXXFLAGS += -DFFS_LINUX
#Gtk - support "no button border"
-CPPFLAGS += `pkg-config --cflags gtk+-2.0`
+CXXFLAGS += `pkg-config --cflags gtk+-2.0`
LINKFLAGS += `pkg-config --libs gtk+-2.0`
ifeq ($(BUILD),Launchpad)
#default build/Launchpad
-CPPFLAGS += `wx-config --cxxflags --debug=no`
+CXXFLAGS += `wx-config --cxxflags --debug=no`
LINKFLAGS += `wx-config --libs --debug=no` -lboost_thread -lboost_system
else
#static wxWidgets and boost library linkage for precompiled release
WX_CONFIG_BIN =$(HOME)/Desktop/wxGTK-2.8.12/lib/release/bin/wx-config
-CPPFLAGS += -I$(HOME)/Desktop/boost_1_53_0
+CXXFLAGS += -I$(HOME)/Desktop/boost_1_53_0
BOOST_LIB_DIR =$(HOME)/Desktop/boost_1_53_0/stage/lib
-CPPFLAGS += `$(WX_CONFIG_BIN) --cxxflags --debug=no --static=yes`
+CXXFLAGS += `$(WX_CONFIG_BIN) --cxxflags --debug=no --static=yes`
LINKFLAGS += `$(WX_CONFIG_BIN) --libs --debug=no --static=yes` $(BOOST_LIB_DIR)/libboost_thread.a $(BOOST_LIB_DIR)/libboost_system.a
endif
@@ -35,16 +37,16 @@ endif
#################### OS X ############################
ifeq ($(OPERATING_SYSTEM_NAME), Darwin)
COMPILER_BIN=clang++ -stdlib=libc++
-CPPFLAGS += -DFFS_MAC
+CXXFLAGS += -DFFS_MAC
WX_CONFIG_BIN =$(HOME)/Desktop/wxWidgets-2.9.4/lib/release/bin/wx-config
-CPPFLAGS += -I$(HOME)/Desktop/boost_1_53_0
+CXXFLAGS += -I$(HOME)/Desktop/boost_1_53_0
BOOST_LIB_DIR =$(HOME)/Desktop/boost_1_53_0/stage/lib
MACOS_SDK =-mmacosx-version-min=10.7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk
#-Wl,-Bstatic not supported on OSX!
# link wxWidgets and boost statically -> check dependencies with: otool -L RealtimeSync
-CPPFLAGS += $(MACOS_SDK) `$(WX_CONFIG_BIN) --cxxflags --debug=no --static=yes`
+CXXFLAGS += $(MACOS_SDK) `$(WX_CONFIG_BIN) --cxxflags --debug=no --static=yes`
LINKFLAGS += $(MACOS_SDK) `$(WX_CONFIG_BIN) --libs --debug=no --static=yes` $(BOOST_LIB_DIR)/libboost_thread.a $(BOOST_LIB_DIR)/libboost_system.a
endif
@@ -81,14 +83,13 @@ all: RealtimeSync
../OBJ/RTS_Release_GCC_Make/RTS/%.o : %.cpp
mkdir -p $(dir $@)
- $(COMPILER_BIN) $(CPPFLAGS) -c $< -o $@
+ $(COMPILER_BIN) $(CXXFLAGS) -c $< -o $@
RealtimeSync: $(OBJECT_LIST)
$(COMPILER_BIN) -o ../BUILD/$(APPNAME) $(OBJECT_LIST) $(LINKFLAGS)
clean:
-#-f doesn't work when deleting directories
- if [ -d ../OBJ/RTS_Release_GCC_Make ]; then rm -rf ../OBJ/RTS_Release_GCC_Make; fi
+ rm -rf ../OBJ/RTS_Release_GCC_Make
rm -f ../BUILD/$(APPNAME)
rm -f ../wx+/pch.h.gch
diff --git a/RealtimeSync/resources.cpp b/RealtimeSync/resources.cpp
index bde89393..2b31ad12 100644
--- a/RealtimeSync/resources.cpp
+++ b/RealtimeSync/resources.cpp
@@ -51,14 +51,20 @@ GlobalResources::GlobalResources()
//for compatibility it seems we need to stick with a "real" icon
programIcon = wxIcon(L"A_PROGRAM_ICON");
-#elif defined FFS_LINUX || defined FFS_MAC
- //use big logo bitmap for better quality
- programIcon.CopyFromBitmap(getImageInt(L"RealtimeSync"));
+#elif defined FFS_LINUX
+ programIcon.CopyFromBitmap(getImage(L"RealtimeSync"));
+
+#elif defined FFS_MAC
+ assert(getImage(L"RealtimeSync").GetWidth () == getImage(L"RealtimeSync").GetHeight() &&
+ getImage(L"RealtimeSync").GetWidth() % 128 == 0);
+ //wxWidgets' bitmap to icon conversion on OS X can only deal with very specific sizes
+ programIcon.CopyFromBitmap(getImage(L"RealtimeSync").ConvertToImage().Scale(128, 128, wxIMAGE_QUALITY_HIGH));
#endif
+
}
-const wxBitmap& GlobalResources::getImageInt(const wxString& name) const
+const wxBitmap& GlobalResources::getImage(const wxString& name) const
{
auto it = bitmaps.find(!contains(name, L'.') ? //assume .png ending if nothing else specified
name + L".png" :
diff --git a/RealtimeSync/resources.h b/RealtimeSync/resources.h
index 86787f9b..623265f3 100644
--- a/RealtimeSync/resources.h
+++ b/RealtimeSync/resources.h
@@ -17,7 +17,7 @@ class GlobalResources
public:
static const GlobalResources& instance();
- static const wxBitmap& getImage(const wxString& name) { return instance().getImageInt(name); }
+ const wxBitmap& getImage(const wxString& name) const;
//image resource objects
wxIcon programIcon;
@@ -27,9 +27,10 @@ private:
GlobalResources(const GlobalResources&); //=delete
GlobalResources& operator=(const GlobalResources&); //=delete
- const wxBitmap& getImageInt(const wxString& name) const;
-
std::map<wxString, wxBitmap> bitmaps;
};
+inline
+const wxBitmap& getResourceImage(const wxString& name) { return GlobalResources::instance().getImage(name); }
+
#endif //RESOURCES_H_INCLUDED_870857342085670826521345
diff --git a/RealtimeSync/tray_menu.cpp b/RealtimeSync/tray_menu.cpp
index 1e9f2ffe..8f2dcfde 100644
--- a/RealtimeSync/tray_menu.cpp
+++ b/RealtimeSync/tray_menu.cpp
@@ -56,9 +56,9 @@ public:
private:
enum Selection
{
- CONTEXT_ABORT,
- CONTEXT_RESTORE,
- CONTEXT_ABOUT
+ CONTEXT_RESTORE = 1, //wxWidgets: "A MenuItem ID of Zero does not work under Mac"
+ CONTEXT_ABORT = wxID_EXIT,
+ CONTEXT_ABOUT = wxID_ABOUT
};
virtual wxMenu* CreatePopupMenu()
@@ -154,9 +154,9 @@ public:
{
wxIcon realtimeIcon;
#if defined FFS_WIN || defined FFS_MAC //16x16 seems to be the only size that is shown correctly on OS X
- realtimeIcon.CopyFromBitmap(GlobalResources::getImage(L"RTS_tray_16x16")); //use a 16x16 bitmap
+ realtimeIcon.CopyFromBitmap(getResourceImage(L"RTS_tray_16x16")); //use a 16x16 bitmap
#elif defined FFS_LINUX
- realtimeIcon.CopyFromBitmap(GlobalResources::getImage(L"RTS_tray_24x24")); //use a 24x24 bitmap for perfect fit
+ realtimeIcon.CopyFromBitmap(getResourceImage(L"RTS_tray_24x24")); //use a 24x24 bitmap for perfect fit
#endif
const wxString postFix = jobName_.empty() ? wxString() : (L"\n\"" + jobName_ + L"\"");
trayMenu->SetIcon(realtimeIcon, _("Monitoring active...") + postFix);
@@ -166,9 +166,9 @@ public:
{
wxIcon realtimeIcon;
#if defined FFS_WIN || defined FFS_MAC
- realtimeIcon.CopyFromBitmap(greyScale(GlobalResources::getImage(L"RTS_tray_16x16")));
+ realtimeIcon.CopyFromBitmap(greyScale(getResourceImage(L"RTS_tray_16x16")));
#elif defined FFS_LINUX
- realtimeIcon.CopyFromBitmap(greyScale(GlobalResources::getImage(L"RTS_tray_24x24")));
+ realtimeIcon.CopyFromBitmap(greyScale(getResourceImage(L"RTS_tray_24x24")));
#endif
const wxString postFix = jobName_.empty() ? wxString() : (L"\n\"" + jobName_ + L"\"");
trayMenu->SetIcon(realtimeIcon, _("Waiting for missing directories...") + postFix);
@@ -247,9 +247,8 @@ public:
#ifdef FFS_WIN
new zen::MouseMoveWindow(*this); //allow moving main dialog by clicking (nearly) anywhere...; ownership passed to "this"
#endif
- m_bitmap10->SetBitmap(GlobalResources::getImage(L"msg_error"));
+ m_bitmap10->SetBitmap(getResourceImage(L"msg_error"));
m_textCtrl8->SetValue(messageText);
- m_buttonRetry->SetFocus();
//count down X seconds then automatically press "retry"
timer.Connect(wxEVT_TIMER, wxEventHandler(ErrorDlgWithTimeout::OnTimerEvent), nullptr, this);
@@ -257,6 +256,7 @@ public:
updateButtonLabel();
Fit(); //child-element widths have changed: image was set
+ m_buttonRetry->SetFocus();
}
enum ButtonPressed
@@ -339,7 +339,14 @@ startDirectoryMonitor() (wire dir-changes and execution of commandline)
rts::AbortReason rts::startDirectoryMonitor(const xmlAccess::XmlRealConfig& config, const wxString& jobname)
{
- const std::vector<Zstring> dirList = toZ(config.directories);
+ std::vector<Zstring> dirList = toZ(config.directories);
+ vector_remove_if(dirList, [](Zstring str) -> bool { trim(str); return str.empty(); }); //remove empty entries WITHOUT formatting dirList yet!
+
+ if (dirList.empty())
+ {
+ wxMessageBox(_("A folder input field is empty."), _("Error"), wxOK | wxICON_ERROR);
+ return SHOW_GUI;
+ }
wxString cmdLine = config.commandline;
trim(cmdLine);
@@ -349,11 +356,6 @@ rts::AbortReason rts::startDirectoryMonitor(const xmlAccess::XmlRealConfig& conf
wxMessageBox(_("Invalid command line:") + L" \"\"", _("Error"), wxOK | wxICON_ERROR);
return SHOW_GUI;
}
- if (dirList.empty() || std::any_of(dirList.begin(), dirList.end(), [](Zstring str) -> bool { trim(str); return str.empty(); }))
- {
- wxMessageBox(_("A folder input field is empty."), _("Error"), wxOK | wxICON_ERROR);
- return SHOW_GUI;
- }
try
{
diff --git a/RealtimeSync/watcher.cpp b/RealtimeSync/watcher.cpp
index 9b1e5a17..4e33bd98 100644
--- a/RealtimeSync/watcher.cpp
+++ b/RealtimeSync/watcher.cpp
@@ -59,7 +59,7 @@ std::vector<Zstring> getFormattedDirs(const std::vector<Zstring>& dirs) //throw
rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNamesNonFmt, WaitCallback& statusHandler) //throw FileError
{
const std::vector<Zstring> dirNamesFmt = getFormattedDirs(dirNamesNonFmt); //throw FileError
- if (dirNamesFmt.empty()) //pathological case, but check is needed nevertheless
+ if (dirNamesFmt.empty()) //pathological case, but we have to check else this function will wait endlessly
throw zen::FileError(_("A folder input field is empty.")); //should have been checked by caller!
//detect when volumes are removed/are not available anymore
bgstack15