Philipp Hörist pushed to branch mainwindow at gajim / gajim

Commits:

4 changed files:

Changes:

  • gajim/common/client.py
    ... ... @@ -28,6 +28,7 @@
    28 28
     from gajim.common import helpers
    
    29 29
     from gajim.common import modules
    
    30 30
     from gajim.common.const import ClientState
    
    31
    +from gajim.common.structs import UNKNOWN_PRESENCE
    
    31 32
     from gajim.common.helpers import get_custom_host
    
    32 33
     from gajim.common.helpers import get_user_proxy
    
    33 34
     from gajim.common.helpers import warn_about_plain_connection
    
    ... ... @@ -294,6 +295,9 @@ def _after_disconnect(self):
    294 295
                 self._destroy_client = False
    
    295 296
                 self._create_client()
    
    296 297
     
    
    298
    +        jid = self.get_own_jid()
    
    299
    +        contact = self.get_module('Contacts').get_contact(jid)
    
    300
    +        contact.update_presence(UNKNOWN_PRESENCE)
    
    297 301
             app.nec.push_incoming_event(NetworkEvent('account-disconnected',
    
    298 302
                                                      account=self._account))
    
    299 303
     
    

  • gajim/gtk/account_side_bar.py
    ... ... @@ -83,9 +83,13 @@ def __init__(self, account):
    83 83
             client = app.get_client(self._account)
    
    84 84
             self._contact = client.get_module('Contacts').get_contact(jid)
    
    85 85
             self._contact.connect('avatar-update', self._on_avatar_update)
    
    86
    +        self._contact.connect('presence-update', self._on_presence_update)
    
    86 87
     
    
    87 88
             self._update_image()
    
    88 89
     
    
    90
    +    def _on_presence_update(self, _contact, _signal_name):
    
    91
    +        self._update_image()
    
    92
    +
    
    89 93
         def _on_avatar_update(self, _contact, _signal_name):
    
    90 94
             self._update_image()
    
    91 95
     
    

  • gajim/gtk/status_selector.py
    ... ... @@ -16,6 +16,7 @@
    16 16
     from gi.repository import Pango
    
    17 17
     
    
    18 18
     from gajim.common import app
    
    19
    +from gajim.common import ged
    
    19 20
     from gajim.common.helpers import get_uf_show
    
    20 21
     from gajim.common.helpers import get_global_show
    
    21 22
     from gajim.common.helpers import statuses_unified
    
    ... ... @@ -30,7 +31,6 @@ def __init__(self, compact=False):
    30 31
             self.set_direction(Gtk.ArrowType.UP)
    
    31 32
             self._compact = compact
    
    32 33
             self._create_popover()
    
    33
    -        self.set_no_show_all(True)
    
    34 34
     
    
    35 35
             self._current_show_icon = Gtk.Image()
    
    36 36
             self._current_show_icon.set_from_icon_name(
    
    ... ... @@ -47,6 +47,8 @@ def __init__(self, compact=False):
    47 47
                 box.show_all()
    
    48 48
             self.add(box)
    
    49 49
     
    
    50
    +        app.ged.register_event_handler('our-show', ged.POSTGUI, self.update)
    
    51
    +
    
    50 52
         def _create_popover(self):
    
    51 53
             popover_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
    
    52 54
             popover_box.get_style_context().add_class('margin-3')
    
    ... ... @@ -106,13 +108,14 @@ def _on_change_status(self, button):
    106 108
             if new_status == 'change_status_message':
    
    107 109
                 new_status = None
    
    108 110
             app.interface.change_status(status=new_status)
    
    111
    +        self.update()
    
    109 112
     
    
    110
    -    def update(self):
    
    111
    -        if not app.connections:
    
    112
    -            self.hide()
    
    113
    -            return
    
    113
    +    def update(self, *args, **kwargs):
    
    114
    +        # if not app.connections:
    
    115
    +        #     self.hide()
    
    116
    +        #     return
    
    114 117
     
    
    115
    -        self.show()
    
    118
    +        # self.show()
    
    116 119
             show = get_global_show()
    
    117 120
             uf_show = get_uf_show(show)
    
    118 121
             self._current_show_icon.set_from_icon_name(
    

  • gajim/gui_interface.py
    ... ... @@ -1653,11 +1653,8 @@ def autoconnect(self):
    1653 1653
                     status_message = helpers.from_one_line(status_message)
    
    1654 1654
     
    
    1655 1655
                 app.connections[account].change_status(status, status_message)
    
    1656
    -            # self.roster.send_status(account, status, status_message)
    
    1657
    -
    
    1658
    -    def change_status(self, status=None):
    
    1659
    -        # status=None means we want to change the message only
    
    1660 1656
     
    
    1657
    +    def change_status(self, status):
    
    1661 1658
             ask = ask_for_status_message(status)
    
    1662 1659
     
    
    1663 1660
             if status is None:
    
    ... ... @@ -1672,12 +1669,9 @@ def change_status(self, status=None):
    1672 1669
                                                         'sync_with_global_status'):
    
    1673 1670
                     continue
    
    1674 1671
     
    
    1675
    -            message = app.get_client(account).status_message
    
    1676
    -            self.roster.send_status(account, status, message)
    
    1677
    -
    
    1678
    -    def change_account_status(self, account, status=None):
    
    1679
    -        # status=None means we want to change the message only
    
    1672
    +            self._change_status(account, status)
    
    1680 1673
     
    
    1674
    +    def change_account_status(self, account, status):
    
    1681 1675
             ask = ask_for_status_message(status)
    
    1682 1676
     
    
    1683 1677
             client = app.get_client(account)
    
    ... ... @@ -1688,8 +1682,26 @@ def change_account_status(self, account, status=None):
    1688 1682
                 open_window('StatusChange', status=status, account=account)
    
    1689 1683
                 return
    
    1690 1684
     
    
    1685
    +        self._change_status(account, status)
    
    1686
    +
    
    1687
    +    @staticmethod
    
    1688
    +    def _change_status(account, status):
    
    1689
    +        client = app.get_client(account)
    
    1691 1690
             message = client.status_message
    
    1692
    -        self.roster.send_status(account, status, message)
    
    1691
    +        if status != 'offline':
    
    1692
    +            app.settings.set_account_setting(account, 'last_status', status)
    
    1693
    +            app.settings.set_account_setting(
    
    1694
    +                account,
    
    1695
    +                'last_status_msg',
    
    1696
    +                helpers.to_one_line(message))
    
    1697
    +            # TODO update systray icon
    
    1698
    +
    
    1699
    +        if status == 'offline':
    
    1700
    +            # TODO delete pep
    
    1701
    +            # self.delete_pep(app.get_jid_from_account(account), account)
    
    1702
    +            pass
    
    1703
    +
    
    1704
    +        client.change_status(status, message)
    
    1693 1705
     
    
    1694 1706
         def show_systray(self):
    
    1695 1707
             if not app.is_display(Display.WAYLAND):