Commits

Vladimir Kolev committed d0198f2

Previous button was added, and searching the searchresult list was enabled

Comments (0)

Files changed (3)

data/gsharkdown.ini

 down_path = /home/vladi/Desktop
 show_stat_icon = 0
 repeat_playlist = 1
-shuffle_playlist = 1
-completition = Roni Size|Eminem|Madonna|Skillet|DMX|Dr. Dre|Ceca|Ceca Velickovic|Syrenia|Within temptation|
+shuffle_playlist = 0
+completition = Roni Size|Eminem|Madonna|Skillet|DMX|Dr. Dre|Ceca|Ceca Velickovic|Syrenia|Within temptation|Lady Gaga|EMinem|Beatles|Scorpions|Deep Purple|

data/main_window.ui

               </packing>
             </child>
             <child>
+              <object class="GtkToolButton" id="toolbutton14">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Previous</property>
+                <property name="use_underline">True</property>
+                <property name="stock_id">gtk-media-previous</property>
+                <signal name="clicked" handler="play_previous"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="homogeneous">True</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkToolButton" id="toolbutton3">
                 <property name="visible">True</property>
                 <property name="tooltip_text" translatable="yes">Play/Stop</property>
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="rules_hint">True</property>
-                                <property name="enable_search">False</property>
                                 <signal name="row_activated" handler="play_selected"/>
                               </object>
                             </child>
         prefs.connect("activate", self.edit_preferences)
         playbut = gtk.ImageMenuItem(gtk.STOCK_MEDIA_PLAY)
         playbut.connect("activate", self.play_selected)
-        ffbut = gtk.ImageMenuItem(gtk.STOCK_MEDIA_FORWARD)
+        prebut = gtk.ImageMenuItem(gtk.STOCK_MEDIA_PREVIOUS)
+        prebut.connect("activate", self.play_previous)
+        ffbut = gtk.ImageMenuItem(gtk.STOCK_MEDIA_NEXT)
         ffbut.connect("activate", self.play_next)
         quiter = gtk.ImageMenuItem(gtk.STOCK_QUIT)
         quiter.connect("activate", self.quit_app)
 
+        menu.append(prebut)
         menu.append(playbut)
         menu.append(ffbut)
         menu.append(gtk.SeparatorMenuItem())
                 t = t_play(self, song)
                 t.start()
 
+    def play_previous(self, widget, data=None):
+        """
+        Plays the previous song from the playlist
+        """
+        if self.playing == None:
+            self.play_selected(self.play_button)
+        else:
+            index = self.playing - 1
+            if int(CONFIG['shuffle_playlist']) == 1:
+                index = random.randint(0, len(self.playitems))
+
+            if index < 0:
+                if int(CONFIG['repeat_playlist']) == 1:
+                    self.playing = len(self.playitems) - 1 
+                    self.player.set_state(gst.STATE_NULL)
+                    song = self.playitems[len(self.playitems) - 1]
+                    self.set_songinfos(song)
+                    t = t_play(self, song)
+                    t.start()
+                else:
+                    self.player.set_state(gst.STATE_NULL)
+                    self.play_button.set_stock_id(gtk.STOCK_MEDIA_PLAY)
+                    self.playing = None
+                    self.set_songinfos()
+            else:
+                self.playing = index
+                self.player.set_state(gst.STATE_NULL)
+                song = self.playitems[index]
+                self.set_songinfos(song)
+                t = t_play(self, song)
+                t.start()
+
     def on_volume_change(self, widget, data=0.5):
         """
         Volume change handler