class Application(Gtk.Application): def __init__(self): Gtk.Application.__init__(self, application_id='org.gnome.Music', flags=Gio.ApplicationFlags.FLAGS_NONE) GLib.set_application_name(_("Music")) cssProviderFile = Gio.File.new_for_uri('resource:///org/gnome/Music/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._window = None def do_startup(self): Gtk.Application.do_startup(self) def do_activate(self): if not self._window: self._window = Window(self) self.service = MediaPlayer2Service(self) self._window.present() def quit(self): self._window.destroy()
def do_activate(self): if not self._window: self._window = Window(self) self.service = MediaPlayer2Service(self) self._notifications = NotificationManager(self._window.player) self._window.present()
def do_activate(self): if not self._window: self._window = Window(self) MediaPlayer2Service(self) if self._settings.get_value('notifications'): self._notifications = NotificationManager(self._window.player) self._window.present()
def do_activate(self): if not self._window: self._window = Window(self) self._window.set_default_icon_name(self._application_id) if self._application_id == 'org.gnome.MusicDevel': self._window.get_style_context().add_class('devel') MediaPlayer2Service(self) self._window.present()
def do_activate(self): if not self._window: self._window = Window(self) self.notify("window") self._window.set_default_icon_name(self.props.application_id) if self.props.application_id == "org.gnome.Music.Devel": self._window.get_style_context().add_class('devel') MPRIS(self) self._window.present()
def do_activate(self): if not self._window: self._window = Window(self) self._window.set_default_icon_name(self._application_id) if self._application_id == 'org.gnome.MusicDevel': self._window.get_style_context().add_class('devel') MediaPlayer2Service(self) # gtk_window_present does not work on Wayland. # Use gtk_present_with_time as a workaround instead. # See https://gitlab.gnome.org/GNOME/gtk/issues/624#note_10996 self._window.present_with_time(GLib.get_monotonic_time() / 1000)
def do_activate(self): if not self._window: self._window = Window(self) self.service = MediaPlayer2Service(self) if self.settings.get_value('notifications'): self._notifications = NotificationManager(self._window.player) self._window.present()
def do_activate(self): if not self._window: self._window = Window(self) self.service = MediaPlayer2Service(self) self._window.present()
class Application(Gtk.Application): def __init__(self): Gtk.Application.__init__(self, application_id='org.gnome.Music', flags=Gio.ApplicationFlags.FLAGS_NONE) GLib.set_application_name(_("Music")) cssProviderFile = Gio.File.new_for_uri('resource:///org/gnome/Music/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._window = None def build_app_menu(self): builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Music/app-menu.ui') menu = builder.get_object('app-menu') self.set_app_menu(menu) aboutAction = Gio.SimpleAction.new('about', None) aboutAction.connect('activate', self.about) self.add_action(aboutAction) newPlaylistAction = Gio.SimpleAction.new('newPlaylist', None) newPlaylistAction.connect('activate', self.new_playlist) self.add_action(newPlaylistAction) nowPlayingAction = Gio.SimpleAction.new('nowPlaying', None) nowPlayingAction.connect('activate', self.now_playing) self.add_action(nowPlayingAction) quitAction = Gio.SimpleAction.new('quit', None) quitAction.connect('activate', self.quit) self.add_action(quitAction) def new_playlist(self, action, param): pass def now_playing(self, action, param): pass def about(self, action, param): builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Music/AboutDialog.ui') about = builder.get_object('about_dialog') about.set_version("0.3") about.connect("response", self.about_response) about.show() def about_response(self, dialog, response): dialog.destroy() def do_startup(self): Gtk.Application.do_startup(self) self.build_app_menu() def quit(self, action, param): self._window.destroy() def do_activate(self): if not self._window: self._window = Window(self) self.service = MediaPlayer2Service(self) self._window.present()
class Application(Gtk.Application): def __repr__(self): return '<Application>' @log def __init__(self): Gtk.Application.__init__(self, application_id='org.gnome.Music', flags=Gio.ApplicationFlags.FLAGS_NONE) GLib.set_application_name(_("Music")) GLib.set_prgname('gnome-music') self.settings = Gio.Settings.new('org.gnome.Music') cssProviderFile = Gio.File.new_for_uri('resource:///org/gnome/Music/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._window = None @log def build_app_menu(self): builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Music/app-menu.ui') menu = builder.get_object('app-menu') self.set_app_menu(menu) aboutAction = Gio.SimpleAction.new('about', None) aboutAction.connect('activate', self.about) self.add_action(aboutAction) helpAction = Gio.SimpleAction.new('help', None) helpAction.connect('activate', self.help) self.add_action(helpAction) newPlaylistAction = Gio.SimpleAction.new('newPlaylist', None) newPlaylistAction.connect('activate', self.new_playlist) self.add_action(newPlaylistAction) quitAction = Gio.SimpleAction.new('quit', None) quitAction.connect('activate', self.quit) self.add_action(quitAction) @log def new_playlist(self, action, param): pass @log def help(self, action, param): Gtk.show_uri(None, "help:gnome-music", Gdk.CURRENT_TIME) @log def about(self, action, param): builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Music/AboutDialog.ui') about = builder.get_object('about_dialog') about.set_transient_for(self._window) about.connect("response", self.about_response) about.show() @log def about_response(self, dialog, response): dialog.destroy() @log def do_startup(self): Gtk.Application.do_startup(self) Notify.init(_("Music")) self.build_app_menu() @log def quit(self, action=None, param=None): self._window.destroy() def do_activate(self): if not self._window: self._window = Window(self) self.service = MediaPlayer2Service(self) if self.settings.get_value('notifications'): self._notifications = NotificationManager(self._window.player) self._window.present()
class Application(Gtk.Application): def __repr__(self): return '<Application>' @log def __init__(self): Gtk.Application.__init__(self, application_id='org.gnome.Music', flags=Gio.ApplicationFlags.FLAGS_NONE) GLib.set_application_name(_("Music")) GLib.set_prgname('gnome-music') self._settings = Gio.Settings.new('org.gnome.Music') self._init_style() self._window = None def _init_style(self): css_provider_file = Gio.File.new_for_uri( 'resource:///org/gnome/Music/application.css') css_provider = Gtk.CssProvider() css_provider.load_from_file(css_provider_file) screen = Gdk.Screen.get_default() style_context = Gtk.StyleContext() style_context.add_provider_for_screen( screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) @log def _build_app_menu(self): action_entries = [ ('about', self._about), ('help', self._help), ('quit', self.quit), ] for action, callback in action_entries: simple_action = Gio.SimpleAction.new(action, None) simple_action.connect('activate', callback) self.add_action(simple_action) @log def _help(self, action, param): Gtk.show_uri(None, "help:gnome-music", Gdk.CURRENT_TIME) @log def _about(self, action, param): def about_response(dialog, response): dialog.destroy() builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Music/AboutDialog.ui') about = builder.get_object('about_dialog') about.set_transient_for(self._window) about.connect("response", about_response) about.show() @log def do_startup(self): Gtk.Application.do_startup(self) Notify.init(_("Music")) self._build_app_menu() @log def quit(self, action=None, param=None): self._window.destroy() def do_activate(self): if not self._window: self._window = Window(self) MediaPlayer2Service(self) if self._settings.get_value('notifications'): self._notifications = NotificationManager(self._window.player) self._window.present()
class Application(Gtk.Application): def __repr__(self): return "<Application>" @log def __init__(self): Gtk.Application.__init__(self, application_id="org.gnome.Music", flags=Gio.ApplicationFlags.FLAGS_NONE) GLib.set_application_name(_("Music")) GLib.set_prgname("gnome-music") self.settings = Gio.Settings.new("org.gnome.Music") cssProviderFile = Gio.File.new_for_uri("resource:///org/gnome/Music/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._window = None @log def build_app_menu(self): actionEntries = [ ("about", self.about), ("help", self.help), ("newPlaylist", self.new_playlist), ("quit", self.quit), ] for action, callback in actionEntries: simpleAction = Gio.SimpleAction.new(action, None) simpleAction.connect("activate", callback) self.add_action(simpleAction) @log def new_playlist(self, action, param): pass @log def help(self, action, param): Gtk.show_uri(None, "help:gnome-music", Gdk.CURRENT_TIME) @log def about(self, action, param): builder = Gtk.Builder() builder.add_from_resource("/org/gnome/Music/AboutDialog.ui") about = builder.get_object("about_dialog") about.set_transient_for(self._window) about.connect("response", self.about_response) about.show() @log def about_response(self, dialog, response): dialog.destroy() @log def do_startup(self): Gtk.Application.do_startup(self) Notify.init(_("Music")) self.build_app_menu() @log def quit(self, action=None, param=None): self._window.destroy() def do_activate(self): if not self._window: self._window = Window(self) self.service = MediaPlayer2Service(self) if self.settings.get_value("notifications"): self._notifications = NotificationManager(self._window.player) self._window.present()
class Application(Gtk.Application): def __repr__(self): return '<Application>' @log def __init__(self, application_id): super().__init__( application_id=application_id, flags=Gio.ApplicationFlags.FLAGS_NONE) self.props.resource_base_path = "/org/gnome/Music" GLib.set_application_name(_("Music")) GLib.set_prgname(application_id) GLib.setenv("PULSE_PROP_media.role", "music", True) self._init_style() self._window = None self._application_id = application_id def _init_style(self): css_provider = Gtk.CssProvider() css_provider.load_from_resource('/org/gnome/Music/org.gnome.Music.css') screen = Gdk.Screen.get_default() style_context = Gtk.StyleContext() style_context.add_provider_for_screen( screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) @log def _build_app_menu(self): action_entries = [ ('about', self._about), ('help', self._help) ] for action, callback in action_entries: simple_action = Gio.SimpleAction.new(action, None) simple_action.connect('activate', callback) self.add_action(simple_action) @log def _help(self, action, param): try: Gtk.show_uri(None, "help:gnome-music", Gdk.CURRENT_TIME) except GLib.Error: logging.warning("Help handler not available.") @log def _about(self, action, param): about = AboutDialog() about.props.transient_for = self._window @log def do_startup(self): Gtk.Application.do_startup(self) self._build_app_menu() @log def quit(self, action=None, param=None): self._window.destroy() def do_activate(self): if not self._window: self._window = Window(self) self._window.set_default_icon_name(self._application_id) if self._application_id == 'org.gnome.MusicDevel': self._window.get_style_context().add_class('devel') MediaPlayer2Service(self) self._window.present()
class Application(Gtk.Application): def __init__(self, application_id): super().__init__(application_id=application_id, flags=Gio.ApplicationFlags.FLAGS_NONE) self.props.resource_base_path = "/org/gnome/Music" GLib.set_application_name(_("Music")) GLib.set_prgname(application_id) GLib.setenv("PULSE_PROP_media.role", "music", True) self._init_style() self._window = None self._log = MusicLogger() self._search = Search() self._notificationmanager = NotificationManager(self) self._coreselection = CoreSelection() self._coremodel = CoreModel(self) # Order is important: CoreGrilo initializes the Grilo sources, # which in turn use CoreModel & CoreSelection extensively. self._coregrilo = CoreGrilo(self) self._settings = Gio.Settings.new('org.gnome.Music') self._lastfm_scrobbler = LastFmScrobbler(self) self._player = Player(self) InhibitSuspend(self) PauseOnSuspend(self._player) def _init_style(self): css_provider = Gtk.CssProvider() css_provider.load_from_resource('/org/gnome/Music/org.gnome.Music.css') screen = Gdk.Screen.get_default() style_context = Gtk.StyleContext() style_context.add_provider_for_screen( screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) @GObject.Property(type=CoreGrilo, default=None, flags=GObject.ParamFlags.READABLE) def coregrilo(self): """Get application-wide CoreGrilo instance. :returns: The grilo wrapper :rtype: CoreGrilo """ return self._coregrilo @GObject.Property(type=MusicLogger, default=None, flags=GObject.ParamFlags.READABLE) def log(self): """Get application-wide logging facility. :returns: the logger :rtype: MusicLogger """ return self._log @GObject.Property(type=Player, default=None, flags=GObject.ParamFlags.READABLE) def player(self): """Get application-wide music player. :returns: the player :rtype: Player """ return self._player @GObject.Property(type=Gio.Settings, flags=GObject.ParamFlags.READABLE) def settings(self): """Get application-wide settings. :returns: settings :rtype: Gio.settings """ return self._settings @GObject.Property(type=CoreModel, flags=GObject.ParamFlags.READABLE) def coremodel(self): """Get class providing all listmodels. :returns: List model provider class :rtype: CoreModel """ return self._coremodel @GObject.Property(type=CoreSelection, flags=GObject.ParamFlags.READABLE) def coreselection(self): """Get selection object. :returns: Object containing all selection info :rtype: CoreSelection """ return self._coreselection @GObject.Property(type=LastFmScrobbler, flags=GObject.ParamFlags.READABLE) def lastfm_scrobbler(self): """Get Last.fm scrobbler. :returns: Last.fm scrobbler :rtype: LastFmScrobbler """ return self._lastfm_scrobbler @GObject.Property(type=Window, flags=GObject.ParamFlags.READABLE) def window(self): """Get main window. :returns: Main window. :rtype: Window """ return self._window @GObject.Property(type=Search, flags=GObject.ParamFlags.READABLE) def search(self): """Get class providing search logic. :returns: List model provider class :rtype: Search """ return self._search @GObject.Property(type=NotificationManager, flags=GObject.ParamFlags.READABLE) def notificationmanager(self): """Get notification manager :returns: notification manager :rtype: NotificationManager """ return self._notificationmanager def _set_actions(self): action_entries = [('about', self._about, None), ("help", self._help, ("app.help", ["F1"])), ("lastfm-configure", self._lastfm_account, None), ("quit", self._quit, ("app.quit", ["<Ctrl>Q"]))] for action, callback, accel in action_entries: simple_action = Gio.SimpleAction.new(action, None) simple_action.connect('activate', callback) self.add_action(simple_action) if accel is not None: self.set_accels_for_action(*accel) def _help(self, action, param): try: Gtk.show_uri(None, "help:gnome-music", Gdk.CURRENT_TIME) except GLib.Error: self._log.message("Help handler not available.") def _lastfm_account(self, action, param): lastfm_dialog = LastfmDialog(self._window, self._lastfm_scrobbler) lastfm_dialog.run() lastfm_dialog.destroy() def _about(self, action, param): about = AboutDialog() about.props.transient_for = self._window about.present() def do_startup(self): Gtk.Application.do_startup(self) self._set_actions() def _quit(self, action=None, param=None): self._window.destroy() def do_activate(self): if not self._window: self._window = Window(self) self.notify("window") self._window.set_default_icon_name(self.props.application_id) if self.props.application_id == "org.gnome.Music.Devel": self._window.get_style_context().add_class('devel') MPRIS(self) self._window.present()
class Application(Gtk.Application): def __init__(self): Gtk.Application.__init__(self, application_id='org.gnome.Music', flags=Gio.ApplicationFlags.FLAGS_NONE) GLib.set_application_name(_("Music")) GLib.set_prgname('gnome-music') cssProviderFile = Gio.File.new_for_uri( 'resource:///org/gnome/Music/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._window = None def build_app_menu(self): builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Music/app-menu.ui') menu = builder.get_object('app-menu') self.set_app_menu(menu) aboutAction = Gio.SimpleAction.new('about', None) aboutAction.connect('activate', self.about) self.add_action(aboutAction) newPlaylistAction = Gio.SimpleAction.new('newPlaylist', None) newPlaylistAction.connect('activate', self.new_playlist) self.add_action(newPlaylistAction) nowPlayingAction = Gio.SimpleAction.new('nowPlaying', None) nowPlayingAction.connect('activate', self.now_playing) self.add_action(nowPlayingAction) quitAction = Gio.SimpleAction.new('quit', None) quitAction.connect('activate', self.quit) self.add_action(quitAction) def new_playlist(self, action, param): pass def now_playing(self, action, param): pass def about(self, action, param): builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Music/AboutDialog.ui') about = builder.get_object('about_dialog') about.set_transient_for(self._window) about.connect("response", self.about_response) about.show() def about_response(self, dialog, response): dialog.destroy() def do_startup(self): Gtk.Application.do_startup(self) Notify.init(_("Music")) self.build_app_menu() def quit(self, action=None, param=None): self._window.destroy() def do_activate(self): if not self._window: self._window = Window(self) self.service = MediaPlayer2Service(self) self._notifications = NotificationManager(self._window.player) self._window.present()
class Application(Gtk.Application): def __repr__(self): return '<Application>' @log def __init__(self, application_id): super().__init__( application_id=application_id, flags=Gio.ApplicationFlags.FLAGS_NONE) self.props.resource_base_path = "/org/gnome/Music" GLib.set_application_name(_("Music")) GLib.set_prgname(application_id) GLib.setenv("PULSE_PROP_media.role", "music", True) self._init_style() self._window = None self._coreselection = CoreSelection() self._coremodel = CoreModel(self._coreselection) self._settings = Gio.Settings.new('org.gnome.Music') self._player = Player(self) InhibitSuspend(self) PauseOnSuspend(self._player) def _init_style(self): css_provider = Gtk.CssProvider() css_provider.load_from_resource('/org/gnome/Music/org.gnome.Music.css') screen = Gdk.Screen.get_default() style_context = Gtk.StyleContext() style_context.add_provider_for_screen( screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) @GObject.Property( type=Player, default=None, flags=GObject.ParamFlags.READABLE) def player(self): """Get application-wide music player. :returns: the player :rtype: Player """ return self._player @GObject.Property( type=Gio.Settings, flags=GObject.ParamFlags.READABLE) def settings(self): """Get application-wide settings. :returns: settings :rtype: Gio.settings """ return self._settings @GObject.Property( type=CoreModel, flags=GObject.ParamFlags.READABLE) def coremodel(self): """Get class providing all listmodels. :returns: List model provider class :rtype: CoreModel """ return self._coremodel @GObject.Property( type=CoreSelection, flags=GObject.ParamFlags.READABLE) def coreselection(self): """Get selection object. :returns: Object containing all selection info :rtype: CoreSelection """ return self._coreselection @log def _build_app_menu(self): action_entries = [ ('about', self._about), ('help', self._help) ] for action, callback in action_entries: simple_action = Gio.SimpleAction.new(action, None) simple_action.connect('activate', callback) self.add_action(simple_action) @log def _help(self, action, param): try: Gtk.show_uri(None, "help:gnome-music", Gdk.CURRENT_TIME) except GLib.Error: logging.warning("Help handler not available.") @log def _about(self, action, param): about = AboutDialog() about.props.transient_for = self._window about.present() @log def do_startup(self): Gtk.Application.do_startup(self) self._build_app_menu() @log def quit(self, action=None, param=None): self._window.destroy() def do_activate(self): if not self._window: self._window = Window(self) self._window.set_default_icon_name(self.props.application_id) if self.props.application_id == 'org.gnome.MusicDevel': self._window.get_style_context().add_class('devel') MPRIS(self) self._window.present()