Commit 6f845266 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Port application menu to GMenu

parent eec1a69e
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkMenu" id="advanced_menuitem_menu">
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="xml_console_menuitem">
<property name="can_focus">False</property>
<property name="label" translatable="yes">Show _XML Console</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="archiving_preferences_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Edit Archi_ving Preferences</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="privacy_lists_menuitem">
<property name="can_focus">False</property>
<property name="label" translatable="yes">Edit _Privacy Lists...</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separator8">
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="administrator_menuitem">
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Administrator</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="administrator_menuitem_menu">
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="send_server_message_menuitem">
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Sends a message to users currently connected to this server</property>
<property name="label" translatable="yes">_Send Server Message...</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separator9">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="set_motd_menuitem">
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Sets Message of the Day</property>
<property name="label" translatable="yes">Set MOTD...</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="update_motd_menuitem">
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Updates Message of the Day</property>
<property name="label" translatable="yes">Update MOTD...</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="delete_motd_menuitem">
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Deletes Message of the Day</property>
<property name="label" translatable="yes">Delete MOTD</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<menu id="menubar">
<submenu>
<attribute name="label" translatable="yes">Accounts</attribute>
</submenu>
<submenu>
<attribute name="label" translatable="yes">View</attribute>
<section>
<item>
<attribute name="label" translatable="yes">Show Roster</attribute>
<attribute name="action">win.show-roster</attribute>
<attribute name="accel">&lt;Primary&gt;R</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Show Offline Contacts</attribute>
<attribute name="action">win.show-offline</attribute>
<attribute name="accel">&lt;Primary&gt;O</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Show Active Contacts</attribute>
<attribute name="action">win.show-active</attribute>
<attribute name="accel">&lt;Primary&gt;Y</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Show Transports</attribute>
<attribute name="action">win.show-transports</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">File Transfer</attribute>
<attribute name="action">app.file-transfer</attribute>
<attribute name="accel">&lt;Primary&gt;T</attribute>
</item>
<item>
<attribute name="label" translatable="yes">History</attribute>
<attribute name="action">app.history</attribute>
</item>
</section>
</submenu>
<submenu>
<attribute name="label" translatable="yes">Help</attribute>
<section>
<item>
<attribute name="label" translatable="yes">Contents</attribute>
<attribute name="action">app.content</attribute>
</item>
<item>
<attribute name="label" translatable="yes">FAQ</attribute>
<attribute name="action">app.faq</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Keyboard Shortcuts</attribute>
<attribute name="action">app.shortcuts</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Features</attribute>
<attribute name="action">app.features</attribute>
</item>
<item>
<attribute name="label" translatable="yes">About</attribute>
<attribute name="action">app.about</attribute>
</item>
</section>
</submenu>
</menu>
<menu id="appmenu">
<section>
<item>
<attribute name="label" translatable="yes">Accounts</attribute>
<attribute name="action">app.accounts</attribute>
<attribute name="accel">&lt;Primary&gt;&lt;Shift&gt;A</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Bookmarks</attribute>
<attribute name="action">app.bookmarks</attribute>
<attribute name="accel">&lt;Primary&gt;B</attribute>
</item>
<item>
<attribute name="label" translatable="yes">History Manager</attribute>
<attribute name="action">app.history-manager</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Plugins</attribute>
<attribute name="action">app.plugins</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Preferences</attribute>
<attribute name="action">app.preferences</attribute>
<attribute name="accel">&lt;Primary&gt;P</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Quit</attribute>
<attribute name="action">app.quit</attribute>
<attribute name="accel">&lt;Primary&gt;Q</attribute>
</item>
</section>
</menu>
</interface>
\ No newline at end of file
......@@ -25,304 +25,7 @@
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkMenuBar" id="menubar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="actions_menu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Actions</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_actions_menuitem_activate" swapped="no"/>
<child type="submenu">
<object class="GtkMenu" id="actions_menu_menu">
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="new_chat_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Start Chat...</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="send_single_message_menuitem">
<property name="can_focus">False</property>
<property name="label" translatable="yes">Send Single _Message...</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="join_gc_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Join _Group Chat</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separatormenuitem1">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="add_new_contact_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Add _Contact...</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="service_disco_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Discover Services</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="advanced_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Advanced</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separator1">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="quit_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">_Quit</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_quit_request" swapped="no"/>
<accelerator key="Q" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="edit_menu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Edit</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_edit_menuitem_activate" swapped="no"/>
<child type="submenu">
<object class="GtkMenu" id="edit_menu_menu">
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="accounts_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Accounts</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_accounts_menuitem_activate" swapped="no"/>
<accelerator key="A" signal="activate" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="profile_avatar_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Profile, A_vatar</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separator2">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="preferences_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">_Preferences</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_preferences_menuitem_activate" swapped="no"/>
<accelerator key="P" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="plugins_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">P_lugins</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_plugins_menuitem_activate" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="view_menu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_View</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_view_menu_activate" swapped="no"/>
<child type="submenu">
<object class="GtkMenu" id="view_menu_menu">
<property name="can_focus">False</property>
<child>
<object class="GtkCheckMenuItem" id="show_offline_contacts_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Show _Offline Contacts</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_show_offline_contacts_menuitem_activate" swapped="no"/>
<accelerator key="O" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
<child>
<object class="GtkCheckMenuItem" id="show_only_active_contacts_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Show Only _Active Contacts</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_show_only_active_contacts_menuitem_activate" swapped="no"/>
<accelerator key="Y" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
<child>
<object class="GtkCheckMenuItem" id="show_transports_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Show T_ransports</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_show_transports_menuitem_activate" swapped="no"/>
</object>
</child>
<child>
<object class="GtkCheckMenuItem" id="show_roster_menuitem">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Show _Roster</property>
<property name="use_underline">True</property>
<property name="active">True</property>
<signal name="toggled" handler="on_show_roster_menuitem_toggled" swapped="no"/>
<accelerator key="R" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separator3">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="file_transfers_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">File _Transfers</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_file_transfers_menuitem_activate" swapped="no"/>
<accelerator key="T" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="history_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_History</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_history_menuitem_activate" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="help_menu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Help</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="help_menu_menu">
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="contents_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Help online</property>
<property name="label" translatable="yes">_Contents</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_contents_menuitem_activate" swapped="no"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="faq_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Frequently Asked Questions (online)</property>
<property name="label" translatable="yes">_FAQ</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_faq_menuitem_activate" swapped="no"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="keyboard_shortcuts_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Keyboard Shortcuts</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_keyboard_shortcuts_menuitem_activate" swapped="no"/>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="menuitem1">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="features_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Fea_tures</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_features_menuitem_activate" swapped="no"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="about_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">_About</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_about_menuitem_activate" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
<placeholder/>
</child>
<child>
<object class="GtkPaned" id="roster_hpaned">
......
# -*- coding: utf-8 -*-
## src/app_actions.py
##
## Copyright (C) 2017 Philipp Hörist <philipp AT hoerist.com>
##
## 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
## 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
## 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/>.
##
from common import helpers
from common import gajim
from common.exceptions import GajimGeneralException
from gi.repository import Gtk
import sys
import os
import config
import dialogs
import features_window
import shortcuts_window
import plugins.gui
import history_window
import disco
class AppActions():
''' Action Callbacks '''
def __init__(self, app: Gtk.Application):
self.application = app
# Application Menu Actions
def on_preferences(self, action, param):
if 'preferences' in gajim.interface.instances:
gajim.interface.instances['preferences'].window.present()
else:
gajim.interface.instances['preferences'] = \
config.PreferencesWindow()
def on_plugins(self, action, param):
if 'plugins' in gajim.interface.instances:
gajim.interface.instances['plugins'].window.present()
else:
gajim.interface.instances['plugins'] = plugins.gui.PluginsWindow()
def on_accounts(self, action, param):
if 'accounts' in gajim.interface.instances:
gajim.interface.instances['accounts'].window.present()
else:
gajim.interface.instances['accounts'] = config.AccountsWindow()
def on_history_manager(self, action, param):
if os.name == 'nt':
if os.path.exists('history_manager.exe'):
# user is running frozen application
helpers.exec_command('history_manager.exe')
else:
# user is running from source
helpers.exec_command('%s history_manager.py' % sys.executable)
else:
# Unix user
helpers.exec_command('%s history_manager.py' % sys.executable)
def on_manage_bookmarks(self, action, param):
config.ManageBookmarksWindow()
def on_quit(self, action, param):
gajim.interface.roster.on_quit_request()
# Accounts Actions
def on_profile(self, action, param):
gajim.interface.edit_own_details(param.get_string())
def on_activate_bookmark(self, action, param):
dict_ = param.unpack()
account, jid, nick, password = \
dict_['account'], dict_['jid'], None, None
if 'nick' in dict_:
nick = dict_['nick']
if 'password' in dict_:
password = dict_['password']
gajim.interface.join_gc_room(account, jid, nick, password)
def on_send_server_message(self, action, param):
account = param.get_string()
server = gajim.config.get_per('accounts', account, 'hostname')
server += '/announce/online'
dialogs.SingleMessageWindow(account, server, 'send')
def on_service_disco(self, action, param):
account = param.get_string()
server_jid = gajim.config.get_per('accounts', account, 'hostname')
if server_jid in gajim.interface.instances[account]['disco']:
gajim.interface.instances[account]['disco'][server_jid].\
window.present()
else:
try:
# Object will add itself to the window dict
disco.ServiceDiscoveryWindow(account, address_entry=True)
except GajimGeneralException:
pass
def on_join_gc(<