File: phatch_recent.py

package info (click to toggle)
phatch 0.1.6-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 9,728 kB
  • ctags: 2,197
  • sloc: python: 17,901; xml: 9; makefile: 8
file content (33 lines) | stat: -rw-r--r-- 1,673 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

from urllib import unquote
from subprocess import call
import nautilus

from phatch.core.config import load_locale_only
load_locale_only()

class phatch_recent_extension(nautilus.MenuProvider):
    def __init__(self):
        pass
        
    def menu_activate_cb(self, menu, files):
        for file in files:
            if file.is_gone():
                return
        files = ["'%s'"%unquote(file.get_uri()[7:]) for file in files]
        call('phatch -d recent %s &'%' '.join(files),shell=True)
        
    def get_file_items(self, window, files):
        #only directories and readable image files are accepted
        files   = [file for file in files             if (file.get_uri_scheme() == 'file' and 
            file.get_mime_type() in ['image/bmp', 'image/bw', 'image/cmyk', 'image/cur', 'image/dcx', 'image/dib', 'image/flc', 'image/fli', 'image/fpx', 'image/gbr', 'image/gd', 'image/gif', 'image/ico', 'image/im', 'image/imt', 'image/jpe', 'image/jpeg', 'image/jpg', 'image/mcidas', 'image/mic', 'image/msp', 'image/pbm', 'image/pcd', 'image/pcx', 'image/pgm', 'image/png', 'image/ppm', 'image/psd', 'image/rgb', 'image/sun', 'image/tga', 'image/tif', 'image/tiff', 'image/xbm', 'image/xpm'])]
        #return if nothing to do
        if not files: return
        #install menu
        item = nautilus.MenuItem('NautilusPython::phatch_recent',
                                 _("Process with recent Phatch action list")+"...",
                                 _("Batch process images with Phatch"))
        #bind/connect menu item with method
        item.connect('activate', self.menu_activate_cb, files)
        #return menu item
        return item,