Daniel Brötzmann pushed to branch gtk4 at gajim / gajim


Commits:
97f6563d by wurstsalat at 2024-11-04T23:35:19+01:00
refactor: ApplyButtonBox: Fix showing icon; add test

- - - - -


2 changed files:

- gajim/gtk/apply_button_box.py
- + test/gtk/ui_test_apply_button_box.py


Changes:

=====================================
gajim/gtk/apply_button_box.py
=====================================
@@ -32,9 +32,9 @@ def __init__(self,
         self._connect(self._button, 'clicked', self._on_clicked)
         self._connect(self._button, 'clicked', on_clicked)
 
+        self.append(self._button)
         self.append(self._status_image)
         self.append(self._spinner)
-        self.append(self._button)
 
     def do_unroot(self) -> None:
         self._disconnect_all()
@@ -73,3 +73,4 @@ def _set_status_image(self, state: str, tooltip_text: str = 
'') -> None:
         self._status_image.set_from_icon_name(icon_name)
         self._status_image.get_style_context().add_class(css_class)
         self._status_image.set_tooltip_text(tooltip_text)
+        self._status_image.show()


=====================================
test/gtk/ui_test_apply_button_box.py
=====================================
@@ -0,0 +1,44 @@
+# This file is part of Gajim.
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+from gi.repository import GLib
+from gi.repository import Gtk
+
+from gajim.gtk.apply_button_box import ApplyButtonBox
+from gajim.gtk.widgets import GajimAppWindow
+
+from . import util
+
+
+class TestApplyButtonBox(GajimAppWindow):
+    def __init__(self):
+        GajimAppWindow.__init__(
+            self,
+            name='',
+            title=__class__.__name__,
+            default_width=600,
+            default_height=600,
+        )
+
+        box = Gtk.Box(halign=Gtk.Align.CENTER, valign=Gtk.Align.CENTER, 
hexpand=True)
+        self.set_child(box)
+
+        self._apply_button_box = ApplyButtonBox('Apply', self._on_clicked)
+        self._apply_button_box.set_button_state(True)
+        box.append(self._apply_button_box)
+
+    def _on_clicked(self, _button: Gtk.Button) -> None:
+        print('clicked')
+        GLib.timeout_add_seconds(2, self._apply_button_box.set_success)
+        GLib.timeout_add_seconds(
+            5, self._apply_button_box.set_error, 'An error occurred'
+        )
+        GLib.timeout_add_seconds(9, self._apply_button_box.set_button_state, 
True)
+        print('Finished')
+
+
+window = TestApplyButtonBox()
+window.show()
+
+util.run_app()



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/97f6563d4931dcd513c407b98a45b3ef40f66a3c

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/97f6563d4931dcd513c407b98a45b3ef40f66a3c
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