def init(self): """ Init main application """ self.__is_fs = False if Gtk.get_minor_version() > 18: cssProviderFile = Gio.File.new_for_uri( 'resource:///org/gnome/Lollypop/application.css') else: cssProviderFile = Gio.File.new_for_uri( 'resource:///org/gnome/Lollypop/application-legacy.css') cssProvider = Gtk.CssProvider() cssProvider.load_from_file(cssProviderFile) screen = Gdk.Screen.get_default() styleContext = Gtk.StyleContext() styleContext.add_provider_for_screen(screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER) self.settings = Settings.new() self.db = Database() self.playlists = Playlists() # We store cursors for main thread SqlCursor.add(self.db) SqlCursor.add(self.playlists) self.albums = AlbumsDatabase() self.artists = ArtistsDatabase() self.genres = GenresDatabase() self.tracks = TracksDatabase() self.player = Player() self.scanner = CollectionScanner() self.art = Art() self.art.update_art_size() if self.settings.get_value('artist-artwork'): GLib.timeout_add(5000, self.art.cache_artists_info) if LastFM is not None: self.lastfm = LastFM() if not self.settings.get_value('disable-mpris'): # Ubuntu > 16.04 if Gtk.get_minor_version() > 18: from lollypop.mpris import MPRIS # Ubuntu <= 16.04, Debian Jessie, ElementaryOS else: from lollypop.mpris_legacy import MPRIS MPRIS(self) if not self.settings.get_value('disable-notifications'): from lollypop.notification import NotificationManager self.notify = NotificationManager() settings = Gtk.Settings.get_default() dark = self.settings.get_value('dark-ui') settings.set_property('gtk-application-prefer-dark-theme', dark) self.__parser = TotemPlParser.Parser.new() self.__parser.connect('entry-parsed', self.__on_entry_parsed) self.add_action(self.settings.create_action('shuffle')) self.db.upgrade()
def do_startup(self): Gtk.Application.do_startup(self) Notify.init("Lollypop") # Check locale, we want unicode! (code, encoding) = getlocale() if encoding is None or encoding != "UTF-8": builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/Unicode.ui') Objects.window = builder.get_object('unicode') Objects.window.set_application(self) Objects.window.show() elif not Objects.window: menu = self._setup_app_menu() # If GNOME, add appmenu if is_gnome(): self.set_app_menu(menu) Objects.window = Window(self) # If not GNOME add menu to toolbar if not is_gnome(): Objects.window.setup_menu(menu) Objects.window.connect('delete-event', self._hide_on_delete) if not Objects.settings.get_value('disable-mpris'): MPRIS(self) if not Objects.settings.get_value('disable-notifications'): NotificationManager() Objects.window.update_lists() Objects.window.update_db() Objects.window.show() Objects.player.restore_state()
def init(self): """ Init main application """ self.settings = Settings.new() # Mount enclosing volume as soon as possible uris = self.settings.get_music_uris() try: for uri in uris: if uri.startswith("file:/"): continue f = Gio.File.new_for_uri(uri) f.mount_enclosing_volume(Gio.MountMountFlags.NONE, None, None, None) except Exception as e: print("Application::init():", e) self.__is_fs = False cssProviderFile = Lio.File.new_for_uri( "resource:///org/gnome/Lollypop/application.css") cssProvider = Gtk.CssProvider() cssProvider.load_from_file(cssProviderFile) screen = Gdk.Screen.get_default() styleContext = Gtk.StyleContext() styleContext.add_provider_for_screen(screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER) self.db = Database() self.playlists = Playlists() # We store cursors for main thread SqlCursor.add(self.db) SqlCursor.add(self.playlists) self.albums = AlbumsDatabase() self.artists = ArtistsDatabase() self.genres = GenresDatabase() self.tracks = TracksDatabase() self.player = Player() self.scanner = CollectionScanner() self.art = Art() self.notify = NotificationManager() self.art.update_art_size() if self.settings.get_value("artist-artwork"): GLib.timeout_add(5000, self.art.cache_artists_info) if LastFM is not None: self.lastfm = LastFM() if not self.settings.get_value("disable-mpris"): from lollypop.mpris import MPRIS MPRIS(self) settings = Gtk.Settings.get_default() self.__gtk_dark = settings.get_property( "gtk-application-prefer-dark-theme") if not self.__gtk_dark: dark = self.settings.get_value("dark-ui") settings.set_property("gtk-application-prefer-dark-theme", dark) # Map some settings to actions self.add_action(self.settings.create_action("playback")) self.add_action(self.settings.create_action("shuffle")) self.db.upgrade()
def init(self): """ Init main application """ self.settings = Settings.new() # Mount enclosing volume as soon as possible uris = self.settings.get_music_uris() try: for uri in uris: if uri.startswith("file:/"): continue f = Gio.File.new_for_uri(uri) f.mount_enclosing_volume(Gio.MountMountFlags.NONE, None, None, None) except Exception as e: Logger.error("Application::init(): %s" % e) cssProviderFile = Gio.File.new_for_uri( "resource:///org/gnome/Lollypop/application.css") cssProvider = Gtk.CssProvider() cssProvider.load_from_file(cssProviderFile) screen = Gdk.Screen.get_default() styleContext = Gtk.StyleContext() styleContext.add_provider_for_screen(screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER) self.db = Database() self.playlists = Playlists() self.albums = AlbumsDatabase() self.artists = ArtistsDatabase() self.genres = GenresDatabase() self.tracks = TracksDatabase() self.player = Player() self.inhibitor = Inhibitor() self.scanner = CollectionScanner() self.art = Art() self.notify = NotificationManager() self.art.update_art_size() self.task_helper = TaskHelper() self.art_helper = ArtHelper() self.spotify = SpotifyHelper() if not self.settings.get_value("disable-mpris"): from lollypop.mpris import MPRIS MPRIS(self) settings = Gtk.Settings.get_default() self.__gtk_dark = settings.get_property( "gtk-application-prefer-dark-theme") if not self.__gtk_dark: dark = self.settings.get_value("dark-ui") settings.set_property("gtk-application-prefer-dark-theme", dark) ApplicationActions.__init__(self) startup_one_ids = self.settings.get_value("startup-one-ids") startup_two_ids = self.settings.get_value("startup-two-ids") if startup_one_ids: self.settings.set_value("state-one-ids", startup_one_ids) self.settings.set_value("state-three-ids", GLib.Variant("ai", [])) if startup_two_ids: self.settings.set_value("state-two-ids", startup_two_ids)
def init(self): """ Init main application """ self.settings = Settings.new() # Mount enclosing volume as soon as possible uris = self.settings.get_music_uris() try: for uri in uris: if uri.startswith("file:/"): continue f = Gio.File.new_for_uri(uri) f.mount_enclosing_volume(Gio.MountMountFlags.NONE, None, None, None) except Exception as e: Logger.error("Application::init(): %s" % e) cssProviderFile = Gio.File.new_for_uri( "resource:///org/gnome/Lollypop/application.css") cssProvider = Gtk.CssProvider() cssProvider.load_from_file(cssProviderFile) screen = Gdk.Screen.get_default() styleContext = Gtk.StyleContext() styleContext.add_provider_for_screen(screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER) self.db = Database() self.cache = CacheDatabase() self.playlists = Playlists() self.albums = AlbumsDatabase(self.db) self.artists = ArtistsDatabase(self.db) self.genres = GenresDatabase(self.db) self.tracks = TracksDatabase(self.db) self.player = Player() self.inhibitor = Inhibitor() self.scanner = CollectionScanner() self.notify = NotificationManager() self.task_helper = TaskHelper() self.art_helper = ArtHelper() self.art = Art() self.art.update_art_size() self.ws_director = DirectorWebService() self.ws_director.start() if not self.settings.get_value("disable-mpris"): from lollypop.mpris import MPRIS MPRIS(self) settings = Gtk.Settings.get_default() self.__gtk_dark = settings.get_property( "gtk-application-prefer-dark-theme") if not self.__gtk_dark: dark = self.settings.get_value("dark-ui") settings.set_property("gtk-application-prefer-dark-theme", dark) ApplicationActions.__init__(self) monitor = Gio.NetworkMonitor.get_default() if monitor.get_network_available() and\ not monitor.get_network_metered() and\ self.settings.get_value("recent-youtube-dl"): self.task_helper.run(install_youtube_dl)
def __init__(self): """ Create application """ Gtk.Application.__init__(self, application_id='org.gnome.Lollypop', flags=Gio.ApplicationFlags.FLAGS_NONE) self._init_proxy() GLib.set_application_name('lollypop') GLib.set_prgname('lollypop') self.set_flags(Gio.ApplicationFlags.HANDLES_OPEN) # TODO: Remove this test later if Gtk.get_minor_version() > 12: self.add_main_option("debug", b'd', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Debug lollypop", None) self.connect('handle-local-options', self._on_handle_local_options) cssProviderFile = Gio.File.new_for_uri( 'resource:///org/gnome/Lollypop/application.css') cssProvider = Gtk.CssProvider() cssProvider.load_from_file(cssProviderFile) screen = Gdk.Screen.get_default() styleContext = Gtk.StyleContext() styleContext.add_provider_for_screen(screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER) Lp.settings = Settings.new() if LastFM is not None: Lp.lastfm = LastFM() Lp.db = Database() # We store a cursor for the main thread Lp.sql = Lp.db.get_cursor() Lp.player = Player() Lp.albums = AlbumsDatabase() Lp.artists = ArtistsDatabase() Lp.genres = GenresDatabase() Lp.tracks = TracksDatabase() Lp.playlists = PlaylistsManager() Lp.scanner = CollectionScanner() Lp.art = Art() if not Lp.settings.get_value('disable-mpris'): MPRIS(self) if not Lp.settings.get_value('disable-notifications'): Lp.notify = NotificationManager() settings = Gtk.Settings.get_default() dark = Lp.settings.get_value('dark-ui') settings.set_property('gtk-application-prefer-dark-theme', dark) self._parser = TotemPlParser.Parser.new() self._parser.connect('entry-parsed', self._on_entry_parsed) self.add_action(Lp.settings.create_action('shuffle')) self._externals_count = 0 self._is_fs = False self.register(None) if self.get_is_remote(): Gdk.notify_startup_complete()
def init(self): """ Init main application """ cssProviderFile = Gio.File.new_for_uri( 'resource:///org/gnome/Lollypop/application.css') cssProvider = Gtk.CssProvider() cssProvider.load_from_file(cssProviderFile) screen = Gdk.Screen.get_default() styleContext = Gtk.StyleContext() styleContext.add_provider_for_screen(screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER) self.settings = Settings.new() ArtSize.BIG = self.settings.get_value('cover-size').get_int32() if LastFM is not None: self.lastfm = LastFM() self.db = Database() self.playlists = Playlists() # We store cursors for main thread SqlCursor.add(self.db) SqlCursor.add(self.playlists) self.albums = AlbumsDatabase() self.artists = ArtistsDatabase() self.genres = GenresDatabase() self.tracks = TracksDatabase() self.player = Player() self.scanner = CollectionScanner() self.art = Art() if not self.settings.get_value('disable-mpris'): MPRIS(self) if not self.settings.get_value('disable-mpd'): self.mpd = MpdServerDaemon( self.settings.get_value('mpd-eth').get_string(), self.settings.get_value('mpd-port').get_int32()) if not self.settings.get_value('disable-notifications'): self.notify = NotificationManager() settings = Gtk.Settings.get_default() dark = self.settings.get_value('dark-ui') settings.set_property('gtk-application-prefer-dark-theme', dark) self._parser = TotemPlParser.Parser.new() self._parser.connect('entry-parsed', self._on_entry_parsed) self.add_action(self.settings.create_action('shuffle')) self._is_fs = False
class Application(Gtk.Application): """ Lollypop application: - Handle appmenu - Handle command line - Create main window """ def __init__(self): """ Create application """ Gtk.Application.__init__( self, application_id='org.gnome.Lollypop', flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE) GLib.setenv('PULSE_PROP_media.role', 'music', True) GLib.setenv('PULSE_PROP_application.icon_name', 'lollypop', True) self.cursors = {} self.window = None self.notify = None self.lastfm = None self.debug = False self.__externals_count = 0 self.__init_proxy() GLib.set_application_name('lollypop') GLib.set_prgname('lollypop') # TODO: Remove this test later if Gtk.get_minor_version() > 12: self.add_main_option("debug", b'd', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Debug lollypop", None) self.add_main_option("set-rating", b'r', GLib.OptionFlags.NONE, GLib.OptionArg.INT, "Rate the current track", None) self.add_main_option("play-pause", b't', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Toggle playback", None) self.add_main_option("next", b'n', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Go to next track", None) self.add_main_option("prev", b'p', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Go to prev track", None) self.add_main_option("emulate-phone", b'e', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Emulate an Android Phone", None) self.connect('command-line', self.__on_command_line) self.connect('activate', self.__on_activate) self.register(None) if self.get_is_remote(): Gdk.notify_startup_complete() def init(self): """ Init main application """ self.__is_fs = False if Gtk.get_minor_version() > 18: cssProviderFile = Gio.File.new_for_uri( 'resource:///org/gnome/Lollypop/application.css') else: cssProviderFile = Gio.File.new_for_uri( 'resource:///org/gnome/Lollypop/application-legacy.css') cssProvider = Gtk.CssProvider() cssProvider.load_from_file(cssProviderFile) screen = Gdk.Screen.get_default() styleContext = Gtk.StyleContext() styleContext.add_provider_for_screen(screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER) self.settings = Settings.new() self.db = Database() self.playlists = Playlists() # We store cursors for main thread SqlCursor.add(self.db) SqlCursor.add(self.playlists) self.albums = AlbumsDatabase() self.artists = ArtistsDatabase() self.genres = GenresDatabase() self.tracks = TracksDatabase() self.player = Player() self.scanner = CollectionScanner() self.art = Art() self.art.update_art_size() if self.settings.get_value('artist-artwork'): GLib.timeout_add(5000, self.art.cache_artists_info) if LastFM is not None: self.lastfm = LastFM() if not self.settings.get_value('disable-mpris'): # Ubuntu > 16.04 if Gtk.get_minor_version() > 18: from lollypop.mpris import MPRIS # Ubuntu <= 16.04, Debian Jessie, ElementaryOS else: from lollypop.mpris_legacy import MPRIS MPRIS(self) if not self.settings.get_value('disable-notifications'): from lollypop.notification import NotificationManager self.notify = NotificationManager() settings = Gtk.Settings.get_default() dark = self.settings.get_value('dark-ui') settings.set_property('gtk-application-prefer-dark-theme', dark) self.__parser = TotemPlParser.Parser.new() self.__parser.connect('entry-parsed', self.__on_entry_parsed) self.add_action(self.settings.create_action('shuffle')) self.db.upgrade() def do_startup(self): """ Init application """ Gtk.Application.do_startup(self) Notify.init("Lollypop") # Check locale, we want unicode! (code, encoding) = getlocale() if encoding is None or encoding != "UTF-8": builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/Unicode.ui') self.window = builder.get_object('unicode') self.window.set_application(self) self.window.show() elif not self.window: self.init() menu = self.__setup_app_menu() # If GNOME/Unity, add appmenu if is_gnome() or is_unity(): self.set_app_menu(menu) self.window = Window(self) # If not GNOME/Unity add menu to toolbar if not is_gnome() and not is_unity(): self.window.setup_menu(menu) self.window.connect('delete-event', self.__hide_on_delete) self.window.init_list_one() self.window.show() self.player.restore_state() # We add to mainloop as we want to run # after player::restore_state() signals GLib.idle_add(self.window.toolbar.set_mark) # Will not start sooner # Ubuntu > 16.04 if Gtk.get_minor_version() > 18: from lollypop.inhibitor import Inhibitor # Ubuntu <= 16.04, Debian Jessie, ElementaryOS else: from lollypop.inhibitor_legacy import Inhibitor self.inhibitor = Inhibitor() self.charts = None if self.settings.get_value('network-search'): if GLib.find_program_in_path("youtube-dl") is not None: from lollypop.charts import Charts self.charts = Charts() if get_network_available(): self.charts.update() cs_api_key = self.settings.get_value( 'cs-api-key').get_string() default_cs_api_key = self.settings.get_default_value( 'cs-api-key').get_string() if (not cs_api_key or cs_api_key == default_cs_api_key) and\ self.notify is not None: self.notify.send( _("Google Web Services need a custom API key"), _("Lollypop needs this to search artwork and music.")) else: self.settings.set_value('network-search', GLib.Variant('b', False)) def prepare_to_exit(self, action=None, param=None): """ Save window position and view """ if self.__is_fs: return if self.settings.get_value('save-state'): self.window.save_view_state() # Save current track if self.player.current_track.id is None: track_id = -1 elif self.player.current_track.id == Type.RADIOS: from lollypop.radios import Radios radios = Radios() track_id = radios.get_id( self.player.current_track.album_artists[0]) else: track_id = self.player.current_track.id # Save albums context try: dump(self.player.context.genre_ids, open(DataPath + "/genre_ids.bin", "wb")) dump(self.player.context.artist_ids, open(DataPath + "/artist_ids.bin", "wb")) self.player.shuffle_albums(False) dump(self.player.get_albums(), open(DataPath + "/albums.bin", "wb")) except Exception as e: print("Application::prepare_to_exit()", e) dump(track_id, open(DataPath + "/track_id.bin", "wb")) # Save current playlist if self.player.current_track.id == Type.RADIOS: playlist_ids = [Type.RADIOS] elif not self.player.get_user_playlist_ids(): playlist_ids = [] else: playlist_ids = self.player.get_user_playlist_ids() dump(playlist_ids, open(DataPath + "/playlist_ids.bin", "wb")) if self.player.current_track.id is not None: position = self.player.position else: position = 0 dump(position, open(DataPath + "/position.bin", "wb")) self.player.stop_all() if self.window: self.window.stop_all() self.quit() def quit(self): """ Quit lollypop """ if self.scanner.is_locked(): self.scanner.stop() GLib.idle_add(self.quit) return self.db.del_tracks(self.tracks.get_non_persistent()) try: from lollypop.radios import Radios with SqlCursor(self.db) as sql: sql.execute('VACUUM') with SqlCursor(self.playlists) as sql: sql.execute('VACUUM') with SqlCursor(Radios()) as sql: sql.execute('VACUUM') except Exception as e: print("Application::quit(): ", e) self.window.destroy() def is_fullscreen(self): """ Return True if application is fullscreen """ return self.__is_fs def set_mini(self, action, param): """ Set mini player on/off @param dialog as Gtk.Dialog @param response id as int """ if self.window is not None: self.window.set_mini() ####################### # PRIVATE # ####################### def __init_proxy(self): """ Init proxy setting env """ try: settings = Gio.Settings.new('org.gnome.system.proxy.http') h = settings.get_value('host').get_string() p = settings.get_value('port').get_int32() if h != '' and p != 0: GLib.setenv('http_proxy', "%s:%s" % (h, p), True) GLib.setenv('https_proxy', "%s:%s" % (h, p), True) except: pass def __on_command_line(self, app, app_cmd_line): """ Handle command line @param app as Gio.Application @param options as Gio.ApplicationCommandLine """ self.__externals_count = 0 options = app_cmd_line.get_options_dict() if options.contains('debug'): self.debug = True if options.contains('set-rating'): value = options.lookup_value('set-rating').get_int32() if value > 0 and value < 6 and\ self.player.current_track.id is not None: self.player.current_track.set_popularity(value) if options.contains('play-pause'): self.player.play_pause() elif options.contains('next'): self.player.next() elif options.contains('prev'): self.player.prev() elif options.contains('emulate-phone'): self.window.add_fake_phone() args = app_cmd_line.get_arguments() if len(args) > 1: self.player.clear_externals() for f in args[1:]: try: f = GLib.filename_to_uri(f) except: pass self.__parser.parse_async(f, True, None, None) if self.window is not None and not self.window.is_visible(): self.window.setup_window() self.window.present() return 0 def __on_entry_parsed(self, parser, uri, metadata): """ Add playlist entry to external files @param parser as TotemPlParser.Parser @param track uri as str @param metadata as GLib.HastTable """ self.player.load_external(uri) if self.__externals_count == 0: if self.player.is_party: self.player.set_party(False) self.player.play_first_external() self.__externals_count += 1 def __hide_on_delete(self, widget, event): """ Hide window @param widget as Gtk.Widget @param event as Gdk.Event """ if not self.settings.get_value('background-mode'): GLib.timeout_add(500, self.prepare_to_exit) self.scanner.stop() return widget.hide_on_delete() def __update_db(self, action=None, param=None): """ Search for new music @param action as Gio.SimpleAction @param param as GLib.Variant """ if self.window: t = Thread(target=self.art.clean_all_cache) t.daemon = True t.start() self.window.update_db() def __set_network(self, action, param): """ Enable/disable network @param action as Gio.SimpleAction @param param as GLib.Variant """ action.set_state(param) self.settings.set_value('network-access', param) if self.charts is not None: if param.get_boolean(): self.charts.update() else: self.charts.stop() self.window.reload_view() def __fullscreen(self, action=None, param=None): """ Show a fullscreen window with cover and artist informations @param action as Gio.SimpleAction @param param as GLib.Variant """ if self.window and not self.__is_fs: from lollypop.fullscreen import FullScreen fs = FullScreen(self, self.window) fs.connect("destroy", self.__on_fs_destroyed) self.__is_fs = True fs.show() def __on_fs_destroyed(self, widget): """ Mark fullscreen as False @param widget as Fullscreen """ self.__is_fs = False if not self.window.is_visible(): self.prepare_to_exit() def __on_activate(self, application): """ Call default handler @param application as Gio.Application """ self.window.present() def __settings_dialog(self, action=None, param=None): """ Show settings dialog @param action as Gio.SimpleAction @param param as GLib.Variant """ dialog = SettingsDialog() dialog.show() def __about(self, action, param): """ Setup about dialog @param action as Gio.SimpleAction @param param as GLib.Variant """ builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/AboutDialog.ui') about = builder.get_object('about_dialog') about.set_transient_for(self.window) about.connect("response", self.__about_response) about.show() def __shortcuts(self, action, param): """ Show help in yelp @param action as Gio.SimpleAction @param param as GLib.Variant """ try: builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/Shortcuts.ui') builder.get_object('shortcuts').set_transient_for(self.window) builder.get_object('shortcuts').show() except: # GTK < 3.20 self.__help(action, param) def __help(self, action, param): """ Show help in yelp @param action as Gio.SimpleAction @param param as GLib.Variant """ try: Gtk.show_uri(None, "help:lollypop", Gtk.get_current_event_time()) except: print(_("Lollypop: You need to install yelp.")) def __about_response(self, dialog, response_id): """ Destroy about dialog when closed @param dialog as Gtk.Dialog @param response id as int """ dialog.destroy() def __setup_app_menu(self): """ Setup application menu @return menu as Gio.Menu """ builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/Appmenu.ui') menu = builder.get_object('app-menu') settingsAction = Gio.SimpleAction.new('settings', None) settingsAction.connect('activate', self.__settings_dialog) self.set_accels_for_action('app.settings', ["<Control>s"]) self.add_action(settingsAction) updateAction = Gio.SimpleAction.new('update_db', None) updateAction.connect('activate', self.__update_db) self.set_accels_for_action('app.update_db', ["<Control>u"]) self.add_action(updateAction) networkAction = Gio.SimpleAction.new_stateful( 'network', None, GLib.Variant.new_boolean(self.settings.get_value('network-access'))) networkAction.connect('change-state', self.__set_network) self.add_action(networkAction) fsAction = Gio.SimpleAction.new('fullscreen', None) fsAction.connect('activate', self.__fullscreen) self.set_accels_for_action('app.fullscreen', ["F11", "F7"]) self.add_action(fsAction) mini_action = Gio.SimpleAction.new('mini', None) mini_action.connect('activate', self.set_mini) self.add_action(mini_action) self.set_accels_for_action("app.mini", ["<Control>m"]) aboutAction = Gio.SimpleAction.new('about', None) aboutAction.connect('activate', self.__about) self.set_accels_for_action('app.about', ["F3"]) self.add_action(aboutAction) shortcutsAction = Gio.SimpleAction.new('shortcuts', None) shortcutsAction.connect('activate', self.__shortcuts) self.set_accels_for_action('app.shortcuts', ["F2"]) self.add_action(shortcutsAction) helpAction = Gio.SimpleAction.new('help', None) helpAction.connect('activate', self.__help) self.set_accels_for_action('app.help', ["F1"]) self.add_action(helpAction) quitAction = Gio.SimpleAction.new('quit', None) quitAction.connect('activate', self.prepare_to_exit) self.set_accels_for_action('app.quit', ["<Control>q"]) self.add_action(quitAction) return menu