Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMario Sopena Novales <masono@mono-cvs.ximian.com>2005-09-11 21:51:04 +0400
committerMario Sopena Novales <masono@mono-cvs.ximian.com>2005-09-11 21:51:04 +0400
commitd3dda17544046d55c43e64cd759a850a3a958379 (patch)
tree14d7e7ef5a4f455db4035c273579fb5b9dccebd4 /docbrowser
parent4610a2390067e15c8a0b74f9cc1cb1b4b00ce995 (diff)
Landed monodoc's simple printing subsystem
svn path=/trunk/mono-tools/; revision=49918
Diffstat (limited to 'docbrowser')
-rw-r--r--docbrowser/ChangeLog16
-rw-r--r--docbrowser/GeckoHtmlRender.cs40
-rw-r--r--docbrowser/GtkHtmlHtmlRender.cs40
-rw-r--r--docbrowser/IHtmlRender.cs2
-rw-r--r--docbrowser/Makefile.am2
-rw-r--r--docbrowser/browser.cs32
-rw-r--r--docbrowser/browser.glade13
7 files changed, 143 insertions, 2 deletions
diff --git a/docbrowser/ChangeLog b/docbrowser/ChangeLog
index 52e014e1..56754903 100644
--- a/docbrowser/ChangeLog
+++ b/docbrowser/ChangeLog
@@ -1,3 +1,19 @@
+2005-09-08 Rafael Ferreira <raf@ophion.org>, Mario Sopena <mario.sopena@gmail.com>
+
+ Landed monodoc's simple printing subsystem
+
+ * IHtmlRender.cs: new Print method
+ * GeckoHtmlRender.cs: implemented new Print method with GtkHtml widget
+ * GtkHtmlHtmlRender.cs: implemented Print method
+ * browser.cs:
+ - add printing support
+ - activate/deactivate print menu item when in view/edit mode
+ * browser.glade:
+ - Added print menu option
+ - Update Contributors list
+ * Makefile.am:
+ - Fixed GeckoHtmlRender.dl.mdb clean up
+
2005-09-05 Mario Sopena Novales <mario.sopena@gmail.com>
Implement basic searching capabilities
* browser.cs:
diff --git a/docbrowser/GeckoHtmlRender.cs b/docbrowser/GeckoHtmlRender.cs
index f18795bc..dfd9e8fc 100644
--- a/docbrowser/GeckoHtmlRender.cs
+++ b/docbrowser/GeckoHtmlRender.cs
@@ -2,6 +2,7 @@
// GeckoHtmlRender.cs: Implementation of IHtmlRender that uses Gecko
//
// Author: Mario Sopena
+// Author: Rafael Ferreira <raf@ophion.org>
//
using System;
using System.Text;
@@ -9,6 +10,7 @@ using System.IO;
using System.Collections;
using Gecko;
using Gtk;
+using Gnome;
namespace Monodoc {
public class GeckoHtmlRender : IHtmlRender {
@@ -152,5 +154,43 @@ public class GeckoHtmlRender : IHtmlRender {
return html.ToString();
}
+ public void Print (string Html) {
+
+ if (Html == null) {
+ Console.WriteLine ("empty print");
+ return;
+ }
+
+ string 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;
+ }
}
}
diff --git a/docbrowser/GtkHtmlHtmlRender.cs b/docbrowser/GtkHtmlHtmlRender.cs
index 28bea68b..886855d7 100644
--- a/docbrowser/GtkHtmlHtmlRender.cs
+++ b/docbrowser/GtkHtmlHtmlRender.cs
@@ -3,9 +3,11 @@
// GtkHtmlHtmlRender.cs: Implementation of IHtmlRender that uses Gtk.HTML
//
// Author: Mario Sopena
+// Author: Rafael Ferreira <raf@ophion.org>
//
using System;
using Gtk;
+using Gnome;
using System.IO;
namespace Monodoc {
@@ -88,5 +90,43 @@ class GtkHtmlHtmlRender : IHtmlRender {
args.Handle.Close (HTMLStreamStatus.Ok);
}
+ public void Print (string Html) {
+
+ if (Html == null) {
+ Console.WriteLine ("empty print");
+ return;
+ }
+
+ string 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;
+ }
}
}
diff --git a/docbrowser/IHtmlRender.cs b/docbrowser/IHtmlRender.cs
index 2bb9a66e..c7163655 100644
--- a/docbrowser/IHtmlRender.cs
+++ b/docbrowser/IHtmlRender.cs
@@ -32,6 +32,8 @@ public interface IHtmlRender {
string Url { get; }
Widget HtmlPanel { get; }
+
+ void Print (string Html);
}
diff --git a/docbrowser/Makefile.am b/docbrowser/Makefile.am
index b0af30f0..52ed9f95 100644
--- a/docbrowser/Makefile.am
+++ b/docbrowser/Makefile.am
@@ -3,7 +3,7 @@ noinst_DATA = admin.exe
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
diff --git a/docbrowser/browser.cs b/docbrowser/browser.cs
index 24d748c6..ca941cb5 100644
--- a/docbrowser/browser.cs
+++ b/docbrowser/browser.cs
@@ -124,6 +124,7 @@ class Browser {
[Glade.Widget] CheckMenuItem comments1;
[Glade.Widget] MenuItem postcomment;
[Glade.Widget] public MenuItem paste1;
+ [Glade.Widget] public MenuItem print;
public Notebook tabs_nb;
public Tab CurrentTab;
bool HoldCtrl;
@@ -333,8 +334,10 @@ class Browser {
if (CurrentTab.Tab_mode == Mode.Viewer) {
CurrentTab.history.ActivateCurrent();
paste1.Sensitive = false;
+ print.Sensitive = true;
} else {
paste1.Sensitive = true;
+ print.Sensitive = false;
}
if (tree_browser.SelectedNode != CurrentTab.CurrentNode)
@@ -707,6 +710,33 @@ ExtLoop:
{
Application.Quit ();
}
+ void on_print_activate (object sender, EventArgs e)
+ {
+ // desactivate css temporary
+ if (UseGecko)
+ HelpSource.use_css = false;
+
+ string url = CurrentUrl;
+ string html;
+ Node cur = CurrentTab.CurrentNode;
+ Node n;
+
+ // deal with the two types of urls
+ if (cur.tree.HelpSource != null) {
+ html = cur.tree.HelpSource.GetText (url, out n);
+ if (html == null)
+ html = help_tree.RenderUrl (url, out n);
+ } else {
+ html = help_tree.RenderUrl (url, out n);
+ }
+
+ // sending Html to be printed.
+ if (html != null)
+ CurrentTab.html.Print (html);
+
+ if (UseGecko)
+ HelpSource.use_css = true;
+ }
void OnCommentsActivate (object o, EventArgs args)
{
@@ -2225,10 +2255,12 @@ class Tab : Notebook {
if (m == Mode.Viewer) {
this.Page = 0;
browser.paste1.Sensitive = false;
+ browser.print.Sensitive = true;
EditImg.Visible = false;
} else {
this.Page = 1;
browser.paste1.Sensitive = true;
+ browser.print.Sensitive = false;
EditImg.Visible = true;
}
diff --git a/docbrowser/browser.glade b/docbrowser/browser.glade
index a3ca3351..1efaaa4b 100644
--- a/docbrowser/browser.glade
+++ b/docbrowser/browser.glade
@@ -93,6 +93,15 @@
</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>
<property name="label" translatable="yes">Quit</property>
@@ -1135,7 +1144,9 @@
Piers Haken
John Luke (jluke@cfl.rr.com)
Ben Maurer
-Mario Sopena novales</property>
+ Mario Sopena Novales (mario.sopena@gmail.com)
+ Rafael Ferreira (raf@ophion.org)
+ </property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>