Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 390607 | Differences between
and this patch

Collapse All | Expand All

(-)pdfshuffler-old (-10 / +27 lines)
Lines 32-37 Link Here
32
import sys          #needed for proccessing of command line args
32
import sys          #needed for proccessing of command line args
33
import urllib       #needed to parse filename information passed by DnD
33
import urllib       #needed to parse filename information passed by DnD
34
import threading
34
import threading
35
import traceback
35
import tempfile
36
import tempfile
36
from copy import copy
37
from copy import copy
37
38
Lines 64-69 Link Here
64
import gobject      #to use custom signals
65
import gobject      #to use custom signals
65
import pango        #to adjust the text alignment in CellRendererText
66
import pango        #to adjust the text alignment in CellRendererText
66
import gio          #to inquire mime types information
67
import gio          #to inquire mime types information
68
import cairo, array
67
69
68
import poppler      #for the rendering of pdf pages
70
import poppler      #for the rendering of pdf pages
69
from pyPdf import PdfFileWriter, PdfFileReader
71
from pyPdf import PdfFileWriter, PdfFileReader
Lines 202-236 Link Here
202
        # Create buttons
204
        # Create buttons
203
        self.button_exit = gtk.Button(stock=gtk.STOCK_QUIT)
205
        self.button_exit = gtk.Button(stock=gtk.STOCK_QUIT)
204
        self.button_exit.connect('clicked', self.close_application)
206
        self.button_exit.connect('clicked', self.close_application)
205
        hbox.pack_start(self.button_exit, expand=True, fill=True, padding=20)
207
        hbox.pack_start(self.button_exit, expand=True, fill=False, padding=20)
206
208
207
        self.button_del = gtk.Button(_('Delete Page(s)'))
209
        self.button_del = gtk.Button(_('Delete Page(s)'))
208
        image = gtk.Image()
210
        image = gtk.Image()
209
        image.set_from_stock(gtk.STOCK_DELETE, gtk.ICON_SIZE_BUTTON)
211
        image.set_from_stock(gtk.STOCK_DELETE, gtk.ICON_SIZE_BUTTON)
210
        self.button_del.set_image(image)
212
        self.button_del.set_image(image)
211
        self.button_del.connect('clicked', self.clear_selected)
213
        self.button_del.connect('clicked', self.clear_selected)
212
        hbox.pack_start(self.button_del, expand=True, fill=True, padding=20)
214
        hbox.pack_start(self.button_del, expand=True, fill=False, padding=20)
213
215
214
        self.button_import = gtk.Button(_('Import pdf'))
216
        self.button_import = gtk.Button(_('Import pdf'))
215
        image = gtk.Image()
217
        image = gtk.Image()
216
        image.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON)
218
        image.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON)
217
        self.button_import.set_image(image)
219
        self.button_import.set_image(image)
218
        self.button_import.connect('clicked', self.on_action_add_doc_activate)
220
        self.button_import.connect('clicked', self.on_action_add_doc_activate)
219
        hbox.pack_start(self.button_import, expand=True, fill=True, padding=20)
221
        hbox.pack_start(self.button_import, expand=True, fill=False, padding=20)
220
222
221
        self.button_export = gtk.Button(_('Export pdf'))
223
        self.button_export = gtk.Button(_('Export pdf'))
222
        image = gtk.Image()
224
        image = gtk.Image()
223
        image.set_from_stock(gtk.STOCK_SAVE_AS, gtk.ICON_SIZE_BUTTON)
225
        image.set_from_stock(gtk.STOCK_SAVE_AS, gtk.ICON_SIZE_BUTTON)
224
        self.button_export.set_image(image)
226
        self.button_export.set_image(image)
225
        self.button_export.connect('clicked', self.choose_export_pdf_name)
227
        self.button_export.connect('clicked', self.choose_export_pdf_name)
226
        hbox.pack_start(self.button_export, expand=True, fill=True, padding=20)
228
        hbox.pack_start(self.button_export, expand=True, fill=False, padding=20)
227
229
228
        self.button_export = gtk.Button(_('About'))
230
        self.button_export = gtk.Button(_('About'))
229
        image = gtk.Image()
231
        image = gtk.Image()
230
        image.set_from_stock(gtk.STOCK_ABOUT, gtk.ICON_SIZE_BUTTON)
232
        image.set_from_stock(gtk.STOCK_ABOUT, gtk.ICON_SIZE_BUTTON)
231
        self.button_export.set_image(image)
233
        self.button_export.set_image(image)
232
        self.button_export.connect('clicked', self.about_dialog)
234
        self.button_export.connect('clicked', self.about_dialog)
233
        hbox.pack_start(self.button_export, expand=True, fill=True, padding=20)
235
        hbox.pack_start(self.button_export, expand=True, fill=False, padding=20)
234
236
235
        # Define window callback function and show window
237
        # Define window callback function and show window
236
        self.window.connect('size_allocate', self.on_window_size_request)        # resize
238
        self.window.connect('size_allocate', self.on_window_size_request)        # resize
Lines 982-990 Link Here
982
            pix_w, pix_h = page.get_size()
984
            pix_w, pix_h = page.get_size()
983
            pix_w = int(pix_w * self.scale)
985
            pix_w = int(pix_w * self.scale)
984
            pix_h = int(pix_h * self.scale)
986
            pix_h = int(pix_h * self.scale)
985
            thumbnail = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False,
987
            stride = cairo.ImageSurface.format_stride_for_width (cairo.FORMAT_ARGB32, pix_w)
986
                                       8, pix_w , pix_h)
988
            data = array.array('c', '\x00' * stride * pix_h)
987
            page.render_to_pixbuf(0,0,pix_w,pix_h,self.scale,0,thumbnail)
989
            pix_surface = cairo.ImageSurface.create_for_data(data, cairo.FORMAT_ARGB32,
990
                          pix_w, pix_h, stride)
991
            ctx = cairo.Context(pix_surface)
992
            ctx.scale(self.scale, self.scale)
993
            page.render(ctx)
994
            if sys.byteorder == 'big':
995
                data[0::4], data[1::4], data[2::4], data[3::4] = \
996
                 data[1::4], data[2::4], data[3::4], data[0::4]
997
            else:
998
                data[0::4], data[2::4] = data[2::4], data[0::4]
999
            thumbnail = gtk.gdk.pixbuf_new_from_data(data,
1000
                                                 gtk.gdk.COLORSPACE_RGB,
1001
                                                 True, 8, pix_w , pix_h,
1002
                                                 stride)
988
            rotation = (-rotation) % 360
1003
            rotation = (-rotation) % 360
989
            rotation = ((rotation + 45) / 90) * 90
1004
            rotation = ((rotation + 45) / 90) * 90
990
            thumbnail = thumbnail.rotate_simple(rotation)
1005
            thumbnail = thumbnail.rotate_simple(rotation)
Lines 995-1001 Link Here
995
                src_y = int( crop[2] * pix_h )
1010
                src_y = int( crop[2] * pix_h )
996
                width = int( (1. - crop[0] - crop[1]) * pix_w )
1011
                width = int( (1. - crop[0] - crop[1]) * pix_w )
997
                height = int( (1. - crop[2] - crop[3]) * pix_h )
1012
                height = int( (1. - crop[2] - crop[3]) * pix_h )
998
                new_thumbnail = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False,
1013
                new_thumbnail = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True,
999
                                               8, width, height)
1014
                                               8, width, height)
1000
                thumbnail.copy_area(src_x, src_y, width, height,
1015
                thumbnail.copy_area(src_x, src_y, width, height,
1001
                                    new_thumbnail, 0, 0)
1016
                                    new_thumbnail, 0, 0)
Lines 1003-1013 Link Here
1003
                pix_w = thumbnail.get_width()
1018
                pix_w = thumbnail.get_width()
1004
                pix_h = thumbnail.get_height()
1019
                pix_h = thumbnail.get_height()
1005
        except:
1020
        except:
1021
            print("Test failed: ")
1022
            traceback.print_exc()
1006
            pix_w = self.default_width
1023
            pix_w = self.default_width
1007
            pix_h = pix_w
1024
            pix_h = pix_w
1008
            thumbnail = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False,
1025
            thumbnail = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False,
1009
                                       8, pix_w, pix_h)
1026
                                       8, pix_w, pix_h)
1010
            pixbuf.fill(0xffffffff)
1027
            thumbnail.fill(0xffffffff)
1011
1028
1012
        #add border
1029
        #add border
1013
        thickness = 3
1030
        thickness = 3

Return to bug 390607