Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits:
9ed4c82e by wurstsalat at 2021-03-04T22:50:32+01:00
Roster: Add filter menu, connect search
- - - - -
3 changed files:
- gajim/data/gui/account_page.ui
- gajim/gtk/account_page.py
- gajim/gtk/roster.py
Changes:
=====================================
gajim/data/gui/account_page.ui
=====================================
@@ -75,6 +75,7 @@
<property name="primary-icon-activatable">False</property>
<property name="primary-icon-sensitive">False</property>
<property name="placeholder-text"
translatable="yes">Search…</property>
+ <signal name="changed" handler="_on_search_changed"
swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
=====================================
gajim/gtk/account_page.py
=====================================
@@ -12,15 +12,21 @@
# You should have received a copy of the GNU General Public License
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
+from gi.repository import Gio
from gi.repository import Gtk
from gajim.common import app
+from gajim.common.i18n import _
from .roster import Roster
from .status_selector import StatusSelector
from .util import get_builder
from .util import open_window
+ROSTER_MENU_DICT = {
+ 'show-offline': _('Show Offline Contacts'),
+}
+
class AccountPage(Gtk.Box):
def __init__(self, account):
@@ -40,6 +46,11 @@ def __init__(self, account):
self._ui.paned.set_position(app.settings.get('chat_handle_position'))
self._ui.paned.connect('button-release-event', self._on_button_release)
+ roster_menu = Gio.Menu()
+ for action, label in ROSTER_MENU_DICT.items():
+ roster_menu.append(label, f'win.{action}-{account}')
+ self._ui.roster_menu_button.set_menu_model(roster_menu)
+
self._ui.connect_signals(self)
self.show_all()
@@ -49,6 +60,10 @@ def _on_account_settings(self, _button):
window = open_window('AccountsWindow')
window.select_account(self._account)
+ def _on_search_changed(self, widget):
+ text = widget.get_text().lower()
+ print(text)
+
@staticmethod
def _on_button_release(paned, event):
if event.window != paned.get_handle_window():
=====================================
gajim/gtk/roster.py
=====================================
@@ -97,6 +97,13 @@ def _add_actions(self):
act.connect('activate', func)
app.window.add_action(act)
+ action = Gio.SimpleAction.new_stateful(
+ f'show-offline-{self._account}',
+ None,
+ GLib.Variant.new_boolean(app.settings.get('showoffline')))
+ action.connect('change-state', self._show_offline)
+ app.window.add_action(action)
+
def update_actions(self):
online = app.account_is_connected(self._account)
blocking_support = self._client.get_module('Blocking').supported
@@ -117,6 +124,7 @@ def _remove_actions(self):
'execute-command',
'block-contact',
'remove-contact',
+ 'show-offline',
]
for action in actions:
app.window.remove_action(f'{action}-{self._account}')
@@ -127,6 +135,12 @@ def _on_account_state(self, _event):
def _on_theme_update(self, _event):
self.redraw()
+ def _show_offline(self, action, param):
+ action.set_state(param)
+ app.settings.set('showoffline', param.get_boolean())
+ print('_show_offline')
+ print(param.get_boolean())
+
def _contact_info(self, _action, param):
app.window.contact_info(self._account, param.get_string())
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/9ed4c82e2701a759ca3224be0d8e5c87077b785f
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/9ed4c82e2701a759ca3224be0d8e5c87077b785f
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits