[glabels/vala] Add print preview and setup tab



commit 4e1a312ec41514a4b71fca1b74ebbd960afe5ffb
Author: Jim Evins <evins snaught com>
Date:   Fri Jul 5 22:58:10 2013 -0400

    Add print preview and setup tab
    
    Commit outstanding changes made months ago to add a print setup tab.

 data/ui/Makefile.am             |    1 +
 data/ui/media-select.ui         |  362 -------------------------------
 data/ui/print_setup_editor.ui   |  453 +++++++++++++++++++++++++++++++++++++++
 glabels/Makefile.am             |    1 +
 glabels/mini_preview.vala       |    1 +
 glabels/model_print.vala        |  122 ++++++++++-
 glabels/print_setup_editor.vala |  287 +++++++++++++++++++++++++
 glabels/svg_cache.vala          |    4 +-
 glabels/window.vala             |   16 +-
 9 files changed, 870 insertions(+), 377 deletions(-)
---
diff --git a/data/ui/Makefile.am b/data/ui/Makefile.am
index d730b20..6e5c8c9 100644
--- a/data/ui/Makefile.am
+++ b/data/ui/Makefile.am
@@ -8,6 +8,7 @@ builder_DATA = \
        merge_property_editor.ui \
        new_label_dialog.ui \
        object_editor.ui \
+       print_setup_editor.ui \
        $(NULL)
 
 
diff --git a/data/ui/print_setup_editor.ui b/data/ui/print_setup_editor.ui
new file mode 100644
index 0000000..536b79e
--- /dev/null
+++ b/data/ui/print_setup_editor.ui
@@ -0,0 +1,453 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkWindow" id="window1">
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkBox" id="print_setup_editor_box">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <property name="spacing">12</property>
+        <child>
+          <object class="GtkBox" id="box4">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">9</property>
+            <child>
+              <object class="GtkFrame" id="copies_frame">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="no_show_all">True</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">none</property>
+                <child>
+                  <object class="GtkAlignment" id="alignment1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <object class="GtkBox" id="box5">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">3</property>
+                        <child>
+                          <object class="GtkRadioButton" id="copies_sheets_radio">
+                            <property name="use_action_appearance">False</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="xalign">0</property>
+                            <property name="active">True</property>
+                            <property name="draw_indicator">True</property>
+                            <child>
+                              <object class="GtkBox" id="box6">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">6</property>
+                                <child>
+                                  <object class="GtkLabel" id="label6">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Sheets:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkSpinButton" id="copies_sheets_spin">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="invisible_char">●</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkRadioButton" id="copies_labels_radio">
+                            <property name="use_action_appearance">False</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="xalign">0</property>
+                            <property name="active">True</property>
+                            <property name="draw_indicator">True</property>
+                            <property name="group">copies_sheets_radio</property>
+                            <child>
+                              <object class="GtkBox" id="box7">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">6</property>
+                                <child>
+                                  <object class="GtkLabel" id="label7">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Labels from:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkSpinButton" id="copies_labels_start_spin">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="invisible_char">●</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="label8">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">to:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkSpinButton" id="copies_labels_end_spin">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="invisible_char">●</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">3</property>
+                                  </packing>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="label3">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">&lt;b&gt;Copies&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkFrame" id="merge_frame">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="no_show_all">True</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">none</property>
+                <child>
+                  <object class="GtkAlignment" id="alignment2">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <object class="GtkBox" id="box8">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">3</property>
+                        <child>
+                          <object class="GtkBox" id="box9">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkLabel" id="label9">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Start on label</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="merge_start_spin">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="invisible_char">●</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label10">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">on 1st sheet</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="box10">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkLabel" id="label11">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Copies:</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="merge_copies_spin">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="invisible_char">●</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="merge_collate_check">
+                                <property name="label" translatable="yes">collate</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="xalign">0</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkImage" id="merge_collate_image">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="stock">gtk-missing-image</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">3</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="label4">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">&lt;b&gt;Merge options&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkFrame" id="frame3">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">none</property>
+                <child>
+                  <object class="GtkAlignment" id="alignment3">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <object class="GtkBox" id="box11">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">3</property>
+                        <child>
+                          <object class="GtkCheckButton" id="print_outlines_check">
+                            <property name="label" translatable="yes">print outlines</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="xalign">0</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkCheckButton" id="print_reverse_check">
+                            <property name="label" translatable="yes">print in reverse (i.e. a mirror 
image)</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="xalign">0</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkCheckButton" id="print_crop_marks_check">
+                            <property name="label" translatable="yes">print crop marks</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="xalign">0</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="label5">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">&lt;b&gt;Print options&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="box2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">6</property>
+            <child>
+              <object class="GtkBox" id="preview_box">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="vexpand">True</property>
+                <property name="orientation">vertical</property>
+                <child>
+                  <placeholder/>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/glabels/Makefile.am b/glabels/Makefile.am
index 82e4d41..9e1ee1c 100644
--- a/glabels/Makefile.am
+++ b/glabels/Makefile.am
@@ -78,6 +78,7 @@ glabels_4_SOURCES = \
        prefs.vala \
        print_op.vala \
        print_op_dialog.vala \
+       print_setup_editor.vala \
        svg_cache.vala \
        template_history.vala \
        text_line.vala \
diff --git a/glabels/mini_preview.vala b/glabels/mini_preview.vala
index 9ed6cf0..3c863cf 100644
--- a/glabels/mini_preview.vala
+++ b/glabels/mini_preview.vala
@@ -87,6 +87,7 @@ namespace glabels
                        set_template( model.label.template );
 
                        model.label.changed.connect( on_label_changed );
+                       model.print.changed.connect( on_label_changed );
                }
 
 
diff --git a/glabels/model_print.vala b/glabels/model_print.vala
index 93e3691..20be599 100644
--- a/glabels/model_print.vala
+++ b/glabels/model_print.vala
@@ -28,15 +28,127 @@ namespace glabels
        public class ModelPrint
        {
 
-               private Label label;
-
                private const double OUTLINE_WIDTH =  0.25;
                private const double TICK_OFFSET   =  2.25;
                private const double TICK_LENGTH   = 18.0;
 
-               public bool  outline_flag    { get; set; }
-               public bool  reverse_flag    { get; set; }
-               public bool  crop_marks_flag { get; set; }
+
+               public signal void changed();
+
+
+               private Label label;
+
+
+               /**
+                * Simple N Sheets
+                */
+               public int simple_n_sheets
+               {
+                       get { return _simple_n_sheets; }
+
+                       set
+                       {
+                               if ( _simple_n_sheets != value )
+                               {
+                                       _simple_n_sheets = value;
+                                       changed();
+                               }
+                       }
+               }
+               private int _simple_n_sheets;
+
+
+               /**
+                * Simple Start
+                */
+               public int simple_start
+               {
+                       get { return _simple_start; }
+
+                       set
+                       {
+                               if ( _simple_start != value )
+                               {
+                                       _simple_start = value;
+                                       changed();
+                               }
+                       }
+               }
+               private int _simple_start;
+
+
+               /**
+                * Simple End
+                */
+               public int simple_end
+               {
+                       get { return _simple_end; }
+
+                       set
+                       {
+                               if ( _simple_end != value )
+                               {
+                                       _simple_end = value;
+                                       changed();
+                               }
+                       }
+               }
+               private int _simple_end;
+
+
+               /**
+                * Print Outline Flag
+                */
+               public bool outline_flag
+               {
+                       get { return _outline_flag; }
+
+                       set
+                       {
+                               if ( _outline_flag != value )
+                               {
+                                       _outline_flag = value;
+                                       changed();
+                               }
+                       }
+               }
+               private bool _outline_flag;
+
+               /**
+                * Print in Reverse Flag
+                */
+               public bool reverse_flag
+               {
+                       get { return _reverse_flag; }
+
+                       set
+                       {
+                               if ( _reverse_flag != value )
+                               {
+                                       _reverse_flag = value;
+                                       changed();
+                               }
+                       }
+               }
+               private bool _reverse_flag;
+
+               /**
+                * Print Crop Marks Flag
+                */
+               public bool crop_marks_flag
+               {
+                       get { return _crop_marks_flag; }
+
+                       set
+                       {
+                               if ( _crop_marks_flag != value )
+                               {
+                                       _crop_marks_flag = value;
+                                       changed();
+                               }
+                       }
+               }
+               private bool _crop_marks_flag;
 
                public int   n_pages         { get; set; }
 
diff --git a/glabels/print_setup_editor.vala b/glabels/print_setup_editor.vala
new file mode 100644
index 0000000..3735e0f
--- /dev/null
+++ b/glabels/print_setup_editor.vala
@@ -0,0 +1,287 @@
+/*  print_setup_editor.vala
+ *
+ *  Copyright (C) 2012  Jim Evins <evins snaught com>
+ *
+ *  This file is part of gLabels.
+ *
+ *  gLabels is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  gLabels is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with gLabels.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+using GLib;
+using libglabels;
+
+namespace glabels
+{
+
+       public class PrintSetupEditor : Gtk.Box
+       {
+
+               private const int DEFAULT_W = 280;
+               private const int DEFAULT_H = 420;
+
+
+               private Model model;
+
+
+               /* Widgets */
+               private Gtk.Box         preview_box;
+               private MiniPreview     preview;
+
+               private Gtk.Frame       copies_frame;
+               private Gtk.RadioButton copies_sheets_radio;
+               private Gtk.SpinButton  copies_sheets_spin;
+               private Gtk.RadioButton copies_labels_radio;
+               private Gtk.SpinButton  copies_labels_start_spin;
+               private Gtk.SpinButton  copies_labels_end_spin;
+
+               private Gtk.Frame       merge_frame;
+               private Gtk.SpinButton  merge_start_spin;
+               private Gtk.SpinButton  merge_copies_spin;
+               private Gtk.CheckButton merge_collate_check;
+               private Gtk.Image       merge_collate_image;
+
+               private Gtk.CheckButton print_outlines_check;
+               private Gtk.CheckButton print_reverse_check;
+               private Gtk.CheckButton print_crop_marks_check;
+
+
+               /* Signal IDs */
+               private ulong sigid_print_outlines_check_toggled;
+               private ulong sigid_print_reverse_check_toggled;
+               private ulong sigid_print_crop_marks_check_toggled;
+
+
+               public PrintSetupEditor()
+               {
+                       /* Load the user interface. */
+                       Gtk.Builder builder = new Gtk.Builder();
+                       try
+                       {
+                               string file = GLib.Path.build_filename( Config.DATADIR, Config.GLABELS_BRANCH,
+                                                                       "ui", "print_setup_editor.ui" );
+                               string[] objects = { "print_setup_editor_box",
+                                                    null };
+                               builder.add_objects_from_file( file, objects );
+                       }
+                       catch ( Error err )
+                       {
+                               error( "Error: %s", err.message );
+                       }
+
+
+                       Gtk.Box print_setup_editor_box = builder.get_object( "print_setup_editor_box" ) as 
Gtk.Box;
+                       pack_start( print_setup_editor_box );
+
+                       preview_box              = builder.get_object( "preview_box" )              as 
Gtk.Box;
+
+                       preview = new MiniPreview( DEFAULT_W, DEFAULT_H );
+                       preview_box.pack_start( preview, true, true, 0 );
+
+
+                       copies_frame             = builder.get_object( "copies_frame" )             as 
Gtk.Frame;
+                       copies_sheets_radio      = builder.get_object( "copies_sheets_radio" )      as 
Gtk.RadioButton;
+                       copies_sheets_spin       = builder.get_object( "copies_sheets_spin" )       as 
Gtk.SpinButton;
+                       copies_labels_radio      = builder.get_object( "copies_labels_radio" )      as 
Gtk.RadioButton;
+                       copies_labels_start_spin = builder.get_object( "copies_labels_start_spin" ) as 
Gtk.SpinButton;
+                       copies_labels_end_spin   = builder.get_object( "copies_labels_end_spin" )   as 
Gtk.SpinButton;
+
+
+                       merge_frame              = builder.get_object( "merge_frame" )              as 
Gtk.Frame;
+                       merge_start_spin         = builder.get_object( "merge_start_spin" )         as 
Gtk.SpinButton;
+                       merge_copies_spin        = builder.get_object( "merge_copies_spin" )        as 
Gtk.SpinButton;
+                       merge_collate_check      = builder.get_object( "merge_collate_check" )      as 
Gtk.CheckButton;
+                       merge_collate_image      = builder.get_object( "merge_collate_image" )      as 
Gtk.Image;
+
+                       print_outlines_check     = builder.get_object( "print_outlines_check" )     as 
Gtk.CheckButton;
+                       print_reverse_check      = builder.get_object( "print_reverse_check" )      as 
Gtk.CheckButton;
+                       print_crop_marks_check   = builder.get_object( "print_crop_marks_check" )   as 
Gtk.CheckButton;
+
+                       sigid_print_outlines_check_toggled =
+                               print_outlines_check.toggled.connect( on_print_outlines_check_toggled );
+                       sigid_print_reverse_check_toggled =
+                               print_reverse_check.toggled.connect( on_print_reverse_check_toggled );
+                       sigid_print_crop_marks_check_toggled =
+                               print_crop_marks_check.toggled.connect( on_print_crop_marks_check_toggled );
+               }
+
+
+               public void set_model( Model model )
+               {
+                       this.model = model;
+
+                       preview.set_model( model );
+
+                       load_copies_frame();
+                       load_merge_frame();
+                       load_print_options();
+
+                       model.label.merge_changed.connect( on_merge_changed );
+
+                       on_merge_changed();
+               }
+
+
+               private void on_merge_changed()
+               {
+                       bool no_merge = model.label.merge is MergeNone;
+
+                       if ( no_merge )
+                       {
+                               copies_frame.show();
+                               merge_frame.hide();
+                       }
+                       else
+                       {
+                               copies_frame.hide();
+                               merge_frame.show();
+                       }
+               }
+
+
+               private void load_merge_frame()
+               {
+               }
+
+
+               private void load_print_options()
+               {
+                       load_print_outlines_check();
+                       load_print_reverse_check();
+                       load_print_crop_marks_check();
+               }
+
+
+               /***************************
+                * copies_* widgets
+                ***************************/
+               private void on_copies_sheets_radio_toggled()
+               {
+                       if ( copies_sheets_radio.get_active() )
+                       {
+                               TemplateFrame frame = model.label.template.frames.first().data;
+
+                               model.print.simple_n_sheets = copies_sheets_spin.get_value_as_int();
+                               model.print.simple_start    = 1;
+                               model.print.simple_end      = frame.get_n_labels();
+
+                               copies_sheets_spin.set_sensitive( true );
+                               copies_labels_start_spin.set_sensitive( false );
+                               copies_labels_end_spin.set_sensitive( false );
+                       }
+               }
+               
+
+               private void on_copies_labels_radio_toggled()
+               {
+                       if ( copies_labels_radio.get_active() )
+                       {
+                               model.print.simple_n_sheets = 1;
+                               model.print.simple_start    = copies_labels_start_spin.get_value_as_int();
+                               model.print.simple_end      = copies_labels_end_spin.get_value_as_int();
+
+                               copies_sheets_spin.set_sensitive( false );
+                               copies_labels_start_spin.set_sensitive( true );
+                               copies_labels_end_spin.set_sensitive( true );
+                       }
+               }
+
+
+               private void on_copies_sheets_spin_changed()
+               {
+                       model.print.simple_n_sheets = copies_sheets_spin.get_value_as_int();
+               }
+               
+
+               private void on_copies_labels_start_spin_changed()
+               {
+                       model.print.simple_start    = copies_labels_start_spin.get_value_as_int();
+               }
+               
+
+               private void on_copies_labels_end_spin_changed()
+               {
+                       model.print.simple_end      = copies_labels_end_spin.get_value_as_int();
+               }
+               
+
+               private void load_copies_frame()
+               {
+                       bool no_merge = model.label.merge is MergeNone;
+
+                       if ( no_merge )
+                       {
+                               
+                       }
+               }
+
+
+               /***************************
+                * print_outlines_check
+                ***************************/
+               private void on_print_outlines_check_toggled()
+               {
+                       model.print.outline_flag = print_outlines_check.get_active();
+               }
+
+               private void load_print_outlines_check()
+               {
+                       GLib.SignalHandler.block( (void*)print_outlines_check, 
sigid_print_outlines_check_toggled );
+
+                       print_outlines_check.set_active( model.print.outline_flag );
+
+                       GLib.SignalHandler.unblock( (void*)print_outlines_check, 
sigid_print_outlines_check_toggled );
+               }
+
+
+               /***************************
+                * print_reverse_check
+                ***************************/
+               private void on_print_reverse_check_toggled()
+               {
+                       model.print.reverse_flag = print_reverse_check.get_active();
+               }
+
+               private void load_print_reverse_check()
+               {
+                       GLib.SignalHandler.block( (void*)print_reverse_check, 
sigid_print_reverse_check_toggled );
+
+                       print_reverse_check.set_active( model.print.reverse_flag );
+
+                       GLib.SignalHandler.unblock( (void*)print_reverse_check, 
sigid_print_reverse_check_toggled );
+               }
+
+
+               /***************************
+                * print_crop_marks_check
+                ***************************/
+               private void on_print_crop_marks_check_toggled()
+               {
+                       model.print.crop_marks_flag = print_crop_marks_check.get_active();
+               }
+
+               private void load_print_crop_marks_check()
+               {
+                       GLib.SignalHandler.block( (void*)print_crop_marks_check, 
sigid_print_crop_marks_check_toggled );
+
+                       print_crop_marks_check.set_active( model.print.crop_marks_flag );
+
+                       GLib.SignalHandler.unblock( (void*)print_crop_marks_check, 
sigid_print_crop_marks_check_toggled );
+               }
+
+
+       }
+
+}
+
diff --git a/glabels/svg_cache.vala b/glabels/svg_cache.vala
index 2cfd0ce..2f0e2e7 100644
--- a/glabels/svg_cache.vala
+++ b/glabels/svg_cache.vala
@@ -45,7 +45,7 @@ namespace glabels
                                Rsvg.Handle? handle;
 
                                try {
-                                       handle = new Rsvg.Handle.from_data( svg.data, svg.length );
+                                       handle = new Rsvg.Handle.from_data( svg.data );
                                }
                                catch ( Error e )
                                {
@@ -63,7 +63,7 @@ namespace glabels
 
                                try {
                                        FileUtils.get_contents( file_name, out svg );
-                                       handle = new Rsvg.Handle.from_data( svg.data, svg.length );
+                                       handle = new Rsvg.Handle.from_data( svg.data );
                                }
                                catch ( Error e )
                                {
diff --git a/glabels/window.vala b/glabels/window.vala
index 14e73d6..3488d29 100644
--- a/glabels/window.vala
+++ b/glabels/window.vala
@@ -46,7 +46,7 @@ namespace glabels
 
                private Gtk.Box             editor_page_box;
                private Gtk.Box             merge_property_page_box;
-               private Gtk.Box             preview_page_box;
+               private Gtk.Box             print_setup_page_box;
 
                public  View                view                  { get; private set; }
                private ObjectEditor        object_editor;
@@ -59,7 +59,7 @@ namespace glabels
                private Gtk.Menu            empty_selection_context_menu;
 
                private MergePropertyEditor merge_property_editor;
-               private MiniPreview         preview;
+               private PrintSetupEditor    print_setup_editor;
 
 
                public Window()
@@ -129,11 +129,11 @@ namespace glabels
                        merge_property_page_box.pack_start( merge_property_editor, true, true, 0 );
                        
 
-                       preview_page_box = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
-                       notebook.append_page( preview_page_box, new Gtk.Label( _("Preview") ) );
+                       print_setup_page_box = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
+                       notebook.append_page( print_setup_page_box, new Gtk.Label( _("Print setup") ) );
 
-                       preview = new MiniPreview( 280, 420 );
-                       preview_page_box.pack_start( preview, true, true, 0 );
+                       print_setup_editor = new PrintSetupEditor();
+                       print_setup_page_box.pack_start( print_setup_editor, true, true, 0 );
 
 
                        notebook.no_show_all = true;
@@ -189,7 +189,7 @@ namespace glabels
                        view.model = model;
                        object_editor.set_model( model );
                        merge_property_editor.set_model( model );
-                       preview.set_model( model );
+                       print_setup_editor.set_model( model );
 
                        view.zoom_to_fit();
 
@@ -214,7 +214,7 @@ namespace glabels
                        notebook.show();
                        editor_page_box.show_all();
                        merge_property_page_box.show_all();
-                       preview_page_box.show_all();
+                       print_setup_page_box.show_all();
 
                        /* TODO: clipboard changed. */
                        /* TODO: set copy/paste sensitivity. */




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]