Esempio n. 1
0
    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()
Esempio n. 2
0
    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()
Esempio n. 3
0
    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()
Esempio n. 4
0
    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()
Esempio n. 5
0
    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()
Esempio n. 6
0
    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()
Esempio n. 7
0
    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))
Esempio n. 8
0
    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()
Esempio n. 9
0
    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))
Esempio n. 10
0
 def __setup_content(self):
     """
         Setup window content
     """
     self.__container = Container()
     self.set_stack(self.container.stack)
     self.add_paned(self.container.paned_one, self.container.list_one)
     self.add_paned(self.container.paned_two, self.container.list_two)
     self.__container.show()
     self.__vgrid = Gtk.Grid()
     self.__vgrid.set_orientation(Gtk.Orientation.VERTICAL)
     self.__vgrid.show()
     self.__toolbar = Toolbar(self)
     self.__toolbar.show()
     if App().settings.get_value("disable-csd") or is_unity():
         self.__vgrid.add(self.__toolbar)
     else:
         self.set_titlebar(self.__toolbar)
         self.__toolbar.set_show_close_button(
             not App().settings.get_value("disable-csd"))
     self.__vgrid.add(self.__container)
     self.add(self.__vgrid)
     self.drag_dest_set(Gtk.DestDefaults.DROP | Gtk.DestDefaults.MOTION, [],
                        Gdk.DragAction.MOVE)
     self.drag_dest_add_uri_targets()
     self.connect("drag-data-received", self.__on_drag_data_received)
Esempio n. 11
0
 def __setup_content(self):
     """
         Setup window content
     """
     vgrid = Gtk.Grid()
     vgrid.set_orientation(Gtk.Orientation.VERTICAL)
     vgrid.show()
     self.__toolbar = Toolbar()
     self.__toolbar.show()
     self.__subtoolbar = Gtk.Grid()
     if Lp().settings.get_value("disable-csd") or is_unity():
         vgrid.add(self.__toolbar)
     else:
         self.set_titlebar(self.__toolbar)
         self.__toolbar.set_show_close_button(
                                 not Lp().settings.get_value("disable-csd"))
     vgrid.add(self.__main_stack)
     vgrid.add(self.__subtoolbar)
     self.add(vgrid)
     self.__main_stack.add_named(self._paned_main_list, "main")
     self.__main_stack.set_visible_child_name("main")
     self.drag_dest_set(Gtk.DestDefaults.DROP | Gtk.DestDefaults.MOTION,
                        [], Gdk.DragAction.MOVE)
     self.drag_dest_add_text_targets()
     self.connect("drag-data-received", self.__on_drag_data_received)
     self.connect("drag-motion", self.__on_drag_motion)
     self.connect("drag-leave", self.__on_drag_leave)
Esempio n. 12
0
    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()
Esempio n. 13
0
 def _setup_content(self):
     """
         Setup window content
     """
     self.set_icon_name('lollypop')
     self._toolbar = Toolbar(self.get_application())
     self._toolbar.show()
     if Lp().settings.get_value('disable-csd') or is_unity():
         vgrid = Gtk.Grid()
         vgrid.set_orientation(Gtk.Orientation.VERTICAL)
         vgrid.add(self._toolbar)
         vgrid.add(self.main_widget())
         vgrid.show()
         self.add(vgrid)
     else:
         self.set_titlebar(self._toolbar)
         self._toolbar.set_show_close_button(True)
         self.add(self.main_widget())
Esempio n. 14
0
 def _setup_content(self):
     """
         Setup window content
     """
     self.set_icon_name('lollypop')
     self._toolbar = Toolbar(self.get_application())
     self._toolbar.show()
     if Lp().settings.get_value('disable-csd') or is_unity():
         vgrid = Gtk.Grid()
         vgrid.set_orientation(Gtk.Orientation.VERTICAL)
         vgrid.add(self._toolbar)
         vgrid.add(self.main_widget())
         vgrid.show()
         self.add(vgrid)
     else:
         self.set_titlebar(self._toolbar)
         self._toolbar.set_show_close_button(True)
         self.add(self.main_widget())
Esempio n. 15
0
 def __setup_content(self):
     """
         Setup window content
     """
     vgrid = Gtk.Grid()
     vgrid.set_orientation(Gtk.Orientation.VERTICAL)
     vgrid.show()
     self.__toolbar = Toolbar()
     self.__toolbar.show()
     self.__subtoolbar = Gtk.Grid()
     if Lp().settings.get_value("disable-csd") or is_unity():
         vgrid.add(self.__toolbar)
     else:
         self.set_titlebar(self.__toolbar)
         self.__toolbar.set_show_close_button(
             not Lp().settings.get_value("disable-csd"))
     vgrid.add(self.__main_stack)
     vgrid.add(self.__subtoolbar)
     self.add(vgrid)
     self.__main_stack.add_named(self._paned_main_list, "main")
     self.__main_stack.set_visible_child_name("main")
Esempio n. 16
0
 def _setup_content(self):
     """
         Setup window content
     """
     self.set_default_icon_name("lollypop")
     vgrid = Gtk.Grid()
     vgrid.set_orientation(Gtk.Orientation.VERTICAL)
     vgrid.show()
     self._toolbar = Toolbar(self.get_application())
     self._toolbar.show()
     self._subtoolbar = Gtk.Grid()
     if Lp().settings.get_value("disable-csd") or is_unity():
         vgrid.add(self._toolbar)
     else:
         self.set_titlebar(self._toolbar)
         self._toolbar.set_show_close_button(not Lp().settings.get_value("disable-csd"))
     vgrid.add(self._main_stack)
     vgrid.add(self._subtoolbar)
     self.add(vgrid)
     self._main_stack.add_named(self.main_widget(), "main")
     self._main_stack.set_visible_child_name("main")
Esempio n. 17
0
 def __setup_content(self):
     """
         Setup window content
     """
     self.set_default_icon_name('lollypop')
     vgrid = Gtk.Grid()
     vgrid.set_orientation(Gtk.Orientation.VERTICAL)
     vgrid.show()
     self.__toolbar = Toolbar(self.get_application())
     self.__toolbar.show()
     self.__subtoolbar = Gtk.Grid()
     if Lp().settings.get_value('disable-csd') or is_unity():
         vgrid.add(self.__toolbar)
     else:
         self.set_titlebar(self.__toolbar)
         self.__toolbar.set_show_close_button(
             not Lp().settings.get_value('disable-csd'))
     vgrid.add(self.__main_stack)
     vgrid.add(self.__subtoolbar)
     self.add(vgrid)
     self.__main_stack.add_named(self.main_widget(), 'main')
     self.__main_stack.set_visible_child_name('main')
Esempio n. 18
0
 def __show_miniplayer(self, show):
     """
         Show/hide miniplayer
         @param show as bool
     """
     mini = self.__main_stack.get_child_by_name('mini')
     if show:
         if mini is not None:
             if self.__timeout is not None:
                 GLib.source_remove(self.__timeout)
         else:
             mini = MiniPlayer()
             self.__main_stack.add_named(mini, 'mini')
         self.__timeout = None
         mini.show()
         self.__main_stack.set_visible_child_name('mini')
         self.__toolbar.set_show_close_button(False)
     elif mini is not None and not show and self.__timeout is None:
         self.__main_stack.set_visible_child_name('main')
         self.__toolbar.set_show_close_button(
             not Lp().settings.get_value('disable-csd') and not is_unity())
         self.__timeout = GLib.timeout_add(1000, mini.destroy)
Esempio n. 19
0
 def __setup_content(self):
     """
         Setup window content
     """
     self.set_default_icon_name('lollypop')
     vgrid = Gtk.Grid()
     vgrid.set_orientation(Gtk.Orientation.VERTICAL)
     vgrid.show()
     self.__toolbar = Toolbar()
     self.__toolbar.show()
     self.__subtoolbar = Gtk.Grid()
     if Lp().settings.get_value('disable-csd') or is_unity():
         vgrid.add(self.__toolbar)
     else:
         self.set_titlebar(self.__toolbar)
         self.__toolbar.set_show_close_button(
                                 not Lp().settings.get_value('disable-csd'))
     vgrid.add(self.__main_stack)
     vgrid.add(self.__subtoolbar)
     self.add(vgrid)
     self.__main_stack.add_named(self._paned_main_list, 'main')
     self.__main_stack.set_visible_child_name('main')
Esempio n. 20
0
 def setup(self):
     """
         Setup window content
     """
     self.__vgrid = Gtk.Grid()
     self.__vgrid.set_orientation(Gtk.Orientation.VERTICAL)
     self.__vgrid.show()
     self.__container = Container()
     self.__container.setup()
     self.__container.show()
     self.__toolbar = Toolbar(self)
     self.__toolbar.show()
     if App().settings.get_value("disable-csd") or is_unity():
         self.__vgrid.add(self.__toolbar)
     else:
         self.set_titlebar(self.__toolbar)
         self.__toolbar.set_show_close_button(
             not App().settings.get_value("disable-csd"))
     self.__vgrid.add(self.__container)
     self.add(self.__vgrid)
     self.__container.widget.connect("notify::folded",
                                     self.__on_container_folded)
Esempio n. 21
0
 def __show_miniplayer(self, show):
     """
         Show/hide miniplayer
         @param show as bool
     """
     mini = self.__main_stack.get_child_by_name('mini')
     if show:
         if mini is not None:
             if self.__timeout is not None:
                 GLib.source_remove(self.__timeout)
         else:
             from lollypop.miniplayer import MiniPlayer
             mini = MiniPlayer()
             self.__main_stack.add_named(mini, 'mini')
         self.__timeout = None
         mini.show()
         self.__main_stack.set_visible_child_name('mini')
         self.__toolbar.set_show_close_button(False)
     elif mini is not None and not show and self.__timeout is None:
         self.__main_stack.set_visible_child_name('main')
         self.__toolbar.set_show_close_button(
                             not Lp().settings.get_value('disable-csd') and
                             not is_unity())
         self.__timeout = GLib.timeout_add(1000, mini.destroy)
Esempio n. 22
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
Esempio n. 23
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
     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
Esempio n. 24
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