[Python-apps-commits] r10102 - in packages/pdfshuffler/trunk/debian/patches (add-save-button)
sez at users.alioth.debian.org
sez at users.alioth.debian.org
Thu Oct 17 21:31:45 UTC 2013
Date: Thursday, October 17, 2013 @ 21:31:42
Author: sez
Revision: 10102
import patches/add-save-button
Added:
packages/pdfshuffler/trunk/debian/patches/add-save-button
Added: packages/pdfshuffler/trunk/debian/patches/add-save-button
===================================================================
--- packages/pdfshuffler/trunk/debian/patches/add-save-button (rev 0)
+++ packages/pdfshuffler/trunk/debian/patches/add-save-button 2013-10-17 21:31:42 UTC (rev 10102)
@@ -0,0 +1,100 @@
+# Description: add "Save" button for single-document manipulation
+# Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=722995
+# Forwarded: no
+# Author: Serafeim Zanikolas <sez at debian.org>
+# Last-Update: 2013-10-06
+--- a/data/pdfshuffler.ui
++++ b/data/pdfshuffler.ui
+@@ -264,13 +264,13 @@
+ </child>
+ <child>
+ <object class="GtkToolButton" id="toolbutton_save">
+- <property name="sensitive">False</property>
++ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+- <property name="no_show_all">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="label" translatable="yes">Save</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-save</property>
++ <signal name="clicked" handler="save_pdf" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+--- a/pdfshuffler/pdfshuffler.py
++++ b/pdfshuffler/pdfshuffler.py
+@@ -6,6 +6,7 @@
+ PdfShuffler 0.6.0 - GTK+ based utility for splitting, rearrangement and
+ modification of PDF documents.
+ Copyright (C) 2008-2012 Konstantinos Poulios
++ Copyright (C) 2013 Google Inc
+ <https://sourceforge.net/projects/pdfshuffler>
+
+ This file is part of PdfShuffler.
+@@ -268,9 +269,15 @@
+
+ self.set_unsaved(False)
+
++ # Clicking on "Save" will store to this filename if only one document
++ # has been imported.
++ self.default_save_filename = None
++
+ # Importing documents passed as command line arguments
+ for filename in sys.argv[1:]:
+- self.add_pdf_pages(filename)
++ successful = self.add_pdf_pages(filename)
++ if successful and self.default_save_filename is None:
++ self.default_save_filename = filename
+
+ def render(self):
+ if self.rendering_thread:
+@@ -455,6 +462,38 @@
+ gobject.idle_add(self.render)
+ return res
+
++ def save_pdf(self, widget=None, only_selected=False):
++ """Stores contents under the filename of the first-ever imported pdf"""
++
++ file_out = self.default_save_filename
++
++ # Do nothing if there's nothing to save.
++ if file_out is None:
++ return
++
++ # Prompt for a filename if multiple documents were imported.
++ if len(self.pdfqueue) > 1:
++ self.choose_export_pdf_name()
++ return
++
++ # TODO extract method (and re-use here and at choose_export_pdf_name())
++ (path, shortname) = os.path.split(file_out)
++ (shortname, ext) = os.path.splitext(shortname)
++ if ext.lower() != '.pdf':
++ file_out = file_out + '.pdf'
++ try:
++ self.export_to_file(file_out, only_selected)
++ self.export_directory = path
++ self.set_unsaved(False)
++ except Exception, e:
++ error_msg_dlg = gtk.MessageDialog(flags=gtk.DIALOG_MODAL,
++ type=gtk.MESSAGE_ERROR,
++ message_format=str(e),
++ buttons=gtk.BUTTONS_OK)
++ response = error_msg_dlg.run()
++ if response == gtk.RESPONSE_OK:
++ error_msg_dlg.destroy()
++
+ def choose_export_pdf_name(self, widget=None, only_selected=False):
+ """Handles choosing a name for exporting """
+
+@@ -599,7 +638,9 @@
+ expected_mime_type = 'application/pdf'
+
+ if mime_type == expected_mime_type:
+- self.add_pdf_pages(filename)
++ successful = self.add_pdf_pages(filename)
++ if successful and self.default_save_filename is None:
++ self.default_save_filename = filename
+ elif mime_type[:34] == 'application/vnd.oasis.opendocument':
+ print(_('OpenDocument not supported yet!'))
+ elif mime_type[:5] == 'image':
More information about the Python-apps-commits
mailing list