def do_startup(self): """ Add startup notification and build gnome-shell menu after Gtk.Application startup """ 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 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()
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 self.inhibitor = Inhibitor()
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') Lp.window = builder.get_object('unicode') Lp.window.set_application(self) Lp.window.show() elif not Lp.window: menu = self._setup_app_menu() # If GNOME/Unity, add appmenu if is_gnome() or is_unity(): self.set_app_menu(menu) Lp.window = Window(self) # If not GNOME add menu to toolbar if not is_gnome() and not is_unity(): Lp.window.setup_menu(menu) Lp.window.connect('delete-event', self._hide_on_delete) Lp.window.init_list_one() Lp.window.show() Lp.player.restore_state()
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 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 do_startup(self): """ Init application """ Gtk.Application.do_startup(self) Notify.init("Lollypop") if 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() # 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) self.charts = None if self.settings.get_value("show-charts"): 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.start() else: self.settings.set_value("network-search", GLib.Variant("b", False)) self.__preload_portal()
def do_startup(self): """ Init application """ Gtk.Application.do_startup(self) Notify.init("Lollypop") if 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() # 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) self.__preload_portal()
def do_startup(self): """ Add startup notification and build gnome-shell menu after Gtk.Application startup """ 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 self.inhibitor = Inhibitor()
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() # 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('show-charts'): 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() else: self.settings.set_value('network-search', GLib.Variant('b', False)) t = Thread(target=self.__preload_portal) t.daemon = True t.start()
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() # 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('show-charts'): 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() else: self.settings.set_value('network-search', GLib.Variant('b', False))
def __init__(self): """ Init notification object with lollypop infos """ self.__notification_timeout_id = None self.__notification_handler_id = None self.__disable_all_notifications = True self.__is_gnome = is_gnome() self.__notification = Gio.Notification.new("") self.__action = Gio.Notification.new("") self.__action.add_button_with_target(_("Previous"), "app.shortcut", GLib.Variant("s", "prev")) self.__action.add_button_with_target(_("Next"), "app.shortcut", GLib.Variant("s", "next")) self.__on_notifications_settings_changed() App().settings.connect( "changed::disable-song-notifications", self.__on_notifications_settings_changed, ) App().settings.connect( "changed::disable-notifications", self.__on_notifications_settings_changed, )
def __init__(self): """ Init notification object with lollypop infos """ self.__inhibitor = False self.__supports_actions = False self.__is_gnome = is_gnome() self.__notification = None GioNotify.async_init("Lollypop", self.__on_init_finish)
def __init__(self): """ Init notification object with lollypop infos """ self.__supports_actions = False self.__disable_all_notifications = True self.__is_gnome = is_gnome() self.__notification = None self.__notification_handler_id = None GioNotify.async_init("Lollypop", self.__on_init_finish)
def do_startup(self): """ Init application """ Gtk.Application.do_startup(self) Notify.init("Lollypop") if 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() # 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) self.charts = None if self.settings.get_value('show-charts'): 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.start() else: self.settings.set_value('network-search', GLib.Variant('b', False)) t = Thread(target=self.__preload_portal) t.daemon = True t.start()
def __init__(self): """ Init notification object with lollypop infos """ self.__notification_timeout_id = None self.__is_gnome = is_gnome() App().player.connect("current-changed", self.__on_current_changed) self.__notification = Gio.Notification.new("") self.__action = Gio.Notification.new("") self.__action.add_button_with_target( _("Previous"), "app.shortcut", GLib.Variant("s", "prev")) self.__action.add_button_with_target( _("Next"), "app.shortcut", GLib.Variant("s", "next"))
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 args = app_cmd_line.get_arguments() 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_string() try: value = min(max(0, int(value)), 5) if self.player.current_track.id is not None: self.player.current_track.set_rate(value) except Exception as e: print(e) pass elif options.contains("play-pause"): self.player.play_pause() elif options.contains("play-ids"): try: value = options.lookup_value("play-ids").get_string() ids = value.split(";") track_ids = [] for id in ids: if id[0:2] == "a:": album = Album(int(id[2:])) track_ids += album.track_ids else: track_ids.append(int(id[2:])) track = Track(track_ids[0]) self.player.load(track) self.player.populate_user_playlist_by_tracks( track_ids, [Type.SEARCH]) except Exception as e: print(e) pass elif options.contains("next"): self.player.next() elif options.contains("prev"): self.player.prev() elif options.contains("emulate-phone"): self.window.add_fake_phone() elif len(args) > 1: self.player.clear_externals() for uri in args[1:]: try: uri = GLib.filename_to_uri(uri) except: pass parser = TotemPlParser.Parser.new() parser.connect("entry-parsed", self.__on_entry_parsed) parser.parse_async(uri, True, None, None) elif self.window is not None and self.window.is_visible(): self.window.present_with_time(Gtk.get_current_event_time()) elif self.window is not None: # self.window.setup_window() # self.window.present() # Horrible HACK: https://bugzilla.gnome.org/show_bug.cgi?id=774130 self.window.save_view_state() self.window.destroy() self.window = Window() # If not GNOME/Unity add menu to toolbar if not is_gnome() and not is_unity(): menu = self.__setup_app_menu() self.window.setup_menu(menu) self.window.connect("delete-event", self.__hide_on_delete) self.window.init_list_one() self.window.show() self.player.emit("status-changed") self.player.emit("current-changed") return 0
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('album'): try: value = options.lookup_value('album').get_string() album_ids = value.split(';') album = Album(int(album_ids.pop(0))) self.player.play_album(album) for album_id in album_ids: self.player.add_album(Album(int(album_id))) except: pass 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 uri in args[1:]: try: uri = GLib.filename_to_uri(uri) except: pass parser = TotemPlParser.Parser.new() parser.connect('entry-parsed', self.__on_entry_parsed) parser.parse_async(uri, True, None, None) if self.window is not None and not self.window.is_visible(): # self.window.setup_window() # self.window.present() # Horrible HACK: https://bugzilla.gnome.org/show_bug.cgi?id=774130 self.window.save_view_state() self.window.destroy() self.window = Window() # If not GNOME/Unity add menu to toolbar if not is_gnome() and not is_unity(): menu = self.__setup_app_menu() self.window.setup_menu(menu) self.window.connect('delete-event', self.__hide_on_delete) self.window.init_list_one() self.window.show() self.player.emit('status-changed') self.player.emit('current-changed') return 0