[gnome-music/wip/merge: 15/343] fixed syntax errors in application windows and player.
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/merge: 15/343] fixed syntax errors in application windows and player.
- Date: Thu, 25 Jul 2013 11:14:46 +0000 (UTC)
commit 9f52c6a93555a4412362588039e1e563c91a1945
Author: Sai <suman sai14 gmail com>
Date: Sat Jul 13 13:13:52 2013 +0530
fixed syntax errors in application windows and player.
gnome-music/application.py | 2 +-
gnome-music/player.py | 122 ++++++++++++++++++++++----------------------
gnome-music/toolbar.py | 40 ++-------------
gnome-music/view.py | 20 ++++----
gnome-music/window.py | 8 +--
5 files changed, 80 insertions(+), 112 deletions(-)
---
diff --git a/gnome-music/application.py b/gnome-music/application.py
index b506529..3264b7d 100644
--- a/gnome-music/application.py
+++ b/gnome-music/application.py
@@ -16,7 +16,7 @@ class Application(Gtk.Application):
Gtk.Application.startup(self)
def do_activate(self):
- if(self._window == null):
+ if self._window is not None:
self._window = Window(self)
self._window.present()
diff --git a/gnome-music/player.py b/gnome-music/player.py
index 8ed0625..cc61cae 100644
--- a/gnome-music/player.py
+++ b/gnome-music/player.py
@@ -14,7 +14,7 @@ class Player():
self._symbolicIcon = self.cache.makeDefaultIcon(ART_SIZE, ART_SIZE)
Gst.init(None, 0)
- self.discoverer = new GstPbutils.Discoverer()
+ self.discoverer = GstPbutils.Discoverer()
self.player = Gst.ElementFactory.make("playbin", "player")
self.bus = self.player.get_bus()
self.bus.add_signal_watch()
@@ -63,7 +63,7 @@ class Player():
self.emit('playing-changed')
def _onBussError(self, bus, message):
- let media = self.playlist.get_value( self.currentTrack, self.playlistField)
+ media = self.playlist.get_value( self.currentTrack, self.playlistField)
if(media != None):
uri = media.get_url()
else:
@@ -88,15 +88,15 @@ class Player():
nextTrack = currentTrack
elif self.repeat == RepeatType.ALL:
nextTrack = currentTrack.copy()
- if !self.playlist.iter_next(nextTrack):
+ if self.playlist.iter_next(nextTrack) is not None:
nextTrack = self.playlist.get_iter_first()[1]
elif self.repeat == RepeatType.NONE:
nextTrack = currentTrack.copy()
- nextTrack = self.playlist.iter_next(nextTrack) ? nextTrack : None
+ nextTrack = nextTrack if self.playlist.iter_next(nextTrack) else None
elif self.repeat == RepeatType.SHUFFLE:
nextTrack = self.playlist.get_iter_first()[1]
- let rows = self.playlist.iter_n_children(None)
- let random = Math.floor(Math.random() * rows)
+ rows = self.playlist.iter_n_children(None)
+ random = Math.floor(Math.random() * rows)
for i in random:
self.playlist.iter_next(nextTrack)
@@ -114,19 +114,18 @@ class Player():
def _getPreviousTrack(self):
- let currentTrack = self.currentTrack
- let previousTrack
+ currentTrack = self.currentTrack
- if self.repeat = RepeatType.SONG:
+ if self.repeat == RepeatType.SONG:
previousTrack = currentTrack
- elif self.repeat = RepeatType.ALL:
+ elif self.repeat == RepeatType.ALL:
previousTrack = currentTrack.copy()
- if !self.playlist.iter_previous(previousTrack):
+ if self.playlist.iter_previous(previousTrack) is not None:
previousTrack = self._getIterLast()
- elif self.repeat = RepeatType.NONE:
+ elif self.repeat == RepeatType.NONE:
previousTrack = currentTrack.copy()
- previousTrack = self.playlist.iter_previous(previousTrack) ? previousTrack : None
- elif self.repeat = RepeatType.SHUFFLE:
+ previousTrack = previousTrack if self.playlist.iter_previous(previousTrack) else None
+ elif self.repeat == RepeatType.SHUFFLE:
previousTrack = self.playlist.get_iter_first()[1]
rows = self.playlist.iter_n_children(None)
random = Math.floor(Math.random() * rows)
@@ -137,18 +136,18 @@ class Player():
def _hasNext(self):
- if self.repeat == RepeatType.ALL or
+ if (self.repeat == RepeatType.ALL or
self.repeat == RepeatType.SONG or
- self.repeat == RepeatType.SHUFFLE:
+ self.repeat == RepeatType.SHUFFLE):
return True
else:
tmp = self.currentTrack.copy()
return self.playlist.iter_next(tmp)
def _hasPrevious(self):
- if self.repeat == RepeatType.ALL or
+ if (self.repeat == RepeatType.ALL or
self.repeat == RepeatType.SONG or
- self.repeat == RepeatType.SHUFFLE:
+ self.repeat == RepeatType.SHUFFLE):
return True
else:
tmp = self.currentTrack.copy()
@@ -165,7 +164,7 @@ class Player():
return False
def _syncPlaying(self):
- self.playBtn.image = self.playing ? self._pauseImage : self._playImage
+ self.playBtn.image = self._playImage if self.playing is True else self._pauseImage
def _syncPrevNext(self):
hasNext = self._hasNext()
@@ -176,14 +175,13 @@ class Player():
self._dbusImpl.emit_property_changed('CanGoNext', GLib.Variant.new('b', hasNext))
self._dbusImpl.emit_property_changed('CanGoPrevious', GLib.Variant.new('b', hasPrevious))
- },
def setPlaying(self, value):
self.eventBox.show()
- if (value)
+ if value:
self.play()
- else
+ else:
self.pause()
media = self.playlist.get_value(self.currentTrack, self.playlistField)
@@ -236,11 +234,11 @@ class Player():
self.emit('current-changed')
def _onCacheLookup(self, pixbuf):
- if (pixbuf != None) {
+ if pixbuf is not None:
self.coverImg.set_from_pixbuf(pixbuf)
def play(self):
- if (self.playlist == None)
+ if self.playlist is None:
return
if self.player.get_state(1)[1] != Gst.State.PAUSED:
@@ -250,7 +248,7 @@ class Player():
self.player.set_state(Gst.State.PLAYING)
self._updatePositionCallback()
- if (!self.timeout)
+ if not self.timeout:
self.timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, self._updatePositionCallback)
self._dbusImpl.emit_property_changed('PlaybackStatus', GLib.Variant.new('s', 'Playing'))
@@ -276,7 +274,7 @@ class Player():
if self.playlist == None:
return True
- if !self.nextBtn.sensitive:
+ if not self.nextBtn.sensitive:
return True
self.stop()
@@ -289,7 +287,7 @@ class Player():
if self.playlist == None:
return
- if !self.prevBtn.sensitive:
+ if self.prevBtn.sensitive is False:
return
self.stop()
@@ -308,14 +306,14 @@ class Player():
self.playlistField = field
self.emit('current-changed')
- def runningPlaylist(self, type, id, force){
- if type == self.playlistType && id == self.playlistId:
+ def runningPlaylist(self, type, id, force):
+ if type == self.playlistType and id == self.playlistId:
return self.playlist
else:
return None
def _setupView(self):
- self._ui = new Gtk.Builder()
+ self._ui = Gtk.Builder()
self._ui.add_from_resource('/org/gnome/music/PlayerToolbar.ui')
self.eventBox = self._ui.get_object('eventBox')
self.prevBtn = self._ui.get_object('previous_button')
@@ -333,32 +331,32 @@ class Player():
self.repeatBtnImage = self._ui.get_object('playlistRepeat')
if Gtk.Settings.get_default().gtk_application_prefer_dark_theme:
- color = new Gdk.Color(red=65535,green=65535,blue=65535)
+ color = Gdk.Color(red=65535,green=65535,blue=65535)
else:
- color = new Gdk.Color(red=0,green=0,blue=0)
+ color = Gdk.Color(red=0,green=0,blue=0)
self._playImage.modify_fg(Gtk.StateType.ACTIVE,color)
self._pauseImage.modify_fg(Gtk.StateType.ACTIVE,color)
self._syncRepeatImage()
- self.prevBtn.connect("clicked", self._onPrevBtnClicked)
- self.playBtn.connect("clicked", self._onPlayBtnClicked)
- self.nextBtn.connect("clicked", self._onNextBtnClicked)
+ self.prevBtn.connect("clicked", self._onPrevBtnClicked())
+ self.playBtn.connect("clicked", self._onPlayBtnClicked())
+ self.nextBtn.connect("clicked", self._onNextBtnClicked())
self.progressScale.connect("button-press-event", _onProgrssScaleEvent)
- self.progressScale.connect("value-changed", Lang.bind(self,
- function() {
- let seconds = Math.floor(self.progressScale.get_value() / 60)
- self.songPlaybackTimeLabel.set_label(self.secondsToString(seconds))
- return false
- }))
- self.progressScale.connect("button-release-event", Lang.bind(self,
- function() {
- self.onProgressScaleChangeValue(self.progressScale)
- self._updatePositionCallback()
- self.player.set_state(self._lastState)
- self.timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, Lang.bind(self,
self._updatePositionCallback))
- return false
- }))
+ self.progressScale.connect("value-changed", self._onProgressValueChanged())
+ self.progressScale.connect("button-release-event", self._onProgressScaleButtonReleased())
+
+ def _onProgressScaleButtonReleased(self):
+ self.onProgressScaleChangeValue(self.progressScale)
+ self._updatePositionCallback()
+ self.player.set_state(self._lastState)
+ self.timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, Lang.bind(self,
self._updatePositionCallback))
+ return False
+
+ def _onProgressValueChanged(self):
+ seconds = Math.floor(self.progressScale.get_value() / 60)
+ self.songPlaybackTimeLabel.set_label(self.secondsToString(seconds))
+ return False
def _onProgressScaleEvent(self):
self._lastState = self.player.get_state(1)[1]
@@ -372,8 +370,10 @@ class Player():
minutes = parseInt( duration / 60 ) % 60
seconds = duration % 60
- return minutes + ":" + (seconds < 10 ? "0" + seconds : seconds)
- },
+ if(seconds < 10):
+ return minutes + ":" + "0" + seconds
+ else:
+ return minutes + ":" + seconds
def _onPlayBtnClicked(self, btn):
if self.playing:
@@ -384,7 +384,7 @@ class Player():
def _onNextBtnClicked(self, btn):
self.playNext()
- def _onPrevBtnClicked(self, btn:
+ def _onPrevBtnClicked(self, btn):
self.playPrevious()
def _setDuration(self, duration):
@@ -456,7 +456,7 @@ class Player():
offset = params
duration = self.player.query_duration(Gst.Format.TIME, None)
- if !duration:
+ if duration is None:
return
if offset < 0:
@@ -479,7 +479,7 @@ class Player():
return
duration = self.player.query_duration(Gst.Format.TIME, None)
- if duration && position >= 0 && duration[1] >= position * 1000:
+ if duration and position >= 0 and duration[1] >= position * 1000:
self.player.seek_simple(Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT, position
* 1000)
self._dbusImpl.emit_signal('Seeked', GLib.Variant.new('(x)', [position]))
@@ -500,7 +500,7 @@ class Player():
else:
return 'Stopped'
- def getLoopStatus(self) {
+ def getLoopStatus(self):
if self.repeat == RepeatType.NONE:
return 'None'
elif self.repeat == RepeatType.SONG:
@@ -508,7 +508,7 @@ class Player():
else:
return 'Playlist'
- def setLoopStatus(mode) {
+ def setLoopStatus(mode):
if mode == 'None':
self.repeat = RepeatType.NONE
elif mode == 'Track':
@@ -527,15 +527,15 @@ class Player():
return self.repeat == RepeatType.SHUFFLE
def setShuffle(self, enable):
- if (enable && self.repeat != RepeatType.SHUFFLE) {
+ if (enable and self.repeat != RepeatType.SHUFFLE):
self.repeat = RepeatType.SHUFFLE
- elif !enable and self.repeat == RepeatType.SHUFFLE:
+ elif enable is not None and self.repeat == RepeatType.SHUFFLE:
self.repeat = RepeatType.NONE
self._syncRepeatImage()
- def getMetadata() {
+ def getMetadata():
if self.currentTrack == None:
- return {}
+ return
media = self.playlist.get_value(self.currentTrack, self.playlistField)
metadata = {
@@ -581,7 +581,7 @@ class Player():
self.player.set_volume(GstAudio.StreamVolumeFormat.LINEAR, rate)
self._dbusImpl.emit_property_changed('Volume', GLib.Variant.new('d', rate))
- def getPosition(self)
+ def getPosition(self):
return self.player.query_position(Gst.Format.TIME, None)[1]/1000
def getMinimumRate(self):
diff --git a/gnome-music/toolbar.py b/gnome-music/toolbar.py
index d6c3a8b..2145752 100644
--- a/gnome-music/toolbar.py
+++ b/gnome-music/toolbar.py
@@ -1,4 +1,4 @@
-from gi.repository import Gtk, Gd
+from gi.repository import Gtk
class Toolbar():
def __init__(self):
@@ -22,7 +22,7 @@ class Toolbar():
def _closeButtonClicked(self, btn):
self._closeButton.get_toplevel().close()
- def set_stack(self, stack)
+ def set_stack(self, stack):
self._stackSwitcher.set_stack(stack)
def get_stack(self):
@@ -42,7 +42,7 @@ class Toolbar():
self._cancelButton.hide()
self._update()
- def setState(self, state, *btn=None):
+ def setState(self, state, btn=None):
self._state = state
self._update()
self.emit('state-changed')
@@ -54,7 +54,7 @@ class Toolbar():
self.title = ""
self.headerBar.custom_title = self._stackSwitcher
- if (self._state == ToolbarState.SINGLE and !self._selectionMode):
+ if (self._state == ToolbarState.SINGLE and self._selectionMode is not None):
self._backButton.show()
else:
self._backButton.hide()
@@ -65,34 +65,4 @@ class Toolbar():
self._closeButton.hide();
else:
self._closeSeparator.show()
- self._closeButton.show()
-
- def _addBackButton(self):
- iconName = (self.get_direction() == Gtk.TextDirection.RTL) ?
- 'go-previous-rtl-symbolic' : 'go-previous-symbolic'
- self._backButton = Gd.HeaderSimpleButton(symbolic_icon_name=iconName,
- label=_("Back"))
- self._backButton.connect('clicked', self.setState);
- self.pack_start(self._backButton, False, False, 0);
-
- def _addSearchButton(self):
- self._searchButton = Gd.HeaderSimpleButton(symbolic_icon_name='folder-saved-search-symbolic',
- label=_("Search"))
- self.pack_end(self._searchButton)
- self._searchButton.show()
-
- def _addSelectButton(self):
- self._selectButton = Gd.HeaderToggleButton(symbolic_icon_name='object-select-symbolic',
- label= _("Select"))
- self.pack_end(self._selectButton)
- self._selectButton.show()
-
- def _addCloseButton(self):
- self._closeSeparator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)
- self.pack_end(self._closeSeparator)
-
- self._closeButton = Gd.HeaderSimpleButton(symbolic_icon_name='window-close-symbolic')
- self._closeButton.set_relief(Gtk.ReliefStyle.NONE)
- self._closeButton.connect('clicked', self._closeButtonClicked)
- self.pack_end(self._closeButton);
-
+ self._closeButton.show()
\ No newline at end of file
diff --git a/gnome-music/view.py b/gnome-music/view.py
index e13a1e2..35d90f6 100644
--- a/gnome-music/view.py
+++ b/gnome-music/view.py
@@ -29,7 +29,7 @@ class ViewContainer(Gtk.Stack):
self.view.set_view_type(Gd.MainViewType.ICON)
self.view.set_model(self._model)
self.selectionToolbar = selectionToolbar
- box = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL})
+ box = Gtk.Box({orientation: Gtk.Orientation.VERTICAL})
box.pack_start(self.view, True, True, 0)
if useStack:
self.stack = Gd.Stack(
@@ -43,7 +43,7 @@ class ViewContainer(Gtk.Stack):
else:
self._grid.add(box)
- self._loadMore = new Widgets.LoadMoreButton(self._getRemainingItemCount)
+ self._loadMore = Widgets.LoadMoreButton(self._getRemainingItemCount)
box.pack_end(self._loadMore.widget, False, False, 0)
self._loadMore.widget.connect("clicked", self.populate)
self.view.connect('item-activated', self._onItemActivated)
@@ -83,13 +83,13 @@ class ViewContainer(Gtk.Stack):
headerBar.setSelectionMode(False)
def _onGriloRead(self):
- if self.headerBar.get_stack().get_visible_child() == self and self._init == False)
+ if (self.headerBar.get_stack().get_visible_child() == self and self._init == False):
self._populate()
self.headerBar.get_stack().connect('notify::visible-child',
self._onHeaderBarVisible)
def _onHeaderBarVisible(self, widget, param):
- if self == widget.get_visible_child() and !self._init:
+ if self == widget.get_visible_child() and self._init:
self._populate()
def _onViewSelectionChanged(self):
@@ -215,7 +215,7 @@ class Albums(ViewContainer):
ViewContainer.__init__("Albums", headerBar,selectionToolbar)
self.view.set_view_type(Gd.MainViewType.ICON)
self.countQuery = Query.album_count
- self._albumWidget = new Widgets.AlbumWidget(player)
+ self._albumWidget = Widgets.AlbumWidget(player)
self.add(self._albumWidget)
self.headerBar.setState (1)
@@ -297,8 +297,8 @@ class Songs(ViewContainer):
cols = listWidget.get_columns()
cells = cols[0].get_cells()
cells[2].visible = False
- nowPlayingSymbolRenderer = new Gtk.CellRendererPixbuf()
- columnNowPlaying = new Gtk.TreeViewColumn()
+ nowPlayingSymbolRenderer = Gtk.CellRendererPixbuf()
+ columnNowPlaying = Gtk.TreeViewColumn()
nowPlayingSymbolRenderer.xalign = 1.0
columnNowPlaying.pack_start(nowPlayingSymbolRenderer, False)
columnNowPlaying.fixed_width = 24
@@ -306,9 +306,9 @@ class Songs(ViewContainer):
columnNowPlaying.add_attribute(nowPlayingSymbolRenderer, "icon_name", 8)
listWidget.insert_column(columnNowPlaying, 0)
- titleRenderer = new Gtk.CellRendererText(xpad=0)
+ titleRenderer = Gtk.CellRendererText(xpad=0)
listWidget.add_renderer(titleRenderer, self._onListWidgetTitleRender)
- starRenderer = new Gtk.CellRendererPixbuf(xpad=32)
+ starRenderer = Gtk.CellRendererPixbuf(xpad=32)
listWidget.add_renderer(starRenderer, self._onListWidgetStarRender)
durationRenderer = Gd.StyledTextRenderer(xpad=32)
durationRenderer.add_class('dim-label')
@@ -386,7 +386,7 @@ class Artists (ViewContainer):
self._artistAlbumsWidget.set_hexpand(True)
self.view.get_style_context().add_class("artist-panel")
self.view.get_generic_view().get_selection().set_mode(Gtk.SelectionMode.SINGLE)
- self._grid.attach(new Gtk.Separator({orientation: Gtk.Orientation.VERTICAL}), 1, 0, 1, 1)
+ self._grid.attach(Gtk.Separator({orientation: Gtk.Orientation.VERTICAL}), 1, 0, 1, 1)
self._grid.attach(self._artistAlbumsWidget, 2, 0, 2, 2)
self._addListRenderers()
if Gtk.Settings.get_default().gtk_application_prefer_dark_theme:
diff --git a/gnome-music/window.py b/gnome-music/window.py
index 8f39230..82d5c29 100644
--- a/gnome-music/window.py
+++ b/gnome-music/window.py
@@ -3,7 +3,7 @@ from gettext import gettext as _
from toolbar import Toolbar
from player import Player, SelectionToolbar
-import views as Views
+import view as Views
import query as Query
tracker = Tracker.SparqlConnection.get (None)
@@ -86,14 +86,12 @@ class Window(Gtk.ApplicationWindow):
)
self._onNotifyModelId = self._stack.connect("notify::visible-child", Lang.bind(self,
self._onNotifyMode))
- self.connect("destroy",Lang.bind(self, function(){
- self._stack.disconnect(self._onNotifyModelId)
- }))
+ self.connect("destroy", self._stack.disconnect(self._onNotifyModelId))
self.views[0].populate()
#To revert to the No Music View when no songs are found
else:
- self.views[0] = new Views.Empty(self.toolbar, self.player)
+ self.views[0] = Views.Empty(self.toolbar, self.player)
self._stack.add_titled(self.views[0],"Empty","Empty")
self.toolbar.header_bar.show()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]