Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwurstsalat <mailtrash@posteo.de>2023-11-05 01:58:44 +0300
committerwurstsalat <mailtrash@posteo.de>2023-11-05 01:59:47 +0300
commitfd7d760609f058d948ba990928b033de020fdddb (patch)
tree12a3f85f4d408def833dff978aa109c81b8e7bff
parent187167640fba0c4269bc8a9f9fc22763d8e20b40 (diff)
fix: Message row menu: Show quote and copy actions only if there is text
Fixes #11652
-rw-r--r--gajim/gtk/menus.py51
1 files changed, 27 insertions, 24 deletions
diff --git a/gajim/gtk/menus.py b/gajim/gtk/menus.py
index 7c767ea23..9fb0693d1 100644
--- a/gajim/gtk/menus.py
+++ b/gajim/gtk/menus.py
@@ -688,37 +688,40 @@ def get_chat_row_menu(contact: types.ChatContactT,
menu_items: MenuItemListT = []
- format_string = app.settings.get('date_time_format')
- timestamp_formatted = timestamp.strftime(format_string)
+ if text:
+ # Text can be an empty string,
+ # e.g. if a preview has not been loaded yet
+ timestamp_formatted = timestamp.strftime(
+ app.settings.get('date_time_format'))
+
+ copy_text = f'{timestamp_formatted} - {name}: '
+ if text.startswith(('```', '> ')):
+ # Prepend a line break in order to keep code block/quotes rendering
+ copy_text += '\n'
+ copy_text += text
- copy_text = f'{timestamp_formatted} - {name}: '
- if text.startswith(('```', '> ')):
- # Prepend a line break in order to keep code block/quotes rendering
- copy_text += '\n'
- copy_text += text
-
- menu_items.append(
- (p_('Message row action', 'Copy'),
- 'win.copy-message',
- copy_text))
+ menu_items.append(
+ (p_('Message row action', 'Copy'),
+ 'win.copy-message',
+ copy_text))
+
+ show_quote = True
+ if isinstance(contact, GroupchatContact):
+ if contact.is_joined:
+ self_contact = contact.get_self()
+ assert self_contact is not None
+ show_quote = not self_contact.role.is_visitor
+ else:
+ show_quote = False
+ if show_quote:
+ menu_items.append((
+ p_('Message row action', 'Quote…'), 'win.quote', text))
menu_items.append(
(p_('Message row action', 'Select Messages…'),
'win.activate-message-selection',
GLib.Variant('u', log_line_id or 0)))
- show_quote = True
- if isinstance(contact, GroupchatContact):
- if contact.is_joined:
- self_contact = contact.get_self()
- assert self_contact is not None
- show_quote = not self_contact.role.is_visitor
- else:
- show_quote = False
- if show_quote:
- menu_items.append((
- p_('Message row action', 'Quote…'), 'win.quote', text))
-
show_correction = False
if message_id is not None:
show_correction = app.window.is_message_correctable(