Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
-
9c252dd0
by wurstsalat at 2022-07-08T22:45:28+02:00
4 changed files:
- gajim/common/preview.py
- gajim/gtk/conversation/rows/base.py
- gajim/gtk/conversation/rows/message.py
- gajim/gtk/preview.py
Changes:
| ... | ... | @@ -61,12 +61,14 @@ def __init__(self, |
| 61 | 61 | thumb_path: Optional[Path],
|
| 62 | 62 | size: int,
|
| 63 | 63 | widget: Any,
|
| 64 | + from_us: bool = False,
|
|
| 64 | 65 | context: Optional[str] = None
|
| 65 | 66 | ) -> None:
|
| 66 | 67 | self._uri = uri
|
| 67 | 68 | self._urlparts = urlparts
|
| 68 | 69 | self._filename = filename_from_uri(uri)
|
| 69 | 70 | self._widget = widget
|
| 71 | + self._from_us = from_us
|
|
| 70 | 72 | self._context = context
|
| 71 | 73 | |
| 72 | 74 | self.account = widget.account
|
| ... | ... | @@ -109,6 +111,10 @@ def is_audio(self) -> bool: |
| 109 | 111 | def uri(self) -> str:
|
| 110 | 112 | return self._uri
|
| 111 | 113 | |
| 114 | + @property
|
|
| 115 | + def from_us(self) -> bool:
|
|
| 116 | + return self._from_us
|
|
| 117 | + |
|
| 112 | 118 | @property
|
| 113 | 119 | def context(self) -> Optional[str]:
|
| 114 | 120 | return self._context
|
| ... | ... | @@ -275,7 +281,7 @@ def is_previewable(self, |
| 275 | 281 | def create_preview(self,
|
| 276 | 282 | uri: str,
|
| 277 | 283 | widget: Any,
|
| 278 | - is_self: bool,
|
|
| 284 | + from_us: bool,
|
|
| 279 | 285 | context: Optional[str] = None
|
| 280 | 286 | ) -> None:
|
| 281 | 287 | if uri.startswith('geo:'):
|
| ... | ... | @@ -283,10 +289,10 @@ def create_preview(self, |
| 283 | 289 | preview.update_widget()
|
| 284 | 290 | return
|
| 285 | 291 | |
| 286 | - preview = self._process_web_uri(uri, widget, context)
|
|
| 292 | + preview = self._process_web_uri(uri, widget, from_us, context)
|
|
| 287 | 293 | |
| 288 | 294 | if not preview.orig_exists():
|
| 289 | - if context is not None and not is_self:
|
|
| 295 | + if context is not None and not from_us:
|
|
| 290 | 296 | allow_in_public = app.settings.get('preview_anonymous_muc')
|
| 291 | 297 | if context == 'public' and not allow_in_public:
|
| 292 | 298 | preview.update_widget()
|
| ... | ... | @@ -307,6 +313,7 @@ def create_preview(self, |
| 307 | 313 | def _process_web_uri(self,
|
| 308 | 314 | uri: str,
|
| 309 | 315 | widget: Any,
|
| 316 | + from_us: bool,
|
|
| 310 | 317 | context: Optional[str] = None
|
| 311 | 318 | ) -> Preview:
|
| 312 | 319 | urlparts = urlparse(uri)
|
| ... | ... | @@ -322,6 +329,7 @@ def _process_web_uri(self, |
| 322 | 329 | thumb_path,
|
| 323 | 330 | size,
|
| 324 | 331 | widget,
|
| 332 | + from_us,
|
|
| 325 | 333 | context=context)
|
| 326 | 334 | |
| 327 | 335 | def _on_orig_load_finished(self,
|
| ... | ... | @@ -78,7 +78,7 @@ def create_timestamp_widget(timestamp: datetime) -> Gtk.Label: |
| 78 | 78 | return label
|
| 79 | 79 | |
| 80 | 80 | @staticmethod
|
| 81 | - def create_name_widget(name: str, is_self: bool) -> Gtk.Label:
|
|
| 81 | + def create_name_widget(name: str, from_us: bool) -> Gtk.Label:
|
|
| 82 | 82 | label = Gtk.Label()
|
| 83 | 83 | label.set_selectable(True)
|
| 84 | 84 | label.set_ellipsize(Pango.EllipsizeMode.END)
|
| ... | ... | @@ -86,7 +86,7 @@ def create_name_widget(name: str, is_self: bool) -> Gtk.Label: |
| 86 | 86 | label.get_style_context().add_class('conversation-nickname')
|
| 87 | 87 | label.set_markup(GLib.markup_escape_text(name))
|
| 88 | 88 | |
| 89 | - if is_self:
|
|
| 89 | + if from_us:
|
|
| 90 | 90 | label.get_style_context().add_class('gajim-outgoing-nickname')
|
| 91 | 91 | else:
|
| 92 | 92 | label.get_style_context().add_class('gajim-incoming-nickname')
|
| ... | ... | @@ -118,9 +118,9 @@ def __init__(self, |
| 118 | 118 | |
| 119 | 119 | if self._is_groupchat:
|
| 120 | 120 | our_nick = get_group_chat_nick(self._account, self._contact.jid)
|
| 121 | - is_self = name == our_nick
|
|
| 121 | + from_us = name == our_nick
|
|
| 122 | 122 | else:
|
| 123 | - is_self = kind == 'outgoing'
|
|
| 123 | + from_us = kind == 'outgoing'
|
|
| 124 | 124 | |
| 125 | 125 | is_previewable = False
|
| 126 | 126 | if additional_data is not None:
|
| ... | ... | @@ -132,7 +132,7 @@ def __init__(self, |
| 132 | 132 | context = get_muc_context(self._contact.jid)
|
| 133 | 133 | self._message_widget = PreviewWidget(account)
|
| 134 | 134 | app.preview_manager.create_preview(
|
| 135 | - text, self._message_widget, is_self, context)
|
|
| 135 | + text, self._message_widget, from_us, context)
|
|
| 136 | 136 | else:
|
| 137 | 137 | self._message_widget = MessageWidget(account)
|
| 138 | 138 | self._message_widget.add_with_styling(text, nickname=name)
|
| ... | ... | @@ -145,7 +145,7 @@ def __init__(self, |
| 145 | 145 | if self._contact.jid == self._client.get_own_jid().bare:
|
| 146 | 146 | name = _('Me')
|
| 147 | 147 | |
| 148 | - name_widget = self.create_name_widget(name, is_self)
|
|
| 148 | + name_widget = self.create_name_widget(name, from_us)
|
|
| 149 | 149 | |
| 150 | 150 | self._meta_box = Gtk.Box(spacing=6)
|
| 151 | 151 | self._meta_box.set_hexpand(True)
|
| ... | ... | @@ -168,7 +168,8 @@ def update(self, preview: Preview, data: Optional[GdkPixbufType]) -> None: |
| 168 | 168 | self._ui.save_as_button.hide()
|
| 169 | 169 | self._ui.open_folder_button.hide()
|
| 170 | 170 | allow_in_public = app.settings.get('preview_anonymous_muc')
|
| 171 | - if preview.context == 'public' and not allow_in_public:
|
|
| 171 | + if (preview.context == 'public' and not
|
|
| 172 | + allow_in_public and not preview.from_us):
|
|
| 172 | 173 | image = Gtk.Image.new_from_icon_name(
|
| 173 | 174 | 'dialog-question', Gtk.IconSize.DIALOG)
|
| 174 | 175 | self._ui.icon_button.set_image(image)
|