mail[Mypaint-discuss] Scrap saving system (SSS :)


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by David Gowers (kampu) on December 08, 2010 - 10:14:
Hi all!
I use the 'save scrap' feature exclusively now -- I only ever used
ordinary 'Save' because I didn't want the filename to cycle _a,_b,_c..
but instead to simply keep saving to the same file.
I have altered the scrap saving functionality to achieve this:

* when no filename is yet assigned to an image, it behaves just the
same (saves as the next PREFIXnnn.ora filename not yet used)
* when there is a filename assigned, it is exactly like Save -- it
overwrites the file.
* no _a,_b,_c suffix is added.
* if you are used to saving variants of images (eg redlines) as
scraps, that will no longer work -- you must 'Save as'

I find this just plain more effective:)
(patch attached, have fun!)

co'o,
David
From 02dae649bbc5ddff669f49edb0a981445464dfba Mon Sep 17 00:00:00 2001
From: David Gowers <00ai99@xxxxxxxxx>
Date: Wed, 8 Dec 2010 18:20:03 +1030
Subject: [PATCH] Scrap saving: Instead of cycling _a,b,c, overwrite the 
current file;
 if there is no current file name, write the next scrap.

Completely obviates the 'save' function, for purposes of rapid accumulation 
of rapid sketches.
---
 gui/filehandling.py |   38 +++++++++++++++-----------------------
 1 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/gui/filehandling.py b/gui/filehandling.py
index 8e2abd6..cef1324 100644
--- a/gui/filehandling.py
+++ b/gui/filehandling.py
@@ -377,6 +377,11 @@ class FileHandler(object):
 
     def save_scrap_cb(self, action):
         filename = self.filename
+        if filename:
+            # always overwrite when the filename is set
+            self.save_file(filename)
+            return
+        #otherwise, save a scrap.
         prefix = self.get_scrap_prefix()
 
         # If necessary, create the folder(s) the scraps are stored under
@@ -390,29 +395,16 @@ class FileHandler(object):
             if l:
                 number = l[0]
 
-        if number:
-            # reuse the number, find the next character
-            char = 'a'
-            for filename in glob(prefix + number + '_*'):
-                c = filename[len(prefix + number + '_')]
-                if c >= 'a' and c <= 'z' and c >= char:
-                    char = chr(ord(c)+1)
-            if char > 'z':
-                # out of characters, increase the number
-                self.filename = None
-                return self.save_scrap_cb(action)
-            filename = '%s%s_%c' % (prefix, number, char)
-        else:
-            # we don't have a scrap filename yet, find the next number
-            maximum = 0
-            for filename in glob(prefix + '[0-9][0-9][0-9]*'):
-                filename = filename[len(prefix):]
-                res = re.findall(r'[0-9]*', filename)
-                if not res: continue
-                number = int(res[0])
-                if number > maximum:
-                    maximum = number
-            filename = '%s%03d_a' % (prefix, maximum+1)
+        # we don't have a scrap filename yet, find the next number
+        maximum = 0
+        for filename in glob(prefix + '[0-9][0-9][0-9]*'):
+            filename = filename[len(prefix):]
+            res = re.findall(r'[0-9]*', filename)
+            if not res: continue
+            number = int(res[0])
+            if number > maximum:
+                maximum = number
+        filename = '%s%03d' % (prefix, maximum+1)
 
         # Add extension
         cfg = self.app.preferences['saving.default_format']
-- 
1.7.3.3


Related Messages


Powered by MHonArc, Updated Thu Dec 09 13:20:10 2010