From be83a8d0ca552ef3492a720a277cf7481ad23cc1 Mon Sep 17 00:00:00 2001
From: Sebastião Guerra <sebastiao.luiz.guerra@gmail.com>
Date: Thu, 15 Oct 2026 06:26:23 -0300
Subject: Avoid runtime dependency on unshipped kglib
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Sebastião Guerra <sebastiao.luiz.guerra@gmail.com>
---
 ConfigureChecks.cmake |  5 +++++
 src/CMakeLists.txt    |  4 +++-
 src/main.cpp          | 21 +++++++++++++++++++--
 3 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 9fed0af..5aadb6d 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -32,3 +32,8 @@ if( NOT POLKIT_TQT_FOUND )
   tde_message_fatal( "polkit-tqt is required, but was not found on your system" )
 endif( )
 
+pkg_search_module( GLIB2 glib-2.0 )
+if( NOT GLIB2_FOUND )
+  tde_message_fatal( "glib-2.0 is required, but was not found on your system" )
+endif( )
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ed2e6d0..e3f4bc4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -19,10 +19,12 @@ include_directories(
   ${TQT_INCLUDE_DIRS}
   ${TDE_INCLUDE_DIR}
   ${POLKIT_TQT_INCLUDE_DIRS}
+  ${GLIB2_INCLUDE_DIRS}
 )
 
 link_directories(
   ${TQT_LIBRARY_DIRS}
+  ${GLIB2_LIBRARY_DIRS}
 )
 
 
@@ -38,6 +40,6 @@ tde_create_translated_desktop(
 tde_add_executable( polkit-agent-tde AUTOMOC
   SOURCES AuthDialogWidget.ui AuthDetailsWidget.ui AuthDialog.h AuthDialog.cpp
           polkit-listener.h polkit-listener.cpp polkit-agent-tde.h polkit-agent-tde.cpp main.cpp
-  LINK tdecore-shared tdeui-shared kglib polkit-tqt-agent-shared
+  LINK tdecore-shared tdeui-shared polkit-tqt-agent-shared ${GLIB2_LIBRARIES}
   DESTINATION ${BIN_INSTALL_DIR}
 )
diff --git a/src/main.cpp b/src/main.cpp
index 9ba083f..bdab847 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -21,13 +21,30 @@
 #include <tdeaboutdata.h>
 #include <tdecmdlineargs.h>
 #include <tdelocale.h>
-#include <TGlibEventLoop.h>
+#include <tqeventloop.h>
+
+#include <glib.h>
 
 #include "polkit-agent-tde.h"
 
+class PolkitAgentEventLoop : public TQEventLoop
+{
+public:
+  PolkitAgentEventLoop() : TQEventLoop()
+  {
+    startTimer(100);
+  }
+
+  bool processEvents(ProcessEventsFlags flags) override
+  {
+    g_main_context_iteration(nullptr, false);
+    return TQEventLoop::processEvents(flags);
+  }
+};
+
 int main(int argc, char *argv[])
 {
-  TGlibEventLoop glibEventLoop;
+  PolkitAgentEventLoop glibEventLoop;
 
   TDEAboutData aboutData("polkit-agent-tde", I18N_NOOP("Polkit-Agent-TDE"), "0.99.1",
           I18N_NOOP("A Polkit authentication agent for TDE"), TDEAboutData::License_GPL,
-- 
cgit v1.2.3

