From d96492968120cc667c9e38cce59ca688268d9240 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Fri, 31 Oct 2025 22:49:38 +0100 Subject: [PATCH] feat: add modman title handler for linux --- .../Web/Platform/Linux/DialogHandlerLinux.cpp | 2 -- .../Platform/Linux/FaviconHandlerLinux.cpp | 22 +++++++++++++ .../Web/Platform/Linux/FaviconHandlerLinux.h | 16 ++++++++++ .../Web/Platform/Linux/TitleHandlerLinux.cpp | 31 +++++++++++++++++++ .../Web/Platform/Linux/TitleHandlerLinux.h | 16 ++++++++++ src/ModMan/main.cpp | 2 ++ 6 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 src/ModMan/Web/Platform/Linux/FaviconHandlerLinux.cpp create mode 100644 src/ModMan/Web/Platform/Linux/FaviconHandlerLinux.h create mode 100644 src/ModMan/Web/Platform/Linux/TitleHandlerLinux.cpp create mode 100644 src/ModMan/Web/Platform/Linux/TitleHandlerLinux.h diff --git a/src/ModMan/Web/Platform/Linux/DialogHandlerLinux.cpp b/src/ModMan/Web/Platform/Linux/DialogHandlerLinux.cpp index 16fcdc6e..ca3c8e09 100644 --- a/src/ModMan/Web/Platform/Linux/DialogHandlerLinux.cpp +++ b/src/ModMan/Web/Platform/Linux/DialogHandlerLinux.cpp @@ -37,8 +37,6 @@ namespace #endif } - void OpenFileDialog() {} - void SetFilters(GtkFileDialog* pDialog, const std::vector& filters) { if (filters.empty()) diff --git a/src/ModMan/Web/Platform/Linux/FaviconHandlerLinux.cpp b/src/ModMan/Web/Platform/Linux/FaviconHandlerLinux.cpp new file mode 100644 index 00000000..08376d4c --- /dev/null +++ b/src/ModMan/Web/Platform/Linux/FaviconHandlerLinux.cpp @@ -0,0 +1,22 @@ +#include "AssetHandlerLinux.h" + +#if defined(WEBVIEW_PLATFORM_LINUX) && defined(WEBVIEW_GTK) + +#include "Web/UiAssets.h" + +#include +#include +#include + +using namespace PLATFORM_NAMESPACE_LINUX; + +namespace +{ +} // namespace + +namespace PLATFORM_NAMESPACE_LINUX +{ + void InstallFaviconHandler(webview::webview& wv) {} +} // namespace PLATFORM_NAMESPACE_LINUX + +#endif diff --git a/src/ModMan/Web/Platform/Linux/FaviconHandlerLinux.h b/src/ModMan/Web/Platform/Linux/FaviconHandlerLinux.h new file mode 100644 index 00000000..2ac806a6 --- /dev/null +++ b/src/ModMan/Web/Platform/Linux/FaviconHandlerLinux.h @@ -0,0 +1,16 @@ +#pragma once + +#include "Web/Platform/Platform.h" + +#include + +#if defined(WEBVIEW_PLATFORM_LINUX) && defined(WEBVIEW_GTK) + +#include "Web/WebViewLib.h" + +namespace PLATFORM_NAMESPACE_LINUX +{ + void InstallFaviconHandler(webview::webview& wv); +} // namespace PLATFORM_NAMESPACE_LINUX + +#endif diff --git a/src/ModMan/Web/Platform/Linux/TitleHandlerLinux.cpp b/src/ModMan/Web/Platform/Linux/TitleHandlerLinux.cpp new file mode 100644 index 00000000..9ca592eb --- /dev/null +++ b/src/ModMan/Web/Platform/Linux/TitleHandlerLinux.cpp @@ -0,0 +1,31 @@ +#include "AssetHandlerLinux.h" + +#if defined(WEBVIEW_PLATFORM_LINUX) && defined(WEBVIEW_GTK) + +#include "Web/UiAssets.h" + +#include +#include +#include + +using namespace PLATFORM_NAMESPACE_LINUX; + +namespace PLATFORM_NAMESPACE_LINUX +{ + void InstallTitleHandler(webview::webview& wv) + { + const auto webViewWidget = static_cast(wv.browser_controller().value()); + const auto webView = WEBKIT_WEB_VIEW(webViewWidget); + const auto windowWidget = static_cast(wv.window().value()); + const auto window = GTK_WINDOW(windowWidget); + + auto on_title_changed = +[](GtkWidget* widget, GParamSpec paramSpec, GtkWindow* window) + { + gtk_window_set_title(window, webkit_web_view_get_title(WEBKIT_WEB_VIEW(widget))); + }; + + g_signal_connect(G_OBJECT(webView), "notify::title", G_CALLBACK(on_title_changed), (gpointer)window); + } +} // namespace PLATFORM_NAMESPACE_LINUX + +#endif diff --git a/src/ModMan/Web/Platform/Linux/TitleHandlerLinux.h b/src/ModMan/Web/Platform/Linux/TitleHandlerLinux.h new file mode 100644 index 00000000..2c1244d1 --- /dev/null +++ b/src/ModMan/Web/Platform/Linux/TitleHandlerLinux.h @@ -0,0 +1,16 @@ +#pragma once + +#include "Web/Platform/Platform.h" + +#include + +#if defined(WEBVIEW_PLATFORM_LINUX) && defined(WEBVIEW_GTK) + +#include "Web/WebViewLib.h" + +namespace PLATFORM_NAMESPACE_LINUX +{ + void InstallTitleHandler(webview::webview& wv); +} // namespace PLATFORM_NAMESPACE_LINUX + +#endif diff --git a/src/ModMan/main.cpp b/src/ModMan/main.cpp index cc42c884..71174c81 100644 --- a/src/ModMan/main.cpp +++ b/src/ModMan/main.cpp @@ -3,6 +3,8 @@ #include "ModManArgs.h" #include "Web/Binds/Binds.h" #include "Web/Platform/AssetHandler.h" +#include "Web/Platform/Linux/FaviconHandlerLinux.h" +#include "Web/Platform/Linux/TitleHandlerLinux.h" #include "Web/Platform/Windows/FaviconHandlerWindows.h" #include "Web/Platform/Windows/TitleHandlerWindows.h" #include "Web/UiCommunication.h"