Updated sunflower
This commit is contained in:
parent
1f4e9911f1
commit
a4ddfd0036
14 changed files with 287 additions and 5 deletions
|
@ -178,5 +178,9 @@
|
|||
"next_tab_2": "",
|
||||
"previous_tab": "<Primary><Shift>Tab",
|
||||
"previous_tab_2": ""
|
||||
},
|
||||
"sessions": {
|
||||
"show_list": "<Primary><Alt>s",
|
||||
"show_list_2": ""
|
||||
}
|
||||
}
|
|
@ -61,10 +61,18 @@
|
|||
},
|
||||
"plugins": [
|
||||
"system_terminal",
|
||||
"sessions",
|
||||
"rename_extensions",
|
||||
"owner_column",
|
||||
"gvim_viewer",
|
||||
"find_file_extensions",
|
||||
"file_list",
|
||||
"default_toolbar"
|
||||
"default_toolbar",
|
||||
"archive_support",
|
||||
"image-manipulation",
|
||||
"archiver"
|
||||
],
|
||||
"show_command_bar": false,
|
||||
"show_command_bar": true,
|
||||
"show_notifications": true,
|
||||
"show_status_bar": 0,
|
||||
"show_titlebar": true,
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
"size_date": 583,
|
||||
"size_extension": 50,
|
||||
"size_mode": 50,
|
||||
"size_name": 200,
|
||||
"size_name": 286,
|
||||
"size_size": 70
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
{
|
||||
"class": "FileList",
|
||||
"lock": null,
|
||||
"path": "/home/dbroqua",
|
||||
"path": "/home/dbroqua/Projects/dbroqua/home",
|
||||
"sort_ascending": true,
|
||||
"sort_column": 0
|
||||
}
|
||||
|
@ -22,5 +22,14 @@
|
|||
"sort_column": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"sessions": {
|
||||
"current": 0,
|
||||
"list": [
|
||||
{
|
||||
"locked": false,
|
||||
"name": "Default"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Binary file not shown.
1
config/sunflower/user_plugins/archiver/__init__.py
Normal file
1
config/sunflower/user_plugins/archiver/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
|
Binary file not shown.
14
config/sunflower/user_plugins/archiver/plugin.conf
Normal file
14
config/sunflower/user_plugins/archiver/plugin.conf
Normal file
|
@ -0,0 +1,14 @@
|
|||
[Name]
|
||||
en=Archiver
|
||||
|
||||
[Description]
|
||||
en=This plugin provides tools for create and extract archives
|
||||
|
||||
[Version]
|
||||
number=0.1
|
||||
|
||||
[Author]
|
||||
name=Arseniy Krasnov
|
||||
contact=arseniy@krasnoff.org
|
||||
site=
|
||||
|
97
config/sunflower/user_plugins/archiver/plugin.py
Normal file
97
config/sunflower/user_plugins/archiver/plugin.py
Normal file
|
@ -0,0 +1,97 @@
|
|||
import os
|
||||
import gtk
|
||||
import zipfile,tarfile
|
||||
|
||||
class Archiver():
|
||||
|
||||
def __init__(self, main_window) :
|
||||
self.main_window = main_window
|
||||
self.archive_mimes = ('application/zip', 'application/x-tar', 'application/x-compressed-tar')
|
||||
self.menu_mimes = ('application/octet-stream', 'inode/directory', 'text/directory', 'folder')
|
||||
self.extract_menu_item = (
|
||||
{
|
||||
'label': 'Extract',
|
||||
'data': False,
|
||||
'callback': self.extract,
|
||||
},
|
||||
{
|
||||
'label': 'Extract in folder',
|
||||
'data': True,
|
||||
'callback': self.extract,
|
||||
},
|
||||
)
|
||||
|
||||
self.extract_menu = gtk.Menu()
|
||||
for item in self.extract_menu_item:
|
||||
self.extract_menu.append(self.main_window.menu_manager.create_menu_item(item))
|
||||
|
||||
|
||||
self.create_menu_item = (
|
||||
{
|
||||
'label': 'Make archive',
|
||||
'callback': self.make_archive,
|
||||
},
|
||||
)
|
||||
|
||||
self.create_menu = gtk.Menu()
|
||||
for item in self.create_menu_item:
|
||||
self.create_menu.append(self.main_window.menu_manager.create_menu_item(item))
|
||||
|
||||
self.archiver_menu = self.main_window.menu_manager.create_menu_item(
|
||||
{
|
||||
'label': 'Archiver',
|
||||
'submenu': ''
|
||||
}
|
||||
)
|
||||
self.archiver_menu.connect("activate", self.expand_menu)
|
||||
|
||||
def expand_menu(self, data):
|
||||
self.archiver_menu.set_submenu(self.create_menu)
|
||||
filename = self.get_selection()
|
||||
|
||||
try:
|
||||
if zipfile.is_zipfile(filename) or tarfile.is_tarfile(filename):
|
||||
self.archiver_menu.set_submenu(self.extract_menu)
|
||||
except IOError as e:
|
||||
if e.errno == 21:
|
||||
pass
|
||||
|
||||
def get_selection(self):
|
||||
selections = self.main_window.get_active_object()._get_selection()
|
||||
return selections
|
||||
|
||||
def extract(self, widget, in_folder):
|
||||
filepath = self.get_selection()
|
||||
path = os.path.dirname(filepath)
|
||||
if in_folder :
|
||||
path = os.path.splitext(filepath)[0]
|
||||
|
||||
try:
|
||||
if zipfile.is_zipfile(filepath):
|
||||
archive = zipfile.ZipFile(filepath)
|
||||
elif tarfile.is_tarfile(filepath):
|
||||
archive = tarfile.open(filepath)
|
||||
archive.extractall(path)
|
||||
archive.close()
|
||||
except Exception, e :
|
||||
print e
|
||||
|
||||
def make_archive(self, widget, data):
|
||||
filepath = self.get_selection()
|
||||
zfile = filepath.rstrip('/') + '.zip'
|
||||
filepath = filepath.rstrip('/')
|
||||
zf = zipfile.ZipFile(zfile, mode='w')
|
||||
if os.path.isfile(filepath):
|
||||
zf.write(filepath, filepath[len(os.path.dirname(filepath)):].strip('/'), compress_type=zipfile.ZIP_DEFLATED)
|
||||
else:
|
||||
for root, dirs, files in os.walk(filepath):
|
||||
for name in files:
|
||||
file_to_zip = os.path.join(root, name)
|
||||
arcname = file_to_zip[len(os.path.dirname(filepath)):].strip('/')
|
||||
zf.write(file_to_zip, arcname, compress_type=zipfile.ZIP_DEFLATED)
|
||||
|
||||
|
||||
def register_plugin(application):
|
||||
archiver = Archiver(application)
|
||||
application.register_popup_menu_action(archiver.menu_mimes, archiver.archiver_menu)
|
||||
|
Binary file not shown.
14
config/sunflower/user_plugins/image-manipulation/plugin.conf
Normal file
14
config/sunflower/user_plugins/image-manipulation/plugin.conf
Normal file
|
@ -0,0 +1,14 @@
|
|||
[Name]
|
||||
en=Image manipulation
|
||||
|
||||
[Description]
|
||||
en=
|
||||
|
||||
[Version]
|
||||
number=0.1
|
||||
|
||||
[Author]
|
||||
name=Arseniy Krasnov
|
||||
contact=arseniy@krasnoff.org
|
||||
site=
|
||||
|
135
config/sunflower/user_plugins/image-manipulation/plugin.py
Normal file
135
config/sunflower/user_plugins/image-manipulation/plugin.py
Normal file
|
@ -0,0 +1,135 @@
|
|||
import os
|
||||
import Image
|
||||
|
||||
class ImageManipulation():
|
||||
|
||||
def __init__(self, main_window) :
|
||||
self.main_window = main_window
|
||||
self.mimes = ('image/png', 'image/jpeg', 'image/gif','image/bmp','image/tiff', )
|
||||
self.items = (
|
||||
{
|
||||
'label': 'Image manipulation',
|
||||
'submenu':
|
||||
(
|
||||
{
|
||||
'label':'Resize 25%',
|
||||
'data': 25,
|
||||
'callback': self.resize,
|
||||
},
|
||||
{
|
||||
'label':'Resize 50%',
|
||||
'data': 50,
|
||||
'callback': self.resize,
|
||||
},
|
||||
{
|
||||
'label':'Resize 75%',
|
||||
'data': 75,
|
||||
'callback': self.resize,
|
||||
},
|
||||
{
|
||||
'type': 'separator',
|
||||
},
|
||||
{
|
||||
'label': 'Rotate 90',
|
||||
'data': Image.ROTATE_90,
|
||||
'callback': self.transpose,
|
||||
},
|
||||
{
|
||||
'label': 'Rotate 180',
|
||||
'data': Image.ROTATE_180,
|
||||
'callback': self.transpose,
|
||||
},
|
||||
{
|
||||
'label': 'Rotate 270',
|
||||
'data': Image.ROTATE_270,
|
||||
'callback': self.transpose,
|
||||
},
|
||||
{
|
||||
'label': 'Flip left to rigth',
|
||||
'data': Image.FLIP_LEFT_RIGHT,
|
||||
'callback': self.transpose,
|
||||
},
|
||||
{
|
||||
'label': 'Flip top to bottom',
|
||||
'data': Image.FLIP_TOP_BOTTOM,
|
||||
'callback': self.transpose,
|
||||
},
|
||||
{
|
||||
'type': 'separator',
|
||||
},
|
||||
{
|
||||
'label': 'Convert',
|
||||
'submenu':
|
||||
(
|
||||
{
|
||||
'label': 'PNG',
|
||||
'data': 'png',
|
||||
'callback': self.convert,
|
||||
},
|
||||
{
|
||||
'label': 'JPEG',
|
||||
'data': 'JPEG',
|
||||
'callback': self.convert,
|
||||
},
|
||||
{
|
||||
'label': 'BMP',
|
||||
'data': 'bmp',
|
||||
'callback': self.convert,
|
||||
},
|
||||
{
|
||||
'label': 'TIFF',
|
||||
'data': 'tiff',
|
||||
'callback': self.convert,
|
||||
},
|
||||
{
|
||||
'label': 'GIF',
|
||||
'data': 'gif',
|
||||
'callback': self.convert,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
def get_selection_mimes(self):
|
||||
|
||||
selections = self.main_window.get_active_object()._get_selection_list()
|
||||
is_subset = lambda x:self.main_window.associations_manager.get_mime_type(x) in self.mimes
|
||||
result = filter(is_subset, selections)
|
||||
return result
|
||||
|
||||
def resize(self, widget, percent):
|
||||
for image in self.get_selection_mimes():
|
||||
try:
|
||||
im = Image.open(image)
|
||||
w,h = im.size
|
||||
im.resize(((percent*w)/100,(percent*h)/100), Image.ANTIALIAS).save(image)
|
||||
except IOError:
|
||||
print "cannot resize", image
|
||||
|
||||
|
||||
def transpose(self, widget, method):
|
||||
for image in self.get_selection_mimes():
|
||||
try:
|
||||
im = Image.open(image)
|
||||
im.transpose(method).save(image)
|
||||
except IOError:
|
||||
print "cannot rotate", image
|
||||
|
||||
def convert(self, widget, format):
|
||||
for image in self.get_selection_mimes():
|
||||
try:
|
||||
im = Image.open(image)
|
||||
file_name = '{0}.{1}'.format(os.path.splitext(image)[0], format)
|
||||
im.save(file_name, format=format)
|
||||
except IOError:
|
||||
print "cannot convert", image
|
||||
|
||||
|
||||
def register_plugin(application):
|
||||
|
||||
im = ImageManipulation(application)
|
||||
for item in im.items:
|
||||
application.register_popup_menu_action(im.mimes, application.menu_manager.create_menu_item(item))
|
|
@ -2,7 +2,7 @@
|
|||
"main": {
|
||||
"geometry": [
|
||||
1906,
|
||||
989
|
||||
977
|
||||
],
|
||||
"handle_position": 953,
|
||||
"hide_on_close": false,
|
||||
|
|
Loading…
Reference in a new issue