Philipp Hörist pushed to branch master at gajim / gajim


Commits:
4d544c10 by wurstsalat at 2025-11-30T22:21:07+00:00
fix: DBMigration: Ensure window modality by setting transient periodically

While the DBMigration window is presented, Gajim's main window may not be
present yet (app.window = None). This prevents the DBMigration window
from becoming modal. Setting the transient periodically makes sure modality
is enabled as soon as Gajim's main window is presented.

Fixes #12520

- - - - -


3 changed files:

- gajim/data/gui/db_migration.ui
- gajim/gtk/db_migration.py
- test/gtk/ui_test_db_migration.py


Changes:

=====================================
gajim/data/gui/db_migration.ui
=====================================
@@ -94,6 +94,7 @@ This may take a while…</property>
                           <object class="GtkScrolledWindow">
                             <property name="height-request">100</property>
                             <property name="focusable">1</property>
+                            <property name="has-frame">1</property>
                             <property name="child">
                               <object class="GtkTextView" id="error_view">
                                 <property name="focusable">1</property>


=====================================
gajim/gtk/db_migration.py
=====================================
@@ -42,6 +42,7 @@ def __init__(
         EventHelper.__init__(self)
 
         self.window.set_deletable(False)
+        self.window.set_resizable(False)
 
         self._ui = get_builder("db_migration.ui")
         self.set_child(self._ui.box)
@@ -65,7 +66,16 @@ def __init__(
             ]
         )
 
+        self._timeout_id = GLib.timeout_add(100, self._set_transient)
+
+    def _set_transient(self) -> int:
+        # Set transient on every update to make sure transient is set as
+        # soon as main window is available
+        self.window.set_transient_for(app.window)
+        return GLib.SOURCE_CONTINUE
+
     def _cleanup(self) -> None:
+        GLib.source_remove(self._timeout_id)
         self.unregister_events()
 
     def _on_start(self, event: DBMigrationStart) -> None:
@@ -84,7 +94,7 @@ def _on_progress(self, event: DBMigrationProgress) -> None:
         while context.pending():
             context.iteration(may_block=False)
 
-    def _on_finished(self, event: DBMigrationFinished) -> None:
+    def _on_finished(self, _event: DBMigrationFinished) -> None:
         self._ui.stack.set_visible_child_name("success-page")
         GLib.timeout_add_seconds(2, self.present)
 


=====================================
test/gtk/ui_test_db_migration.py
=====================================
@@ -6,6 +6,7 @@
 
 import time
 
+from gi.repository import GLib
 from gi.repository import Gtk
 
 from gajim.common import app
@@ -44,7 +45,16 @@ def __init__(self) -> None:
 
         window.show()
 
-    def _on_progress_clicked(self, _button: Gtk.Button) -> None:
+        GLib.timeout_add_seconds(3, self._add_window)
+
+        self._progress()
+
+    def _add_window(self) -> None:
+        # Simulate main window becoming available
+        app.window = Gtk.Window(width_request=800, height_request=800)
+        app.window.show()
+
+    def _progress(self) -> None:
         app.ged.raise_event(DBMigrationStart(version=1))
         self._progressing = True
 
@@ -57,6 +67,9 @@ def _on_progress_clicked(self, _button: Gtk.Button) -> None:
             if i % 1000 == 0:
                 app.ged.raise_event(DBMigrationProgress(count=count, 
progress=i))
 
+    def _on_progress_clicked(self, _button: Gtk.Button) -> None:
+        self._progress()
+
     def _on_finish_clicked(self, _button: Gtk.Button) -> None:
         self._progressing = False
 



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/4d544c101234d13c18af8692ffa48b58a5139034

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/4d544c101234d13c18af8692ffa48b58a5139034
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to