Daniel Brötzmann pushed to branch newcontrol at gajim / gajim
Commits: 4cb28f77 by wurstsalat at 2022-07-29T17:05:09+02:00 fix: MessageActionBox: Show quick invite button for group chats only
- - - - - 342f027e by wurstsalat at 2022-07-29T17:35:03+02:00 Control/View: Cleanup scroll to end and unused methods
- - - - -
4 changed files:
- gajim/gtk/controls/base.py - gajim/gtk/conversation/jump_to_end_button.py - gajim/gtk/conversation/view.py - gajim/gtk/message_actions_box.py
Changes:
===================================== gajim/gtk/controls/base.py ===================================== @@ -63,7 +63,6 @@ from gajim.gui.util import get_hardware_key_codes 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.const import ControlType from gajim.gui.const import TARGET_TYPE_URI_LIST
@@ -118,11 +117,6 @@ def __init__(self, widget_name: str, account: str, jid: JID) -> None:
self.control_id: str = str(uuid.uuid4())
- if app.settings.get('use_kib_mib'): - self._units = GLib.FormatSizeFlags.IEC_UNITS - else: - self._units = GLib.FormatSizeFlags.DEFAULT - self.xml = get_builder(f'{widget_name}.ui') self.xml.connect_signals(self) self.widget: Gtk.Box = self.xml.get_object(f'{widget_name}_hbox') @@ -155,7 +149,6 @@ def __init__(self, widget_name: str, account: str, jid: JID) -> None:
# Create ConversationView and connect signals self.conversation_view = ConversationView(self.account, self.contact) - self.conversation_view.connect('scroll-to-end', self._on_scroll_to_end)
id_ = self.conversation_view.connect( 'key-press-event', self._on_conversation_view_key_press) @@ -360,9 +353,6 @@ def shutdown(self) -> None:
self.unregister_events()
- def _on_scroll_to_end(self, _view: ConversationView) -> None: - scroll_to_end(self._scrolled_view) - def _on_autoscroll_changed(self, _widget: ScrolledView, autoscroll: bool @@ -376,8 +366,7 @@ def _on_autoscroll_changed(self, app.window.mark_as_read(self.account, self.contact.jid)
def _on_jump_to_end(self, _button: Gtk.Button) -> None: - self.scroll_to_end(force=True) - self._jump_to_end_button.reset_unread_count() + self.reset_view()
def _on_drag_data_received(self, widget: Gtk.Widget, @@ -483,7 +472,7 @@ def add_message(self,
if not self._scrolled_view.get_autoscroll(): if kind == 'outgoing': - self.scroll_to_end() + self.reset_view() else: self._jump_to_end_button.add_unread_count() else: @@ -590,11 +579,6 @@ def reset_view(self) -> None: def get_autoscroll(self) -> bool: return self._scrolled_view.get_autoscroll()
- def scroll_to_end(self, force: bool = False) -> None: - # Clear view and reload conversation - self.reset_view() - self.conversation_view.scroll_to_end(force) - def scroll_to_message(self, log_line_id: int, timestamp: float) -> None: row = self.conversation_view.get_row_by_log_line_id(log_line_id) if row is None: @@ -708,9 +692,3 @@ def add_messages(self, messages: list[ConversationRow]): log_line_id=msg.log_line_id, marker=msg.marker, error=msg.error) - - def has_focus(self) -> bool: - if app.window.get_property('has-toplevel-focus'): - if self == app.window.get_active_control(): - return True - return False
===================================== gajim/gtk/conversation/jump_to_end_button.py ===================================== @@ -77,6 +77,7 @@ def __init__(self, contact: ContactT) -> None: self.set_no_show_all(True)
def _on_jump_clicked(self, _button: Gtk.Button) -> None: + self.reset_unread_count() self.emit('clicked')
def toggle(self, visible: bool) -> None:
===================================== gajim/gtk/conversation/view.py ===================================== @@ -27,7 +27,6 @@ from datetime import timedelta
from gi.repository import GLib -from gi.repository import GObject from gi.repository import Gtk
from nbxmpp.errors import StanzaError @@ -66,15 +65,6 @@
class ConversationView(Gtk.ListBox): - - __gsignals__ = { - 'scroll-to-end': ( - GObject.SignalFlags.RUN_LAST | GObject.SignalFlags.ACTION, - None, - () - ), - } - def __init__(self, account: str, contact: ChatContactT) -> None: Gtk.ListBox.__init__(self) self.set_selection_mode(Gtk.SelectionMode.NONE) @@ -471,10 +461,6 @@ def update_avatars(self) -> None: if isinstance(row, MessageRow): row.update_avatar()
- def scroll_to_end(self, force: bool = False) -> None: - if self.autoscroll or force: - GLib.idle_add(self.emit, 'scroll-to-end') - def correct_message(self, correct_id: str, text: str,
===================================== gajim/gtk/message_actions_box.py ===================================== @@ -203,18 +203,23 @@ def switch_contact(self, contact: ChatContactT) -> None: 'state-changed', self._on_client_state_changed)
self._contact = contact + if isinstance(self._contact, GroupchatContact): + self._ui.quick_invite_button.show() self._contact.multi_connect({ 'state-changed': self._on_muc_state_changed, 'user-role-changed': self._on_muc_state_changed, }) - if isinstance(self._contact, GroupchatParticipant): + elif isinstance(self._contact, GroupchatParticipant): + self._ui.quick_invite_button.hide() self._contact.multi_connect({ 'user-joined': self._on_user_state_changed, 'user-left': self._on_user_state_changed, 'room-joined': self._on_user_state_changed, 'room-left': self._on_user_state_changed, }) + else: + self._ui.quick_invite_button.hide()
self._set_settings_menu(contact)
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/135b0fd6bac2a0b700c5438cb1118fd1...