[gnome-music] application.py : Cleanup following PEP 8
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] application.py : Cleanup following PEP 8
- Date: Mon, 13 Feb 2017 22:02:00 +0000 (UTC)
commit 88563bebfc2b4f3b1f7fa3354989168e2ac3447e
Author: theawless <theawless gmail com>
Date: Mon Jan 16 18:14:23 2017 +0530
application.py : Cleanup following PEP 8
Followed PEP guidelines and a minor reformat of the code.
MediaPlayer2Service need not have a reference in application.py.
It does not get garbage collected.
https://bugzilla.gnome.org/show_bug.cgi?id=777219
gnomemusic/application.py | 72 ++++++++++++++++++++++-----------------------
1 files changed, 35 insertions(+), 37 deletions(-)
---
diff --git a/gnomemusic/application.py b/gnomemusic/application.py
index b49cdee..5b0d8da 100644
--- a/gnomemusic/application.py
+++ b/gnomemusic/application.py
@@ -30,78 +30,76 @@
# code, but you are not obligated to do so. If you do not wish to do so,
# delete this exception statement from your version.
+from gettext import gettext as _
+
import gi
gi.require_version('Notify', '0.7')
from gi.repository import Gtk, Gio, GLib, Gdk, Notify
-from gettext import gettext as _
-from gnomemusic.window import Window
+
+from gnomemusic import log
from gnomemusic.mpris import MediaPlayer2Service
from gnomemusic.notification import NotificationManager
-from gnomemusic import log
-import logging
-logger = logging.getLogger(__name__)
+from gnomemusic.window import Window
class Application(Gtk.Application):
-
def __repr__(self):
return '<Application>'
@log
def __init__(self):
- Gtk.Application.__init__(self,
- application_id='org.gnome.Music',
+ 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._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_USER)
+
@log
- def build_app_menu(self):
- actionEntries = [
- ('about', self.about),
- ('help', self.help),
+ def _build_app_menu(self):
+ action_entries = [
+ ('about', self._about),
+ ('help', self._help),
('quit', self.quit),
]
- for action, callback in actionEntries:
- simpleAction = Gio.SimpleAction.new(action, None)
- simpleAction.connect('activate', callback)
- self.add_action(simpleAction)
+ 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):
+ def _help(self, action, param):
Gtk.show_uri(None, "help:gnome-music", Gdk.CURRENT_TIME)
@log
- def about(self, action, param):
+ 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", self.about_response)
+ about.connect("response", 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()
+ self._build_app_menu()
@log
def quit(self, action=None, param=None):
@@ -110,8 +108,8 @@ class Application(Gtk.Application):
def do_activate(self):
if not self._window:
self._window = Window(self)
- self.service = MediaPlayer2Service(self)
- if self.settings.get_value('notifications'):
+ MediaPlayer2Service(self)
+ if self._settings.get_value('notifications'):
self._notifications = NotificationManager(self._window.player)
self._window.present()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]