Re: Monodoc print support patch - feedback needed.
Rafael Ferreira <[email protected]>
| Newsgroups | gmane.comp.gnome.mono.documentation |
|---|---|
| Message-ID | <[email protected]> |
Mario, here's the updated patch. It took me some time to get this to you because I updated my docbrowser and monodoc sources so I had to merge the printing patch upstream. This time I basically edited the browser.glade file by hand, adding only the needed entries. Let me know what you could use a hand with next. - raf On Mon, 2005-09-05 at 18:08 +0200, Mario Sopena wrote: > Hello Rafa, > > > I have no clue what those "ellipsize" glade tags are. I played around > > with glade for a while to see if I could remove those with no luck. > > Aside from manually editing the xml I have no idea how to make them go > > away. But to answer your question, the only other change I made to this > I usually remove the lines of the patch (it easier than editing the > xml) and then apply the patch to an unmodified version of the file > (you can revert your changes with svn revert file). But is up to you > how to do that. However, those lines should be kept away. > > > file (besides adding the gtk-stock-print menu item) is to enforce that > > the About menu item is using the gtk-stock-about icon. Originally > > FC4/Clearlooks was having problems saving the glade file because it > > could not find the About icon. > > I think the change you refer is this one: > - <property name="stock">gnome-stock-about</property> > + <property name="stock">gtk-about</property> > > but there is also a lot of things like: > - <widget class="GtkImage" id="image132"> > + <widget class="GtkImage" id="image141"> > or > - <widget class="GtkImage" id="image119"> > + <widget class="GtkImage" id="image139"> > or > - <widget class="GtkImage" id="image118"> > + <widget class="GtkImage" id="image138"> > > that I'm not sure what are doing, so I prefer to leave them out. > Please, send me (and to the monodoc list) a mail with an updated patch > so I can send it to SVN. > > Thanks for your work. > Mario > _______________________________________________ Mono-docs-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-docs-list
docbrowser.patch
(text/x-patch, 5.4 KB)
Index: GtkHTMLPrintManager.cs =================================================================== --- GtkHTMLPrintManager.cs (revision 0) +++ GtkHTMLPrintManager.cs (revision 0) @@ -0,0 +1,56 @@ +// +// GtkHTMLPrintManager.cs: Handles monodoc printing on Gnome using GtkHTML +// Author: +// Rafael Ferreira <[email protected]> +// +// (C) 2005 Rafael Ferreira +// +namespace Monodoc { + using System; + using Gtk; + using Gnome; + + public class GtkHTMLPrintManager : IPrintManager { + public void Print(string Html, string Css, string Caption) { + + if (Html == null) { + Console.WriteLine("empty print"); + return; + } + + if (Caption==null) + Caption="Monodoc Printing"; + + PrintJob pj = new PrintJob (PrintConfig.Default ()); + PrintDialog dialog = new PrintDialog (pj, Caption, 0); + + Gtk.HTML gtk_html = new Gtk.HTML(Html); + gtk_html.PrintSetMaster(pj); + + PrintContext ctx = pj.Context; + gtk_html.Print(ctx); + + pj.Close(); + + // hello user + int response = dialog.Run (); + + if (response == (int) PrintButtons.Cancel) { + dialog.Hide (); + dialog.Dispose (); + return; + } + else if (response == (int) PrintButtons.Print) { + pj.Print(); + + }else if (response == (int) PrintButtons.Preview) { + new PrintJobPreview(pj,Caption).Show(); + } + + ctx.Close(); + dialog.Hide(); + dialog.Dispose(); + return; + } + } +} Index: browser.cs =================================================================== --- browser.cs (revision 49518) +++ browser.cs (working copy) @@ -185,7 +185,10 @@ this.Url = url; } } + // handles printing + IPrintManager print_manager = null; + public ArrayList bookList; public Browser (bool UseGecko) @@ -293,6 +296,9 @@ bookList = new ArrayList (); index_browser = IndexBrowser.MakeIndexBrowser (this); + + // print manager logic + print_manager = (IPrintManager) new GtkHTMLPrintManager(); AddTab(); MainWindow.ShowAll(); @@ -707,6 +713,12 @@ { Application.Quit (); } + + void on_print_activate (object sender, EventArgs e) { + Node n; + // sending Html to the printed. + print_manager.Print(help_tree.RenderUrl (CurrentUrl, out n),null,n.Caption); + } void OnCommentsActivate (object o, EventArgs args) { @@ -1484,6 +1496,7 @@ { BookmarkEditBox = null; } + } } Index: ChangeLog =================================================================== --- ChangeLog (revision 49518) +++ ChangeLog (working copy) @@ -1,3 +1,19 @@ +2005-09-05 Rafael Ferreira <[email protected]> + + Landed monodoc's simple printing subsystem + + * browser.cs: add printing support + * browser.glade: + - Added print menu option + - Changed gnome-stock-about to gtk-about + * Makefile.am: + - Added new source files + - Fixed GeckoHtmlRender.dl.mdb clean up + * IPrintManager.cs: added + - New Printing interface to allow multiple printing backends + * GtkHTMLPrintManager.cs: added + - New GtkHtml based implementation of IPrintManager + 2005-09-05 Mario Sopena Novales <[email protected]> Implement basic searching capabilities * browser.cs: Index: browser.glade =================================================================== --- browser.glade (revision 49518) +++ browser.glade (working copy) @@ -91,7 +91,14 @@ <accelerator key="U" modifiers="GDK_CONTROL_MASK" signal="activate"/> </widget> </child> - + <child> ++ <widget class="GtkImageMenuItem" id="print"> ++ <property name="visible">True</property> ++ <property name="label">gtk-print</property> ++ <property name="use_stock">True</property> ++ <signal name="activate" handler="on_print_activate" last_modification_time="Tue, 30 Aug 2005 05:02:29 GMT"/> ++ </widget> ++ </child> <child> <widget class="GtkImageMenuItem" id="quit1"> <property name="visible">True</property> @@ -293,7 +300,7 @@ <child internal-child="image"> <widget class="GtkImage" id="image121"> <property name="visible">True</property> - <property name="stock">gnome-stock-about</property> + <property name="stock">gtk-about</property> <property name="icon_size">1</property> <property name="xalign">0.5</property> <property name="yalign">0.5</property> Index: IPrintManager.cs =================================================================== --- IPrintManager.cs (revision 0) +++ IPrintManager.cs (revision 0) @@ -0,0 +1,14 @@ +// +// IPrintManager.cs: An abstraction to allow printing on multiple platforms +// Author: +// Rafael Ferreira <[email protected]> +// +// (C) 2005 Rafael Ferreira +// + +namespace Monodoc { + public interface IPrintManager { + void Print(string Html, string Css, string Caption); + } +} + Index: Makefile.am =================================================================== --- Makefile.am (revision 49518) +++ Makefile.am (working copy) @@ -3,7 +3,7 @@ if ENABLE_GECKO -CLEANFILES = browser.exe browser.exe.mdb admin.exe admin.exe.mdb GeckoHtmlRender.dll +CLEANFILES = browser.exe browser.exe.mdb admin.exe admin.exe.mdb GeckoHtmlRender.dll GeckoHtmlRender.dll.mdb monodoc_DATA = browser.exe GeckoHtmlRender.dll else CLEANFILES = browser.exe browser.exe.mdb admin.exe admin.exe.mdb @@ -23,7 +23,9 @@ $(srcdir)/Contributions.cs \ $(srcdir)/XmlNodeWriter.cs \ $(srcdir)/GtkHtmlHtmlRender.cs \ - $(srcdir)/IHtmlRender.cs + $(srcdir)/IHtmlRender.cs \ + $(srcdir)/IPrintManager.cs \ + $(srcdir)/GtkHTMLPrintManager.cs geckorender_sources = \