[gnome-music] Improve startup time
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] Improve startup time
- Date: Wed, 7 Jan 2015 10:36:19 +0000 (UTC)
commit c87f76c17c23ad50b8e6c0478d7c32c43111c382
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date: Wed Jan 7 11:33:59 2015 +0100
Improve startup time
gnomemusic/playlists.py | 25 ++++++++++++-------------
gnomemusic/view.py | 12 +-----------
gnomemusic/widgets.py | 31 +++++++++++--------------------
gnomemusic/window.py | 4 +++-
4 files changed, 27 insertions(+), 45 deletions(-)
---
diff --git a/gnomemusic/playlists.py b/gnomemusic/playlists.py
index 109ab9b..29f2592 100644
--- a/gnomemusic/playlists.py
+++ b/gnomemusic/playlists.py
@@ -35,13 +35,6 @@ from gnomemusic import log
import logging
logger = logging.getLogger(__name__)
-try:
- tracker = Tracker.SparqlConnection.get(None)
-except Exception as e:
- from sys import exit
- logger.error("Cannot connect to tracker, error '%s'\Exiting" % str(e))
- exit(1)
-
class Playlists(GObject.GObject):
__gsignals__ = {
@@ -67,6 +60,12 @@ class Playlists(GObject.GObject):
@log
def __init__(self):
GObject.GObject.__init__(self)
+ try:
+ self.tracker = Tracker.SparqlConnection.get(None)
+ except Exception as e:
+ from sys import exit
+ logger.error("Cannot connect to tracker, error '%s'\Exiting" % str(e))
+ exit(1)
@log
def create_playlist(self, name):
@@ -83,12 +82,12 @@ class Playlists(GObject.GObject):
def update_callback(conn, res, data):
playlist_urn = conn.update_blank_finish(res)[0][0]['playlist']
- tracker.query_async(
+ self.trackerquery_async(
Query.get_playlist_with_urn(playlist_urn),
None, query_callback, None
)
- tracker.update_blank_async(
+ self.trackerupdate_blank_async(
Query.create_playlist(name), GLib.PRIORITY_DEFAULT,
None, update_callback, None
)
@@ -99,7 +98,7 @@ class Playlists(GObject.GObject):
conn.update_finish(res)
self.emit('playlist-deleted', item)
- tracker.update_async(
+ self.trackerupdate_async(
Query.delete_playlist(item.get_id()), GLib.PRIORITY_DEFAULT,
None, update_callback, None
)
@@ -121,7 +120,7 @@ class Playlists(GObject.GObject):
def update_callback(conn, res, data):
entry_urn = conn.update_blank_finish(res)[0][0]['entry']
- tracker.query_async(
+ self.trackerquery_async(
Query.get_playlist_song_with_urn(entry_urn),
None, query_callback, None
)
@@ -130,7 +129,7 @@ class Playlists(GObject.GObject):
uri = item.get_url()
if not uri:
continue
- tracker.update_blank_async(
+ self.trackerupdate_blank_async(
Query.add_song_to_playlist(playlist.get_id(), uri),
GLib.PRIORITY_DEFAULT,
None, update_callback, None
@@ -143,7 +142,7 @@ class Playlists(GObject.GObject):
self.emit('song-removed-from-playlist', playlist, data)
for item in items:
- tracker.update_async(
+ self.trackerupdate_async(
Query.remove_song_from_playlist(
playlist.get_id(), item.get_id()
),
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index d564f9b..6092c1d 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -32,14 +32,12 @@
from gi.repository import Gtk
-from gi.repository import Gdk
from gi.repository import GObject
from gi.repository import Gd
from gi.repository import Grl
from gi.repository import Pango
from gi.repository import GLib
from gi.repository import GdkPixbuf
-from gi.repository import Tracker
from gettext import gettext as _, ngettext
from gnomemusic.grilo import grilo
@@ -52,13 +50,6 @@ from gnomemusic import log
import logging
logger = logging.getLogger(__name__)
-try:
- tracker = Tracker.SparqlConnection.get(None)
-except Exception as e:
- from sys import exit
- logger.error("Cannot connect to tracker, error '%s'\Exiting" % str(e))
- exit(1)
-
playlists = Playlists.get_default()
@@ -97,7 +88,6 @@ class ViewContainer(Gtk.Stack):
)
self.view.set_view_type(view_type)
self.view.set_model(self._model)
- self.vadjustment = self.view.get_vadjustment()
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
box.pack_start(self.view, True, True, 0)
if use_sidebar:
@@ -232,7 +222,7 @@ class ViewContainer(Gtk.Stack):
or item.get_author()\
or _("Unknown Artist")
title = albumArtCache.get_media_title(item)
- item.set_title(title)
+ # item.set_title(title)
def add_new_item():
_iter = self._model.append(None)
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index 9680b16..0c21ab1 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -33,7 +33,6 @@
from gi.repository import Gtk, Gdk, Gd, GLib, GObject, Pango, Gio
from gi.repository import GdkPixbuf, Grl
-from gi.repository import Tracker
from gettext import gettext as _, ngettext
from gnomemusic.grilo import grilo
from gnomemusic.albumArtCache import AlbumArtCache
@@ -42,19 +41,17 @@ from gnomemusic import log
import logging
logger = logging.getLogger(__name__)
-playlist = Playlists.get_default()
-
-try:
- tracker = Tracker.SparqlConnection.get(None)
-except Exception as e:
- from sys import exit
- logger.error("Cannot connect to tracker, error '%s'\Exiting" % str(e))
- exit(1)
-
ALBUM_ART_CACHE = AlbumArtCache.get_default()
NOW_PLAYING_ICON_NAME = 'media-playback-start-symbolic'
ERROR_ICON_NAME = 'dialog-error-symbolic'
+try:
+ settings = Gio.Settings.new('org.gnome.Music')
+ MAX_TITLE_WIDTH = settings.get_int('max-width-chars')
+except Exception as e:
+ MAX_TITLE_WIDTH = 20
+ logger.error("Error on setting widget max-width-chars: %s" % str(e))
+
class AlbumWidget(Gtk.EventBox):
@@ -503,13 +500,6 @@ class ArtistAlbumWidget(Gtk.Box):
GLib.idle_add(grilo.populate_album_songs, album, self.add_item)
self.pack_start(self.ui.get_object('ArtistAlbumWidget'), True, True, 0)
- try:
- self.settings = Gio.Settings.new('org.gnome.Music')
- self.max_title_width = self.settings.get_int('max-width-chars')
- except Exception as e:
- self.max_title_width = 20
- logger.error("Error on setting widget max-width-chars: %s" % str(e))
-
@log
def _on_discovered(self, info, error, song_widget):
if error:
@@ -536,7 +526,7 @@ class ArtistAlbumWidget(Gtk.Box):
title = AlbumArtCache.get_media_title(track)
ui.get_object('title').set_text(title)
ui.get_object('title').set_alignment(0.0, 0.5)
- ui.get_object('title').set_max_width_chars(self.max_title_width)
+ ui.get_object('title').set_max_width_chars(MAX_TITLE_WIDTH)
self.songsGrid.attach(
song_widget,
@@ -657,7 +647,8 @@ class PlaylistDialog():
self._cancel_button.connect('clicked', self._on_cancel_button_clicked)
self._select_button.connect('clicked', self._on_selection)
- playlist.connect('playlist-created', self._on_playlist_created)
+ self.playlist = Playlists.get_default()
+ self.playlist.connect('playlist-created', self._on_playlist_created)
@log
def get_selected(self):
@@ -739,7 +730,7 @@ class PlaylistDialog():
@log
def _on_editing_done(self, editable, data=None):
if editable.get_text() != '':
- playlist.create_playlist(editable.get_text())
+ self.playlist.create_playlist(editable.get_text())
@log
def _on_playlist_created(self, playlists, item):
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index b98b341..2ce4c9b 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -89,9 +89,11 @@ class Window(Gtk.ApplicationWindow):
if self.settings.get_value('window-maximized'):
self.maximize()
+ self._setup_view()
+
self.connect("window-state-event", self._on_window_state_event)
self.connect("configure-event", self._on_configure_event)
- self._setup_view()
+
self.proxy = Gio.DBusProxy.new_sync(Gio.bus_get_sync(Gio.BusType.SESSION, None),
Gio.DBusProxyFlags.NONE,
None,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]