diff options
-rw-r--r-- | .SRCINFO | 6 | ||||
-rw-r--r-- | PKGBUILD | 13 | ||||
-rw-r--r-- | save_as_tweaks_1.3.patch | 107 |
3 files changed, 121 insertions, 5 deletions
@@ -1,8 +1,8 @@ # Generated by mksrcinfo v8 -# Sat Nov 3 18:52:03 UTC 2018 +# Sat Dec 29 12:47:10 UTC 2018 pkgbase = mcomix-git pkgdesc = A user-friendly, customizable image viewer specifically designed to handle comic books - pkgver = r1488.30700bf + pkgver = r1494.0b5e6d4 pkgrel = 1 url = https://sourceforge.net/projects/mcomix/ install = mcomix-git.install @@ -25,7 +25,9 @@ pkgbase = mcomix-git provides = mcomix conflicts = mcomix source = mcomix-git::git+http://git.code.sf.net/p/mcomix/git + source = save_as_tweaks_1.3.patch sha256sums = SKIP + sha256sums = 10fcc2045e49dac348de37d9ea8d0491b6d74300267396054a913ffac8fefdab pkgname = mcomix-git @@ -4,7 +4,7 @@ # Contributor: Ray Powell <ray_al@xphoniexx.net> pkgname=mcomix-git -pkgver=r1488.30700bf +pkgver=r1494.0b5e6d4 pkgrel=1 pkgdesc="A user-friendly, customizable image viewer specifically designed to handle comic books" arch=('any') @@ -20,8 +20,10 @@ optdepends=('libunrar: for rar compressed comics' \ 'mupdf: for PDF comics') provides=("mcomix") conflicts=("mcomix") -source=("${pkgname}::git+http://git.code.sf.net/p/mcomix/git") -sha256sums=('SKIP') +source=("${pkgname}::git+http://git.code.sf.net/p/mcomix/git" + 'save_as_tweaks_1.3.patch') +sha256sums=('SKIP' + '10fcc2045e49dac348de37d9ea8d0491b6d74300267396054a913ffac8fefdab') install=${pkgname}.install pkgver() { @@ -29,6 +31,11 @@ pkgver() { printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" } +prepare() { + cd "${pkgname}" + patch -Np1 -i "${srcdir}/save_as_tweaks_1.3.patch" +} + package() { cd "${srcdir}/${pkgname}" mkdir -p ${pkgdir}/usr diff --git a/save_as_tweaks_1.3.patch b/save_as_tweaks_1.3.patch new file mode 100644 index 000000000000..0917ed759c21 --- /dev/null +++ b/save_as_tweaks_1.3.patch @@ -0,0 +1,107 @@ +diff --git a/mcomix/main.py b/mcomix/main.py +index 80f74dc..d341238 100644 +--- a/mcomix/main.py ++++ b/mcomix/main.py +@@ -278,6 +278,8 @@ class MainWindow(gtk.Window): + if show_library: + self.actiongroup.get_action('library').activate() + ++ self.last_used_directory=None ++ + self.cursor_handler.auto_hide_on() + # Make sure we receive *all* mouse motion events, + # even if a modal dialog is being shown. +@@ -984,6 +986,7 @@ class MainWindow(gtk.Window): + def extract_page(self, *args): + """ Derive some sensible filename (archive name + _ + filename should do) and offer + the user the choice to save the current page with the selected name. """ ++ + if self.filehandler.archive_type is not None: + archive_name = self.filehandler.get_pretty_current_filename() + file_name = self.imagehandler.get_path_to_page() +@@ -995,15 +998,50 @@ class MainWindow(gtk.Window): + save_dialog = gtk.FileChooserDialog(_('Save page as'), self, + gtk.FILE_CHOOSER_ACTION_SAVE, (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT, + gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)) +- save_dialog.set_do_overwrite_confirmation(True) + save_dialog.set_current_name(suggested_name.encode('utf-8')) ++ save_dialog.set_do_overwrite_confirmation(True) + +- if save_dialog.run() == gtk.RESPONSE_ACCEPT and save_dialog.get_filename(): +- shutil.copy(self.imagehandler.get_path_to_page(), +- save_dialog.get_filename().decode('utf-8')) ++ if self.last_used_directory is not None and prefs['store recently saved in directory']: ++ # Automatically select previously used directory: ++ save_dialog.set_current_folder(self.last_used_directory) ++ else: ++ self.last_used_directory = os.getcwd() ++ ++ if prefs['append number to suggested name']: ++ last_used_directory_plus_suggested_name = os.path.join(self.last_used_directory, suggested_name) ++ try_number = 1 ++ # If the suggested filename already exists we try to suggest a new one: ++ if os.path.exists(last_used_directory_plus_suggested_name): ++ temp_suggested_name = suggested_name ++ lastpath_plus_new_suggested_name = last_used_directory_plus_suggested_name ++ ++ while os.path.exists(lastpath_plus_new_suggested_name): ++ temp_suggested_name_loop = self.generate_numbered_filename(temp_suggested_name.encode('utf-8'), try_number) ++ lastpath_plus_new_suggested_name = self.last_used_directory + os.sep + temp_suggested_name_loop ++ try_number += 1 ++ if not os.path.exists(lastpath_plus_new_suggested_name): ++ # Keep this unused appended number ++ break ++ save_dialog.set_current_name(temp_suggested_name_loop) + ++ if save_dialog.run() == gtk.RESPONSE_ACCEPT and save_dialog.get_filename(): ++ try: ++ shutil.copy(self.imagehandler.get_path_to_page(), ++ save_dialog.get_filename().decode('utf-8')) ++ except Exception, ex: ++ log.warning('An error occured: %s', ex) ++ ++ if prefs['store recently saved in directory']: ++ self.last_used_directory = save_dialog.get_current_folder() + save_dialog.destroy() + ++ def generate_numbered_filename(self, filename, number): ++ """ Generate the same filename with an appended (number) before the .extension""" ++ file_no_ext = os.path.splitext(filename)[0] ++ ext = os.path.splitext(filename)[1] ++ new_name_with_number = file_no_ext + (" (%s)" %(number)) + ext ++ return new_name_with_number ++ + def delete(self, *args): + """ The currently opened file/archive will be deleted after showing + a confirmation dialog. """ +diff --git a/mcomix/preferences.py b/mcomix/preferences.py +index 3803c18..9beaac8 100644 +--- a/mcomix/preferences.py ++++ b/mcomix/preferences.py +@@ -51,6 +51,8 @@ prefs = { + 'smart scroll percentage': 0.5, + 'flip with wheel': True, + 'store recent file info': True, ++ 'store recently saved in directory': False, ++ 'append number to suggested name': False, + 'hide all': False, + 'hide all in fullscreen': True, + 'stored hide all values': [True, True, True, True, True], +diff --git a/mcomix/preferences_dialog.py b/mcomix/preferences_dialog.py +index 6fdbef7..4d4230e 100644 +--- a/mcomix/preferences_dialog.py ++++ b/mcomix/preferences_dialog.py +@@ -305,6 +305,13 @@ class _PreferencesDialog(gtk.Dialog): + page.add_row(gtk.Label(_('Animation mode:')), + self._create_animation_mode_combobox()) + ++ page.new_section(_('Save as Dialog')) ++ page.add_row(self._create_pref_check_button(_('Automatically select the last used directory'), ++ 'store recently saved in directory', 'Directs the Save As dialog to the last used directory automatically.')) ++ # FIXME: disable the following checkbutton if the previous one is disabled ++ page.add_row(self._create_pref_check_button(_('Append numbers to suggested filename if it already exists'), ++ 'append number to suggested name', 'Appends a number at the end of the suggested filename in case a similar filename already exists in the current directory.')) ++ + return page + + def _init_shortcuts_tab(self): |