Aggiunto widget per il range di pagine

Leonardo Robol [2009-09-20 13:35]
Aggiunto widget per il range di pagine
Filename
DrPrintBackend.py
DrPrintGui/Input.py
DrPrintGui/Input.pyc
DrPrintGui/MainWin.py
DrPrintGui/MainWin.pyc
diff --git a/DrPrintBackend.py b/DrPrintBackend.py
index 62a128e..12944d4 100644
--- a/DrPrintBackend.py
+++ b/DrPrintBackend.py
@@ -10,7 +10,7 @@ class Backend(gobject.GObject):

         gobject.signal_new("auth_failed", Backend, gobject.SIGNAL_RUN_FIRST, None, ())

-    def send_print(self, printer, username, password, page_per_page, filename):
+    def send_print(self, printer, username, password, page_per_page, filename, page_range):
         # Get printer name
         print "Selected printer: %s" % printer

@@ -37,12 +37,20 @@ class Backend(gobject.GObject):

         cmd_opts = ""

+        ## Pagine logiche per pagine
         if not page_per_page == 1:
             cmd_opts += "number-up=%s " % str(page_per_page)

+        ## Da a
+        if not page_range == None:
+            cmd_opts += "page-ranges=%s" % page_range
+
+        ## Se ci sono opzioni dai il -o e specificale
         if not cmd_opts == "":
             cmd = cmd + "-o %s" % cmd_opts

+        ## Diamo il comando sul canale e infiliamo il file
+        ## dentro lo stdin :)
         channel.exec_command(cmd)
         channel.sendall( f.read() )
         f.close()
diff --git a/DrPrintGui/Input.py b/DrPrintGui/Input.py
index f750f48..af1330a 100644
--- a/DrPrintGui/Input.py
+++ b/DrPrintGui/Input.py
@@ -195,3 +195,55 @@ class PrinterSettingsBlock(gtk.HBox):
         return self.page_per_page.get_page_per_page()


+
+class PageRangeBlock(gtk.VBox):
+
+    def __init__(self):
+
+        gtk.VBox.__init__(self)
+
+        self.check_button = gtk.CheckButton("Stampa solo una parte del documento",
+                                       True)
+
+        self.check_button.set_active(False)
+
+        self.check_button.connect('clicked', self.check_button_callback)
+
+        self.pack_start(self.check_button)
+        self.check_button.show()
+
+        self.hbox = gtk.HBox()
+
+        self.range_field = gtk.Entry()
+
+        label = LeftAlignedLabel("Range di pagine", 2)
+        self.hbox.pack_start(label)
+        self.hbox.pack_start(self.range_field)
+        label.show()
+
+        self.pack_start(self.hbox)
+
+        self.range_field.show()
+
+        self.hbox.show()
+        self.hbox.set_spacing( 5 )
+        self.hbox.set_sensitive(False)
+
+    def check_button_callback(self, obj):
+
+        if self.check_button.get_active() == False:
+            self.hbox.set_sensitive(False)
+        else:
+            self.hbox.set_sensitive(True)
+
+    def get_page_range(self):
+
+        if self.check_button.get_active() == False:
+            return None
+
+        return self.range_field.get_text()
+
+
+
+
+
diff --git a/DrPrintGui/Input.pyc b/DrPrintGui/Input.pyc
index d4fff15..803b8dd 100644
Binary files a/DrPrintGui/Input.pyc and b/DrPrintGui/Input.pyc differ
diff --git a/DrPrintGui/MainWin.py b/DrPrintGui/MainWin.py
index efb3b40..5c0a385 100644
--- a/DrPrintGui/MainWin.py
+++ b/DrPrintGui/MainWin.py
@@ -9,7 +9,7 @@ __author__ = 'Leonardo Robol <leo@robol.it>'

 import gtk, pygtk

-from Input import AuthBlock, PrinterSettingsBlock, PrintButton, LeftAlignedLabel
+from Input import AuthBlock, PrinterSettingsBlock, PrintButton, LeftAlignedLabel, PageRangeBlock
 from Dialogs import ErrorDialog

 class MainWin(gtk.Window):
@@ -66,6 +66,14 @@ class MainWin(gtk.Window):
         layout_box.pack_start(self.printer_settings_block)
         self.printer_settings_block.show()

+        label = LeftAlignedLabel("<b>Configurazione Avanzata</b>")
+        layout_box.pack_start(label)
+        label.show()
+
+        self.page_range_block = PageRangeBlock()
+        layout_box.pack_start(self.page_range_block)
+        self.page_range_block.show()
+
         self.print_button = PrintButton()
         layout_box.pack_start(self.print_button)
         self.print_button.show()
@@ -86,12 +94,14 @@ class MainWin(gtk.Window):
             password = self.auth_block.get_password()
             filename = self.printer_settings_block.get_filename()
             page_per_page = self.printer_settings_block.get_page_per_page()
+            page_range = self.page_range_block.get_page_range()

             self.backend.send_print(printer = printer,
                                     username = username,
                                     password = password,
                                     filename = filename,
-                                    page_per_page = page_per_page)
+                                    page_per_page = page_per_page,
+                                    page_range = page_range)
         else:
             self.debug( "Sembra che non ci sia un backend attaccato\
  a questa interfaccia, quindi non faccio nulla")
diff --git a/DrPrintGui/MainWin.pyc b/DrPrintGui/MainWin.pyc
index 4bcc91b..6f72302 100644
Binary files a/DrPrintGui/MainWin.pyc and b/DrPrintGui/MainWin.pyc differ
ViewGit