Daniel Brötzmann pushed to branch newcontrol at gajim / gajim
Commits: 3c6ace6b by wurstsalat at 2022-06-27T23:55:51+02:00 refactor: ChatBanner: Adapt to moved functionality
- - - - -
9 changed files:
- gajim/data/gui/chat_control.ui - gajim/data/gui/groupchat_control.ui - gajim/gtk/builder.pyi - gajim/gtk/chat_banner.py - gajim/gtk/control_stack.py - gajim/gtk/controls/base.py - gajim/gtk/controls/chat.py - gajim/gtk/controls/groupchat.py - gajim/gtk/controls/private.py
Changes:
===================================== gajim/data/gui/chat_control.ui ===================================== @@ -95,144 +95,7 @@ <property name="can-focus">False</property> <property name="orientation">vertical</property> <child> - <object class="GtkEventBox" id="banner_eventbox"> - <property name="name">ChatControl-BannerEventBox</property> - <property name="can-focus">False</property> - <property name="no-show-all">True</property> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="spacing">6</property> - <child> - <object class="GtkEventBox" id="avatar_eventbox"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="visible-window">False</property> - <child> - <object class="GtkImage" id="avatar_image"> - <property name="width-request">48</property> - <property name="height-request">48</property> - <property name="visible">True</property> - <property name="can-focus">False</property> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <!-- n-columns=3 n-rows=3 --> - <object class="GtkGrid"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="valign">center</property> - <property name="hexpand">True</property> - <property name="row-spacing">3</property> - <property name="column-spacing">3</property> - <child> - <object class="GtkLabel" id="banner_name_label"> - <property name="name">ChatControl-BannerNameLabel</property> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="halign">start</property> - <property name="hexpand">True</property> - <property name="label">Contact name</property> - <property name="ellipsize">end</property> - <property name="xalign">0</property> - <style> - <class name="large-header"/> - </style> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">0</property> - <property name="width">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="banner_label"> - <property name="name">ChatControl-BannerLabel</property> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="halign">start</property> - <property name="hexpand">True</property> - <property name="label">label</property> - <property name="selectable">True</property> - <property name="ellipsize">end</property> - <property name="xalign">0</property> - </object> - <packing> - <property name="left-attach">1</property> - <property name="top-attach">1</property> - </packing> - </child> - <child> - <object class="GtkImage" id="phone_image"> - <property name="can-focus">False</property> - <property name="no-show-all">True</property> - <property name="tooltip-text" translatable="yes">The last message was written on a mobile client</property> - <property name="halign">start</property> - <property name="margin-end">4</property> - <property name="icon-name">phone-apple-iphone-symbolic</property> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">1</property> - </packing> - </child> - <child> - <object class="GtkBox" id="account_badge_box"> - <property name="can-focus">False</property> - <property name="no-show-all">True</property> - <property name="halign">end</property> - <property name="valign">center</property> - <property name="orientation">vertical</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="left-attach">2</property> - <property name="top-attach">0</property> - </packing> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <child> - <placeholder/> - </child> - </object> - </child> - <style> - <class name="gajim-banner"/> - </style> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> + <placeholder/> </child> <child> <object class="GtkSeparator">
===================================== gajim/data/gui/groupchat_control.ui ===================================== @@ -105,181 +105,7 @@ <property name="hexpand">True</property> <property name="orientation">vertical</property> <child> - <object class="GtkEventBox" id="banner_eventbox"> - <property name="name">GroupChatControl-BannerEventBox</property> - <property name="can-focus">False</property> - <property name="no-show-all">True</property> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="spacing">6</property> - <child> - <object class="GtkImage" id="avatar_image"> - <property name="width-request">48</property> - <property name="height-request">48</property> - <property name="visible">True</property> - <property name="can-focus">False</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="banner_name_label"> - <property name="name">GroupChatControl-BannerNameLabel</property> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="hexpand">True</property> - <property name="label">Group Chat Name</property> - <property name="selectable">True</property> - <property name="ellipsize">end</property> - <property name="single-line-mode">True</property> - <property name="xalign">0</property> - <style> - <class name="large-header"/> - </style> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <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> - <property name="no-show-all">True</property> - <property name="halign">end</property> - <property name="valign">center</property> - <property name="margin-end">6</property> - <property name="hexpand">True</property> - <property name="orientation">vertical</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">3</property> - </packing> - </child> - <child> - <object class="GtkButton" id="toggle_roster_button"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">True</property> - <property name="tooltip-text" translatable="yes">Toggle participants list</property> - <property name="valign">center</property> - <signal name="clicked" handler="_show_roster" swapped="no"/> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="spacing">3</property> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="icon-name">system-users-symbolic</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkImage" id="toggle_roster_image"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="icon-name">go-previous-symbolic</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <style> - <class name="dim-label"/> - </style> - </object> - </child> - <style> - <class name="flat"/> - </style> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">4</property> - </packing> - </child> - </object> - </child> - <style> - <class name="gajim-banner"/> - </style> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> + <placeholder/> </child> <child> <object class="GtkSeparator"> @@ -1612,12 +1438,6 @@ <property name="position">9</property> </packing> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> </object> <packing> <property name="index">-1</property> @@ -1631,70 +1451,4 @@ </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/builder.pyi ===================================== @@ -217,13 +217,6 @@ class ChatControlBuilder(Builder): chat_control_hbox: Gtk.Box overlay: Gtk.Overlay textview_box: Gtk.Box - banner_eventbox: Gtk.EventBox - avatar_eventbox: Gtk.EventBox - avatar_image: Gtk.Image - banner_name_label: Gtk.Label - banner_label: Gtk.Label - phone_image: Gtk.Image - account_badge_box: Gtk.Box conv_view_overlay: Gtk.Overlay hbox: Gtk.Box emoticons_button: Gtk.MenuButton @@ -418,14 +411,6 @@ class GroupchatControlBuilder(Builder): stack: Gtk.Stack groupchat_control_vbox: Gtk.Box textview_box: Gtk.Box - banner_eventbox: Gtk.EventBox - avatar_image: Gtk.Image - banner_name_label: Gtk.Label - visitor_box: Gtk.Box - visitor_menu_button: Gtk.MenuButton - account_badge_box: Gtk.Box - toggle_roster_button: Gtk.Button - toggle_roster_image: Gtk.Image conv_view_overlay: Gtk.Overlay hbox: Gtk.Box quick_invite_button: Gtk.Button @@ -463,7 +448,6 @@ class GroupchatControlBuilder(Builder): destroy_reason_entry: Gtk.Entry invite_grid: Gtk.Grid invite_button: Gtk.Button - visitor_popover: Gtk.Popover
class GroupchatCreationBuilder(Builder):
===================================== gajim/gtk/chat_banner.py ===================================== @@ -61,7 +61,9 @@ def __init__(self) -> None: self.register_events([ ('message-received', ged.GUI1, self._on_message_received), ('bookmarks-received', ged.GUI1, self._on_bookmarks_received), - ('muc-disco-update', ged.GUI1, self._on_muc_disco_update) + ('muc-disco-update', ged.GUI1, self._on_muc_disco_update), + ('account-enabled', ged.GUI2, self._on_account_changed), + ('account-disabled', ged.GUI2, self._on_account_changed) ])
app.settings.connect_signal( @@ -200,6 +202,9 @@ def _on_muc_disco_update(self, event: MucDiscoUpdate) -> None:
self._update_content()
+ def _on_account_changed(self, *args: Any) -> None: + self._update_account_badge() + def _on_message_received(self, event: MessageReceived) -> None: if not event.msgtxt or self._contact is None: return
===================================== gajim/gtk/control_stack.py ===================================== @@ -24,7 +24,6 @@ from nbxmpp import JID
from gajim.common import app -from gajim.common import ged from gajim.common.i18n import _
from .controls.chat import ChatControl @@ -32,26 +31,18 @@ from .controls.private import PrivateChatControl
from .types import ControlT -from .util import EventHelper
log = logging.getLogger('gajim.gui.controlstack')
-class ControlStack(Gtk.Stack, EventHelper): +class ControlStack(Gtk.Stack): def __init__(self): Gtk.Stack.__init__(self) - EventHelper.__init__(self) - self.set_vexpand(True) self.set_hexpand(True)
self.add_named(ChatPlaceholderBox(), 'empty')
- self.register_events([ - ('account-enabled', ged.GUI2, self._on_account_changed), - ('account-disabled', ged.GUI2, self._on_account_changed), - ]) - self.show_all() self._controls: dict[tuple[str, JID], ControlT] = {} self._current_control = None @@ -148,10 +139,6 @@ def remove_chats_for_account(self, account: str) -> None: continue self.remove_chat(account, jid)
- def _on_account_changed(self, *args: Any) -> None: - for control in self._controls.values(): - control.update_account_badge() -
class ChatPlaceholderBox(Gtk.Box): def __init__(self):
===================================== gajim/gtk/controls/base.py ===================================== @@ -71,7 +71,6 @@ from gajim.gui.builder import get_builder from gajim.gui.util import set_urgency_hint from gajim.gui.util import scroll_to_end -from gajim.gui.util import AccountBadge from gajim.gui.const import ControlType from gajim.gui.const import TARGET_TYPE_URI_LIST
@@ -142,11 +141,6 @@ def __init__(self, widget_name: str, account: str, jid: JID) -> None: # self.xml.connect_signals(self) self.widget: Gtk.Box = self.xml.get_object(f'{widget_name}_hbox')
- self._account_badge = AccountBadge(self.account) - self.xml.account_badge_box.add(self._account_badge) - show_account_badge = len(app.settings.get_active_accounts()) > 1 - self.xml.account_badge_box.set_visible(show_account_badge) - # Drag and drop self.xml.overlay.add_overlay(self.xml.drop_area) self.xml.drop_area.hide() @@ -985,10 +979,6 @@ def has_focus(self) -> bool: return True return False
- def update_account_badge(self) -> None: - show = len(app.settings.get_active_accounts()) > 1 - self.xml.account_badge_box.set_visible(show) -
class ScrolledWindow(Gtk.ScrolledWindow): def __init__(self, *args: Any, **kwargs: Any) -> None:
===================================== gajim/gtk/controls/chat.py ===================================== @@ -45,7 +45,6 @@ from gajim.common.client import Client from gajim.common.i18n import _ from gajim.common.helpers import AdditionalDataDict -from gajim.common.const import AvatarSize from gajim.common.const import SimpleClientState from gajim.common.const import KindConstant from gajim.common.modules.contacts import BareContact @@ -57,7 +56,6 @@ from gajim.command_system.implementation.hosts import ChatCommands from gajim.command_system.framework import CommandHost
- log = logging.getLogger('gajim.gui.controls.chat')
===================================== gajim/gtk/controls/groupchat.py ===================================== @@ -46,10 +46,8 @@
from gajim.common import app from gajim.common import events -from gajim.common import ged from gajim.common import helpers from gajim.common.client import Client -from gajim.common.const import AvatarSize from gajim.common.const import SimpleClientState from gajim.common.helpers import AdditionalDataDict from gajim.common.helpers import event_filter @@ -74,9 +72,6 @@ from gajim.gui.groupchat_state import GroupchatState from gajim.gui.util import open_window
-from ..menus import get_encryption_menu -from ..menus import get_groupchat_menu - log = logging.getLogger('gajim.gui.controls.groupchat')
@@ -133,10 +128,6 @@ def __init__(self, account: str, jid: JID) -> None: 'hide_groupchat_occupants_list', self.xml.roster_revealer, 'set_reveal_child') - self._set_toggle_roster_button_icon(show_roster) - app.settings.connect_signal( - 'hide_groupchat_occupants_list', - self._set_toggle_roster_button_icon) self.roster.connect('row-activated', self._on_roster_row_activated)
self.add_actions() @@ -146,8 +137,6 @@ def __init__(self, account: str, jid: JID) -> None: # if True, the room has mentioned us self.attention_flag: bool = False
- self._update_avatar() - # Holds CaptchaRequest widget self._captcha_request: Optional[DataFormWidget] = None
@@ -182,7 +171,6 @@ def __init__(self, account: str, jid: JID) -> None: def _connect_contact_signals(self) -> None: self.contact.multi_connect({ 'state-changed': self._on_muc_state_changed, - 'avatar-update': self._on_avatar_update, 'user-joined': self._on_user_joined, 'user-left': self._on_user_left, 'user-affiliation-changed': self._on_user_affiliation_changed, @@ -476,17 +464,8 @@ def _on_change_affiliation(self, self.room_jid, {jid: {'affiliation': affiliation}})
- def _set_toggle_roster_button_icon(self, - show_roster: bool, - *args: Any) -> None: - icon = 'go-next-symbolic' if show_roster else 'go-previous-symbolic' - self.xml.toggle_roster_image.set_from_icon_name( - icon, Gtk.IconSize.BUTTON) - def _show_roster(self, *args: Any) -> None: show = not self.xml.roster_revealer.get_reveal_child() - self._set_toggle_roster_button_icon(show) - transition = Gtk.RevealerTransitionType.SLIDE_RIGHT if show: transition = Gtk.RevealerTransitionType.SLIDE_LEFT @@ -510,17 +489,6 @@ def _on_roster_row_activated(self, contact = self.contact.get_resource(nick) app.window.add_private_chat(self.account, contact.jid, select=True)
- def _on_avatar_update(self, - _contact: GroupchatContact, - _signal_name: str - ) -> None: - self._update_avatar() - - def _update_avatar(self) -> None: - surface = self.contact.get_avatar( - AvatarSize.CHAT, app.window.get_scale_factor()) - self.xml.avatar_image.set_from_surface(surface) - def _on_room_voice_request(self, _contact: GroupchatContact, _signal_name: str, @@ -701,11 +669,8 @@ def _nec_ping(self, event: events.ApplicationEvent) -> None: self.add_info_message(event.error)
def _set_control_active(self) -> None: - contact = self.contact.get_self() - if contact.role.is_visitor: - self.xml.visitor_box.show() - else: - self.set_message_input_state(True) + self_contact = self.contact.get_self() + self.set_message_input_state(not self_contact.role.is_visitor)
self.roster.initial_draw() self.conversation_view.update_avatars() @@ -714,7 +679,6 @@ def _set_control_active(self) -> None:
def _set_control_inactive(self) -> None: self.set_message_input_state(False) - self.xml.visitor_box.hide()
self.roster.enable_sort(False) self.roster.clear() @@ -858,10 +822,6 @@ 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_state(not user_contact.role.is_visitor) message = _('** Your Role has been set to ' '{role}{actor}{reason}').format(role=role,
===================================== gajim/gtk/controls/private.py ===================================== @@ -24,8 +24,6 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see http://www.gnu.org/licenses/.
-from typing import Any - from nbxmpp import JID from nbxmpp.structs import MessageProperties from nbxmpp.structs import PresenceProperties
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/3c6ace6b4a85454f754ffe219f264f4e7...