diff options
Diffstat (limited to 'FreeFileSync/Source/RealTimeSync/application.cpp')
-rw-r--r-- | FreeFileSync/Source/RealTimeSync/application.cpp | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/FreeFileSync/Source/RealTimeSync/application.cpp b/FreeFileSync/Source/RealTimeSync/application.cpp index 443da37d..307f7d34 100644 --- a/FreeFileSync/Source/RealTimeSync/application.cpp +++ b/FreeFileSync/Source/RealTimeSync/application.cpp @@ -41,7 +41,33 @@ bool Application::OnInit() { //do not call wxApp::OnInit() to avoid using wxWidgets command line parser - ::gtk_rc_parse((fff::getResourceDirPf() + "styles.gtk_rc").c_str()); //remove inner border from bitmap buttons + //GTK should already have been initialized by wxWidgets (see \src\gtk\app.cpp:wxApp::Initialize) +#if GTK_MAJOR_VERSION == 2 + ::gtk_rc_parse((fff::getResourceDirPf() + "Gtk2Styles.rc").c_str()); + +#elif GTK_MAJOR_VERSION == 3 + try + { + GtkCssProvider* provider = ::gtk_css_provider_new (); + ZEN_ON_SCOPE_EXIT(::g_object_unref(provider)); + + GError* error = nullptr; + ZEN_ON_SCOPE_EXIT(if (error) ::g_error_free(error);); + + ::gtk_css_provider_load_from_path(provider, //GtkCssProvider* css_provider, + (fff::getResourceDirPf() + "Gtk3Styles.css").c_str(), //const gchar* path, + &error); //GError** error + if (error) + throw SysError(formatSystemError(L"gtk_css_provider_load_from_data", replaceCpy(_("Error Code %x"), L"%x", numberTo<std::wstring>(error->code)), utfTo<std::wstring>(error->message))); + + ::gtk_style_context_add_provider_for_screen(::gdk_screen_get_default(), //GdkScreen* screen, + GTK_STYLE_PROVIDER(provider), //GtkStyleProvider* provider, + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); //guint priority + } + catch (const SysError& e) { std::cerr << utfTo<std::string>(e.toString()) << "\n"; } +#else +#error unknown GTK version! +#endif //Windows User Experience Interaction Guidelines: tool tips should have 5s timeout, info tips no timeout => compromise: wxToolTip::Enable(true); //yawn, a wxWidgets screw-up: wxToolTip::SetAutoPop is no-op if global tooltip window is not yet constructed: wxToolTip::Enable creates it @@ -57,8 +83,8 @@ bool Application::OnInit() } catch (const FileError& e) { - //following dialog does NOT trigger "exit on frame delete" while we are in OnInit(): http://docs.wxwidgets.org/trunk/overview_app.html#overview_app_shutdown - showNotificationDialog(nullptr, DialogInfoType::ERROR2, PopupDialogCfg().setDetailInstructions(e.toString())); + //following dialog does NOT trigger "exit on frame delete" while we are in OnInit(): https://docs.wxwidgets.org/trunk/overview_app.html#overview_app_shutdown + showNotificationDialog(nullptr, DialogInfoType::error, PopupDialogCfg().setDetailInstructions(e.toString())); //continue! } @@ -100,7 +126,7 @@ void Application::onEnterEventLoop(wxEvent& event) filePath += Zstr(".ffs_batch"); else { - showNotificationDialog(nullptr, DialogInfoType::ERROR2, PopupDialogCfg().setMainInstructions(replaceCpy(_("Cannot find file %x."), L"%x", fmtPath(filePath)))); + showNotificationDialog(nullptr, DialogInfoType::error, PopupDialogCfg().setMainInstructions(replaceCpy(_("Cannot find file %x."), L"%x", fmtPath(filePath)))); return; } } |