Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
77613c22
by Philipp Hörist at 2019-12-07T12:14:58Z
-
71197932
by Philipp Hörist at 2019-12-07T12:14:58Z
-
c986abcd
by Philipp Hörist at 2019-12-07T12:14:58Z
-
b022f883
by Philipp Hörist at 2019-12-07T12:14:58Z
-
9f5b83e0
by Philipp Hörist at 2019-12-07T12:14:58Z
6 changed files:
- gajim/application.py
- gajim/common/app.py
- gajim/gtk/accounts.py
- gajim/gtk/groupchat_creation.py
- gajim/gui_interface.py
- gajim/roster_window.py
Changes:
| ... | ... | @@ -239,6 +239,7 @@ class GajimApplication(Gtk.Application): |
| 239 | 239 |
self._set_shortcuts()
|
| 240 | 240 |
from gajim import gui_menu_builder
|
| 241 | 241 |
gui_menu_builder.build_accounts_menu()
|
| 242 |
+ self.update_app_actions_state()
|
|
| 242 | 243 |
|
| 243 | 244 |
app.ged.register_event_handler('feature-discovered',
|
| 244 | 245 |
ged.CORE,
|
| ... | ... | @@ -535,6 +536,13 @@ class GajimApplication(Gtk.Application): |
| 535 | 536 |
# We go online
|
| 536 | 537 |
self.lookup_action(account + action_name).set_enabled(True)
|
| 537 | 538 |
|
| 539 |
+ def update_app_actions_state(self):
|
|
| 540 |
+ active_accounts = bool(app.get_connected_accounts(exclude_local=True))
|
|
| 541 |
+ self.lookup_action('create-groupchat').set_enabled(active_accounts)
|
|
| 542 |
+ |
|
| 543 |
+ enabled_accounts = app.contacts.get_accounts()
|
|
| 544 |
+ self.lookup_action('start-chat').set_enabled(enabled_accounts)
|
|
| 545 |
+ |
|
| 538 | 546 |
def _set_shortcuts(self):
|
| 539 | 547 |
shortcuts = {
|
| 540 | 548 |
'app.quit': ['<Primary>Q'],
|
| ... | ... | @@ -415,12 +415,14 @@ def get_number_of_connected_accounts(accounts_list=None): |
| 415 | 415 |
connected_accounts = connected_accounts + 1
|
| 416 | 416 |
return connected_accounts
|
| 417 | 417 |
|
| 418 |
-def get_connected_accounts():
|
|
| 418 |
+def get_connected_accounts(exclude_local=False):
|
|
| 419 | 419 |
"""
|
| 420 | 420 |
Returns a list of CONNECTED accounts
|
| 421 | 421 |
"""
|
| 422 | 422 |
account_list = []
|
| 423 | 423 |
for account in connections:
|
| 424 |
+ if account == 'Local' and exclude_local:
|
|
| 425 |
+ continue
|
|
| 424 | 426 |
if account_is_connected(account):
|
| 425 | 427 |
account_list.append(account)
|
| 426 | 428 |
return account_list
|
| ... | ... | @@ -521,7 +521,6 @@ class AccountRow(Gtk.ListBoxRow): |
| 521 | 521 |
app.connections[account].change_status('offline', 'offline')
|
| 522 | 522 |
app.connections[account].disconnect(reconnect=False)
|
| 523 | 523 |
app.interface.disable_account(account)
|
| 524 |
- app.config.set_per('accounts', account, 'active', False)
|
|
| 525 | 524 |
switch.set_state(state)
|
| 526 | 525 |
|
| 527 | 526 |
old_state = app.config.get_per('accounts', account, 'active')
|
| ... | ... | @@ -547,7 +546,6 @@ class AccountRow(Gtk.ListBoxRow): |
| 547 | 546 |
app.interface.enable_account(account)
|
| 548 | 547 |
else:
|
| 549 | 548 |
app.interface.disable_account(account)
|
| 550 |
- app.config.set_per('accounts', account, 'active', state)
|
|
| 551 | 549 |
|
| 552 | 550 |
return Gdk.EVENT_PROPAGATE
|
| 553 | 551 |
|
| ... | ... | @@ -62,7 +62,7 @@ class CreateGroupchatWindow(Gtk.ApplicationWindow): |
| 62 | 62 |
self.set_focus(self._ui.address_entry)
|
| 63 | 63 |
|
| 64 | 64 |
def _fill_account_combo(self, account):
|
| 65 |
- accounts = app.get_enabled_accounts_with_labels()
|
|
| 65 |
+ accounts = app.get_enabled_accounts_with_labels(connected_only=True)
|
|
| 66 | 66 |
account_liststore = self._ui.account_combo.get_model()
|
| 67 | 67 |
for acc in accounts:
|
| 68 | 68 |
account_liststore.append(acc)
|
| ... | ... | @@ -1762,6 +1762,8 @@ class Interface: |
| 1762 | 1762 |
self.roster.setup_and_draw_roster()
|
| 1763 | 1763 |
gui_menu_builder.build_accounts_menu()
|
| 1764 | 1764 |
self.roster.send_status(account, 'online', '')
|
| 1765 |
+ app.config.set_per('accounts', account, 'active', True)
|
|
| 1766 |
+ app.app.update_app_actions_state()
|
|
| 1765 | 1767 |
|
| 1766 | 1768 |
def disable_account(self, account):
|
| 1767 | 1769 |
self.roster.close_all(account, force=True)
|
| ... | ... | @@ -1796,42 +1798,21 @@ class Interface: |
| 1796 | 1798 |
'accounts', account, 'roster_version', '')
|
| 1797 | 1799 |
self.roster.setup_and_draw_roster()
|
| 1798 | 1800 |
gui_menu_builder.build_accounts_menu()
|
| 1801 |
+ app.config.set_per('accounts', account, 'active', False)
|
|
| 1802 |
+ app.app.update_app_actions_state()
|
|
| 1799 | 1803 |
|
| 1800 | 1804 |
def remove_account(self, account):
|
| 1801 |
- # Close all opened windows
|
|
| 1802 |
- self.roster.close_all(account, force=True)
|
|
| 1803 | 1805 |
if account in app.connections:
|
| 1804 | 1806 |
app.connections[account].disconnect(reconnect=False)
|
| 1805 |
- app.connections[account].cleanup()
|
|
| 1806 |
- del app.connections[account]
|
|
| 1807 |
+ |
|
| 1808 |
+ self.disable_account(account)
|
|
| 1809 |
+ |
|
| 1807 | 1810 |
app.logger.remove_roster(app.get_jid_from_account(account))
|
| 1808 | 1811 |
# Delete password must be before del_per() because it calls set_per()
|
| 1809 | 1812 |
# which would recreate the account with defaults values if not found
|
| 1810 | 1813 |
passwords.delete_password(account)
|
| 1811 | 1814 |
app.config.del_per('accounts', account)
|
| 1812 |
- del self.instances[account]
|
|
| 1813 |
- if account in app.nicks:
|
|
| 1814 |
- del self.minimized_controls[account]
|
|
| 1815 |
- del app.nicks[account]
|
|
| 1816 |
- del app.block_signed_in_notifications[account]
|
|
| 1817 |
- del app.groups[account]
|
|
| 1818 |
- app.contacts.remove_account(account)
|
|
| 1819 |
- del app.gc_connected[account]
|
|
| 1820 |
- del app.automatic_rooms[account]
|
|
| 1821 |
- del app.to_be_removed[account]
|
|
| 1822 |
- del app.newly_added[account]
|
|
| 1823 |
- del app.sleeper_state[account]
|
|
| 1824 |
- del app.last_message_time[account]
|
|
| 1825 |
- del app.status_before_autoaway[account]
|
|
| 1826 |
- del app.gajim_optional_features[account]
|
|
| 1827 |
- del app.caps_hash[account]
|
|
| 1828 |
- if len(app.connections) >= 2: # Do not merge accounts if only one exists
|
|
| 1829 |
- self.roster.regroup = app.config.get('mergeaccounts')
|
|
| 1830 |
- else:
|
|
| 1831 |
- self.roster.regroup = False
|
|
| 1832 |
- self.roster.setup_and_draw_roster()
|
|
| 1833 | 1815 |
app.app.remove_account_actions(account)
|
| 1834 |
- gui_menu_builder.build_accounts_menu()
|
|
| 1835 | 1816 |
|
| 1836 | 1817 |
window = get_app_window('AccountsWindow')
|
| 1837 | 1818 |
if window is not None:
|
| ... | ... | @@ -2597,6 +2597,7 @@ class RosterWindow: |
| 2597 | 2597 |
if app.get_number_of_connected_accounts() == 0:
|
| 2598 | 2598 |
model[iter_][3] = False
|
| 2599 | 2599 |
self.application.set_account_actions_state(obj.conn.name)
|
| 2600 |
+ self.application.update_app_actions_state()
|
|
| 2600 | 2601 |
else:
|
| 2601 | 2602 |
# sensitivity for this menuitem
|
| 2602 | 2603 |
model[iter_][3] = True
|
| ... | ... | @@ -2652,6 +2653,7 @@ class RosterWindow: |
| 2652 | 2653 |
|
| 2653 | 2654 |
def _nec_signed_in(self, obj):
|
| 2654 | 2655 |
self.application.set_account_actions_state(obj.conn.name, True)
|
| 2656 |
+ self.application.update_app_actions_state()
|
|
| 2655 | 2657 |
self.draw_account(obj.conn.name)
|
| 2656 | 2658 |
|
| 2657 | 2659 |
def _nec_decrypted_message_received(self, obj):
|