Daniel Brötzmann pushed to branch gtk4 at gajim / gajim
Commits:
87a7fe48 by wurstsalat at 2024-10-12T20:56:41+02:00
refactor: ChatFilter: Activate 'All' by default, correctly finalize
widget
- - - - -
1 changed file:
- gajim/gtk/chat_filter.py
Changes:
=====================================
gajim/gtk/chat_filter.py
=====================================
@@ -2,15 +2,16 @@
#
# SPDX-License-Identifier: GPL-3.0-only
-from typing import Any
-
from gi.repository import GObject
from gi.repository import Gtk
+from gajim.common import app
from gajim.common.i18n import _
+from gajim.gtk.util import SignalManager
+
-class ChatFilter(Gtk.Box):
+class ChatFilter(Gtk.Box, SignalManager):
__gsignals__ = {
'filter-changed': (GObject.SignalFlags.RUN_LAST,
@@ -20,19 +21,20 @@ class ChatFilter(Gtk.Box):
def __init__(self, icons: bool = False) -> None:
Gtk.Box.__init__(self, halign=Gtk.Align.CENTER)
+ SignalManager.__init__(self)
toolbar = Gtk.Box(css_classes=['toolbar'])
if icons:
toolbar.add_css_class('chat-filter-icons')
- self._all_button = Gtk.ToggleButton()
+ self._all_button = Gtk.ToggleButton(active=True)
if icons:
self._all_button.set_icon_name('feather-home-symbolic')
self._all_button.set_tooltip_text(_('All'))
else:
self._all_button.set_label(_('All'))
self._all_button.set_name('all')
- self._all_button.connect('clicked', self._on_button_clicked)
+ self._connect(self._all_button, 'clicked', self._on_button_clicked)
toolbar.append(self._all_button)
chats_button = Gtk.ToggleButton(group=self._all_button)
@@ -42,7 +44,7 @@ def __init__(self, icons: bool = False) -> None:
else:
chats_button.set_label(_('Chats'))
chats_button.set_name('chats')
- chats_button.connect('clicked', self._on_button_clicked)
+ self._connect(chats_button, 'clicked', self._on_button_clicked)
toolbar.append(chats_button)
group_chats_button = Gtk.ToggleButton(group=self._all_button)
@@ -52,12 +54,17 @@ def __init__(self, icons: bool = False) -> None:
else:
group_chats_button.set_label(_('Group Chats'))
group_chats_button.set_name('group_chats')
- group_chats_button.connect('clicked', self._on_button_clicked)
+ self._connect(group_chats_button, 'clicked', self._on_button_clicked)
toolbar.append(group_chats_button)
self.append(toolbar)
- def _on_button_clicked(self, button: Any) -> None:
+ def do_unroot(self) -> None:
+ Gtk.Box.do_unroot(self)
+ self._disconnect_all()
+ app.check_finalize(self)
+
+ def _on_button_clicked(self, button: Gtk.ToggleButton) -> None:
if button.get_active():
self.emit('filter-changed', button.get_name())
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/87a7fe485ad0cbcbbfa0b79c30ea771536df7f90
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/87a7fe485ad0cbcbbfa0b79c30ea771536df7f90
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]