Re: printing preferences?




On 2001.08.13 11:40:36 -0700 Albrecht Dreß wrote:
> Lynn, I just saw your mail when I logged in... I also hacked a patch which
> adds a page to the preferences dialog (attached below, against today's cvs).
> Maybe we can share our ideas/approaches? Or, Pawel, which patch do you prefer?

I initially implemented almost the same thing in prefs but wasn't quite happy
with the result.  I wanted to avoid creating a new page in prefs and really
didn't like to use the entire GnomePaperSelect widget there (it seems to me to
be designed for use in print dialogs).  I decided that I wanted to add a simple
button menu that contained the list of available papers to select from which
would present a less busy method of setting paper size in the UI.  Unfortunately
I'm not a gtk guru and I couldn't get the button to display any text, so I set
it aside until I get some more time to play with it.

> As I expected, the necessary changes are really small and easy to do (I also
> did not take code from gedit). Two other ideas are (1) make the margins
> configurable (the way gnumeric does it looks really nice. But it's some kind
> of overkill, though...) and (2) add a selection for header and body fonts (I
> dislike Courier... ;-)). Therefore, I named the new page "printing" and not
> simply "paper". I also added a missing paper selection line in the actual
> print code, btw.

I see that you added a call to set the paper, but it still seems to work
fine without it.  Wonder why?

I'm attaching my changes to add the GnomePaperSelector widget to the print dialog
(and remember the last setting) so that the papersize can be set on a per print
request.  I've done some minimal testing with your patch Albrecht and it did
exactly what I expected.  Maybe if Pawel is happy with the preferences dialog
stuff you did he can commit the combination of our patches.  I'd still rather
see a menu button in preferences where just the paper name is present for
selection instead of another page and the full paper selection dialog but that
is just my opinion.

-- 
Lynn Kerby <mailto:lfk@kerbit.net>
--- print.c.orig	Wed May 23 01:39:01 2001
+++ print.c	Thu Jul 12 23:00:57 2001
@@ -933,11 +933,47 @@
     message_print(msg);
 }
 
+/*
+ * Adds GnomePaperSelector Widget from libgnomeui to print dialog
+ */
+static GtkWidget *
+print_paper_select_new(GtkWidget * dialog, const gchar * name)
+{
+    GtkWidget	*frame;
+    GtkWidget	*paper;
+    const GnomePaper	*gpaper;
+    const gchar	*defpaper;
+
+    if ((gpaper = gnome_paper_with_name(name)) == NULL) {
+	balsa_information(LIBBALSA_INFORMATION_WARNING,
+			  _("Balsa could not find paper type \"%s\", using"
+			    " system default.\n"), name);
+	balsa_information(LIBBALSA_INFORMATION_WARNING,
+			  _("Check your paper type configuration or balsa preferences\n"));
+     	defpaper = gnome_paper_name_default();
+    } else {
+	defpaper = name;
+    }
+    frame = gtk_frame_new(_("Paper Selection"));
+    gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(dialog)->vbox), GTK_WIDGET(frame),
+				    FALSE, FALSE, 3);
+    gtk_container_set_border_width(GTK_CONTAINER(frame), 3);
+    paper = gnome_paper_selector_new();
+    gtk_container_add(GTK_CONTAINER(frame), paper);
+    gtk_widget_show_all(frame);
+    gnome_paper_selector_set_name(GNOME_PAPER_SELECTOR(paper), defpaper);
+
+    return paper;
+}
+
 void
 message_print(LibBalsaMessage * msg)
 {
     GtkWidget *dialog;
+    GtkWidget *paperselect;
     PrintInfo *pi;
+    static gchar *lastpaper;
+    const gchar *dlgpaper;
     gboolean preview = FALSE;
 
     g_return_if_fail(msg);
@@ -945,8 +980,15 @@
 	!is_font_ok(BALSA_PRINT_HEAD_FONT))
 	return;
 
+    if (lastpaper == NULL) {
+	    lastpaper = g_strdup(balsa_app.paper_size);
+    }
     dialog = gnome_print_dialog_new(_("Print message"),
 				    GNOME_PRINT_DIALOG_COPIES);
+    /*
+     * add GnomePaperSelector Widget to print dialog
+     */
+    paperselect = print_paper_select_new(dialog, lastpaper);
     gnome_dialog_set_parent(GNOME_DIALOG(dialog),
 			    GTK_WINDOW(balsa_app.main_window));
     gtk_window_set_wmclass(GTK_WINDOW(dialog), "print", "Balsa");
@@ -962,7 +1004,12 @@
     default:
 	return;
     }
-    pi = print_info_new(balsa_app.paper_size, msg, GNOME_PRINT_DIALOG(dialog));
+    dlgpaper = gnome_paper_selector_get_name(GNOME_PAPER_SELECTOR(paperselect));
+    pi = print_info_new(dlgpaper, msg, GNOME_PRINT_DIALOG(dialog));
+    if (g_strcasecmp(dlgpaper, lastpaper) != 0) {
+	    g_free(lastpaper);
+	    lastpaper = g_strdup(dlgpaper);
+    }
     gnome_dialog_close(GNOME_DIALOG(dialog));
 
     /* do the Real Job */


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