Philipp Hörist pushed to branch mainwindow at gajim / gajim
Commits: c2accf28 by lovetox at 2021-03-01T23:46:17+01:00 Fix status selector
- - - - -
4 changed files:
- gajim/common/client.py - gajim/gtk/account_side_bar.py - gajim/gtk/status_selector.py - gajim/gui_interface.py
Changes:
===================================== gajim/common/client.py ===================================== @@ -28,6 +28,7 @@ from gajim.common import helpers from gajim.common import modules from gajim.common.const import ClientState +from gajim.common.structs import UNKNOWN_PRESENCE from gajim.common.helpers import get_custom_host from gajim.common.helpers import get_user_proxy from gajim.common.helpers import warn_about_plain_connection @@ -294,6 +295,9 @@ def _after_disconnect(self): self._destroy_client = False self._create_client()
+ jid = self.get_own_jid() + contact = self.get_module('Contacts').get_contact(jid) + contact.update_presence(UNKNOWN_PRESENCE) app.nec.push_incoming_event(NetworkEvent('account-disconnected', account=self._account))
===================================== gajim/gtk/account_side_bar.py ===================================== @@ -83,9 +83,13 @@ def __init__(self, account): client = app.get_client(self._account) self._contact = client.get_module('Contacts').get_contact(jid) self._contact.connect('avatar-update', self._on_avatar_update) + self._contact.connect('presence-update', self._on_presence_update)
self._update_image()
+ def _on_presence_update(self, _contact, _signal_name): + self._update_image() + def _on_avatar_update(self, _contact, _signal_name): self._update_image()
===================================== gajim/gtk/status_selector.py ===================================== @@ -16,6 +16,7 @@ from gi.repository import Pango
from gajim.common import app +from gajim.common import ged from gajim.common.helpers import get_uf_show from gajim.common.helpers import get_global_show from gajim.common.helpers import statuses_unified @@ -30,7 +31,6 @@ def __init__(self, compact=False): self.set_direction(Gtk.ArrowType.UP) self._compact = compact self._create_popover() - self.set_no_show_all(True)
self._current_show_icon = Gtk.Image() self._current_show_icon.set_from_icon_name( @@ -47,6 +47,8 @@ def __init__(self, compact=False): box.show_all() self.add(box)
+ app.ged.register_event_handler('our-show', ged.POSTGUI, self.update) + def _create_popover(self): popover_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) popover_box.get_style_context().add_class('margin-3') @@ -106,13 +108,14 @@ def _on_change_status(self, button): if new_status == 'change_status_message': new_status = None app.interface.change_status(status=new_status) + self.update()
- def update(self): - if not app.connections: - self.hide() - return + def update(self, *args, **kwargs): + # if not app.connections: + # self.hide() + # return
- self.show() + # self.show() show = get_global_show() uf_show = get_uf_show(show) self._current_show_icon.set_from_icon_name(
===================================== gajim/gui_interface.py ===================================== @@ -1653,11 +1653,8 @@ def autoconnect(self): status_message = helpers.from_one_line(status_message)
app.connections[account].change_status(status, status_message) - # self.roster.send_status(account, status, status_message) - - def change_status(self, status=None): - # status=None means we want to change the message only
+ def change_status(self, status): ask = ask_for_status_message(status)
if status is None: @@ -1672,12 +1669,9 @@ def change_status(self, status=None): 'sync_with_global_status'): continue
- message = app.get_client(account).status_message - self.roster.send_status(account, status, message) - - def change_account_status(self, account, status=None): - # status=None means we want to change the message only + self._change_status(account, status)
+ def change_account_status(self, account, status): ask = ask_for_status_message(status)
client = app.get_client(account) @@ -1688,8 +1682,26 @@ def change_account_status(self, account, status=None): open_window('StatusChange', status=status, account=account) return
+ self._change_status(account, status) + + @staticmethod + def _change_status(account, status): + client = app.get_client(account) message = client.status_message - self.roster.send_status(account, status, message) + if status != 'offline': + app.settings.set_account_setting(account, 'last_status', status) + app.settings.set_account_setting( + account, + 'last_status_msg', + helpers.to_one_line(message)) + # TODO update systray icon + + if status == 'offline': + # TODO delete pep + # self.delete_pep(app.get_jid_from_account(account), account) + pass + + client.change_status(status, message)
def show_systray(self): if not app.is_display(Display.WAYLAND):
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/c2accf288b308b018bc4f32601b247449...