From 0788ce0479c6c5ae5baedc6087cc6817b68355d9 Mon Sep 17 00:00:00 2001 From: Zsolt Foldvari Date: Sat, 15 Sep 2007 21:51:44 +0000 Subject: [PATCH] * src/ReportBase/_ReportDialog.py: * src/glade/paper_settings.glade: Add paper margins to report dialog. (Only GUI is implemented for feedback.) 2007-09-15 Zsolt Foldvari svn: r8977 --- ChangeLog | 6 + src/ReportBase/_ReportDialog.py | 163 ++++--- src/glade/paper_settings.glade | 723 ++++++++++++++++++++++++++++++++ 3 files changed, 835 insertions(+), 57 deletions(-) create mode 100644 src/glade/paper_settings.glade diff --git a/ChangeLog b/ChangeLog index f60291966..b9cc65a8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-09-15 Zsolt Foldvari + * src/ReportBase/_ReportDialog.py: + * src/glade/paper_settings.glade: + Add paper margins to report dialog. (Only GUI is implemented for + feedback.) + 2007-09-15 Zsolt Foldvari * src/ReportBase/_ReportDialog.py (parse_paper_frame): Fix paper size default value in case of exception. diff --git a/src/ReportBase/_ReportDialog.py b/src/ReportBase/_ReportDialog.py index 9aa383c34..25ec51492 100644 --- a/src/ReportBase/_ReportDialog.py +++ b/src/ReportBase/_ReportDialog.py @@ -301,20 +301,21 @@ class ReportDialog(BareReportDialog): self.target_fileentry.set_filename(spath) def setup_output_notebook(self): - """Set up the output notebook of the dialog. This sole - purpose of this function is to grab a pointer for later use in - the callback from when the file format is changed.""" + """Set up the output notebook of the dialog. + + This sole purpose of this function is to grab a pointer for later + use in the callback from when the file format is changed. + + """ pass - def size_changed(self,obj): - (paper,name) = self.papersize_menu.get_value() + def size_changed(self, obj): + """Paper size combobox 'changed' callback.""" + (paper, name) = self.papersize_menu.get_value() - if name == _("Custom Size"): - self.pwidth.set_sensitive(1) - self.pheight.set_sensitive(1) - else: - self.pwidth.set_sensitive(0) - self.pheight.set_sensitive(0) + is_custom = name == _("Custom Size") + self.pwidth.set_sensitive(is_custom) + self.pheight.set_sensitive(is_custom) if paper.get_width() > 0 and paper.get_height() > 0: if self.metric.get_active(): @@ -324,75 +325,123 @@ class ReportDialog(BareReportDialog): self.pwidth.set_text("%.2f" % paper.get_width_inches()) self.pheight.set_text("%.2f" % paper.get_height_inches()) - def units_changed(self,obj): - (paper,name) = self.papersize_menu.get_value() + def units_changed(self, obj): + """Metric checkbox 'toggled' callback.""" + (paper, name) = self.papersize_menu.get_value() if self.metric.get_active(): self.lunits1.set_text("cm") self.lunits2.set_text("cm") + self.lunits3.set_text("cm") + self.lunits4.set_text("cm") + self.lunits5.set_text("cm") + self.lunits6.set_text("cm") self.pwidth.set_text("%.2f" % paper.get_width()) self.pheight.set_text("%.2f" % paper.get_height()) + self.lmargin.set_text("%.2f" % 2.54) + self.rmargin.set_text("%.2f" % 2.54) + self.tmargin.set_text("%.2f" % 2.54) + self.bmargin.set_text("%.2f" % 2.54) else: self.lunits1.set_text("in.") self.lunits2.set_text("in.") + self.lunits3.set_text("in.") + self.lunits4.set_text("in.") + self.lunits5.set_text("in.") + self.lunits6.set_text("in.") self.pwidth.set_text("%.2f" % paper.get_width_inches()) self.pheight.set_text("%.2f" % paper.get_height_inches()) + self.lmargin.set_text("%.2f" % 1.0) + self.rmargin.set_text("%.2f" % 1.0) + self.tmargin.set_text("%.2f" % 1.0) + self.bmargin.set_text("%.2f" % 1.0) def setup_paper_frame(self): """Set up the paper selection frame of the dialog.""" + glade_file = os.path.join(const.GLADE_DIR, "paper_settings.glade") + glade_xml = gtk.glade.XML(glade_file, "paper_table", "gramps") - self.paper_table = gtk.Table(4,6) - self.paper_table.set_col_spacings(12) - self.paper_table.set_row_spacings(6) - self.paper_table.set_border_width(6) - + self.paper_table = glade_xml.get_widget('paper_table') + + # get all the widgets + widgets = ('pwidth', 'pheight', 'lmargin', 'rmargin', 'tmargin', + 'bmargin', 'lunits1', 'lunits2', 'lunits3', 'lunits4', + 'lunits5', 'lunits6', 'metric') + + for w in widgets: + setattr(self, w, glade_xml.get_widget(w)) + + # insert custom widgets self.papersize_menu = PaperComboBox() - self.papersize_menu.connect('changed',self.size_changed) - self.orientation_menu = OrientationComboBox() - l = gtk.Label("%s:" % _("Size")) - l.set_alignment(0.0,0.5) - - self.paper_table.attach(l,1,2,0,1,gtk.SHRINK|gtk.FILL) - self.paper_table.attach(self.papersize_menu,2,3,0,1, - yoptions=gtk.SHRINK) - l = gtk.Label("%s:" % _("Height")) - l.set_alignment(0.0,0.5) - self.paper_table.attach(l,3,4,0,1,gtk.SHRINK|gtk.FILL) - self.pheight = gtk.Entry() - self.pheight.set_sensitive(0) - self.paper_table.attach(self.pheight,4,5,0,1) - - self.lunits1 = gtk.Label(_("cm")) - self.lunits1.set_alignment(0.0,0.5) - self.paper_table.attach(self.lunits1,5,6,0,1,gtk.SHRINK|gtk.FILL) - - self.metric = gtk.CheckButton (_("Metric")) - self.paper_table.attach(self.metric,2,3,1,2,gtk.SHRINK|gtk.FILL) + format_table = glade_xml.get_widget('format_table') + format_table.attach(self.papersize_menu, 1, 3, 0, 1, + yoptions=gtk.SHRINK) + format_table.attach(self.orientation_menu, 1, 3, 3, 4, + yoptions=gtk.SHRINK) + + # connect signals + self.papersize_menu.connect('changed',self.size_changed) self.metric.connect('toggled',self.units_changed) - l = gtk.Label("%s:" % _("Orientation")) - l.set_alignment(0.0,0.5) - self.paper_table.attach(l,1,2,2,3,gtk.SHRINK|gtk.FILL) - self.paper_table.attach(self.orientation_menu,2,3,2,3, - yoptions=gtk.SHRINK) - l = gtk.Label("%s:" % _("Width")) - l.set_alignment(0.0,0.5) - self.paper_table.attach(l,3,4,1,2,gtk.SHRINK|gtk.FILL) - - self.pwidth = gtk.Entry() - self.pwidth.set_sensitive(0) - self.paper_table.attach(self.pwidth,4,5,1,2) - - self.lunits2 = gtk.Label(_("cm")) - self.lunits2.set_alignment(0.0,0.5) - self.paper_table.attach(self.lunits2,5,6,1,2,gtk.SHRINK|gtk.FILL) - + # set initial values self.papersize_menu.set(paper_sizes, self.options.handler.get_paper_name()) self.orientation_menu.set(self.options.handler.get_orientation()) - self.metric.set_active(1) + + ##self.paper_table = gtk.Table(4,6) + ##self.paper_table.set_col_spacings(12) + ##self.paper_table.set_row_spacings(6) + ##self.paper_table.set_border_width(6) + + ##self.papersize_menu = PaperComboBox() + ##self.papersize_menu.connect('changed',self.size_changed) + + ##self.orientation_menu = OrientationComboBox() + ##l = gtk.Label("%s:" % _("Size")) + ##l.set_alignment(0.0,0.5) + + ##self.paper_table.attach(l,1,2,0,1,gtk.SHRINK|gtk.FILL) + ##self.paper_table.attach(self.papersize_menu,2,3,0,1, + ##yoptions=gtk.SHRINK) + ##l = gtk.Label("%s:" % _("Height")) + ##l.set_alignment(0.0,0.5) + ##self.paper_table.attach(l,3,4,0,1,gtk.SHRINK|gtk.FILL) + + ##self.pheight = gtk.Entry() + ##self.pheight.set_sensitive(0) + ##self.paper_table.attach(self.pheight,4,5,0,1) + + ##self.lunits1 = gtk.Label(_("cm")) + ##self.lunits1.set_alignment(0.0,0.5) + ##self.paper_table.attach(self.lunits1,5,6,0,1,gtk.SHRINK|gtk.FILL) + + ##self.metric = gtk.CheckButton (_("Metric")) + ##self.paper_table.attach(self.metric,2,3,1,2,gtk.SHRINK|gtk.FILL) + ##self.metric.connect('toggled',self.units_changed) + + ##l = gtk.Label("%s:" % _("Orientation")) + ##l.set_alignment(0.0,0.5) + ##self.paper_table.attach(l,1,2,2,3,gtk.SHRINK|gtk.FILL) + ##self.paper_table.attach(self.orientation_menu,2,3,2,3, + ##yoptions=gtk.SHRINK) + ##l = gtk.Label("%s:" % _("Width")) + ##l.set_alignment(0.0,0.5) + ##self.paper_table.attach(l,3,4,1,2,gtk.SHRINK|gtk.FILL) + + ##self.pwidth = gtk.Entry() + ##self.pwidth.set_sensitive(0) + ##self.paper_table.attach(self.pwidth,4,5,1,2) + + ##self.lunits2 = gtk.Label(_("cm")) + ##self.lunits2.set_alignment(0.0,0.5) + ##self.paper_table.attach(self.lunits2,5,6,1,2,gtk.SHRINK|gtk.FILL) + + ##self.papersize_menu.set(paper_sizes, + ##self.options.handler.get_paper_name()) + ##self.orientation_menu.set(self.options.handler.get_orientation()) + ##self.metric.set_active(1) def html_file_enable(self,obj): active = obj.get_active() diff --git a/src/glade/paper_settings.glade b/src/glade/paper_settings.glade new file mode 100644 index 000000000..a4a67796f --- /dev/null +++ b/src/glade/paper_settings.glade @@ -0,0 +1,723 @@ + + + + + + + True + window2 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + False + + + + 6 + True + False + 6 + + + + + + + + True + 0 + 0.5 + GTK_SHADOW_ETCHED_IN + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + 6 + True + 4 + 3 + False + 6 + 6 + + + + True + Size: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Width: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Height: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + Orientation: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + False + True + True + True + 0 + + True + + False + + + 1 + 2 + 1 + 2 + + + + + + + True + False + True + True + True + 0 + + True + + False + + + 1 + 2 + 2 + 3 + + + + + + + True + cm + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + 3 + False + 0 + + + 2 + 3 + 1 + 2 + fill + + + + + + + True + cm + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + 3 + False + 0 + + + 2 + 3 + 2 + 3 + fill + + + + + + + + + + + True + <b>Paper format</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + True + True + + + + + + True + 0 + 0.5 + GTK_SHADOW_ETCHED_IN + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + 6 + True + 4 + 3 + False + 6 + 6 + + + + True + Left: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Right: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Top: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + Bottom: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + cm + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + 3 + False + 0 + + + 2 + 3 + 0 + 1 + fill + + + + + + + True + cm + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + 3 + False + 0 + + + 2 + 3 + 2 + 3 + fill + + + + + + + True + cm + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + 3 + False + 0 + + + 2 + 3 + 3 + 4 + fill + + + + + + + True + False + True + True + True + 0 + 2.54 + True + + False + + + 1 + 2 + 0 + 1 + + + + + + + True + False + True + True + True + 0 + 2.54 + True + + False + + + 1 + 2 + 1 + 2 + + + + + + + True + False + True + True + True + 0 + 2.54 + True + + False + + + 1 + 2 + 2 + 3 + + + + + + + True + False + True + True + True + 0 + 2.54 + True + + False + + + 1 + 2 + 3 + 4 + + + + + + + True + cm + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + 3 + False + 0 + + + 2 + 3 + 1 + 2 + fill + + + + + + + + + + + True + <b>Margins</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + True + True + + + + + + True + False + 0 + + + + + + + + True + True + Metric + True + GTK_RELIEF_NORMAL + True + True + False + True + + + 0 + False + False + GTK_PACK_END + + + + + 0 + False + False + + + + + + +