Daniel Brötzmann pushed to branch master at gajim / gajim
Commits: c2feb0ef by wurstsalat at 2022-01-11T13:57:27+01:00 GroupchatControl: Add visitor box with voice request button
- - - - -
2 changed files:
- gajim/data/gui/groupchat_control.ui - gajim/gtk/controls/groupchat.py
Changes:
===================================== gajim/data/gui/groupchat_control.ui ===================================== @@ -233,6 +233,56 @@ <property name="position">1</property> </packing> </child> + <child> + <object class="GtkBox" id="visitor_box"> + <property name="can-focus">False</property> + <property name="no-show-all">True</property> + <property name="spacing">12</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">You are a visitor</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkMenuButton" id="visitor_menu_button"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="focus-on-click">False</property> + <property name="receives-default">True</property> + <property name="tooltip-text" translatable="yes">What does this mean?</property> + <property name="valign">center</property> + <property name="popover">visitor_popover</property> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="icon-name">dialog-information-symbolic</property> + </object> + </child> + <style> + <class name="suggested-action"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> <child> <object class="GtkBox" id="account_badge_box"> <property name="can-focus">False</property> @@ -249,7 +299,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">2</property> + <property name="position">3</property> </packing> </child> <child> @@ -301,7 +351,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">3</property> + <property name="position">4</property> </packing> </child> </object> @@ -2423,4 +2473,70 @@ </packing> </child> </object> + <object class="GtkPopover" id="visitor_popover"> + <property name="can-focus">False</property> + <property name="relative-to">visitor_menu_button</property> + <property name="position">bottom</property> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">You are a visitor</property> + <style> + <class name="bold"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">In order to write messages in this chat, you need to request voice first. +A moderator will process your request.</property> + <property name="wrap">True</property> + <property name="max-width-chars">30</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton"> + <property name="label" translatable="yes">_Request</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="halign">center</property> + <property name="use-underline">True</property> + <signal name="clicked" handler="_on_request_voice_clicked" swapped="no"/> + <style> + <class name="suggested-action"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack-type">end</property> + <property name="position">2</property> + </packing> + </child> + <style> + <class name="padding-6"/> + </style> + </object> + </child> + </object> </interface>
===================================== gajim/gtk/controls/groupchat.py ===================================== @@ -40,6 +40,7 @@ from nbxmpp.errors import StanzaError from nbxmpp.modules.security_labels import Displaymarking from nbxmpp.modules.vcard_temp import VCard +from nbxmpp.structs import PresenceProperties
from gi.repository import Gtk from gi.repository import Gdk @@ -55,6 +56,8 @@ from gajim.common.const import AvatarSize
from gajim.common.i18n import _ +from gajim.common.modules.contacts import GroupchatContact +from gajim.common.modules.contacts import GroupchatParticipant from gajim.common.structs import OutgoingMessage
from gajim.gui.controls.base import BaseControl @@ -310,7 +313,7 @@ def add_actions(self) -> None: act.connect("activate", func) app.window.add_action(act)
- def update_actions(self, *args): + def update_actions(self, *args: Any) -> None: joined = self.contact.is_joined if joined: contact = self.contact.get_self() @@ -564,10 +567,17 @@ def _on_configure_form_received(self, task): return GroupchatConfig(self.account, result.jid, 'owner', result.form)
- def _on_request_voice(self, _action, _param): - """ - Request voice in the current room - """ + def _on_request_voice_clicked(self, _button: Gtk.Button) -> None: + self._request_voice() + self.xml.visitor_popover.popdown() + + def _on_request_voice(self, + _action: Gio.SimpleAction, + _param: Optional[GLib.Variant] + ) -> None: + self._request_voice() + + def _request_voice(self) -> None: self._client.get_module('MUC').request_voice(self.room_jid)
def _on_execute_command(self, _action, param): @@ -882,7 +892,9 @@ def _set_message_input_sensitive(self, state: bool) -> None:
def _set_control_active(self) -> None: contact = self.contact.get_self() - if not contact.role.is_visitor: + if contact.role.is_visitor: + self.xml.visitor_box.show() + else: self._set_message_input_sensitive(True)
self.roster.initial_draw() @@ -892,6 +904,7 @@ def _set_control_active(self) -> None:
def _set_control_inactive(self) -> None: self._set_message_input_sensitive(False) + self.xml.visitor_box.hide()
self.roster.enable_sort(False) self.roster.clear() @@ -971,10 +984,11 @@ def _on_user_status_show_changed(self, properties.is_muc_self_presence)
def _on_user_affiliation_changed(self, - _contact, - _signal_name, - user_contact, - properties): + _contact: GroupchatContact, + _signal_name: str, + user_contact: GroupchatParticipant, + properties: PresenceProperties + ) -> None: affiliation = helpers.get_uf_affiliation(user_contact.affiliation) nick = user_contact.name reason = properties.muc_user.reason @@ -1002,10 +1016,11 @@ def _on_user_affiliation_changed(self, self.update_actions()
def _on_user_role_changed(self, - _contact, - _signal_name, - user_contact, - properties): + _contact: GroupchatContact, + _signal_name: str, + user_contact: GroupchatParticipant, + properties: PresenceProperties + ) -> None: role = helpers.get_uf_role(user_contact.role) nick = user_contact.name reason = properties.muc_user.reason @@ -1016,6 +1031,10 @@ def _on_user_role_changed(self, actor = '' if actor is None else _(' by {actor}').format(actor=actor)
if properties.is_muc_self_presence: + if user_contact.role.is_visitor: + self.xml.visitor_box.show() + else: + self.xml.visitor_box.hide() self._set_message_input_sensitive(not user_contact.role.is_visitor) message = _('** Your Role has been set to ' '{role}{actor}{reason}').format(role=role,
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/c2feb0ef168698be519a6a711fe37dcad...