Aggiunto il support a long-edge, short-edge e simili

Leonardo Robol [2009-10-02 08:02]
Aggiunto il support a long-edge, short-edge e simili
Filename
DrPrintBackend.py
DrPrintGui/Input.py
DrPrintGui/MainWin.py
diff --git a/DrPrintBackend.py b/DrPrintBackend.py
index a4b2a4a..afa790a 100644
--- a/DrPrintBackend.py
+++ b/DrPrintBackend.py
@@ -11,7 +11,7 @@ class Backend(gobject.GObject):
         gobject.signal_new("auth_failed", Backend, gobject.SIGNAL_RUN_FIRST, None, ())
         gobject.signal_new('io_error', Backend, gobject.SIGNAL_RUN_FIRST, None, ())

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

@@ -60,10 +60,13 @@ class Backend(gobject.GObject):
         if not orientation == "":
             cmd_opts += "-o %s " % orientation

+        ## Long edge, short edge ed amici vari
+        cmd_opts += "-o sides=%s " % sides
+
         ## Se ci sono opzioni dai il -o e specificale
         if not cmd_opts == "":
             cmd = cmd + "%s" % cmd_opts
-
+

         ## Diamo il comando sul canale e infiliamo il file
         ## dentro lo stdin :)
diff --git a/DrPrintGui/Input.py b/DrPrintGui/Input.py
index 9db4481..27cedbf 100644
--- a/DrPrintGui/Input.py
+++ b/DrPrintGui/Input.py
@@ -331,7 +331,44 @@ class OrientationSelect(gtk.HBox):
         ## Questo non dovrebbe succedere
         return None

+class SidesSelect(gtk.VBox):
+
+    def __init__(self):
+
+        gtk.VBox.__init__(self)
+
+        self.one_sided = gtk.RadioButton(None,
+                                         "Solo fronte",
+                                         True)
+        self.two_sided_short_edge = gtk.RadioButton(self.one_sided,
+                                     "Fronte retro sul lato corto",
+                                     True)
+        self.two_sided_long_edge = gtk.RadioButton(self.one_sided,
+                                    "Fronte retro sul lato lungo",
+                                    True)
+
+        for widget in (self.one_sided,
+                       self.two_sided_short_edge,
+                       self.two_sided_long_edge) :
+            a = PaddingLeftWidget(widget, 20)
+            self.pack_start(a)
+            a.show()
+
+        self.two_sided_long_edge.set_active(True)
+
+    def get_sides_select(self):
+
+        if( self.one_sided.get_active() ):
+            return "one-sided"
+
+        if( self.two_sided_short_edge.get_active() ):
+            return "two-sided-short-edge"
+
+        if( self.two_sided_long_edge.get_active() ):
+            return "two-sided-long-edge"
+

+



diff --git a/DrPrintGui/MainWin.py b/DrPrintGui/MainWin.py
index 5c5fdd8..e8258f2 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, PageRangeBlock, OrientationSelect
+from Input import AuthBlock, PrinterSettingsBlock, PrintButton, LeftAlignedLabel, PageRangeBlock, OrientationSelect, SidesSelect
 from Dialogs import ErrorDialog

 class MainWin(gtk.Window):
@@ -77,7 +77,14 @@ class MainWin(gtk.Window):
         self.page_range_block = PageRangeBlock()
         layout_box.pack_start(self.page_range_block)
         self.page_range_block.show()
+
+        label = LeftAlignedLabel( "<b>Fronte retro</b>" )
+        layout_box.pack_start(label)
+        label.show()

+        self.sides_select = SidesSelect()
+        layout_box.pack_start(self.sides_select)
+        self.sides_select.show()

         self.print_button = PrintButton()
         layout_box.pack_start(self.print_button)
@@ -103,6 +110,7 @@ class MainWin(gtk.Window):
             page_range = self.page_range_block.get_page_range()
             copies = self.printer_settings_block.get_copies()
             orientation = self.orientation_select.get_orientation()
+            sides = self.sides_select.get_sides_select()

             self.backend.send_print(printer = printer,
                                     username = username,
@@ -111,7 +119,8 @@ class MainWin(gtk.Window):
                                     page_per_page = page_per_page,
                                     page_range = page_range,
                                     copies = copies,
-                                    orientation=orientation)
+                                    orientation=orientation,
+                                    sides = sides)
         else:
             self.debug( "Sembra che non ci sia un backend attaccato\
  a questa interfaccia, quindi non faccio nulla")
ViewGit