Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits: 27e41d44 by wurstsalat at 2021-11-02T22:25:35+01:00 ChatList: Unread counter improvements
- - - - - 1ca3041a by wurstsalat at 2021-11-02T23:48:58+01:00 Imrpove Note to myself feature
- - - - -
4 changed files:
- gajim/gtk/chat_list.py - gajim/gtk/controls/chat.py - gajim/gtk/conversation/rows/message.py - gajim/gui_menu_builder.py
Changes:
===================================== gajim/gtk/chat_list.py ===================================== @@ -408,6 +408,8 @@ def _add_unread(row, properties): return
if properties.is_from_us(): + # Last message was from us, reset counter + row.reset_unread() return
row.add_unread() @@ -635,16 +637,21 @@ def update_time(self): get_uf_relative_time(self.timestamp))
def _update_unread(self): - if self._unread_count < 1000: - self._ui.unread_label.set_text(str(self._unread_count)) - else: - self._ui.unread_label.set_text('999+') + unread_count = self._get_unread_string(self._unread_count) + self._ui.unread_label.set_text(unread_count) self._ui.unread_label.set_visible(bool(self._unread_count))
+ @staticmethod + def _get_unread_string(count: int) -> str: + if count < 1000: + return str(count) + return '999+' + def add_unread(self): control = app.window.get_control(self.account, self.jid) if self.is_active and control.get_autoscroll(): return + self.unread_count += 1 if self.unread_count == 1: self.changed()
===================================== gajim/gtk/controls/chat.py ===================================== @@ -47,7 +47,8 @@ from gajim.common.const import KindConstant from gajim.common.const import PEPEventType
-from gajim import gui_menu_builder +from gajim.gui_menu_builder import get_encryption_menu +from gajim.gui_menu_builder import get_singlechat_menu
from gajim.gui.call_widget import CallWidget from gajim.gui.const import TARGET_TYPE_URI_LIST @@ -109,7 +110,7 @@ def __init__(self, account, jid): self.conversation_view.connect('decline-call', self._on_decline_call)
# Menu for the HeaderBar - self.control_menu = gui_menu_builder.get_singlechat_menu( + self.control_menu = get_singlechat_menu( self.control_id, self.account, self.contact.jid, self._type)
# Settings menu @@ -136,9 +137,8 @@ def __init__(self, account, jid): self.update_ui() self.set_lock_image()
- self.xml.encryption_menu.set_menu_model( - gui_menu_builder.get_encryption_menu( - self.control_id, self._type, self.account == 'Local')) + self.xml.encryption_menu.set_menu_model(get_encryption_menu( + self.control_id, self._type, self.account == 'Local')) self.set_encryption_menu_icon() self.msg_textview.grab_focus()
@@ -536,6 +536,9 @@ def draw_banner_text(self): contact = self.contact name = contact.name
+ if self.jid == self._client.get_own_jid().bare: + name = _('Note to myself') + if self._type.is_privatechat: name = f'{name} ({self.room_name})'
===================================== gajim/gtk/conversation/rows/message.py ===================================== @@ -102,6 +102,10 @@ def __init__(self, is_self = name == our_nick else: is_self = kind == 'outgoing' + + if self._contact.jid == self._client.get_own_jid().bare: + name = _('Me') + name_widget = self.create_name_widget(name, is_self)
self._meta_box = Gtk.Box(spacing=6)
===================================== gajim/gui_menu_builder.py ===================================== @@ -28,21 +28,33 @@
def get_singlechat_menu(control_id, account, jid, type_): + client = app.get_client(account) + is_self_contact = jid.bare == client.get_own_jid().bare + singlechat_menu = [ (_('Send File'), [ ('win.send-file-httpupload-', _('Upload File…')), - ('win.send-file-jingle-', _('Send File Directly…')), - ]), + ('win.send-file-jingle-', _('Send File Directly…')) + ]) + ] + + additional_menu = [ ('win.send-marker-', _('Send Read Markers')), (_('Send Chatstate'), ['chatstate']), ('win.invite-contacts-', _('Invite Contacts…')), ('win.add-to-roster-', _('Add to Contact List…')), ('win.block-contact-', _('Block Contact…')), ('win.start-call-', _('Start Call…')), - ('win.information-', _('Information')), - ('win.search-history', _('Search…')), + ('win.information-', _('Information')) ]
+ if is_self_contact: + singlechat_menu.append(('profile', _('Profile'))) + else: + singlechat_menu.extend(additional_menu) + + singlechat_menu.append(('win.search-history', _('Search…'))) + def build_chatstate_menu(): menu = Gio.Menu() entries = [ @@ -69,6 +81,12 @@ def build_menu(preset): menuitem = Gio.MenuItem.new(label, action_name) menuitem.set_action_and_target_value(action_name, None) menu.append_item(menuitem) + elif action_name == 'profile': + action = f'app.{account}-{action_name}' + menuitem = Gio.MenuItem.new(label, action) + variant = GLib.Variant('s', account) + menuitem.set_action_and_target_value(action, variant) + menu.append_item(menuitem) elif action_name == 'app.browse-history': menuitem = Gio.MenuItem.new(label, action_name) dict_ = {'account': GLib.Variant('s', account),
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/7d847b1ebc3972f3b3ff3a25a6823ab6...