diff options
author | Mike Kestner <mkestner@gmail.com> | 2007-11-09 01:56:32 +0300 |
---|---|---|
committer | Mike Kestner <mkestner@gmail.com> | 2007-11-09 01:56:32 +0300 |
commit | e068831e6d3f89bb72facd59d62b57196f7f5cbc (patch) | |
tree | 3f04bd64e004d267027bc11a8dce642fac3f7353 /docbrowser | |
parent | 9ae9be9c4f373003b86b14c6793b4f2b963e94c6 (diff) |
2007-11-08 Mike Kestner <mkestner@novell.com>
* configure.in: configure checks for gtkhtml-sharp-3.14
with fallback to 2.0.
2007-11-08 Mike Kestner <mkestner@novell.com>
* PrintManager.cs: extracted existing duplicated print
code from the two renderers and put it here, along with a
new Gtk.Print based implementation for gtkhtml-sharp 3.14
and beyond.
* GeckoHtmlRender.cs: refactor to use PrintManager.
* GtkHtmlHtmlRender.cs : ditto.
* Makefile.am : add some gtkhtml library install magic.
svn path=/trunk/mono-tools/; revision=89284
Diffstat (limited to 'docbrowser')
-rw-r--r-- | docbrowser/ChangeLog | 10 | ||||
-rw-r--r-- | docbrowser/GeckoHtmlRender.cs | 35 | ||||
-rw-r--r-- | docbrowser/GtkHtmlHtmlRender.cs | 31 | ||||
-rw-r--r-- | docbrowser/Makefile.am | 12 | ||||
-rw-r--r-- | docbrowser/PrintManager.cs | 59 |
5 files changed, 80 insertions, 67 deletions
diff --git a/docbrowser/ChangeLog b/docbrowser/ChangeLog index 0e96d948..f5f42094 100644 --- a/docbrowser/ChangeLog +++ b/docbrowser/ChangeLog @@ -1,3 +1,13 @@ +2007-11-08 Mike Kestner <mkestner@novell.com> + + * PrintManager.cs: extracted existing duplicated print + code from the two renderers and put it here, along with a + new Gtk.Print based implementation for gtkhtml-sharp 3.14 + and beyond. + * GeckoHtmlRender.cs: refactor to use PrintManager. + * GtkHtmlHtmlRender.cs : ditto. + * Makefile.am : add some gtkhtml library install magic. + 2007-10-01 Raja R Harinath <rharinath@novell.com> * Makefile.am (browser_sources): Move AssemblyInfo.cs ... diff --git a/docbrowser/GeckoHtmlRender.cs b/docbrowser/GeckoHtmlRender.cs index 1d0a2c7d..175357b8 100644 --- a/docbrowser/GeckoHtmlRender.cs +++ b/docbrowser/GeckoHtmlRender.cs @@ -182,7 +182,9 @@ public class GeckoHtmlRender : IHtmlRender { } Console.WriteLine ("XXXX"); -#if !USE_GTKHTML_PRINT +#if USE_GTKHTML_PRINT + PrintManager.Print (Html); +#else MessageDialog md = new MessageDialog (null, DialogFlags.DestroyWithParent, MessageType.Error, @@ -190,37 +192,6 @@ public class GeckoHtmlRender : IHtmlRender { int result = md.Run (); md.Destroy(); -#else - string Caption = "Monodoc Printing"; - - Gnome.PrintJob pj = new Gnome.PrintJob (PrintConfig.Default ()); - PrintDialog dialog = new PrintDialog (pj, Caption, 0); - - Gtk.HTML gtk_html = new Gtk.HTML (Html); - gtk_html.PrintSetMaster (pj); - - Gnome.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; #endif } } diff --git a/docbrowser/GtkHtmlHtmlRender.cs b/docbrowser/GtkHtmlHtmlRender.cs index 979b478a..48f071ee 100644 --- a/docbrowser/GtkHtmlHtmlRender.cs +++ b/docbrowser/GtkHtmlHtmlRender.cs @@ -106,36 +106,7 @@ class GtkHtmlHtmlRender : IHtmlRender { return; } - string Caption = "Monodoc Printing"; - - Gnome.PrintJob pj = new Gnome.PrintJob (PrintConfig.Default ()); - PrintDialog dialog = new PrintDialog (pj, Caption, 0); - - Gtk.HTML gtk_html = new Gtk.HTML (Html); - gtk_html.PrintSetMaster (pj); - - Gnome.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; + PrintManager.Print (Html); } } } diff --git a/docbrowser/Makefile.am b/docbrowser/Makefile.am index 4a4fe7af..5d22e782 100644 --- a/docbrowser/Makefile.am +++ b/docbrowser/Makefile.am @@ -12,7 +12,7 @@ GTKHTML_TARGET=GtkHtmlHtmlRender.dll endif CLEANFILES = browser.exe browser.exe.mdb admin.exe admin.exe.mdb $(GECKO_TARGET) $(GECKO_TARGET).mdb $(GTKHTML_TARGET) $(GTKHTML_TARGET).mdb monodoc.desktop -monodoc_DATA = browser.exe $(GECKO_TARGET) $(GTKHTML_TARGET) +monodoc_DATA = browser.exe $(GECKO_TARGET) $(GTKHTML_TARGET) $(GTKHTMLDLLCOPY) DISTCLEANFILES = AssemblyInfo.cs monodoc.desktop monodoc @@ -31,10 +31,12 @@ browser_sources = \ browser_built_sources = AssemblyInfo.cs -geckorender_sources = \ +geckorender_sources = \ + $(srcdir)/PrintManager.cs \ $(srcdir)/GeckoHtmlRender.cs -gtkhtmlrender_sources = \ +gtkhtmlrender_sources = \ + $(srcdir)/PrintManager.cs \ $(srcdir)/GtkHtmlHtmlRender.cs admin_sources = \ @@ -68,10 +70,10 @@ browser.exe: $(browser_sources) $(browser_built_sources) $(srcdir)/browser.glade $(MCS) -debug -out:browser.exe $(browser_sources) $(browser_built_sources) -resource:$(srcdir)/monodoc.png,monodoc.png -resource:$(srcdir)/browser.glade,browser.glade $(browser_assemblies) GeckoHtmlRender.dll : $(geckorender_sources) browser.exe - $(MCS) -debug -target:library -out:$@ $(geckorender_sources) $(geckorender_assemblies) $(GECKO_PRINTING_DEF) + $(MCS) -debug -target:library -out:$@ $(geckorender_sources) $(geckorender_assemblies) $(GECKO_PRINTING_DEF) $(CSHARP_FLAGS) GtkHtmlHtmlRender.dll : $(gtkhtmlrender_sources) browser.exe - $(MCS) -debug -target:library -out:$@ $(gtkhtmlrender_sources) $(gtkhtmlrender_assemblies) + $(MCS) -debug -target:library -out:$@ $(gtkhtmlrender_sources) $(gtkhtmlrender_assemblies) $(CSHARP_FLAGS) b: browser.exe MONO_PATH=. $(RUNTIME) --debug browser.exe diff --git a/docbrowser/PrintManager.cs b/docbrowser/PrintManager.cs new file mode 100644 index 00000000..2f24ee32 --- /dev/null +++ b/docbrowser/PrintManager.cs @@ -0,0 +1,59 @@ +// +// +// PrintManager.cs: GtkHTML version dependent printing support. +// +// Authors: Mario Sopena +// Rafael Ferreira <raf@ophion.org> +// Mike Kestner <mkestner@novell.com> +// + +using System; +using Gtk; +using Gnome; + +namespace Monodoc { + class PrintManager { + +#if GTKHTML_SHARP_3_14 + public static void Print (string html) + { + new Gtk.HTML (html).PrintOperationRun (new PrintOperation (), PrintOperationAction.PrintDialog, null, null, null, null, null); + } +#else + // Fallback to the original GNOME Print API. + public static void Print (string html) + { + string caption = "Monodoc Printing"; + + Gnome.PrintJob pj = new Gnome.PrintJob (PrintConfig.Default ()); + PrintDialog dialog = new PrintDialog (pj, caption, 0); + + Gtk.HTML gtk_html = new Gtk.HTML (html); + gtk_html.PrintSetMaster (pj); + + Gnome.PrintContext ctx = pj.Context; + gtk_html.Print (ctx); + + pj.Close (); + + // hello user + int response = dialog.Run (); + + if (response == (int) PrintButtons.Cancel) { + dialog.Hide (); + dialog.Destroy (); + 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.Destroy (); + } +#endif + } +} + |