eog-plugins r86 - in trunk: . plugins/slideshowshuffle po



Author: friemann
Date: Sun Apr 12 19:41:24 2009
New Revision: 86
URL: http://svn.gnome.org/viewvc/eog-plugins?rev=86&view=rev

Log:
2009-04-12  Felix Riemann  <friemann svn gnome org>

	* configure.ac:
	* plugins/slideshowshuffle/Makefile.am:
	* 
plugins/slideshowshuffle/slideshowshuffle.eog-plugin.desktop.in:
	* plugins/slideshowshuffle/slideshowshuffle.py:
	Add plugin to randomize image order during slideshows.
	Fixes bug #526135 (Johannes Marbach).


Added:
   trunk/plugins/slideshowshuffle/
   trunk/plugins/slideshowshuffle/Makefile.am
   trunk/plugins/slideshowshuffle/slideshowshuffle.eog-plugin.desktop.in
   trunk/plugins/slideshowshuffle/slideshowshuffle.py
Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/po/ChangeLog
   trunk/po/POTFILES.in

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Sun Apr 12 19:41:24 2009
@@ -62,9 +62,9 @@
 USEFUL_PLUGINS="postr champlain"
 DEFAULT_PLUGINS="postr champlain"
 
-PYTHON_ALL_PLUGINS="pythonconsole"
-PYTHON_USEFUL_PLUGINS="pythonconsole"
-PYTHON_DEFAULT_PLUGINS="pythonconsole"
+PYTHON_ALL_PLUGINS="slideshowshuffle pythonconsole"
+PYTHON_USEFUL_PLUGINS="slideshowshuffle pythonconsole"
+PYTHON_DEFAULT_PLUGINS="slideshowshuffle pythonconsole"
 
 DIST_PLUGINS="$ALL_PLUGINS $PYTHON_ALL_PLUGINS"
 
@@ -327,6 +327,7 @@
 Makefile
 plugins/Makefile
 plugins/champlain/Makefile
+plugins/slideshowshuffle/Makefile
 plugins/postr/Makefile
 plugins/pythonconsole/Makefile
 po/Makefile.in])

Added: trunk/plugins/slideshowshuffle/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/plugins/slideshowshuffle/Makefile.am	Sun Apr 12 19:41:24 2009
@@ -0,0 +1,15 @@
+# Slideshow Shuffle plugin
+plugindir = $(libdir)/eog/plugins
+plugin_in_files = slideshowshuffle.eog-plugin.desktop.in
+
+plugin_PYTHON = \
+	slideshowshuffle.py
+
+%.eog-plugin: %.eog-plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+
+plugin_DATA = $(plugin_in_files:.eog-plugin.desktop.in=.eog-plugin)
+
+EXTRA_DIST = $(plugin_in_files)
+
+CLEANFILES = $(plugin_DATA)
+DISTCLEANFILES = $(plugin_DATA)

Added: trunk/plugins/slideshowshuffle/slideshowshuffle.eog-plugin.desktop.in
==============================================================================
--- (empty file)
+++ trunk/plugins/slideshowshuffle/slideshowshuffle.eog-plugin.desktop.in	Sun Apr 12 19:41:24 2009
@@ -0,0 +1,9 @@
+[Eog Plugin]
+Loader=python
+Module=slideshowshuffle
+IAge=2
+_Name=Slideshow Shuffle
+Icon=media-playlist-shuffle
+_Description=Shuffles images in slideshow mode
+Authors=Johannes Marbach <jm rapidrabbit de>
+Copyright=Copyright  2008 Johannes Marbach

Added: trunk/plugins/slideshowshuffle/slideshowshuffle.py
==============================================================================
--- (empty file)
+++ trunk/plugins/slideshowshuffle/slideshowshuffle.py	Sun Apr 12 19:41:24 2009
@@ -0,0 +1,85 @@
+# Slideshow Shuffle Plugin for Eye of GNOME
+# Copyright (C) 2008  Johannes Marbach <jm rapidrabbit de>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+import eog, random
+
+class SlideshowShufflePlugin(eog.Plugin):
+    def __init__(self):
+        eog.Plugin.__init__(self)
+    
+    def activate(self, window):
+        random.seed()
+        self.slideshow = False
+        self.state_handler_id = \
+            window.connect('window-state-event', self.state_changed_cb)
+    
+    def deactivate(self, window):
+        window.disconnect(self.state_handler_id)
+    
+    def state_changed_cb(self, window, data = None):
+        mode = window.get_mode()
+        
+        if mode == eog.WindowMode(3) and not self.slideshow:
+            # Slideshow starts
+            self.slideshow = True
+            
+            # Query position of current image
+            if not window.get_image():
+                pos = 0
+            else:
+                pos = window.get_store().get_pos_by_image(window.get_image())
+            
+            # Generate random map
+            uri_list = [row[2].get_uri_for_display() \
+                        for row in window.get_store()]
+            self.map = {uri_list.pop(pos): 0}
+            supply = list(range(1, len(uri_list) + 1))
+            for uri in uri_list:
+                self.map[uri] = supply.pop(random.randint(0, len(supply) - 1))
+            
+            # Put random sort function in place
+            window.get_store().\
+                set_default_sort_func(self.random_sort_function)
+        elif mode == eog.WindowMode(1) and self.slideshow:
+            # Slideshow ends
+            self.slideshow = False
+            
+            # Put alphabetic sort function in place
+            window.get_store().\
+                set_default_sort_func(self.alphabetic_sort_function)
+    
+    def random_sort_function(self, store, iter1, iter2, data = None):
+        pos1 = self.map[store[iter1][2].get_uri_for_display()]
+        pos2 = self.map[store[iter2][2].get_uri_for_display()]
+        
+        if  pos1 > pos2:
+            return 1
+        elif pos1 < pos2:
+            return -1
+        else:
+            return 0
+    
+    def alphabetic_sort_function(self, store, iter1, iter2, data = None):
+        uri1 = store[iter1][2].get_uri_for_display().lower()
+        uri2 = store[iter2][2].get_uri_for_display().lower()
+        
+        if uri1 > uri2:
+            return 1
+        elif uri1 < uri2:
+            return -1
+        else:
+            return 0

Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in	(original)
+++ trunk/po/POTFILES.in	Sun Apr 12 19:41:24 2009
@@ -1,4 +1,5 @@
 plugins/champlain/champlain.eog-plugin.desktop.in
+plugins/slideshowshuffle/slideshowshuffle.eog-plugin.desktop.in
 plugins/postr/postr.eog-plugin.desktop.in
 plugins/postr/eog-postr-plugin.c
 plugins/pythonconsole/pythonconsole.eog-plugin.desktop.in



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]