Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
-
52d46908
by wurstsalat at 2023-05-18T00:33:50+02:00
4 changed files:
- gajim/data/gui/groupchat_state.ui
- gajim/data/style/gajim.css
- gajim/gtk/chat_list_row.py
- gajim/gtk/groupchat_state.py
Changes:
| ... | ... | @@ -115,6 +115,7 @@ |
| 115 | 115 | <object class="GtkSpinner">
|
| 116 | 116 | <property name="visible">True</property>
|
| 117 | 117 | <property name="can-focus">False</property>
|
| 118 | + <property name="active">True</property>
|
|
| 118 | 119 | </object>
|
| 119 | 120 | <packing>
|
| 120 | 121 | <property name="expand">False</property>
|
| ... | ... | @@ -139,9 +140,75 @@ |
| 139 | 140 | </style>
|
| 140 | 141 | </object>
|
| 141 | 142 | <packing>
|
| 142 | - <property name="name">fetching</property>
|
|
| 143 | + <property name="name">mam-sync-started</property>
|
|
| 143 | 144 | <property name="position">2</property>
|
| 144 | 145 | </packing>
|
| 145 | 146 | </child>
|
| 147 | + <child>
|
|
| 148 | + <object class="GtkBox">
|
|
| 149 | + <property name="visible">True</property>
|
|
| 150 | + <property name="can-focus">False</property>
|
|
| 151 | + <property name="spacing">12</property>
|
|
| 152 | + <child>
|
|
| 153 | + <object class="GtkImage">
|
|
| 154 | + <property name="visible">True</property>
|
|
| 155 | + <property name="can-focus">False</property>
|
|
| 156 | + <property name="icon-name">dialog-error-symbolic</property>
|
|
| 157 | + <style>
|
|
| 158 | + <class name="error-color"/>
|
|
| 159 | + </style>
|
|
| 160 | + </object>
|
|
| 161 | + <packing>
|
|
| 162 | + <property name="expand">False</property>
|
|
| 163 | + <property name="fill">True</property>
|
|
| 164 | + <property name="position">0</property>
|
|
| 165 | + </packing>
|
|
| 166 | + </child>
|
|
| 167 | + <child>
|
|
| 168 | + <object class="GtkLabel">
|
|
| 169 | + <property name="visible">True</property>
|
|
| 170 | + <property name="can-focus">False</property>
|
|
| 171 | + <property name="label" translatable="yes">There has been an error while trying to fetch messages.</property>
|
|
| 172 | + <property name="wrap">True</property>
|
|
| 173 | + <property name="max-width-chars">50</property>
|
|
| 174 | + <property name="xalign">0</property>
|
|
| 175 | + </object>
|
|
| 176 | + <packing>
|
|
| 177 | + <property name="expand">False</property>
|
|
| 178 | + <property name="fill">True</property>
|
|
| 179 | + <property name="position">1</property>
|
|
| 180 | + </packing>
|
|
| 181 | + </child>
|
|
| 182 | + <child>
|
|
| 183 | + <object class="GtkButton">
|
|
| 184 | + <property name="visible">True</property>
|
|
| 185 | + <property name="can-focus">True</property>
|
|
| 186 | + <property name="receives-default">True</property>
|
|
| 187 | + <property name="tooltip-text" translatable="yes">Close</property>
|
|
| 188 | + <property name="valign">center</property>
|
|
| 189 | + <signal name="clicked" handler="_on_close_clicked" swapped="no"/>
|
|
| 190 | + <child>
|
|
| 191 | + <object class="GtkImage">
|
|
| 192 | + <property name="visible">True</property>
|
|
| 193 | + <property name="can-focus">False</property>
|
|
| 194 | + <property name="icon-name">window-close-symbolic</property>
|
|
| 195 | + </object>
|
|
| 196 | + </child>
|
|
| 197 | + </object>
|
|
| 198 | + <packing>
|
|
| 199 | + <property name="expand">False</property>
|
|
| 200 | + <property name="fill">True</property>
|
|
| 201 | + <property name="position">2</property>
|
|
| 202 | + </packing>
|
|
| 203 | + </child>
|
|
| 204 | + <style>
|
|
| 205 | + <class name="floating-overlay-box"/>
|
|
| 206 | + </style>
|
|
| 207 | + </object>
|
|
| 208 | + <packing>
|
|
| 209 | + <property name="name">mam-sync-error</property>
|
|
| 210 | + <property name="position">3</property>
|
|
| 211 | + </packing>
|
|
| 212 | + </child>
|
|
| 146 | 213 | </object>
|
| 147 | 214 | </interface> |
| ... | ... | @@ -95,6 +95,7 @@ .padding-left30 { padding-left: 30px; } |
| 95 | 95 | .success-color { color: @success_color; }
|
| 96 | 96 | .error-color { color: @error_color; }
|
| 97 | 97 | .warning-color { color: @warning_color; }
|
| 98 | +.info-color { color: rgb(75, 150, 200); }
|
|
| 98 | 99 | .selected-color { color: @theme_selected_bg_color; }
|
| 99 | 100 | .insensitive-fg-color {color: @insensitive_fg_color;}
|
| 100 | 101 | .encrypted-color { color: rgb(75, 181, 67); }
|
| ... | ... | @@ -517,6 +517,9 @@ def _connect_contact_signals(self) -> None: |
| 517 | 517 | elif isinstance(self.contact, GroupchatContact):
|
| 518 | 518 | self.contact.connect('avatar-update', self._on_avatar_update)
|
| 519 | 519 | self.contact.connect('state-changed', self._on_muc_state_changed)
|
| 520 | + self.contact.connect('mam-sync-started', self._on_mam_sync_changed)
|
|
| 521 | + self.contact.connect('mam-sync-finished', self._on_mam_sync_changed)
|
|
| 522 | + self.contact.connect('mam-sync-error', self._on_mam_sync_changed)
|
|
| 520 | 523 | |
| 521 | 524 | self._client.connect_signal('state-changed',
|
| 522 | 525 | self._on_client_state_changed)
|
| ... | ... | @@ -555,29 +558,55 @@ def _on_muc_state_changed(self, *args: Any) -> None: |
| 555 | 558 | self._update_joined_state()
|
| 556 | 559 | |
| 557 | 560 | def _update_joined_state(self) -> None:
|
| 558 | - self._ui.connection_icon.get_style_context().remove_class('spin')
|
|
| 559 | - self._ui.connection_icon.get_style_context().remove_class(
|
|
| 560 | - 'warning-color')
|
|
| 561 | - self._ui.connection_icon.get_style_context().remove_class(
|
|
| 562 | - 'dim-label')
|
|
| 561 | + self._reset_connection_icon()
|
|
| 562 | + context = self._ui.connection_icon.get_style_context()
|
|
| 563 | 563 | |
| 564 | 564 | if self.contact.is_joining:
|
| 565 | 565 | self._ui.connection_icon.set_from_icon_name(
|
| 566 | 566 | 'feather-refresh-cw-symbolic', Gtk.IconSize.MENU)
|
| 567 | - self._ui.connection_icon.get_style_context().add_class('spin')
|
|
| 568 | - self._ui.connection_icon.get_style_context().add_class('dim-label')
|
|
| 567 | + context.add_class('spin')
|
|
| 568 | + context.add_class('dim-label')
|
|
| 569 | 569 | self._ui.connection_icon.set_tooltip_text(_('Joining Group Chat…'))
|
| 570 | 570 | self._ui.connection_icon.show()
|
| 571 | 571 | elif (self.contact.is_not_joined or
|
| 572 | 572 | not self._client.state.is_available):
|
| 573 | 573 | self._ui.connection_icon.set_from_icon_name(
|
| 574 | 574 | 'feather-zap-symbolic', Gtk.IconSize.MENU)
|
| 575 | - self._ui.connection_icon.get_style_context().add_class(
|
|
| 576 | - 'warning-color')
|
|
| 575 | + context.add_class('warning-color')
|
|
| 577 | 576 | self._ui.connection_icon.set_tooltip_text(_('Not connected'))
|
| 578 | 577 | self._ui.connection_icon.show()
|
| 579 | - else:
|
|
| 580 | - self._ui.connection_icon.hide()
|
|
| 578 | + |
|
| 579 | + def _on_mam_sync_changed(self,
|
|
| 580 | + _contact: GroupchatContact,
|
|
| 581 | + signal_name: str
|
|
| 582 | + ) -> None:
|
|
| 583 | + |
|
| 584 | + self._reset_connection_icon()
|
|
| 585 | + context = self._ui.connection_icon.get_style_context()
|
|
| 586 | + |
|
| 587 | + if signal_name == 'mam-sync-started':
|
|
| 588 | + self._ui.connection_icon.set_from_icon_name(
|
|
| 589 | + 'feather-refresh-cw-symbolic', Gtk.IconSize.MENU)
|
|
| 590 | + context.add_class('spin')
|
|
| 591 | + context.add_class('info-color')
|
|
| 592 | + self._ui.connection_icon.set_tooltip_text(_('Fetching messages…'))
|
|
| 593 | + self._ui.connection_icon.show()
|
|
| 594 | + elif signal_name == 'mam-sync-error':
|
|
| 595 | + self._ui.connection_icon.set_from_icon_name(
|
|
| 596 | + 'feather-zap-symbolic', Gtk.IconSize.MENU)
|
|
| 597 | + context.add_class('error-color')
|
|
| 598 | + self._ui.connection_icon.set_tooltip_text(
|
|
| 599 | + _('There has been an error while trying to fetch messages.'))
|
|
| 600 | + self._ui.connection_icon.show()
|
|
| 601 | + |
|
| 602 | + def _reset_connection_icon(self) -> None:
|
|
| 603 | + self._ui.connection_icon.hide()
|
|
| 604 | + context = self._ui.connection_icon.get_style_context()
|
|
| 605 | + context.remove_class('spin')
|
|
| 606 | + context.remove_class('dim-label')
|
|
| 607 | + context.remove_class('info-color')
|
|
| 608 | + context.remove_class('warning-color')
|
|
| 609 | + context.remove_class('error-color')
|
|
| 581 | 610 | |
| 582 | 611 | def _on_muc_user_update(self,
|
| 583 | 612 | _contact: GroupchatParticipant,
|
| ... | ... | @@ -59,6 +59,9 @@ def switch_contact(self, contact: types.ChatContactT) -> None: |
| 59 | 59 | |
| 60 | 60 | self._contact = contact
|
| 61 | 61 | self._contact.connect('state-changed', self._on_muc_state_changed)
|
| 62 | + self._contact.connect('mam-sync-started', self._on_mam_sync_changed)
|
|
| 63 | + self._contact.connect('mam-sync-finished', self._on_mam_sync_changed)
|
|
| 64 | + self._contact.connect('mam-sync-error', self._on_mam_sync_changed)
|
|
| 62 | 65 | |
| 63 | 66 | self._client = app.get_client(contact.account)
|
| 64 | 67 | self._client.connect_signal('state-changed',
|
| ... | ... | @@ -92,8 +95,20 @@ def _update_state(self, contact: GroupchatContact) -> None: |
| 92 | 95 | self.set_visible(self._client.state.is_available and
|
| 93 | 96 | not contact.is_joined)
|
| 94 | 97 | |
| 95 | - def set_fetching(self) -> None:
|
|
| 96 | - self._ui.groupchat_state.set_visible_child_name('fetching')
|
|
| 98 | + def _on_mam_sync_changed(self,
|
|
| 99 | + _contact: GroupchatContact,
|
|
| 100 | + signal_name: str
|
|
| 101 | + ) -> None:
|
|
| 102 | + |
|
| 103 | + if signal_name in ('mam-sync-started', 'mam-sync-error'):
|
|
| 104 | + self.set_visible(True)
|
|
| 105 | + self._ui.groupchat_state.set_visible_child_name(signal_name)
|
|
| 106 | + return
|
|
| 107 | + |
|
| 108 | + self.hide()
|
|
| 109 | + |
|
| 110 | + def _on_close_clicked(self, _button: Gtk.Button) -> None:
|
|
| 111 | + self.hide()
|
|
| 97 | 112 | |
| 98 | 113 | def _on_join_clicked(self, _button: Gtk.Button) -> None:
|
| 99 | 114 | assert self._contact is not None
|