diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 2b4581d839..e747b3c97e 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -437,7 +437,7 @@ target_link_libraries( if (MSVC) target_link_libraries(libslic3r_gui PUBLIC Setupapi.lib) elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux") - target_link_libraries(libslic3r_gui PUBLIC ${DBUS_LIBRARIES}) + target_link_libraries(libslic3r_gui PUBLIC ${DBUS_LIBRARIES}) elseif (APPLE) target_link_libraries(libslic3r_gui PUBLIC ${DISKARBITRATION_LIBRARY} ${COREWLAN_LIBRARY}) endif() @@ -457,8 +457,12 @@ endif () # link these libraries. if (UNIX AND NOT APPLE) find_package(GTK${SLIC3R_GTK} REQUIRED) - target_include_directories(libslic3r_gui PRIVATE ${GTK${SLIC3R_GTK}_INCLUDE_DIRS}) - target_link_libraries(libslic3r_gui PUBLIC ${GTK${SLIC3R_GTK}_LIBRARIES} fontconfig) + find_package(PkgConfig REQUIRED) + + pkg_check_modules(WEBKIT2GTK REQUIRED webkit2gtk-4.0) + + target_include_directories(libslic3r_gui PRIVATE ${GTK${SLIC3R_GTK}_INCLUDE_DIRS} ${WEBKIT2GTK_INCLUDE_DIRS}) + target_link_libraries(libslic3r_gui PUBLIC ${GTK${SLIC3R_GTK}_LIBRARIES} fontconfig ${WEBKIT2GTK_LIBS}) endif () # Add a definition so that we can tell we are compiling slic3r. diff --git a/src/slic3r/GUI/RulerForDoubleSlider.hpp b/src/slic3r/GUI/RulerForDoubleSlider.hpp index afdf70ff34..89d9aa78d9 100644 --- a/src/slic3r/GUI/RulerForDoubleSlider.hpp +++ b/src/slic3r/GUI/RulerForDoubleSlider.hpp @@ -8,6 +8,7 @@ #include #include #include +#include namespace DoubleSlider { diff --git a/src/slic3r/GUI/WebViewPlatformUtilsLinux.cpp b/src/slic3r/GUI/WebViewPlatformUtilsLinux.cpp index 64ecb600dc..196081173e 100644 --- a/src/slic3r/GUI/WebViewPlatformUtilsLinux.cpp +++ b/src/slic3r/GUI/WebViewPlatformUtilsLinux.cpp @@ -11,21 +11,32 @@ struct Credentials { std::string password; }; -using WebViewCredentialsMap = std::unordered_map>; -WebViewCredentialsMap g_credentials; - gboolean webkit_authorize_handler(WebKitWebView *web_view, WebKitAuthenticationRequest *request, gpointer user_data) { const Credentials& creds = *static_cast(user_data); - webkit_authentication_request_authenticate(request, webkit_credential_new(creds.username.c_str(), creds.password.c_str())); + webkit_authentication_request_authenticate(request, webkit_credential_new(creds.username.c_str(), creds.password.c_str(), WEBKIT_CREDENTIAL_PERSISTENCE_FOR_SESSION)); + return TRUE; } - void setup_webview_with_credentials(wxWebView* web_view, const std::string& username, const std::string& password) +void free_credentials(gpointer user_data, GClosure* closure) { - std::unique_ptr ptr(new Credentials{username, password}); - g_credentials[web_view->GetNativeBackend()] = std::move(ptr); - g_signal_connect(web_view, "authorize", - G_CALLBACK(webkit_authorize_handler), g_credentials[web_view].get()); + Credentials* creds = static_cast(user_data); + delete creds; +} + +void setup_webview_with_credentials(wxWebView* web_view, const std::string& username, const std::string& password) +{ + WebKitWebView* native_backend = static_cast(web_view->GetNativeBackend()); + Credentials* user_data = new Credentials{username, password}; + + g_signal_connect_data( + native_backend, + "authenticate", + G_CALLBACK(webkit_authorize_handler), + user_data, + &free_credentials, + static_cast(0) + ); }