Add dedicated zeroconf menu
This commit is contained in:
parent
828ae5bb42
commit
2410121ddb
|
@ -1,24 +1,19 @@
|
||||||
# -*- coding: utf-8 -*-
|
#
|
||||||
## src/app_actions.py
|
# Copyright (C) 2017 Philipp Hörist <philipp AT hoerist.com>
|
||||||
##
|
#
|
||||||
## Copyright (C) 2017 Philipp Hörist <philipp AT hoerist.com>
|
# This file is part of Gajim.
|
||||||
##
|
#
|
||||||
## This file is part of Gajim.
|
# Gajim is free software; you can redistribute it and/or modify
|
||||||
##
|
# it under the terms of the GNU General Public License as published
|
||||||
## Gajim is free software; you can redistribute it and/or modify
|
# by the Free Software Foundation; version 3 only.
|
||||||
## it under the terms of the GNU General Public License as published
|
#
|
||||||
## by the Free Software Foundation; version 3 only.
|
# Gajim is distributed in the hope that it will be useful,
|
||||||
##
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
## Gajim is distributed in the hope that it will be useful,
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# GNU General Public License for more details.
|
||||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
#
|
||||||
## GNU General Public License for more details.
|
# You should have received a copy of the GNU General Public License
|
||||||
##
|
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||||
## You should have received a copy of the GNU General Public License
|
|
||||||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
##
|
|
||||||
|
|
||||||
from gi.repository import Gtk
|
|
||||||
|
|
||||||
from gajim.common import app
|
from gajim.common import app
|
||||||
from gajim.common import helpers
|
from gajim.common import helpers
|
||||||
|
@ -36,59 +31,63 @@ from gajim.history_sync import HistorySyncAssistant
|
||||||
from gajim.server_info import ServerInfoDialog
|
from gajim.server_info import ServerInfoDialog
|
||||||
|
|
||||||
|
|
||||||
class AppActions():
|
# General Actions
|
||||||
''' Action Callbacks '''
|
|
||||||
def __init__(self, application: Gtk.Application):
|
|
||||||
self.application = application
|
|
||||||
|
|
||||||
# General Actions
|
def on_add_contact_jid(action, param):
|
||||||
|
|
||||||
def on_add_contact_jid(self, action, param):
|
|
||||||
dialogs.AddNewContactWindow(None, param.get_string())
|
dialogs.AddNewContactWindow(None, param.get_string())
|
||||||
|
|
||||||
# Application Menu Actions
|
# Application Menu Actions
|
||||||
|
|
||||||
def on_preferences(self, action, param):
|
|
||||||
|
def on_preferences(action, param):
|
||||||
if 'preferences' in interface.instances:
|
if 'preferences' in interface.instances:
|
||||||
interface.instances['preferences'].window.present()
|
interface.instances['preferences'].window.present()
|
||||||
else:
|
else:
|
||||||
interface.instances['preferences'] = \
|
interface.instances['preferences'] = \
|
||||||
config.PreferencesWindow()
|
config.PreferencesWindow()
|
||||||
|
|
||||||
def on_plugins(self, action, param):
|
|
||||||
|
def on_plugins(action, param):
|
||||||
if 'plugins' in interface.instances:
|
if 'plugins' in interface.instances:
|
||||||
interface.instances['plugins'].window.present()
|
interface.instances['plugins'].window.present()
|
||||||
else:
|
else:
|
||||||
interface.instances['plugins'] = gajim.plugins.gui.PluginsWindow()
|
interface.instances['plugins'] = gajim.plugins.gui.PluginsWindow()
|
||||||
|
|
||||||
def on_accounts(self, action, param):
|
|
||||||
|
def on_accounts(action, param):
|
||||||
if 'accounts' in app.interface.instances:
|
if 'accounts' in app.interface.instances:
|
||||||
app.interface.instances['accounts'].present()
|
app.interface.instances['accounts'].present()
|
||||||
else:
|
else:
|
||||||
app.interface.instances['accounts'] = accounts_window.AccountsWindow()
|
app.interface.instances['accounts'] = accounts_window.AccountsWindow()
|
||||||
|
|
||||||
def on_history_manager(self, action, param):
|
|
||||||
|
def on_history_manager(action, param):
|
||||||
from gajim.history_manager import HistoryManager
|
from gajim.history_manager import HistoryManager
|
||||||
HistoryManager()
|
HistoryManager()
|
||||||
|
|
||||||
def on_manage_bookmarks(self, action, param):
|
|
||||||
|
def on_manage_bookmarks(action, param):
|
||||||
config.ManageBookmarksWindow()
|
config.ManageBookmarksWindow()
|
||||||
|
|
||||||
def on_quit(self, action, param):
|
|
||||||
|
def on_quit(action, param):
|
||||||
interface.roster.on_quit_request()
|
interface.roster.on_quit_request()
|
||||||
|
|
||||||
def on_new_chat(self, action, param):
|
|
||||||
|
def on_new_chat(action, param):
|
||||||
if 'start_chat' in app.interface.instances:
|
if 'start_chat' in app.interface.instances:
|
||||||
app.interface.instances['start_chat'].present()
|
app.interface.instances['start_chat'].present()
|
||||||
else:
|
else:
|
||||||
app.interface.instances['start_chat'] = dialogs.StartChatDialog()
|
app.interface.instances['start_chat'] = dialogs.StartChatDialog()
|
||||||
|
|
||||||
# Accounts Actions
|
# Accounts Actions
|
||||||
|
|
||||||
def on_profile(self, action, param):
|
|
||||||
|
def on_profile(action, param):
|
||||||
interface.edit_own_details(param.get_string())
|
interface.edit_own_details(param.get_string())
|
||||||
|
|
||||||
def on_activate_bookmark(self, action, param):
|
|
||||||
|
def on_activate_bookmark(action, param):
|
||||||
dict_ = param.unpack()
|
dict_ = param.unpack()
|
||||||
account, jid, nick, password = \
|
account, jid, nick, password = \
|
||||||
dict_['account'], dict_['jid'], None, None
|
dict_['account'], dict_['jid'], None, None
|
||||||
|
@ -98,13 +97,15 @@ class AppActions():
|
||||||
password = dict_['password']
|
password = dict_['password']
|
||||||
interface.join_gc_room(account, jid, nick, password)
|
interface.join_gc_room(account, jid, nick, password)
|
||||||
|
|
||||||
def on_send_server_message(self, action, param):
|
|
||||||
|
def on_send_server_message(action, param):
|
||||||
account = param.get_string()
|
account = param.get_string()
|
||||||
server = app.config.get_per('accounts', account, 'hostname')
|
server = app.config.get_per('accounts', account, 'hostname')
|
||||||
server += '/announce/online'
|
server += '/announce/online'
|
||||||
dialogs.SingleMessageWindow(account, server, 'send')
|
dialogs.SingleMessageWindow(account, server, 'send')
|
||||||
|
|
||||||
def on_service_disco(self, action, param):
|
|
||||||
|
def on_service_disco(action, param):
|
||||||
account = param.get_string()
|
account = param.get_string()
|
||||||
server_jid = app.config.get_per('accounts', account, 'hostname')
|
server_jid = app.config.get_per('accounts', account, 'hostname')
|
||||||
if server_jid in interface.instances[account]['disco']:
|
if server_jid in interface.instances[account]['disco']:
|
||||||
|
@ -117,7 +118,8 @@ class AppActions():
|
||||||
except GajimGeneralException:
|
except GajimGeneralException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def on_join_gc(self, action, param):
|
|
||||||
|
def on_join_gc(action, param):
|
||||||
account = param.get_string()
|
account = param.get_string()
|
||||||
invisible_show = app.SHOW_LIST.index('invisible')
|
invisible_show = app.SHOW_LIST.index('invisible')
|
||||||
if app.connections[account].connected == invisible_show:
|
if app.connections[account].connected == invisible_show:
|
||||||
|
@ -129,34 +131,41 @@ class AppActions():
|
||||||
interface.instances[account]['join_gc'] = \
|
interface.instances[account]['join_gc'] = \
|
||||||
dialogs.JoinGroupchatWindow(account, None)
|
dialogs.JoinGroupchatWindow(account, None)
|
||||||
|
|
||||||
def on_add_contact(self, action, param):
|
|
||||||
|
def on_add_contact(action, param):
|
||||||
dialogs.AddNewContactWindow(param.get_string())
|
dialogs.AddNewContactWindow(param.get_string())
|
||||||
|
|
||||||
def on_single_message(self, action, param):
|
|
||||||
|
def on_single_message(action, param):
|
||||||
dialogs.SingleMessageWindow(param.get_string(), action='send')
|
dialogs.SingleMessageWindow(param.get_string(), action='send')
|
||||||
|
|
||||||
def on_merge_accounts(self, action, param):
|
|
||||||
|
def on_merge_accounts(action, param):
|
||||||
action.set_state(param)
|
action.set_state(param)
|
||||||
value = param.get_boolean()
|
value = param.get_boolean()
|
||||||
app.config.set('mergeaccounts', value)
|
app.config.set('mergeaccounts', value)
|
||||||
if len(app.connections) >= 2: # Do not merge accounts if only one active
|
# Do not merge accounts if only one active
|
||||||
|
if len(app.connections) >= 2:
|
||||||
app.interface.roster.regroup = value
|
app.interface.roster.regroup = value
|
||||||
else:
|
else:
|
||||||
app.interface.roster.regroup = False
|
app.interface.roster.regroup = False
|
||||||
app.interface.roster.setup_and_draw_roster()
|
app.interface.roster.setup_and_draw_roster()
|
||||||
|
|
||||||
def on_use_pgp_agent(self, action, param):
|
|
||||||
|
def on_use_pgp_agent(action, param):
|
||||||
action.set_state(param)
|
action.set_state(param)
|
||||||
app.config.set('use_gpg_agent', param.get_boolean())
|
app.config.set('use_gpg_agent', param.get_boolean())
|
||||||
|
|
||||||
def on_add_account(self, action, param):
|
|
||||||
|
def on_add_account(action, param):
|
||||||
if 'account_creation_wizard' in app.interface.instances:
|
if 'account_creation_wizard' in app.interface.instances:
|
||||||
app.interface.instances['account_creation_wizard'].window.present()
|
app.interface.instances['account_creation_wizard'].window.present()
|
||||||
else:
|
else:
|
||||||
app.interface.instances['account_creation_wizard'] = \
|
app.interface.instances['account_creation_wizard'] = \
|
||||||
config.AccountCreationWizardWindow()
|
config.AccountCreationWizardWindow()
|
||||||
|
|
||||||
def on_import_contacts(self, action, param):
|
|
||||||
|
def on_import_contacts(action, param):
|
||||||
account = param.get_string()
|
account = param.get_string()
|
||||||
if 'import_contacts' in app.interface.instances:
|
if 'import_contacts' in app.interface.instances:
|
||||||
app.interface.instances['import_contacts'].dialog.present()
|
app.interface.instances['import_contacts'].dialog.present()
|
||||||
|
@ -164,9 +173,10 @@ class AppActions():
|
||||||
app.interface.instances['import_contacts'] = \
|
app.interface.instances['import_contacts'] = \
|
||||||
dialogs.SynchroniseSelectAccountDialog(account)
|
dialogs.SynchroniseSelectAccountDialog(account)
|
||||||
|
|
||||||
# Advanced Actions
|
# Advanced Actions
|
||||||
|
|
||||||
def on_archiving_preferences(self, action, param):
|
|
||||||
|
def on_archiving_preferences(action, param):
|
||||||
account = param.get_string()
|
account = param.get_string()
|
||||||
if 'archiving_preferences' in interface.instances[account]:
|
if 'archiving_preferences' in interface.instances[account]:
|
||||||
interface.instances[account]['archiving_preferences'].window.\
|
interface.instances[account]['archiving_preferences'].window.\
|
||||||
|
@ -175,7 +185,8 @@ class AppActions():
|
||||||
interface.instances[account]['archiving_preferences'] = \
|
interface.instances[account]['archiving_preferences'] = \
|
||||||
dialogs.Archiving313PreferencesWindow(account)
|
dialogs.Archiving313PreferencesWindow(account)
|
||||||
|
|
||||||
def on_history_sync(self, action, param):
|
|
||||||
|
def on_history_sync(action, param):
|
||||||
account = param.get_string()
|
account = param.get_string()
|
||||||
if 'history_sync' in interface.instances[account]:
|
if 'history_sync' in interface.instances[account]:
|
||||||
interface.instances[account]['history_sync'].present()
|
interface.instances[account]['history_sync'].present()
|
||||||
|
@ -183,7 +194,8 @@ class AppActions():
|
||||||
interface.instances[account]['history_sync'] = \
|
interface.instances[account]['history_sync'] = \
|
||||||
HistorySyncAssistant(account, interface.roster.window)
|
HistorySyncAssistant(account, interface.roster.window)
|
||||||
|
|
||||||
def on_privacy_lists(self, action, param):
|
|
||||||
|
def on_privacy_lists(action, param):
|
||||||
account = param.get_string()
|
account = param.get_string()
|
||||||
if 'privacy_lists' in interface.instances[account]:
|
if 'privacy_lists' in interface.instances[account]:
|
||||||
interface.instances[account]['privacy_lists'].window.present()
|
interface.instances[account]['privacy_lists'].window.present()
|
||||||
|
@ -191,7 +203,8 @@ class AppActions():
|
||||||
interface.instances[account]['privacy_lists'] = \
|
interface.instances[account]['privacy_lists'] = \
|
||||||
dialogs.PrivacyListsWindow(account)
|
dialogs.PrivacyListsWindow(account)
|
||||||
|
|
||||||
def on_server_info(self, action, param):
|
|
||||||
|
def on_server_info(action, param):
|
||||||
account = param.get_string()
|
account = param.get_string()
|
||||||
if 'server_info' in interface.instances[account]:
|
if 'server_info' in interface.instances[account]:
|
||||||
interface.instances[account]['server_info'].present()
|
interface.instances[account]['server_info'].present()
|
||||||
|
@ -199,7 +212,8 @@ class AppActions():
|
||||||
interface.instances[account]['server_info'] = \
|
interface.instances[account]['server_info'] = \
|
||||||
ServerInfoDialog(account)
|
ServerInfoDialog(account)
|
||||||
|
|
||||||
def on_xml_console(self, action, param):
|
|
||||||
|
def on_xml_console(action, param):
|
||||||
account = param.get_string()
|
account = param.get_string()
|
||||||
if 'xml_console' in interface.instances[account]:
|
if 'xml_console' in interface.instances[account]:
|
||||||
interface.instances[account]['xml_console'].present()
|
interface.instances[account]['xml_console'].present()
|
||||||
|
@ -207,77 +221,89 @@ class AppActions():
|
||||||
interface.instances[account]['xml_console'] = \
|
interface.instances[account]['xml_console'] = \
|
||||||
dialogs.XMLConsoleWindow(account)
|
dialogs.XMLConsoleWindow(account)
|
||||||
|
|
||||||
def on_manage_proxies(self, action, param):
|
|
||||||
|
def on_manage_proxies(action, param):
|
||||||
if 'manage_proxies' in app.interface.instances:
|
if 'manage_proxies' in app.interface.instances:
|
||||||
app.interface.instances['manage_proxies'].window.present()
|
app.interface.instances['manage_proxies'].window.present()
|
||||||
else:
|
else:
|
||||||
app.interface.instances['manage_proxies'] = \
|
app.interface.instances['manage_proxies'] = \
|
||||||
config.ManageProxiesWindow(interface.roster.window)
|
config.ManageProxiesWindow(interface.roster.window)
|
||||||
|
|
||||||
# Admin Actions
|
# Admin Actions
|
||||||
|
|
||||||
def on_set_motd(self, action, param):
|
|
||||||
|
def on_set_motd(action, param):
|
||||||
account = param.get_string()
|
account = param.get_string()
|
||||||
server = app.config.get_per('accounts', account, 'hostname')
|
server = app.config.get_per('accounts', account, 'hostname')
|
||||||
server += '/announce/motd'
|
server += '/announce/motd'
|
||||||
dialogs.SingleMessageWindow(account, server, 'send')
|
dialogs.SingleMessageWindow(account, server, 'send')
|
||||||
|
|
||||||
def on_update_motd(self, action, param):
|
|
||||||
|
def on_update_motd(action, param):
|
||||||
account = param.get_string()
|
account = param.get_string()
|
||||||
server = app.config.get_per('accounts', account, 'hostname')
|
server = app.config.get_per('accounts', account, 'hostname')
|
||||||
server += '/announce/motd/update'
|
server += '/announce/motd/update'
|
||||||
dialogs.SingleMessageWindow(account, server, 'send')
|
dialogs.SingleMessageWindow(account, server, 'send')
|
||||||
|
|
||||||
def on_delete_motd(self, action, param):
|
|
||||||
|
def on_delete_motd(action, param):
|
||||||
account = param.get_string()
|
account = param.get_string()
|
||||||
server = app.config.get_per('accounts', account, 'hostname')
|
server = app.config.get_per('accounts', account, 'hostname')
|
||||||
server += '/announce/motd/delete'
|
server += '/announce/motd/delete'
|
||||||
app.connections[account].send_motd(server)
|
app.connections[account].send_motd(server)
|
||||||
|
|
||||||
# Help Actions
|
# Help Actions
|
||||||
|
|
||||||
def on_contents(self, action, param):
|
|
||||||
|
def on_contents(action, param):
|
||||||
helpers.launch_browser_mailer(
|
helpers.launch_browser_mailer(
|
||||||
'url', 'https://dev.gajim.org/gajim/gajim/wikis')
|
'url', 'https://dev.gajim.org/gajim/gajim/wikis')
|
||||||
|
|
||||||
def on_faq(self, action, param):
|
|
||||||
|
def on_faq(action, param):
|
||||||
helpers.launch_browser_mailer(
|
helpers.launch_browser_mailer(
|
||||||
'url', 'https://dev.gajim.org/gajim/gajim/wikis/help/gajimfaq')
|
'url', 'https://dev.gajim.org/gajim/gajim/wikis/help/gajimfaq')
|
||||||
|
|
||||||
def on_keyboard_shortcuts(self, action, param):
|
|
||||||
shortcuts_window.show(self.application.get_active_window())
|
|
||||||
|
|
||||||
def on_features(self, action, param):
|
def on_keyboard_shortcuts(action, param):
|
||||||
|
shortcuts_window.show(app.app.get_active_window())
|
||||||
|
|
||||||
|
|
||||||
|
def on_features(action, param):
|
||||||
features_window.FeaturesWindow()
|
features_window.FeaturesWindow()
|
||||||
|
|
||||||
def on_about(self, action, param):
|
|
||||||
|
def on_about(action, param):
|
||||||
dialogs.AboutDialog()
|
dialogs.AboutDialog()
|
||||||
|
|
||||||
# View Actions
|
# View Actions
|
||||||
|
|
||||||
def on_file_transfers(self, action, param):
|
|
||||||
|
def on_file_transfers(action, param):
|
||||||
if interface.instances['file_transfers']. \
|
if interface.instances['file_transfers']. \
|
||||||
window.get_property('visible'):
|
window.get_property('visible'):
|
||||||
interface.instances['file_transfers'].window.present()
|
interface.instances['file_transfers'].window.present()
|
||||||
else:
|
else:
|
||||||
interface.instances['file_transfers'].window.show_all()
|
interface.instances['file_transfers'].window.show_all()
|
||||||
|
|
||||||
def on_history(self, action, param):
|
|
||||||
|
def on_history(action, param):
|
||||||
if 'logs' in interface.instances:
|
if 'logs' in interface.instances:
|
||||||
interface.instances['logs'].window.present()
|
interface.instances['logs'].window.present()
|
||||||
else:
|
else:
|
||||||
interface.instances['logs'] = history_window.\
|
interface.instances['logs'] = history_window.\
|
||||||
HistoryWindow()
|
HistoryWindow()
|
||||||
|
|
||||||
def on_open_event(self, action, param):
|
|
||||||
|
def on_open_event(action, param):
|
||||||
dict_ = param.unpack()
|
dict_ = param.unpack()
|
||||||
app.interface.handle_event(dict_['account'], dict_['jid'],
|
app.interface.handle_event(
|
||||||
dict_['type_'])
|
dict_['account'], dict_['jid'], dict_['type_'])
|
||||||
|
|
||||||
|
|
||||||
# Other Actions
|
# Other Actions
|
||||||
|
|
||||||
def toggle_ipython(self, action, param):
|
def toggle_ipython(action, param):
|
||||||
"""
|
"""
|
||||||
Show/hide the ipython window
|
Show/hide the ipython window
|
||||||
"""
|
"""
|
||||||
|
@ -287,7 +313,8 @@ class AppActions():
|
||||||
else:
|
else:
|
||||||
app.interface.create_ipython_window()
|
app.interface.create_ipython_window()
|
||||||
|
|
||||||
def show_next_pending_event(self, action, param):
|
|
||||||
|
def show_next_pending_event(action, param):
|
||||||
"""
|
"""
|
||||||
Show the window(s) with next pending event in tabbed/group chats
|
Show the window(s) with next pending event in tabbed/group chats
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -284,37 +284,14 @@ class GajimApplication(Gtk.Application):
|
||||||
|
|
||||||
def add_actions(self):
|
def add_actions(self):
|
||||||
''' Build Application Actions '''
|
''' Build Application Actions '''
|
||||||
from gajim.app_actions import AppActions
|
from gajim import app_actions
|
||||||
action = AppActions(self)
|
|
||||||
|
|
||||||
self.account_actions = [
|
|
||||||
('-start-single-chat', action.on_single_message, 'online', 's'),
|
|
||||||
('-join-groupchat', action.on_join_gc, 'online', 's'),
|
|
||||||
('-add-contact', action.on_add_contact, 'online', 's'),
|
|
||||||
('-services', action.on_service_disco, 'online', 's'),
|
|
||||||
('-profile', action.on_profile, 'feature', 's'),
|
|
||||||
('-xml-console', action.on_xml_console, 'always', 's'),
|
|
||||||
('-server-info', action.on_server_info, 'online', 's'),
|
|
||||||
('-archive', action.on_archiving_preferences, 'feature', 's'),
|
|
||||||
('-sync-history', action.on_history_sync, 'online', 's'),
|
|
||||||
('-privacylists', action.on_privacy_lists, 'feature', 's'),
|
|
||||||
('-send-server-message',
|
|
||||||
action.on_send_server_message, 'online', 's'),
|
|
||||||
('-set-motd', action.on_set_motd, 'online', 's'),
|
|
||||||
('-update-motd', action.on_update_motd, 'online', 's'),
|
|
||||||
('-delete-motd', action.on_delete_motd, 'online', 's'),
|
|
||||||
('-activate-bookmark',
|
|
||||||
action.on_activate_bookmark, 'online', 'a{sv}'),
|
|
||||||
('-open-event', action.on_open_event, 'always', 'a{sv}'),
|
|
||||||
('-import-contacts', action.on_import_contacts, 'online', 's'),
|
|
||||||
]
|
|
||||||
|
|
||||||
# General Stateful Actions
|
# General Stateful Actions
|
||||||
|
|
||||||
act = Gio.SimpleAction.new_stateful(
|
act = Gio.SimpleAction.new_stateful(
|
||||||
'merge', None,
|
'merge', None,
|
||||||
GLib.Variant.new_boolean(app.config.get('mergeaccounts')))
|
GLib.Variant.new_boolean(app.config.get('mergeaccounts')))
|
||||||
act.connect('change-state', action.on_merge_accounts)
|
act.connect('change-state', app_actions.on_merge_accounts)
|
||||||
self.add_action(act)
|
self.add_action(act)
|
||||||
|
|
||||||
act = Gio.SimpleAction.new_stateful(
|
act = Gio.SimpleAction.new_stateful(
|
||||||
|
@ -324,40 +301,38 @@ class GajimApplication(Gtk.Application):
|
||||||
|
|
||||||
# General Actions
|
# General Actions
|
||||||
|
|
||||||
self.general_actions = [
|
general_actions = [
|
||||||
('quit', action.on_quit),
|
('quit', app_actions.on_quit),
|
||||||
('accounts', action.on_accounts),
|
('accounts', app_actions.on_accounts),
|
||||||
('add-account', action.on_add_account),
|
('add-account', app_actions.on_add_account),
|
||||||
('manage-proxies', action.on_manage_proxies),
|
('manage-proxies', app_actions.on_manage_proxies),
|
||||||
('start-chat', action.on_new_chat),
|
('start-chat', app_actions.on_new_chat),
|
||||||
('bookmarks', action.on_manage_bookmarks),
|
('bookmarks', app_actions.on_manage_bookmarks),
|
||||||
('history-manager', action.on_history_manager),
|
('history-manager', app_actions.on_history_manager),
|
||||||
('preferences', action.on_preferences),
|
('preferences', app_actions.on_preferences),
|
||||||
('plugins', action.on_plugins),
|
('plugins', app_actions.on_plugins),
|
||||||
('file-transfer', action.on_file_transfers),
|
('file-transfer', app_actions.on_file_transfers),
|
||||||
('history', action.on_history),
|
('history', app_actions.on_history),
|
||||||
('shortcuts', action.on_keyboard_shortcuts),
|
('shortcuts', app_actions.on_keyboard_shortcuts),
|
||||||
('features', action.on_features),
|
('features', app_actions.on_features),
|
||||||
('content', action.on_contents),
|
('content', app_actions.on_contents),
|
||||||
('about', action.on_about),
|
('about', app_actions.on_about),
|
||||||
('faq', action.on_faq),
|
('faq', app_actions.on_faq),
|
||||||
('ipython', action.toggle_ipython),
|
('ipython', app_actions.toggle_ipython),
|
||||||
('show-next-pending-event', action.show_next_pending_event),
|
('show-next-pending-event', app_actions.show_next_pending_event),
|
||||||
]
|
]
|
||||||
|
|
||||||
act = Gio.SimpleAction.new('add-contact', GLib.VariantType.new('s'))
|
act = Gio.SimpleAction.new('add-contact', GLib.VariantType.new('s'))
|
||||||
act.connect("activate", action.on_add_contact_jid)
|
act.connect("activate", app_actions.on_add_contact_jid)
|
||||||
self.add_action(act)
|
self.add_action(act)
|
||||||
|
|
||||||
for action in self.general_actions:
|
for action in general_actions:
|
||||||
action_name, func = action
|
action_name, func = action
|
||||||
act = Gio.SimpleAction.new(action_name, None)
|
act = Gio.SimpleAction.new(action_name, None)
|
||||||
act.connect("activate", func)
|
act.connect("activate", func)
|
||||||
self.add_action(act)
|
self.add_action(act)
|
||||||
|
|
||||||
accounts_list = sorted(app.config.get_per('accounts'))
|
accounts_list = sorted(app.config.get_per('accounts'))
|
||||||
if 'Local' in accounts_list:
|
|
||||||
accounts_list.remove('Local')
|
|
||||||
if not accounts_list:
|
if not accounts_list:
|
||||||
return
|
return
|
||||||
if len(accounts_list) > 1:
|
if len(accounts_list) > 1:
|
||||||
|
@ -366,10 +341,38 @@ class GajimApplication(Gtk.Application):
|
||||||
else:
|
else:
|
||||||
self.add_account_actions(accounts_list[0])
|
self.add_account_actions(accounts_list[0])
|
||||||
|
|
||||||
def add_account_actions(self, account):
|
def _get_account_actions(self, account):
|
||||||
|
from gajim import app_actions
|
||||||
|
|
||||||
if account == 'Local':
|
if account == 'Local':
|
||||||
return
|
return [
|
||||||
for action in self.account_actions:
|
('-xml-console', app_actions.on_xml_console, 'always', 's')
|
||||||
|
]
|
||||||
|
|
||||||
|
return [
|
||||||
|
('-start-single-chat', app_actions.on_single_message, 'online', 's'),
|
||||||
|
('-join-groupchat', app_actions.on_join_gc, 'online', 's'),
|
||||||
|
('-add-contact', app_actions.on_add_contact, 'online', 's'),
|
||||||
|
('-services', app_actions.on_service_disco, 'online', 's'),
|
||||||
|
('-profile', app_actions.on_profile, 'feature', 's'),
|
||||||
|
('-xml-console', app_actions.on_xml_console, 'always', 's'),
|
||||||
|
('-server-info', app_actions.on_server_info, 'online', 's'),
|
||||||
|
('-archive', app_actions.on_archiving_preferences, 'feature', 's'),
|
||||||
|
('-sync-history', app_actions.on_history_sync, 'online', 's'),
|
||||||
|
('-privacylists', app_actions.on_privacy_lists, 'feature', 's'),
|
||||||
|
('-send-server-message',
|
||||||
|
app_actions.on_send_server_message, 'online', 's'),
|
||||||
|
('-set-motd', app_actions.on_set_motd, 'online', 's'),
|
||||||
|
('-update-motd', app_actions.on_update_motd, 'online', 's'),
|
||||||
|
('-delete-motd', app_actions.on_delete_motd, 'online', 's'),
|
||||||
|
('-activate-bookmark',
|
||||||
|
app_actions.on_activate_bookmark, 'online', 'a{sv}'),
|
||||||
|
('-open-event', app_actions.on_open_event, 'always', 'a{sv}'),
|
||||||
|
('-import-contacts', app_actions.on_import_contacts, 'online', 's'),
|
||||||
|
]
|
||||||
|
|
||||||
|
def add_account_actions(self, account):
|
||||||
|
for action in self._get_account_actions(account):
|
||||||
action_name, func, state, type_ = action
|
action_name, func, state, type_ = action
|
||||||
action_name = account + action_name
|
action_name = account + action_name
|
||||||
if self.lookup_action(action_name):
|
if self.lookup_action(action_name):
|
||||||
|
@ -383,14 +386,12 @@ class GajimApplication(Gtk.Application):
|
||||||
self.add_action(act)
|
self.add_action(act)
|
||||||
|
|
||||||
def remove_account_actions(self, account):
|
def remove_account_actions(self, account):
|
||||||
for action in self.account_actions:
|
for action in self._get_account_actions(account):
|
||||||
action_name = account + action[0]
|
action_name = account + action[0]
|
||||||
self.remove_action(action_name)
|
self.remove_action(action_name)
|
||||||
|
|
||||||
def set_account_actions_state(self, account, new_state=False):
|
def set_account_actions_state(self, account, new_state=False):
|
||||||
if account == 'Local':
|
for action in self._get_account_actions(account):
|
||||||
return
|
|
||||||
for action in self.account_actions:
|
|
||||||
action_name, _, state, _ = action
|
action_name, _, state, _ = action
|
||||||
if not new_state and state in ('online', 'feature'):
|
if not new_state and state in ('online', 'feature'):
|
||||||
# We go offline
|
# We go offline
|
||||||
|
|
|
@ -747,6 +747,10 @@ def get_account_menu(account):
|
||||||
]),
|
]),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
zeroconf_menu = [
|
||||||
|
('-xml-console', _('XML Console')),
|
||||||
|
]
|
||||||
|
|
||||||
def build_menu(preset):
|
def build_menu(preset):
|
||||||
menu = Gio.Menu()
|
menu = Gio.Menu()
|
||||||
for item in preset:
|
for item in preset:
|
||||||
|
@ -769,6 +773,8 @@ def get_account_menu(account):
|
||||||
menu.append_submenu(label, submenu)
|
menu.append_submenu(label, submenu)
|
||||||
return menu
|
return menu
|
||||||
|
|
||||||
|
if account == 'Local':
|
||||||
|
return build_menu(zeroconf_menu)
|
||||||
return build_menu(account_menu)
|
return build_menu(account_menu)
|
||||||
|
|
||||||
|
|
||||||
|
@ -781,7 +787,7 @@ def build_accounts_menu():
|
||||||
|
|
||||||
acc_menu = menubar.get_item_link(menu_position, 'submenu')
|
acc_menu = menubar.get_item_link(menu_position, 'submenu')
|
||||||
acc_menu.remove_all()
|
acc_menu.remove_all()
|
||||||
accounts_list = sorted(app.contacts.get_accounts(zeroconf=False))
|
accounts_list = sorted(app.contacts.get_accounts())
|
||||||
if not accounts_list:
|
if not accounts_list:
|
||||||
no_accounts = _('No Accounts available')
|
no_accounts = _('No Accounts available')
|
||||||
acc_menu.append_item(Gio.MenuItem.new(no_accounts, None))
|
acc_menu.append_item(Gio.MenuItem.new(no_accounts, None))
|
||||||
|
|
Loading…
Reference in New Issue