[polari] roomList: Add mute/unmute items to context menu
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] roomList: Add mute/unmute items to context menu
- Date: Wed, 1 Apr 2020 02:04:26 +0000 (UTC)
commit 45374e6448e6243ddf090638b065d507fa290b75
Author: Florian Müllner <fmuellner gnome org>
Date: Sat Apr 20 12:28:58 2019 +0000
roomList: Add mute/unmute items to context menu
Now that we handle muted nicks in the relevant places, it is
finally time to expose the action to the user. The existing
context menu is the most appropriate place we have, so add
a corresponding action there.
https://gitlab.gnome.org/GNOME/polari/-/merge_requests/153
src/roomList.js | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
---
diff --git a/src/roomList.js b/src/roomList.js
index f7e09418..b0ae354d 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -242,11 +242,42 @@ class RoomRowPopover extends Gtk.Popover {
this._menu = new Gio.Menu();
const isRoom = row.room.type === Tp.HandleType.ROOM;
+ if (!isRoom) {
+ this._muteItem = new Gio.MenuItem();
+ this._muteTarget = new GLib.Variant('(ss)', [
+ row.account.object_path,
+ row.room.channel_name,
+ ]);
+ this._menu.append_item(this._muteItem);
+ }
+
const label = isRoom ? _('Leave chatroom') : _('End conversation');
this._menu.append(label, `app.leave-room(("${this._row.room.id}", ""))`);
this.bind_model(this._menu, null);
}
+
+ vfunc_map() {
+ if (this._row.room.type !== Tp.HandleType.ROOM)
+ this._updateMuteItem();
+ super.vfunc_map();
+ }
+
+ _updateMuteItem() {
+ this._menu.remove(0);
+
+ if (this._row.muted) {
+ this._muteItem.set_label(_('Unmute'));
+ this._muteItem.set_action_and_target_value(
+ 'app.unmute-nick', this._muteTarget);
+ } else {
+ this._muteItem.set_label(_('Mute'));
+ this._muteItem.set_action_and_target_value(
+ 'app.mute-nick', this._muteTarget);
+ }
+
+ this._menu.insert_item(0, this._muteItem);
+ }
});
var RoomListHeader = GObject.registerClass({
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]