Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits:
-
27e41d44
by wurstsalat at 2021-11-02T22:25:35+01:00
-
1ca3041a
by wurstsalat at 2021-11-02T23:48:58+01:00
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:
| ... | ... | @@ -408,6 +408,8 @@ def _add_unread(row, properties): |
| 408 | 408 |
return
|
| 409 | 409 |
|
| 410 | 410 |
if properties.is_from_us():
|
| 411 |
+ # Last message was from us, reset counter
|
|
| 412 |
+ row.reset_unread()
|
|
| 411 | 413 |
return
|
| 412 | 414 |
|
| 413 | 415 |
row.add_unread()
|
| ... | ... | @@ -635,16 +637,21 @@ def update_time(self): |
| 635 | 637 |
get_uf_relative_time(self.timestamp))
|
| 636 | 638 |
|
| 637 | 639 |
def _update_unread(self):
|
| 638 |
- if self._unread_count < 1000:
|
|
| 639 |
- self._ui.unread_label.set_text(str(self._unread_count))
|
|
| 640 |
- else:
|
|
| 641 |
- self._ui.unread_label.set_text('999+')
|
|
| 640 |
+ unread_count = self._get_unread_string(self._unread_count)
|
|
| 641 |
+ self._ui.unread_label.set_text(unread_count)
|
|
| 642 | 642 |
self._ui.unread_label.set_visible(bool(self._unread_count))
|
| 643 | 643 |
|
| 644 |
+ @staticmethod
|
|
| 645 |
+ def _get_unread_string(count: int) -> str:
|
|
| 646 |
+ if count < 1000:
|
|
| 647 |
+ return str(count)
|
|
| 648 |
+ return '999+'
|
|
| 649 |
+ |
|
| 644 | 650 |
def add_unread(self):
|
| 645 | 651 |
control = app.window.get_control(self.account, self.jid)
|
| 646 | 652 |
if self.is_active and control.get_autoscroll():
|
| 647 | 653 |
return
|
| 654 |
+ |
|
| 648 | 655 |
self.unread_count += 1
|
| 649 | 656 |
if self.unread_count == 1:
|
| 650 | 657 |
self.changed()
|
| ... | ... | @@ -47,7 +47,8 @@ |
| 47 | 47 |
from gajim.common.const import KindConstant
|
| 48 | 48 |
from gajim.common.const import PEPEventType
|
| 49 | 49 |
|
| 50 |
-from gajim import gui_menu_builder
|
|
| 50 |
+from gajim.gui_menu_builder import get_encryption_menu
|
|
| 51 |
+from gajim.gui_menu_builder import get_singlechat_menu
|
|
| 51 | 52 |
|
| 52 | 53 |
from gajim.gui.call_widget import CallWidget
|
| 53 | 54 |
from gajim.gui.const import TARGET_TYPE_URI_LIST
|
| ... | ... | @@ -109,7 +110,7 @@ def __init__(self, account, jid): |
| 109 | 110 |
self.conversation_view.connect('decline-call', self._on_decline_call)
|
| 110 | 111 |
|
| 111 | 112 |
# Menu for the HeaderBar
|
| 112 |
- self.control_menu = gui_menu_builder.get_singlechat_menu(
|
|
| 113 |
+ self.control_menu = get_singlechat_menu(
|
|
| 113 | 114 |
self.control_id, self.account, self.contact.jid, self._type)
|
| 114 | 115 |
|
| 115 | 116 |
# Settings menu
|
| ... | ... | @@ -136,9 +137,8 @@ def __init__(self, account, jid): |
| 136 | 137 |
self.update_ui()
|
| 137 | 138 |
self.set_lock_image()
|
| 138 | 139 |
|
| 139 |
- self.xml.encryption_menu.set_menu_model(
|
|
| 140 |
- gui_menu_builder.get_encryption_menu(
|
|
| 141 |
- self.control_id, self._type, self.account == 'Local'))
|
|
| 140 |
+ self.xml.encryption_menu.set_menu_model(get_encryption_menu(
|
|
| 141 |
+ self.control_id, self._type, self.account == 'Local'))
|
|
| 142 | 142 |
self.set_encryption_menu_icon()
|
| 143 | 143 |
self.msg_textview.grab_focus()
|
| 144 | 144 |
|
| ... | ... | @@ -536,6 +536,9 @@ def draw_banner_text(self): |
| 536 | 536 |
contact = self.contact
|
| 537 | 537 |
name = contact.name
|
| 538 | 538 |
|
| 539 |
+ if self.jid == self._client.get_own_jid().bare:
|
|
| 540 |
+ name = _('Note to myself')
|
|
| 541 |
+ |
|
| 539 | 542 |
if self._type.is_privatechat:
|
| 540 | 543 |
name = f'{name} ({self.room_name})'
|
| 541 | 544 |
|
| ... | ... | @@ -102,6 +102,10 @@ def __init__(self, |
| 102 | 102 |
is_self = name == our_nick
|
| 103 | 103 |
else:
|
| 104 | 104 |
is_self = kind == 'outgoing'
|
| 105 |
+ |
|
| 106 |
+ if self._contact.jid == self._client.get_own_jid().bare:
|
|
| 107 |
+ name = _('Me')
|
|
| 108 |
+ |
|
| 105 | 109 |
name_widget = self.create_name_widget(name, is_self)
|
| 106 | 110 |
|
| 107 | 111 |
self._meta_box = Gtk.Box(spacing=6)
|
| ... | ... | @@ -28,21 +28,33 @@ |
| 28 | 28 |
|
| 29 | 29 |
|
| 30 | 30 |
def get_singlechat_menu(control_id, account, jid, type_):
|
| 31 |
+ client = app.get_client(account)
|
|
| 32 |
+ is_self_contact = jid.bare == client.get_own_jid().bare
|
|
| 33 |
+ |
|
| 31 | 34 |
singlechat_menu = [
|
| 32 | 35 |
(_('Send File'), [
|
| 33 | 36 |
('win.send-file-httpupload-', _('Upload File…')),
|
| 34 |
- ('win.send-file-jingle-', _('Send File Directly…')),
|
|
| 35 |
- ]),
|
|
| 37 |
+ ('win.send-file-jingle-', _('Send File Directly…'))
|
|
| 38 |
+ ])
|
|
| 39 |
+ ]
|
|
| 40 |
+ |
|
| 41 |
+ additional_menu = [
|
|
| 36 | 42 |
('win.send-marker-', _('Send Read Markers')),
|
| 37 | 43 |
(_('Send Chatstate'), ['chatstate']),
|
| 38 | 44 |
('win.invite-contacts-', _('Invite Contacts…')),
|
| 39 | 45 |
('win.add-to-roster-', _('Add to Contact List…')),
|
| 40 | 46 |
('win.block-contact-', _('Block Contact…')),
|
| 41 | 47 |
('win.start-call-', _('Start Call…')),
|
| 42 |
- ('win.information-', _('Information')),
|
|
| 43 |
- ('win.search-history', _('Search…')),
|
|
| 48 |
+ ('win.information-', _('Information'))
|
|
| 44 | 49 |
]
|
| 45 | 50 |
|
| 51 |
+ if is_self_contact:
|
|
| 52 |
+ singlechat_menu.append(('profile', _('Profile')))
|
|
| 53 |
+ else:
|
|
| 54 |
+ singlechat_menu.extend(additional_menu)
|
|
| 55 |
+ |
|
| 56 |
+ singlechat_menu.append(('win.search-history', _('Search…')))
|
|
| 57 |
+ |
|
| 46 | 58 |
def build_chatstate_menu():
|
| 47 | 59 |
menu = Gio.Menu()
|
| 48 | 60 |
entries = [
|
| ... | ... | @@ -69,6 +81,12 @@ def build_menu(preset): |
| 69 | 81 |
menuitem = Gio.MenuItem.new(label, action_name)
|
| 70 | 82 |
menuitem.set_action_and_target_value(action_name, None)
|
| 71 | 83 |
menu.append_item(menuitem)
|
| 84 |
+ elif action_name == 'profile':
|
|
| 85 |
+ action = f'app.{account}-{action_name}'
|
|
| 86 |
+ menuitem = Gio.MenuItem.new(label, action)
|
|
| 87 |
+ variant = GLib.Variant('s', account)
|
|
| 88 |
+ menuitem.set_action_and_target_value(action, variant)
|
|
| 89 |
+ menu.append_item(menuitem)
|
|
| 72 | 90 |
elif action_name == 'app.browse-history':
|
| 73 | 91 |
menuitem = Gio.MenuItem.new(label, action_name)
|
| 74 | 92 |
dict_ = {'account': GLib.Variant('s', account),
|