Daniel Brötzmann pushed to branch mainwindow at gajim / gajim

Commits:

3 changed files:

Changes:

  • gajim/data/gui/account_page.ui
    ... ... @@ -75,6 +75,7 @@
    75 75
                     <property name="primary-icon-activatable">False</property>
    
    76 76
                     <property name="primary-icon-sensitive">False</property>
    
    77 77
                     <property name="placeholder-text" translatable="yes">Search…</property>
    
    78
    +                <signal name="changed" handler="_on_search_changed" swapped="no"/>
    
    78 79
                   </object>
    
    79 80
                   <packing>
    
    80 81
                     <property name="expand">False</property>
    

  • gajim/gtk/account_page.py
    ... ... @@ -12,15 +12,21 @@
    12 12
     # You should have received a copy of the GNU General Public License
    
    13 13
     # along with Gajim. If not, see <http://www.gnu.org/licenses/>.
    
    14 14
     
    
    15
    +from gi.repository import Gio
    
    15 16
     from gi.repository import Gtk
    
    16 17
     
    
    17 18
     from gajim.common import app
    
    19
    +from gajim.common.i18n import _
    
    18 20
     
    
    19 21
     from .roster import Roster
    
    20 22
     from .status_selector import StatusSelector
    
    21 23
     from .util import get_builder
    
    22 24
     from .util import open_window
    
    23 25
     
    
    26
    +ROSTER_MENU_DICT = {
    
    27
    +    'show-offline': _('Show Offline Contacts'),
    
    28
    +}
    
    29
    +
    
    24 30
     
    
    25 31
     class AccountPage(Gtk.Box):
    
    26 32
         def __init__(self, account):
    
    ... ... @@ -40,6 +46,11 @@ def __init__(self, account):
    40 46
             self._ui.paned.set_position(app.settings.get('chat_handle_position'))
    
    41 47
             self._ui.paned.connect('button-release-event', self._on_button_release)
    
    42 48
     
    
    49
    +        roster_menu = Gio.Menu()
    
    50
    +        for action, label in ROSTER_MENU_DICT.items():
    
    51
    +            roster_menu.append(label, f'win.{action}-{account}')
    
    52
    +        self._ui.roster_menu_button.set_menu_model(roster_menu)
    
    53
    +
    
    43 54
             self._ui.connect_signals(self)
    
    44 55
             self.show_all()
    
    45 56
     
    
    ... ... @@ -49,6 +60,10 @@ def _on_account_settings(self, _button):
    49 60
             window = open_window('AccountsWindow')
    
    50 61
             window.select_account(self._account)
    
    51 62
     
    
    63
    +    def _on_search_changed(self, widget):
    
    64
    +        text = widget.get_text().lower()
    
    65
    +        print(text)
    
    66
    +
    
    52 67
         @staticmethod
    
    53 68
         def _on_button_release(paned, event):
    
    54 69
             if event.window != paned.get_handle_window():
    

  • gajim/gtk/roster.py
    ... ... @@ -97,6 +97,13 @@ def _add_actions(self):
    97 97
                 act.connect('activate', func)
    
    98 98
                 app.window.add_action(act)
    
    99 99
     
    
    100
    +        action = Gio.SimpleAction.new_stateful(
    
    101
    +            f'show-offline-{self._account}',
    
    102
    +            None,
    
    103
    +            GLib.Variant.new_boolean(app.settings.get('showoffline')))
    
    104
    +        action.connect('change-state', self._show_offline)
    
    105
    +        app.window.add_action(action)
    
    106
    +
    
    100 107
         def update_actions(self):
    
    101 108
             online = app.account_is_connected(self._account)
    
    102 109
             blocking_support = self._client.get_module('Blocking').supported
    
    ... ... @@ -117,6 +124,7 @@ def _remove_actions(self):
    117 124
                 'execute-command',
    
    118 125
                 'block-contact',
    
    119 126
                 'remove-contact',
    
    127
    +            'show-offline',
    
    120 128
             ]
    
    121 129
             for action in actions:
    
    122 130
                 app.window.remove_action(f'{action}-{self._account}')
    
    ... ... @@ -127,6 +135,12 @@ def _on_account_state(self, _event):
    127 135
         def _on_theme_update(self, _event):
    
    128 136
             self.redraw()
    
    129 137
     
    
    138
    +    def _show_offline(self, action, param):
    
    139
    +        action.set_state(param)
    
    140
    +        app.settings.set('showoffline', param.get_boolean())
    
    141
    +        print('_show_offline')
    
    142
    +        print(param.get_boolean())
    
    143
    +
    
    130 144
         def _contact_info(self, _action, param):
    
    131 145
             app.window.contact_info(self._account, param.get_string())
    
    132 146