From dmalcolm@redhat.com Thu Oct 13 02:01:11 2005 Return-Path: X-Original-To: gnome-doc-devel-list@gnome.org Delivered-To: gnome-doc-devel-list@gnome.org Received: from localhost (unknown [127.0.0.1]) by menubar.gnome.org (Postfix) with ESMTP id 56E423B0B00; Thu, 13 Oct 2005 02:01:11 -0400 (EDT) Received: from menubar.gnome.org ([127.0.0.1]) by localhost (menubar.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 16458-05; Thu, 13 Oct 2005 02:01:09 -0400 (EDT) Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31]) by menubar.gnome.org (Postfix) with ESMTP id DAF5B3B0AAA; Thu, 13 Oct 2005 02:01:08 -0400 (EDT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j9D618OG002300; Thu, 13 Oct 2005 02:01:08 -0400 Received: from mail.boston.redhat.com (mail.boston.redhat.com [172.16.76.12]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j9D618V26677; Thu, 13 Oct 2005 02:01:08 -0400 Received: from vpn83-129.boston.redhat.com (vpn83-129.boston.redhat.com [172.16.83.129]) by mail.boston.redhat.com (8.12.8/8.12.8) with ESMTP id j9D617fb012113; Thu, 13 Oct 2005 02:01:07 -0400 From: Dave Malcolm To: gnome-doc-devel-list@gnome.org Content-Type: multipart/mixed; boundary="=-CUDRMlybahnrJETYCNyI" Date: Thu, 13 Oct 2005 02:05:26 -0400 Message-Id: <1129183526.6821.14.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.4 (2.0.4-6) X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Status: No, score=-1.9 tagged_above=-999 required=2 tests=[BAYES_00, HTML_MESSAGE] X-Spam-Score: -1.9 X-Spam-Level: Cc: dogtail-devel-list@gnome.org Subject: Script for generating parodies of bad documentation X-BeenThere: gnome-doc-devel-list@gnome.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about development of yelp, gnome-doc-utils, and other documentation-related utilities" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2005 06:01:11 -0000 --=-CUDRMlybahnrJETYCNyI Content-Type: text/plain Content-Transfer-Encoding: 7bit I've been a bad, bad, person and written this dogtail [1] script: http://cvs.gnome.org/viewcvs/dogtail/examples/no-help-at-all.py?view=markup You pass it the accessible name of a running application, and it scours that application's GUI, reading it back to you in DocBook form. The idea is (i) to parody some of the unhelpful user documentation I've seen over the years - please don't write documentation that looks like this! This was inspired in part by reading Shaun McCance's Project Mallard notes here: http://www.gnome.org/~shaunm/quack/mallard.xml (ii) to provide a source of test data for help viewers, such as Yelp, and for stylesheet authors Attached is an example of the output when I pointed the script at gedit. My apologies... [1] http://people.redhat.com/zcerza/dogtail/index.html --=-CUDRMlybahnrJETYCNyI Content-Disposition: attachment; filename=not-the-gedit-manual.xml Content-Type: text/xml; name=not-the-gedit-manual.xml; charset=UTF-8 Content-Transfer-Encoding: 7bit
The Totally Definitive No-Nonsense Unhelpful Complete Guide to <application>gedit</application> for Mannequins in 40 Days - Unleashed! Introduction Do not take these instructions seriously. They are a parody of unhelpful help files found on many computer systems, and were autogenerated by no-help-at-all You can start gedit by opening a terminal and typing the gedit command. The <guimenu>File</guimenu> menu Use the File menu to work with files Newing a file To new a file, choose File > New Open...ing a file To open... a file, choose File > Open... Open Location...ing a file To open location... a file, choose File > Open Location... Saveing a file To save a file, choose File > Save Save As...ing a file To save as... a file, choose File > Save As... Reverting a file To revert a file, choose File > Revert Page Setuping a file To page setup a file, choose File > Page Setup Print Preview...ing a file To print preview... a file, choose File > Print Preview... Print...ing a file To print... a file, choose File > Print... 1. No-Help-At-All.Pying a file To 1. no-help-at-all.py a file, choose File > 1. no-help-at-all.py 2. Tmp.Xmling a file To 2. tmp.xml a file, choose File > 2. tmp.xml 3. Tree.Pying a file To 3. tree.py a file, choose File > 3. tree.py 4. Test-Docbook.Xmling a file To 4. test-docbook.xml a file, choose File > 4. test-docbook.xml 5. Abiword-Test.Pying a file To 5. abiword-test.py a file, choose File > 5. abiword-test.py Closeing a file To close a file, choose File > Close Quiting a file To quit a file, choose File > Quit The <guimenu>Edit</guimenu> menu Use the Edit menu to work with edits Undoing a edit To undo a edit, choose Edit > Undo Redoing a edit To redo a edit, choose Edit > Redo Cuting a edit To cut a edit, choose Edit > Cut Copying a edit To copy a edit, choose Edit > Copy Pasteing a edit To paste a edit, choose Edit > Paste Deleteing a edit To delete a edit, choose Edit > Delete Select Alling a edit To select all a edit, choose Edit > Select All Preferencesing a edit To preferences a edit, choose Edit > Preferences The <guimenu>View</guimenu> menu Use the View menu to work with views The <guimenu>Customise Toolbar</guimenu> menu Use the Customise Toolbar menu to work with customise toolbars The <guimenu>Highlight Mode</guimenu> menu Use the Highlight Mode menu to work with highlight modes The <guimenu>Sources</guimenu> menu Use the Sources menu to work with sourcess The <guimenu>Scripts</guimenu> menu Use the Scripts menu to work with scriptss The <guimenu>Markup</guimenu> menu Use the Markup menu to work with markups The <guimenu>Others</guimenu> menu Use the Others menu to work with otherss The <guimenu>Search</guimenu> menu Use the Search menu to work with searchs Find...ing a search To find... a search, choose Search > Find... Find Nexting a search To find next a search, choose Search > Find Next Find Previousing a search To find previous a search, choose Search > Find Previous Replace...ing a search To replace... a search, choose Search > Replace... Go To Line...ing a search To go to line... a search, choose Search > Go to Line... The <guimenu>Tools</guimenu> menu Use the Tools menu to work with toolss Check Spellinging a tools To check spelling a tools, choose Tools > Check Spelling Set Languageing a tools To set language a tools, choose Tools > Set Language The <guimenu>Documents</guimenu> menu Use the Documents menu to work with documentss Save Alling a documents To save all a documents, choose Documents > Save All Close Alling a documents To close all a documents, choose Documents > Close All Move To New Windowing a documents To move to new window a documents, choose Documents > Move to New Window Gedit-Test-Results.Txting a documents To gedit-test-results.txt a documents, choose Documents > gedit-test-results.txt Test-Docbook.Xmling a documents To test-docbook.xml a documents, choose Documents > test-docbook.xml Tmp.Xmling a documents To tmp.xml a documents, choose Documents > tmp.xml Tree.Pying a documents To tree.py a documents, choose Documents > tree.py No-Help-At-All.Pying a documents To no-help-at-all.py a documents, choose Documents > no-help-at-all.py The <guimenu>Help</guimenu> menu Use the Help menu to work with helps Contentsing a help To contents a help, choose Help > Contents Abouting a help To about a help, choose Help > About
--=-CUDRMlybahnrJETYCNyI-- From zcerza@redhat.com Thu Oct 13 10:51:47 2005 Return-Path: X-Original-To: gnome-doc-devel-list@gnome.org Delivered-To: gnome-doc-devel-list@gnome.org Received: from localhost (unknown [127.0.0.1]) by menubar.gnome.org (Postfix) with ESMTP id 6EF7E3B0906; Thu, 13 Oct 2005 10:51:47 -0400 (EDT) Received: from menubar.gnome.org ([127.0.0.1]) by localhost (menubar.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 20683-08; Thu, 13 Oct 2005 10:51:45 -0400 (EDT) Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31]) by menubar.gnome.org (Postfix) with ESMTP id 320173B0697; Thu, 13 Oct 2005 10:51:45 -0400 (EDT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j9DEpihX003828; Thu, 13 Oct 2005 10:51:44 -0400 Received: from mail.boston.redhat.com (mail.boston.redhat.com [172.16.76.12]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j9DEpiV15189; Thu, 13 Oct 2005 10:51:44 -0400 Received: from [172.16.83.8] (dhcp83-8.boston.redhat.com [172.16.83.8]) by mail.boston.redhat.com (8.12.8/8.12.8) with ESMTP id j9DEphfb012648; Thu, 13 Oct 2005 10:51:43 -0400 Message-ID: <434E7489.9090503@redhat.com> Date: Thu, 13 Oct 2005 10:51:53 -0400 From: Zack Cerza User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051010) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dave Malcolm References: <1129183526.6821.14.camel@localhost.localdomain> In-Reply-To: <1129183526.6821.14.camel@localhost.localdomain> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Status: No, score=-4.9 tagged_above=-999 required=2 tests=[BAYES_00] X-Spam-Score: -4.9 X-Spam-Level: X-Mailman-Approved-At: Thu, 13 Oct 2005 10:53:13 -0400 Cc: dogtail-devel-list@gnome.org, gnome-doc-devel-list@gnome.org Subject: Re: dogtail-devel Script for generating parodies of bad documentation X-BeenThere: gnome-doc-devel-list@gnome.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about development of yelp, gnome-doc-utils, and other documentation-related utilities" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2005 14:51:47 -0000 Dave Malcolm wrote: > I've been a bad, bad, person and written this dogtail [1] script: > http://cvs.gnome.org/viewcvs/dogtail/examples/no-help-at-all.py?view=markup > > You pass it the accessible name of a running application, and it scours > that application's GUI, reading it back to you in DocBook form. > > The idea is (i) to parody some of the unhelpful user documentation I've > seen over the years - please don't write documentation that looks like > this! This was inspired in part by reading Shaun McCance's Project > Mallard notes here: http://www.gnome.org/~shaunm/quack/mallard.xml > (ii) to provide a source of test data for help viewers, such as Yelp, > and for stylesheet authors > > Attached is an example of the output when I pointed the script at gedit. > My apologies... > > [1] http://people.redhat.com/zcerza/dogtail/index.html Hah. That's awesome. You evil, evil man. Zack From ash@contact.bg Fri Oct 21 04:41:03 2005 Return-Path: X-Original-To: gnome-doc-devel-list@gnome.org Delivered-To: gnome-doc-devel-list@gnome.org Received: from localhost (unknown [127.0.0.1]) by menubar.gnome.org (Postfix) with ESMTP id 06F043B4F7B; Fri, 21 Oct 2005 04:41:03 -0400 (EDT) Received: from menubar.gnome.org ([127.0.0.1]) by localhost (menubar.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 20510-04; Fri, 21 Oct 2005 04:41:01 -0400 (EDT) Received: from mail.rightnet.net (palpatine.rightnet.net [62.204.159.2]) by menubar.gnome.org (Postfix) with ESMTP id C9AF53B4F79; Fri, 21 Oct 2005 04:41:00 -0400 (EDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.rightnet.net (Postfix) with ESMTP id 0F6B01802A3; Fri, 21 Oct 2005 11:39:59 +0300 (EEST) Received: from mail.rightnet.net ([127.0.0.1]) by localhost (palpatine [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 14225-09; Fri, 21 Oct 2005 11:39:56 +0300 (EEST) Received: from [172.29.69.70] (unknown [172.29.69.70]) by mail.rightnet.net (Postfix) with ESMTP id 31A5E180271; Fri, 21 Oct 2005 11:39:56 +0300 (EEST) From: Alexander Shopov To: gnome-doc-list@gnome.org Content-Type: text/plain Date: Fri, 21 Oct 2005 11:42:03 +0300 Message-Id: <1129884123.18684.10.camel@kochinka.spectrum.local> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at rightnet.net X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Status: No, score=-4.9 tagged_above=-999 required=2 tests=[BAYES_00] X-Spam-Score: -4.9 X-Spam-Level: Cc: gnome-doc-devel-list@gnome.org Subject: Introduction of Alexander Shopov X-BeenThere: gnome-doc-devel-list@gnome.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about development of yelp, gnome-doc-utils, and other documentation-related utilities" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Oct 2005 08:41:03 -0000 Hi everybody, My name is Alexander Shopov and I am the leader of the Bulgarian Gnome translation team. We have already finished the translation of the core interface and we are gradually starting to look at the documentation. In the following months I expect us to finish the tranlastion of the documentation of several modules and converting the ready translations to the Gnome docbook format. I have subscribed to gnome-doc-list to be in touch with the documentation changes and I have subscribed to gnome-doc-devel-list to look at the changes in the tools. I hope to be able to make some commits during next week but I cannot promise that. I have still not read everything on Gnome site about documentation translations and if there are resources I need to take in mind i'll be thankful if you lead me to them. Best regards: al_shopov From sri@aracnet.com Fri Oct 21 12:27:37 2005 Return-Path: X-Original-To: gnome-doc-devel-list@gnome.org Delivered-To: gnome-doc-devel-list@gnome.org Received: from localhost (unknown [127.0.0.1]) by menubar.gnome.org (Postfix) with ESMTP id 3B8AC3B0F74; Fri, 21 Oct 2005 12:27:36 -0400 (EDT) Received: from menubar.gnome.org ([127.0.0.1]) by localhost (menubar.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 23012-05; Fri, 21 Oct 2005 12:27:33 -0400 (EDT) Received: from onyx.spiritone.com (onyx.spiritone.com [216.99.193.114]) by menubar.gnome.org (Postfix) with ESMTP id D1AEA3B0F31; Fri, 21 Oct 2005 12:26:49 -0400 (EDT) Received: from onyx.spiritone.com (onyx.spiritone.com [127.0.0.1]) by onyx.spiritone.com (8.12.8/8.12.8) with ESMTP id j9LGQhBC018667; Fri, 21 Oct 2005 09:26:43 -0700 Received: (from sri@localhost) by onyx.spiritone.com (8.12.8/8.12.8/Submit) id j9LGQgxr018665; Fri, 21 Oct 2005 09:26:42 -0700 Date: Fri, 21 Oct 2005 09:26:42 -0700 From: Sriram Ramkrishna To: Alexander Shopov Message-ID: <20051021162642.GI30669@aracnet.com> References: <1129884123.18684.10.camel@kochinka.spectrum.local> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1129884123.18684.10.camel@kochinka.spectrum.local> User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Status: No, score=-4.9 tagged_above=-999 required=2 tests=[BAYES_00] X-Spam-Score: -4.9 X-Spam-Level: Cc: gnome-doc-devel-list@gnome.org, gnome-doc-list@gnome.org Subject: Re: Introduction of Alexander Shopov X-BeenThere: gnome-doc-devel-list@gnome.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about development of yelp, gnome-doc-utils, and other documentation-related utilities" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Oct 2005 16:27:37 -0000 Welcome, Al! :) sri On Fri, Oct 21, 2005 at 11:42:03AM +0300, Alexander Shopov wrote: > Hi everybody, > > My name is Alexander Shopov and I am the leader of the Bulgarian Gnome > translation team. We have already finished the translation of the core > interface and we are gradually starting to look at the documentation. > In the following months I expect us to finish the tranlastion of the > documentation of several modules and converting the ready translations > to the Gnome docbook format. > I have subscribed to gnome-doc-list to be in touch with the > documentation changes and I have subscribed to gnome-doc-devel-list to > look at the changes in the tools. > I hope to be able to make some commits during next week but I cannot > promise that. > I have still not read everything on Gnome site about documentation > translations and if there are resources I need to take in mind i'll be > thankful if you lead me to them. > > Best regards: > al_shopov > > _______________________________________________ > gnome-doc-list mailing list > gnome-doc-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gnome-doc-list -- From shaunm@gnome.org Sat Oct 22 15:00:44 2005 Return-Path: X-Original-To: gnome-doc-devel-list@gnome.org Delivered-To: gnome-doc-devel-list@gnome.org Received: from localhost (unknown [127.0.0.1]) by menubar.gnome.org (Postfix) with ESMTP id CFB8A3B314F; Sat, 22 Oct 2005 15:00:44 -0400 (EDT) Received: from menubar.gnome.org ([127.0.0.1]) by localhost (menubar.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 18056-01; Sat, 22 Oct 2005 15:00:43 -0400 (EDT) Received: from mx1.wolfram.com (relay.wolfram.com [140.177.205.5]) by menubar.gnome.org (Postfix) with ESMTP id B4FEF3B3148; Sat, 22 Oct 2005 15:00:42 -0400 (EDT) Received: from cornholio.housenet.network (12-208-67-103.client.insightBB.com [12.208.67.103]) (authenticated bits=0) by mx1.wolfram.com (8.12.11/8.12.11) with ESMTP id j9MJ0fZs004145 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT); Sat, 22 Oct 2005 14:00:41 -0500 From: Shaun McCance To: gnome-doc-devel-list@gnome.org, gnome-i18n@gnome.org Content-Type: text/plain Date: Sat, 22 Oct 2005 14:00:40 -0500 Message-Id: <1130007641.17733.21.camel@cornholio.housenet.network> Mime-Version: 1.0 X-Mailer: Evolution 2.4.0 Content-Transfer-Encoding: 7bit Received-SPF: pass (mx1.wolfram.com: authenticated connection) receiver=mx1.wolfram.com; client-ip=12.208.67.103; helo=cornholio.housenet.network; envelope-from=shaunm@gnome.org; x-software=spfmilter 0.97 http://www.acme.com/software/spfmilter/ with libspf2-1.0.0; X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Status: No, score=-4.8 tagged_above=-999 required=2 tests=[BAYES_00, RCVD_IN_SORBS] X-Spam-Score: -4.8 X-Spam-Level: Cc: Subject: Digit formatters in gnome-doc-utils X-BeenThere: gnome-doc-devel-list@gnome.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about development of yelp, gnome-doc-utils, and other documentation-related utilities" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Oct 2005 19:00:45 -0000 Currently, to format the number for a section, the section.number localization is called up, which might look like this: . This formats the parent number, whatever that may be, and the "digit" for the section, which is just the position of that section in its parent. The digit formatting is then controlled by the section.digit localization, which is just a single-character thing saying what numbering system to use to format it. If a section is a top-level, the section.number localization is bypassed and section.digit is called directly. The problem is that at least the French team needs to do formatting on the digit: http://bugzilla.gnome.org/show_bug.cgi?id=315190 This particular case involves wrapping the digit in some markup, which you can't do reliably with the current system. You could wrap the call to in the number formatter, but that won't help you when the number formatter is bypassed for top-level things. Here's some possible solutions: 1) Get rid of the single character digit things, and instead put attributes on any call to digit. This, you'd have something like this: . I would then remove the current digit formatter localizations, but I'd have to add localizations for top-level things. Net result is the same number of localized strings. This could also potentially be a tad faster, as template depth gets reduced. 2) Do the same thing, but instead of attributes, use special named elements, like so: . So we'd have digitI, digiti, digitA, digita, and digit1. This annoys me, though it could potentially emphasize more the need to mark the formatter. It has the same advantages as the first option. 3) Keep number formatters just as they are, but turn digit formatters into things that can have markup. So section.number would still just be . But section.digit would become Where n would have to become some meaningful element name. This has the advantage that only digit formatters have to be changed, and the change can be done automatically. I could even adjust all the PO files, if translators wanted me to. The other advantage is that you still only need to specify the digit formatting in a single place. It does, on the whole, seem cleaner to me. On the other hand, it means I have to come up with yet another element name, I think. Due to the way XSLT works, and the way my i18n system works in XSLT, I probably can't just re-use "digit" or "number" as element names here. And I'm sort of at a loss for another element name to convey the meaning. Thoughts? -- Shaun From clahey@ximian.com Mon Oct 31 14:23:37 2005 Return-Path: X-Original-To: gnome-doc-devel-list@gnome.org Delivered-To: gnome-doc-devel-list@gnome.org Received: from localhost (unknown [127.0.0.1]) by menubar.gnome.org (Postfix) with ESMTP id B83523B27A2 for ; Mon, 31 Oct 2005 14:23:37 -0500 (EST) Received: from menubar.gnome.org ([127.0.0.1]) by localhost (menubar.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 28212-03 for ; Mon, 31 Oct 2005 14:23:35 -0500 (EST) Received: from peabody.ximian.com (peabody.ximian.com [130.57.169.10]) by menubar.gnome.org (Postfix) with ESMTP id 610F53B279E for ; Mon, 31 Oct 2005 14:23:33 -0500 (EST) Received: (qmail 18517 invoked from network); 31 Oct 2005 19:23:32 -0000 Received: from outbound.ximian.com (HELO rigger.boston.ximian.com) (130.57.170.250) by peabody.ximian.com with SMTP; 31 Oct 2005 19:23:32 -0000 From: Christopher James Lahey To: gnome-doc-devel-list@gnome.org Content-Type: multipart/mixed; boundary="=-9ORf8ZtCi7oCmctsklwp" Date: Mon, 31 Oct 2005 14:25:26 -0500 Message-Id: <1130786726.5961.28.camel@rigger.boston.ximian.com> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Status: No, score=1.439 tagged_above=-999 required=2 tests=[BAYES_00, HTML_MESSAGE, HTML_TITLE_EMPTY, TW_BG, TW_BX, TW_GT, TW_IB] X-Spam-Score: 1.439 X-Spam-Level: * X-Mailman-Approved-At: Mon, 31 Oct 2005 16:59:07 -0500 Subject: yelp patches X-BeenThere: gnome-doc-devel-list@gnome.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about development of yelp, gnome-doc-utils, and other documentation-related utilities" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2005 19:23:38 -0000 --=-9ORf8ZtCi7oCmctsklwp Content-Type: text/plain Content-Transfer-Encoding: 7bit I've been working on adding some features to yelp and wish to work on getting them upstreamed. Included are 4 yelp patches. The first, yelp-helpuri.patch, enables yelp to recognize help: uris as used by KDE. It will also find things in some gnome directories (with the same behavior as the patch I added to khelpcenter for SuSE a while back.) I've written up a standard, but it needs some discussion. This could go in as is to match with KDE. The second, yelp-libmenu.patch, causes yelp to use the menu system to generate its table of contents instead of using scrollkeeper. This will allow us to get rid of the installtime hit from scrollkeeper as well as make the help menu match the Applications menu. This is just reading from a .menu file, so we can have a help.menu file that includes applications.menu so we can include stuff not in the menus. The third, yelp-printing.patch, adds printing support to yelp. It will print either the page or the whole document. The fourth, yelp-toctree.patch, displays the table of contents as a tree on a single page instead of across multiple pages. All 4 patches can be applied to the same tree. Known bugs: - Printing the whole document leaks some memory because I'm not sure how to know when the printing is done so I can free the temporary mozilla window. - Having the table of contents tree remember which nodes are open across sessions requires yelp_html_initialize from yelp-printing.patch, but I didn't want to have the patches conflict too much. Enjoy, Chris --=-9ORf8ZtCi7oCmctsklwp Content-Disposition: attachment; filename=yelp-helpuri.patch Content-Type: text/x-patch; name=yelp-helpuri.patch; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 7bit Index: src/yelp-utils.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-utils.c,v retrieving revision 1.26 diff -u -p -r1.26 yelp-utils.c --- src/yelp-utils.c 28 Oct 2005 20:37:37 -0000 1.26 +++ src/yelp-utils.c 31 Oct 2005 19:10:29 -0000 @@ -68,6 +68,7 @@ struct _YelpDocInfo { static YelpDocType get_doc_type (gchar *uri); static gchar * convert_ghelp_uri (gchar *uri); +static gchar * convert_help_uri (gchar *uri); static gchar * convert_man_uri (gchar *uri); static gchar * convert_info_uri (gchar *uri); @@ -78,7 +79,7 @@ yelp_doc_info_new (const gchar *uri) YelpDocInfo *doc; gchar *doc_uri = NULL; gchar *full_uri = NULL; - YelpDocType doc_type; + YelpDocType doc_type = YELP_DOC_TYPE_EXTERNAL; YelpURIType uri_type; gchar *cur; @@ -106,6 +107,27 @@ yelp_doc_info_new (const gchar *uri) doc_type = get_doc_type (doc_uri); uri_type = YELP_URI_TYPE_GHELP; } + else if (g_str_has_prefix (full_uri, "help:")) { + doc_uri = convert_help_uri (full_uri); + if (doc_uri) + doc_type = get_doc_type (doc_uri); +#if 0 + if ((cur = strchr (doc_uri, '#'))) { + char *temp; + + if (!strchr (full_uri, '#')) { + temp = full_uri; + full_uri = g_strconcat (full_uri, "#", cur + 1, NULL); + g_free (temp); + } + + temp = doc_uri; + doc_uri = g_strndup (doc_uri, cur - doc_uri); + g_free (temp); + } +#endif + uri_type = YELP_URI_TYPE_HELP; + } else if (g_str_has_prefix (full_uri, "man:")) { doc_uri = convert_man_uri (full_uri); doc_type = YELP_DOC_TYPE_MAN; @@ -117,7 +139,7 @@ yelp_doc_info_new (const gchar *uri) uri_type = YELP_URI_TYPE_INFO; } else if (g_str_has_prefix (full_uri, "x-yelp-toc:")) { - doc_uri = g_strdup ("file://" DATADIR "/yelp/toc.xml"); + doc_uri = g_strdup ("file://" DATADIR "/yelp/xslt/toc2html.xsl"); doc_type = YELP_DOC_TYPE_TOC; uri_type = YELP_URI_TYPE_TOC; } @@ -189,7 +211,7 @@ yelp_doc_info_get (const gchar *uri) if (!doc) { doc = yelp_doc_info_new (doc_uri); if (doc && doc->type != YELP_DOC_TYPE_EXTERNAL) { - YelpDocInfo *old_doc; + YelpDocInfo *old_doc = NULL; for (i = 0; i < doc->num_uris; i++) { old_doc = g_hash_table_lookup (doc_info_table, @@ -478,6 +500,18 @@ yelp_uri_get_fragment (const gchar *uri) if (*(++cur) != '\0') frag_id = g_strdup (cur); + if (g_str_has_prefix (uri, "help:")) + if (g_str_has_suffix (uri, ".html")) { + YelpDocInfo *doc = yelp_doc_info_get (uri); + char *file_uri; + file_uri = yelp_doc_info_get_uri (doc, NULL, YELP_URI_TYPE_FILE); + if (!g_str_has_suffix (file_uri, ".html")) { + cur = strrchr (uri, '/'); + frag_id = g_strndup (cur + 1, strlen (cur + 1) - strlen (".html")); + } + g_free (file_uri); + } + if ((cur = strchr (uri, '#'))) if (*(++cur) != '\0') { if (frag_id) @@ -520,7 +554,7 @@ get_doc_type (gchar *uri) if (mime_type == NULL) return YELP_DOC_TYPE_ERROR; - if (g_str_equal (mime_type, "text/xml")) + if (g_str_equal (mime_type, "text/xml") || g_str_equal (mime_type, "application/docbook+xml")) type = YELP_DOC_TYPE_DOCBOOK_XML; else if (g_str_equal (mime_type, "text/sgml")) type = YELP_DOC_TYPE_DOCBOOK_SGML; @@ -567,6 +601,161 @@ yelp_doc_info_add_uri (YelpDocInfo *doc_ /******************************************************************************/ /** Convert fancy URIs to file URIs *******************************************/ + +static gchar * +help_uri_check_file (gchar *filename, gchar *reference) { + d(g_print ("Checking %s\n", filename)); + if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) { + gchar *full_uri; + if (reference) { + full_uri = g_strconcat ("file://", filename, NULL, "#", reference, NULL); + } else { + full_uri = g_strconcat ("file://", filename, NULL); + } + + return full_uri; + } + + return NULL; +} + +static gchar * +help_uri_check_dir (gchar *path, gchar *identifier, gchar *reference) +{ + gchar *result; + + gchar *full_path; + gchar *full_identifier; + + result = help_uri_check_file (path, reference); + if (result) + return result; + + full_path = g_build_filename (path, "index.docbook", NULL); + result = help_uri_check_file (full_path, reference); + g_free (full_path); + if (result) + return result; + + full_identifier = g_strconcat (identifier, ".xml", NULL); + full_path = g_build_filename (path, full_identifier, NULL); + result = help_uri_check_file (full_path, reference); + g_free (full_path); + g_free (full_identifier); + if (result) + return result; + + return NULL; +} + +static gchar * +help_uri_search (gchar *path, gchar *identifier, char *reference) +{ + gchar *result; + + result = help_uri_check_dir (path, identifier, reference); + if (result) + return result; + + if (strlen (path) > 5 && ! strcmp (path + strlen (path) - 5, ".html")) { + gchar *slash = strrchr (path, '/'); + if (slash != NULL) { + gchar *shortened = g_strndup (path, slash - path); + gchar *shortened_reference = g_strndup (slash + 1, strlen (slash + 1) - 5); + result = help_uri_check_dir (shortened, identifier, reference ? reference : shortened_reference); + g_free (reference); + g_free (shortened); + if (result) + return result; + } + } + return NULL; +} + +static gchar * +help_uri_expand_datadirs (gchar *path, gchar *identifier, char *reference) +{ + char const* const* data_dirs = g_get_system_data_dirs (); + int i; + char *result; + for (i = 0; data_dirs[i]; i++) { + char *full_path = g_build_filename (data_dirs[i], path, NULL); + result = help_uri_search (full_path, identifier, reference); + g_free (full_path); + if (result) + return result; + } + return NULL; +} + +static gchar * +convert_help_uri (gchar *uri) +{ + gchar *path; + gchar *file_name = NULL; + const gchar * const * langs; + gchar *result = NULL; + gchar *full_path; + int i; + gchar *reference; + + if ((path = strchr(uri, ':'))) + path++; + else + return NULL; + + while (*path == '/') + path++; + + path = g_strdup (path); + + reference = strchr (path, '#'); + if (reference) { + *reference = 0; + reference ++; + } + + /* This isn't the filename so much as the rest of the path after the first bit of the path. */ + file_name = strchr (path, '/'); + if (file_name) { + *file_name = 0; + file_name ++; + } else { + file_name = ""; + } + + langs = g_get_language_names (); + + for (i = 0; langs[i] != NULL; i++) { + full_path = g_strdup_printf ("/gnome/help/%s/%s/%s", path, langs[i], file_name); + help_uri_expand_datadirs (full_path, path, reference); + g_free (full_path); + if (result) + goto end; + + full_path = g_strdup_printf ("/doc/HTML/%s/%s/%s", langs[i], path, file_name); + help_uri_expand_datadirs (full_path, path, reference); + g_free (full_path); + if (result) + goto end; + } + + full_path = g_strdup_printf ("/gnome/help/%s/C/%s", path, file_name); + result = help_uri_expand_datadirs (full_path, path, reference); + g_free (full_path); + if (result) + goto end; + + full_path = g_strdup_printf ("/doc/HTML/en/%s/%s", path, file_name); + result = help_uri_expand_datadirs (full_path, path, reference); + g_free (full_path); + if (result) + goto end; + + end: + g_free (path); + return result; +} static gchar * locate_file_lang (gchar *path, gchar *file, const gchar *lang) Index: src/yelp-utils.h =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-utils.h,v retrieving revision 1.12 diff -u -p -r1.12 yelp-utils.h --- src/yelp-utils.h 28 Oct 2005 20:37:37 -0000 1.12 +++ src/yelp-utils.h 31 Oct 2005 19:10:29 -0000 @@ -67,6 +67,7 @@ typedef enum { YELP_URI_TYPE_TOC = 1 << 4, YELP_URI_TYPE_EXTERNAL = 1 << 5, YELP_URI_TYPE_SEARCH = 1 << 6, + YELP_URI_TYPE_HELP = 1 << 7, YELP_URI_TYPE_NO_FILE = YELP_URI_TYPE_GHELP | @@ -74,9 +75,10 @@ typedef enum { YELP_URI_TYPE_INFO | YELP_URI_TYPE_TOC | YELP_URI_TYPE_EXTERNAL | + YELP_URI_TYPE_HELP | YELP_URI_TYPE_SEARCH, YELP_URI_TYPE_ANY = - YELP_URI_TYPE_FILE | + YELP_URI_TYPE_FILE | YELP_URI_TYPE_NO_FILE } YelpURIType; --=-9ORf8ZtCi7oCmctsklwp Content-Disposition: attachment; filename=yelp-libmenu.patch Content-Type: text/x-patch; name=yelp-libmenu.patch; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 7bit Index: configure.in =================================================================== RCS file: /cvs/gnome/yelp/configure.in,v retrieving revision 1.192 diff -u -p -r1.192 configure.in --- configure.in 28 Oct 2005 20:37:36 -0000 1.192 +++ configure.in 31 Oct 2005 18:44:10 -0000 @@ -63,6 +63,7 @@ PKG_CHECK_MODULES(YELP, libxml-2.0 >= 2.6.5 libxslt >= 1.1.4 libexslt >= 0.8.1 + libgnome-menu >= 2.11.1 ]) AC_SUBST([YELP_CFLAGS]) AC_SUBST([YELP_LIBS]) Index: src/yelp-toc-pager.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-toc-pager.c,v retrieving revision 1.51 diff -u -p -r1.51 yelp-toc-pager.c --- src/yelp-toc-pager.c 21 Oct 2005 01:47:56 -0000 1.51 +++ src/yelp-toc-pager.c 31 Oct 2005 18:44:10 -0000 @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,12 @@ #include "yelp-toc-pager.h" #include "yelp-utils.h" +#define GMENU_I_KNOW_THIS_IS_UNSTABLE +#include + +#define DESKTOP_ENTRY_GROUP "Desktop Entry" +#define KDE_DESKTOP_ENTRY_GROUP "KDE Desktop Entry" + #ifdef YELP_DEBUG #define d(x) x #else @@ -96,6 +103,9 @@ struct _YelpTocPagerPriv { xsltStylesheetPtr stylesheet; xsltTransformContextPtr transformContext; + + GMenuTree *libmenu_tree; + GSList *libmenu_stack; }; struct _YelpListing { @@ -125,10 +135,14 @@ GtkTreeModel * toc_pager_get_secti static gboolean toc_process_pending (YelpTocPager *pager); -static gboolean process_read_menu (YelpTocPager *pager); +static gboolean process_libmenu (YelpTocPager *pager); +static gboolean process_libmenu_node (YelpTocPager *pager); static gboolean process_xslt (YelpTocPager *pager); +#ifdef ENABLE_SCROLLKEEPER +static gboolean process_read_menu (YelpTocPager *pager); static gboolean process_read_scrollkeeper (YelpTocPager *pager); static gboolean process_omf_pending (YelpTocPager *pager); +#endif #ifdef ENABLE_MAN static gboolean process_mandir_pending (YelpTocPager *pager); #endif @@ -137,11 +151,13 @@ static gboolean process_info_dir_pe static gboolean process_info_pending (YelpTocPager *pager); #endif +#ifdef ENABLE_SCROLLKEEPER static void toc_add_doc_info (YelpTocPager *pager, YelpDocInfo *doc_info); static void toc_remove_doc_info (YelpTocPager *pager, YelpDocInfo *doc_info); static void xml_trim_titles (xmlNodePtr node); +#endif static void xslt_yelp_document (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, @@ -213,6 +229,9 @@ toc_pager_init (YelpTocPager *pager) priv->cancel = 0; priv->pause_count = 0; priv->pending_func = NULL; + + priv->libmenu_tree = NULL; + priv->libmenu_stack = NULL; } static void @@ -320,7 +339,7 @@ toc_pager_process (YelpPager *pager) yelp_pager_set_state (pager, YELP_PAGER_STATE_RUNNING); g_signal_emit_by_name (pager, "start"); - priv->pending_func = (ProcessFunction) process_read_menu; + priv->pending_func = (ProcessFunction) process_libmenu; gtk_idle_add_priority (G_PRIORITY_LOW, (GtkFunction) toc_process_pending, @@ -351,10 +370,15 @@ toc_process_pending (YelpTocPager *pager gboolean readd; YelpTocPagerPriv *priv = pager->priv; static gpointer process_funcs[] = { + process_libmenu, + process_libmenu_node, + process_xslt, +#ifdef ENABLE_SCROLLKEEPER process_read_menu, process_read_scrollkeeper, process_omf_pending, process_xslt, +#endif #ifdef ENABLE_MAN process_mandir_pending, process_xslt, @@ -386,6 +410,204 @@ toc_process_pending (YelpTocPager *pager return FALSE; } +static void +set_icon (xmlNode *node, const char *icon) +{ + if (icon) { + GtkIconInfo *info; + GtkIconTheme *theme = + (GtkIconTheme *) yelp_settings_get_icon_theme (); + info = gtk_icon_theme_lookup_icon (theme, icon, 48, 0); + if (info) { + xmlNodePtr new = xmlNewChild (node, NULL, "icon", NULL); + xmlNewNsProp (new, NULL, "file", gtk_icon_info_get_filename (info)); + gtk_icon_info_free (info); + } + } +} + +typedef struct { + xmlNode *tree; + GSList *children; + GSList *iterator; + gboolean non_empty; +} LibmenuStackFrame; + +static void +push_stack_frame (YelpTocPager *pager, GMenuTreeDirectory *dir) +{ + LibmenuStackFrame *frame; + YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv; + + frame = g_new (LibmenuStackFrame, 1); + frame->iterator = frame->children = gmenu_tree_directory_get_contents (dir); + frame->non_empty = FALSE; + + frame->tree = xmlNewNode (NULL, "toc"); + xmlSetProp (frame->tree, "id", gmenu_tree_directory_get_menu_id (dir)); + xmlNewTextChild (frame->tree, NULL, "title", gmenu_tree_directory_get_name (dir)); + set_icon (frame->tree, gmenu_tree_directory_get_icon (dir)); + + priv->libmenu_stack = g_slist_prepend (priv->libmenu_stack, frame); +} + +static void +pop_stack_frame (YelpTocPager *pager) +{ + LibmenuStackFrame *frame; + YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv; + + frame = priv->libmenu_stack->data; + + g_slist_free (frame->children); + g_free (frame); + + priv->libmenu_stack = g_slist_delete_link (priv->libmenu_stack, priv->libmenu_stack); +} + +static GTimer *timer; +/* iterator points to next node to process and is incremented at the + end of the function. NULL means finished with this level. Parent + iterators are incremented before processing the child tree. */ +static gboolean +process_libmenu_node (YelpTocPager *pager) +{ + LibmenuStackFrame *frame; + GMenuTreeItem *item; + YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv; + gulong ms_start; + + + frame = priv->libmenu_stack->data; + + if (frame->iterator == NULL) { + if (priv->libmenu_stack->next) { + if (frame->non_empty) { + xmlNode *tree = frame->tree; + pop_stack_frame (pager); + + frame = priv->libmenu_stack->data; + xmlAddChild (frame->tree, tree); + frame->non_empty = TRUE; + } else { + xmlFreeNode (frame->tree); + pop_stack_frame(pager); + } + + return TRUE; + } else { + YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv; + xmlNode *title; + + priv->toc_doc = xmlNewDoc ("1.0"); + xmlSetProp (frame->tree, "id", "index"); + xmlDocSetRootElement (priv->toc_doc, frame->tree); + + for (title = frame->tree->children; title; title = title->next) { + if (g_str_equal (title->name, "title")) { + xmlNodeSetContent (title, _("Help Topics")); + break; + } + } + if (title == NULL) { + xmlNewTextChild (frame->tree, NULL, "title", _("Help Topics")); + } + + pop_stack_frame (pager); + + gmenu_tree_unref (priv->libmenu_tree); + priv->libmenu_tree = NULL; + + + + return FALSE; + } + } + + item = frame->iterator->data; + + switch (gmenu_tree_item_get_type (item)) { + case GMENU_TREE_ITEM_DIRECTORY: + { + push_stack_frame (pager, GMENU_TREE_DIRECTORY (item)); + } + break; + case GMENU_TREE_ITEM_ENTRY: + { + GMenuTreeEntry *entry = GMENU_TREE_ENTRY (item); + const char *path = gmenu_tree_entry_get_desktop_file_path (entry); + const char *desktop_entry_group; + char *docpath = NULL; + GKeyFile *key_file; + + key_file = g_key_file_new (); + + + if (!g_key_file_load_from_file (key_file, path, 0, NULL)) { + g_key_file_free (key_file); + break; + } + + if (g_key_file_has_group (key_file, DESKTOP_ENTRY_GROUP)) { + desktop_entry_group = DESKTOP_ENTRY_GROUP; + } else { + if (g_key_file_has_group (key_file, KDE_DESKTOP_ENTRY_GROUP)) { + desktop_entry_group = KDE_DESKTOP_ENTRY_GROUP; + } else { + g_key_file_free (key_file); + break; + } + } + + docpath = g_key_file_get_string (key_file, desktop_entry_group, "DocPath", NULL); + + if (docpath) { + xmlNode *new = xmlNewChild (frame->tree, NULL, "doc", NULL); + if (strchr(docpath, ':')) { + xmlNewNsProp (new, NULL, "href", docpath); + } else { + char *href = g_strdup_printf ("help:%s", docpath); + xmlNewNsProp (new, NULL, "href", href); + g_free (href); + } + + xmlNewTextChild (new, NULL, "title", gmenu_tree_entry_get_name (entry)); + xmlNewTextChild (new, NULL, "description", gmenu_tree_entry_get_comment (entry)); + set_icon (new, gmenu_tree_entry_get_icon (entry)); + + frame->non_empty = TRUE; + + g_free (docpath); + } + } + break; + default: + /* Ignore */ + break; + } + + + frame->iterator = frame->iterator->next; + return TRUE; +} + + +static gboolean +process_libmenu (YelpTocPager *pager) +{ + YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv; + + + priv->libmenu_tree = gmenu_tree_lookup ("applications.menu", + GMENU_TREE_FLAGS_NONE); + + push_stack_frame (pager, gmenu_tree_get_root_directory (priv->libmenu_tree)); + + return FALSE; +} + +#ifdef ENABLE_SCROLLKEEPER + /** process_read_scrollkeeper *************************************************/ static void @@ -559,6 +781,7 @@ process_omf_pending (YelpTocPager *pager else return FALSE; } +#endif #ifdef ENABLE_MAN static gboolean @@ -752,6 +975,7 @@ process_info_pending (YelpTocPager *page } #endif /* ENABLE_INFO */ +#ifdef ENABLE_SCROLLKEEPER static gboolean process_read_menu (YelpTocPager *pager) { @@ -796,17 +1020,7 @@ process_read_menu (YelpTocPager *pager) xml_trim_titles (node); icon = xmlGetProp (node, "icon"); - if (icon) { - GtkIconInfo *info; - GtkIconTheme *theme = - (GtkIconTheme *) yelp_settings_get_icon_theme (); - info = gtk_icon_theme_lookup_icon (theme, icon, 48, 0); - if (info) { - xmlNodePtr new = xmlNewChild (node, NULL, "icon", NULL); - xmlNewNsProp (new, NULL, "file", gtk_icon_info_get_filename (info)); - gtk_icon_info_free (info); - } - } + set_icon (node, icon); xmlFree (icon); } @@ -864,12 +1078,13 @@ process_read_menu (YelpTocPager *pager) return FALSE; } +#endif static gboolean process_xslt (YelpTocPager *pager) { GError *error = NULL; - xmlDocPtr outdoc; + xmlDocPtr outdoc = NULL; YelpTocPagerPriv *priv = pager->priv; gchar **params = NULL; gint params_i = 0; @@ -948,6 +1163,7 @@ process_xslt (YelpTocPager *pager) return FALSE; } +#ifdef ENABLE_SCROLLKEEPER static void toc_add_doc_info (YelpTocPager *pager, YelpDocInfo *doc_info) { @@ -1002,6 +1218,8 @@ toc_remove_doc_info (YelpTocPager *pager #endif } +#endif + static void xslt_yelp_document (xsltTransformContextPtr ctxt, xmlNodePtr node, @@ -1122,6 +1340,7 @@ xslt_yelp_document (xsltTransformContext xsltFreeStylesheet (style); } +#ifdef ENABLE_SCROLLKEEPER static void xml_trim_titles (xmlNodePtr node) { @@ -1171,3 +1390,4 @@ xml_trim_titles (xmlNodePtr node) } xmlFree (keep_lang); } +#endif --=-9ORf8ZtCi7oCmctsklwp Content-Disposition: attachment; filename=yelp-printing.patch Content-Type: text/x-patch; name=yelp-printing.patch; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit ? document.ps ? page.ps Index: data/ui/yelp-ui.xml =================================================================== RCS file: /cvs/gnome/yelp/data/ui/yelp-ui.xml,v retrieving revision 1.11 diff -u -p -r1.11 yelp-ui.xml --- data/ui/yelp-ui.xml 28 Oct 2005 20:37:37 -0000 1.11 +++ data/ui/yelp-ui.xml 31 Oct 2005 18:33:36 -0000 @@ -6,6 +6,9 @@ + + + Index: data/ui/yelp.glade =================================================================== RCS file: /cvs/gnome/yelp/data/ui/yelp.glade,v retrieving revision 1.11 diff -u -p -r1.11 yelp.glade --- data/ui/yelp.glade 15 Oct 2005 16:34:55 -0000 1.11 +++ data/ui/yelp.glade 31 Oct 2005 18:33:36 -0000 @@ -19,6 +19,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True False @@ -102,6 +103,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -173,6 +178,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -200,7 +209,7 @@ True 0.5 1 - 0.9 + 0.899999976158 0.5 0 0 @@ -233,6 +242,10 @@ 0 0 find_entry + PANGO_ELLIPSIZE_NONE + -1 + False + 0 3 @@ -340,6 +353,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True False @@ -409,6 +423,10 @@ 0 0 location_entry + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -461,6 +479,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True False @@ -521,6 +540,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -597,6 +620,10 @@ 0 0 variable_font + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -622,6 +649,10 @@ 0 0 fixed_font + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -706,6 +737,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -779,6 +814,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True False @@ -837,6 +873,10 @@ 0 0 bookmarks_view + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -920,6 +960,9 @@ False False True + False + False + False @@ -955,6 +998,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True False @@ -1036,6 +1080,10 @@ 0 0 bookmark_title_entry + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1064,6 +1112,249 @@ + + + + 0 + True + True + + + + + + + + True + Print + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + True + True + True + True + True + gtk-print + True + GTK_RELIEF_NORMAL + True + 0 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 6 + True + False + 6 + + + + True + True + GTK_RELIEF_NORMAL + True + True + False + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-file + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Print current pa_ge + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + True + False + False + True + radiobutton_page + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gnome-stock-book-blue + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Print entire _document + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + Index: src/Makefile.am =================================================================== RCS file: /cvs/gnome/yelp/src/Makefile.am,v retrieving revision 1.85 diff -u -p -r1.85 Makefile.am --- src/Makefile.am 28 Oct 2005 20:37:37 -0000 1.85 +++ src/Makefile.am 31 Oct 2005 18:33:36 -0000 @@ -9,6 +9,7 @@ yelp_SOURCES = \ yelp-bookmarks.c yelp-bookmarks.h \ yelp-cache.c yelp-cache.h \ yelp-db-pager.c yelp-db-pager.h \ + yelp-db-print-pager.c yelp-db-print-pager.h \ yelp-error.c yelp-error.h \ yelp-gecko-utils.cpp yelp-gecko-utils.h \ yelp-html.cpp yelp-html.h \ @@ -112,6 +113,7 @@ test_man_parser_LDADD = $(YELP_LIBS) $(Z test_pager_SOURCES = \ yelp-db-pager.c yelp-db-pager.h \ + yelp-db-print-pager.c yelp-db-print-pager.h \ yelp-error.c yelp-error.h \ yelp-io-channel.c yelp-io-channel.h \ yelp-man-pager.c yelp-man-pager.h \ Index: src/yelp-db-print-pager.c =================================================================== RCS file: src/yelp-db-print-pager.c diff -N src/yelp-db-print-pager.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/yelp-db-print-pager.c 31 Oct 2005 18:33:36 -0000 @@ -0,0 +1,295 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2003 Shaun McCance + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Shaun McCance + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "yelp-error.h" +#include "yelp-db-print-pager.h" +#include "yelp-toc-pager.h" +#include "yelp-settings.h" + +#ifdef YELP_DEBUG +#define d(x) x +#else +#define d(x) +#endif + +#define STYLESHEET_PATH DATADIR"/yelp/xslt/" +#define DB_STYLESHEET STYLESHEET_PATH"db2html.xsl" +#define DB_TITLE STYLESHEET_PATH"db-title.xsl" + +#define BOOK_CHUNK_DEPTH 2 +#define ARTICLE_CHUNK_DEPTH 1 + +#define EVENTS_PENDING while (yelp_pager_get_state (pager) <= YELP_PAGER_STATE_RUNNING && gtk_events_pending ()) gtk_main_iteration (); +#define CANCEL_CHECK if (!main_running || yelp_pager_get_state (pager) >= YELP_PAGER_STATE_ERROR) goto done; + +extern gboolean main_running; + +#define YELP_DB_PRINT_PAGER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), YELP_TYPE_DB_PRINT_PAGER, YelpDBPrintPagerPriv)) + +struct _YelpDBPrintPagerPriv { + gchar *root_id; +}; + +static void db_print_pager_class_init (YelpDBPrintPagerClass *klass); +static void db_print_pager_init (YelpDBPrintPager *pager); +static void db_print_pager_dispose (GObject *gobject); + +static void db_print_pager_cancel (YelpPager *pager); +static xmlDocPtr db_print_pager_parse (YelpPager *pager); +static gchar ** db_print_pager_params (YelpPager *pager); + +static const gchar * db_print_pager_resolve_frag (YelpPager *pager, + const gchar *frag_id); +static GtkTreeModel * db_print_pager_get_sections (YelpPager *pager); + +static YelpPagerClass *parent_class; + +GType +yelp_db_print_pager_get_type (void) +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo info = { + sizeof (YelpDBPrintPagerClass), + NULL, + NULL, + (GClassInitFunc) db_print_pager_class_init, + NULL, + NULL, + sizeof (YelpDBPrintPager), + 0, + (GInstanceInitFunc) db_print_pager_init, + }; + type = g_type_register_static (YELP_TYPE_XSLT_PAGER, + "YelpDBPrintPager", + &info, 0); + } + return type; +} + +static void +db_print_pager_class_init (YelpDBPrintPagerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + YelpPagerClass *pager_class = YELP_PAGER_CLASS (klass); + YelpXsltPagerClass *xslt_class = YELP_XSLT_PAGER_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + object_class->dispose = db_print_pager_dispose; + + pager_class->cancel = db_print_pager_cancel; + + pager_class->resolve_frag = db_print_pager_resolve_frag; + + xslt_class->parse = db_print_pager_parse; + xslt_class->params = db_print_pager_params; + + xslt_class->stylesheet = DB_STYLESHEET; + + g_type_class_add_private (klass, sizeof (YelpDBPrintPagerPriv)); +} + +static void +db_print_pager_init (YelpDBPrintPager *pager) +{ + YelpDBPrintPagerPriv *priv; + + pager->priv = priv = YELP_DB_PRINT_PAGER_GET_PRIVATE (pager); + + pager->priv->root_id = NULL; +} + +static void +db_print_pager_dispose (GObject *object) +{ + YelpDBPrintPager *pager = YELP_DB_PRINT_PAGER (object); + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +/******************************************************************************/ + +YelpPager * +yelp_db_print_pager_new (YelpDocInfo *doc_info) +{ + YelpDBPrintPager *pager; + + g_return_val_if_fail (doc_info != NULL, NULL); + + pager = (YelpDBPrintPager *) g_object_new (YELP_TYPE_DB_PRINT_PAGER, + "document-info", doc_info, + NULL); + + return (YelpPager *) pager; +} + +static xmlDocPtr +db_print_pager_parse (YelpPager *pager) +{ + YelpDBPrintPagerPriv *priv; + YelpDocInfo *doc_info; + gchar *filename = NULL; + + xmlParserCtxtPtr parserCtxt = NULL; + xmlDocPtr doc = NULL; + + xmlChar *id; + GError *error = NULL; + + d (g_print ("db_print_pager_parse\n")); + + doc_info = yelp_pager_get_doc_info (pager); + + g_return_val_if_fail (pager != NULL, NULL); + g_return_val_if_fail (YELP_IS_DB_PRINT_PAGER (pager), NULL); + priv = YELP_DB_PRINT_PAGER (pager)->priv; + + g_object_ref (pager); + + if (yelp_pager_get_state (pager) >= YELP_PAGER_STATE_ERROR) + goto done; + + filename = yelp_doc_info_get_filename (doc_info); + + parserCtxt = xmlNewParserCtxt (); + doc = xmlCtxtReadFile (parserCtxt, + (const char *) filename, NULL, + XML_PARSE_DTDLOAD | XML_PARSE_NOCDATA | + XML_PARSE_NOENT | XML_PARSE_NONET ); + if (doc == NULL) { + g_set_error (&error, YELP_ERROR, YELP_ERROR_NO_DOC, + _("The file ā€˜%s’ could not be parsed. Either the file " + "does not exist, or it is not well-formed XML."), + filename); + yelp_pager_error (pager, error); + goto done; + } + + xmlXIncludeProcessFlags (doc, + XML_PARSE_DTDLOAD | XML_PARSE_NOCDATA | + XML_PARSE_NOENT | XML_PARSE_NONET ); + + + priv->root_id = g_strdup ("index"); + + EVENTS_PENDING; + CANCEL_CHECK; + + done: + g_free (filename); + + if (parserCtxt) + xmlFreeParserCtxt (parserCtxt); + + g_object_unref (pager); + + return doc; +} + +static gchar ** +db_print_pager_params (YelpPager *pager) +{ + YelpDBPrintPagerPriv *priv; + YelpDocInfo *doc_info; + gchar **params; + gint params_i = 0; + gint params_max = 20; + + d (g_print ("db_print_pager_process\n")); + + doc_info = yelp_pager_get_doc_info (pager); + + g_return_val_if_fail (pager != NULL, FALSE); + g_return_val_if_fail (YELP_IS_DB_PRINT_PAGER (pager), FALSE); + priv = YELP_DB_PRINT_PAGER (pager)->priv; + + if (yelp_pager_get_state (pager) >= YELP_PAGER_STATE_ERROR) + return NULL; + + params = g_new0 (gchar *, params_max); + + yelp_settings_params (¶ms, ¶ms_i, ¶ms_max); + + if ((params_i + 10) >= params_max - 1) { + params_max += 20; + params = g_renew (gchar *, params, params_max); + } + params[params_i++] = "db.chunk.extension"; + params[params_i++] = g_strdup ("\"\""); + params[params_i++] = "db.chunk.info_basename"; + params[params_i++] = g_strdup ("\"index\""); + params[params_i++] = "db.chunk.max_depth"; + params[params_i++] = g_strdup_printf ("0"); + params[params_i++] = "yelp.javascript"; + params[params_i++] = g_strdup_printf ("\"%s\"", DATADIR "/yelp/yelp.js"); + + params[params_i] = NULL; + + return params; +} + +static void +db_print_pager_cancel (YelpPager *pager) +{ + YelpDBPrintPagerPriv *priv = YELP_DB_PRINT_PAGER (pager)->priv; + + d (g_print ("db_print_pager_cancel\n")); + + yelp_pager_set_state (pager, YELP_PAGER_STATE_INVALID); + + g_free (priv->root_id); + priv->root_id = NULL; + + YELP_PAGER_CLASS (parent_class)->cancel (pager); +} + +static const gchar * +db_print_pager_resolve_frag (YelpPager *pager, const gchar *frag_id) +{ + YelpDBPrintPager *db_print_pager; + + g_return_val_if_fail (pager != NULL, NULL); + g_return_val_if_fail (YELP_IS_DB_PRINT_PAGER (pager), NULL); + + db_print_pager = YELP_DB_PRINT_PAGER (pager); + + return frag_id; +} + Index: src/yelp-db-print-pager.h =================================================================== RCS file: src/yelp-db-print-pager.h diff -N src/yelp-db-print-pager.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/yelp-db-print-pager.h 31 Oct 2005 18:33:36 -0000 @@ -0,0 +1,55 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2003 Shaun McCance + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Shaun McCance + */ + +#ifndef __YELP_DB_PRINT_PAGER_H__ +#define __YELP_DB_PRINT_PAGER_H__ + +#include + +#include "yelp-pager.h" +#include "yelp-xslt-pager.h" + +#define YELP_TYPE_DB_PRINT_PAGER (yelp_db_print_pager_get_type ()) +#define YELP_DB_PRINT_PAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), YELP_TYPE_DB_PRINT_PAGER, YelpDBPrintPager)) +#define YELP_DB_PRINT_PAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), YELP_TYPE_DB_PRINT_PAGER, YelpDBPrintPagerClass)) +#define YELP_IS_DB_PRINT_PAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), YELP_TYPE_DB_PRINT_PAGER)) +#define YELP_IS_DB_PRINT_PAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), YELP_TYPE_DB_PRINT_PAGER)) +#define YELP_DB_PRINT_PAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), YELP_TYPE_DB_PRINT_PAGER, YelpDBPrintPagerClass)) + +typedef struct _YelpDBPrintPager YelpDBPrintPager; +typedef struct _YelpDBPrintPagerClass YelpDBPrintPagerClass; +typedef struct _YelpDBPrintPagerPriv YelpDBPrintPagerPriv; + +struct _YelpDBPrintPager { + YelpXsltPager parent; + + YelpDBPrintPagerPriv *priv; +}; + +struct _YelpDBPrintPagerClass { + YelpXsltPagerClass parent_class; +}; + +GType yelp_db_print_pager_get_type (void); +YelpPager * yelp_db_print_pager_new (YelpDocInfo *doc_info); + +#endif /* __YELP_DB_PRINT_PAGER_H__ */ Index: src/yelp-html.cpp =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-html.cpp,v retrieving revision 1.1 diff -u -p -r1.1 yelp-html.cpp --- src/yelp-html.cpp 16 May 2005 21:02:33 -0000 1.1 +++ src/yelp-html.cpp 31 Oct 2005 18:33:36 -0000 @@ -34,6 +34,12 @@ #include "Yelper.h" +#include "gtkmozembed_internal.h" +#include "nsIWebBrowserPrint.h" +#include "nsIInterfaceRequestorUtils.h" + +#include + #ifdef GNOME_ENABLE_DEBUG #define d(x) x #else @@ -42,6 +48,9 @@ #define YELP_HTML_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), YELP_TYPE_HTML, YelpHtmlPriv)) +#define MOZILLA_PROFILE_DIR "/mozilla" +#define MOZILLA_PROFILE_NAME "yelp" + struct _YelpHtmlPriv { Yelper *yelper; gchar *base_uri; @@ -51,6 +60,7 @@ struct _YelpHtmlPriv { static void html_set_fonts (void); static void html_set_colors (void); static void html_set_a11y (void); +static void open_new_window (GtkMozEmbed **newEmbed, guint chrome_mask); enum { URI_SELECTED, @@ -120,6 +130,14 @@ html_realize (GtkWidget *widget) } static void +html_new_window (GtkMozEmbed *embed, + GtkMozEmbed **newEmbed, + guint chrome_mask) +{ + open_new_window (newEmbed, chrome_mask); +} + +static void html_init (YelpHtml *html) { YelpHtmlPriv *priv; @@ -197,6 +215,7 @@ html_class_init (YelpHtmlClass *klass) moz_embed_class->title = html_title; moz_embed_class->dom_mouse_down = html_dom_mouse_down; moz_embed_class->open_uri = html_open_uri; + moz_embed_class->new_window = html_new_window; klass->font_handler = 0; @@ -385,6 +404,24 @@ yelp_html_select_all (YelpHtml *html) html->priv->yelper->DoCommand ("cmd_selectAll"); } +void +yelp_html_print (YelpHtml *html) +{ + nsCOMPtr webBrowser; + + gtk_moz_embed_get_nsIWebBrowser (GTK_MOZ_EMBED (html), getter_AddRefs(webBrowser)); + + if (webBrowser) { + + nsCOMPtr print(do_GetInterface(webBrowser)); + + if (print) { + /* FIXME: Deal with retval. */ + print->Print (nsnull, nsnull); + } + } +} + static void html_set_fonts (void) { @@ -421,4 +458,123 @@ html_set_a11y (void) caret = yelp_settings_get_caret (); yelp_gecko_set_caret (caret); +} + +static void +new_window_orphan_cb (GtkMozEmbedSingle *moz_single, + GtkMozEmbed **newEmbed, + guint chrome_mask, + gpointer user_data) +{ + open_new_window (newEmbed, chrome_mask); +} + +void +yelp_html_initialize (void) +{ + static gboolean initialized = FALSE; + GtkMozEmbedSingle *single; + char *profile_path; + + if (initialized) + return; + initialized = TRUE; + + /* get single */ + single = gtk_moz_embed_single_get (); + if (single == NULL) { + g_warning ("Failed to get singleton embed object!\n"); + } + + /* allow creation of orphan windows */ + g_signal_connect (G_OBJECT (single), "new_window_orphan", + G_CALLBACK (new_window_orphan_cb), + NULL); + + profile_path = g_build_filename (g_get_home_dir (), + GNOME_DOT_GNOME, + "yelp.d", + MOZILLA_PROFILE_DIR, + NULL); + gtk_moz_embed_set_profile_path (profile_path, MOZILLA_PROFILE_NAME); + g_free (profile_path); +} + +static GtkMozEmbed *new_xul_dialog (void); + +static void +xul_visibility_cb (GtkWidget *embed, gboolean visibility, GtkWidget *window) +{ + if (visibility) { + gtk_widget_show (window); + } else { + gtk_widget_hide (window); + } +} + +static void +xul_size_to_cb (GtkWidget *embed, gint width, gint height, gpointer dummy) +{ + gtk_widget_set_size_request (embed, width, height); +} + +static void +xul_new_window_cb (GtkMozEmbed *embed, + GtkMozEmbed **retval, + guint chrome_mask, + gpointer dummy) +{ + g_assert (chrome_mask & GTK_MOZ_EMBED_FLAG_OPENASCHROME); + + *retval = new_xul_dialog (); +} + +static void +xul_title_cb (GtkMozEmbed *embed, + GtkWindow *window) +{ + char *title; + + title = gtk_moz_embed_get_title (embed); + gtk_window_set_title (window, title); + g_free (title); +} + +static GtkMozEmbed * +new_xul_dialog (void) +{ + GtkWidget *window, *embed; + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + embed = gtk_moz_embed_new (); + gtk_widget_show (embed); + gtk_container_add (GTK_CONTAINER (window), embed); + + g_signal_connect_object (embed, "destroy_browser", + G_CALLBACK (gtk_widget_destroy), + window, G_CONNECT_SWAPPED); + g_signal_connect_object (embed, "visibility", + G_CALLBACK (xul_visibility_cb), + window, (GConnectFlags) 0); + g_signal_connect_object (embed, "size_to", + G_CALLBACK (xul_size_to_cb), + NULL, (GConnectFlags) 0); + g_signal_connect_object (embed, "new_window", + G_CALLBACK (xul_new_window_cb), + NULL, (GConnectFlags) 0); + g_signal_connect_object (embed, "title", + G_CALLBACK (xul_title_cb), + window, (GConnectFlags) 0); + + return GTK_MOZ_EMBED (embed); +} + +static void +open_new_window (GtkMozEmbed **newEmbed, + guint chrome_mask) +{ + if (chrome_mask & GTK_MOZ_EMBED_FLAG_OPENASCHROME) { + *newEmbed = new_xul_dialog (); + return; + } } Index: src/yelp-html.h =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-html.h,v retrieving revision 1.30 diff -u -p -r1.30 yelp-html.h --- src/yelp-html.h 16 May 2005 21:02:33 -0000 1.30 +++ src/yelp-html.h 31 Oct 2005 18:33:36 -0000 @@ -98,6 +98,10 @@ void yelp_html_copy_selection void yelp_html_select_all (YelpHtml *html); +void yelp_html_print (YelpHtml *html); + +void yelp_html_initialize (void); + G_END_DECLS #endif /* __YELP_HTML_H__ */ Index: src/yelp-main.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-main.c,v retrieving revision 1.38 diff -u -p -r1.38 yelp-main.c --- src/yelp-main.c 6 Mar 2005 20:07:11 -0000 1.38 +++ src/yelp-main.c 31 Oct 2005 18:33:36 -0000 @@ -42,6 +42,7 @@ #include "GNOME_Yelp.h" #include "yelp-window.h" #include "yelp-base.h" +#include "yelp-html.h" #define YELP_FACTORY_OAFIID "OAFIID:GNOME_Yelp_Factory" @@ -365,6 +366,8 @@ main (int argc, char **argv) if (!factory) { /* Not started, start now */ BonoboGenericFactory *factory; char *registration_id; + + yelp_html_initialize (); registration_id = bonobo_activation_make_registration_id ( YELP_FACTORY_OAFIID, Index: src/yelp-window.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-window.c,v retrieving revision 1.178 diff -u -p -r1.178 yelp-window.c --- src/yelp-window.c 28 Oct 2005 20:37:37 -0000 1.178 +++ src/yelp-window.c 31 Oct 2005 18:33:37 -0000 @@ -42,6 +42,7 @@ #include "yelp-bookmarks.h" #include "yelp-db-pager.h" +#include "yelp-db-print-pager.h" #include "yelp-error.h" #include "yelp-html.h" #include "yelp-pager.h" @@ -160,6 +161,8 @@ static void window_add_widget GtkWidget *vbox); static void window_new_window_cb (GtkAction *action, YelpWindow *window); static void window_about_document_cb (GtkAction *action, YelpWindow *window); +static void window_print_document_cb (GtkAction *action, YelpWindow *window); +static void window_print_page_cb (GtkAction *action, YelpWindow *window); static void window_open_location_cb (GtkAction *action, YelpWindow *window); static void window_close_window_cb (GtkAction *action, YelpWindow *window); static void window_copy_cb (GtkAction *action, YelpWindow *window); @@ -308,6 +311,16 @@ static const GtkActionEntry entries[] = "N", NULL, G_CALLBACK (window_new_window_cb) }, + { "PrintDocument", NULL, + N_("Print This Document"), + NULL, + NULL, + G_CALLBACK (window_print_document_cb) }, + { "PrintPage", NULL, + N_("Print This Page"), + NULL, + NULL, + G_CALLBACK (window_print_page_cb) }, { "AboutDocument", NULL, N_("About This Document"), NULL, @@ -1925,6 +1938,181 @@ window_new_window_cb (GtkAction *action, g_return_if_fail (YELP_IS_WINDOW (window)); g_signal_emit (window, signals[NEW_WINDOW_REQUESTED], 0, NULL); +} + +typedef struct { + gulong page_handler; + gulong error_handler; + gulong cancel_handler; + gulong finish_handler; + YelpPager *pager; +} PrintStruct; + +static void +print_disconnect (PrintStruct *data) +{ + d(g_print ("print disconnect\n")); + if (data->page_handler) { + g_signal_handler_disconnect (data->pager, + data->page_handler); + data->page_handler = 0; + } + if (data->error_handler) { + g_signal_handler_disconnect (data->pager, + data->error_handler); + data->error_handler = 0; + } + if (data->cancel_handler) { + g_signal_handler_disconnect (data->pager, + data->cancel_handler); + data->cancel_handler = 0; + } + if (data->finish_handler) { + g_signal_handler_disconnect (data->pager, + data->finish_handler); + data->finish_handler = 0; + } +#if 0 + if (data) { + if (data->pager) + g_object_unref (data->pager); + } +#endif + g_free (data); +} + +static void +print_pager_page_cb (YelpPager *pager, + gchar *page_id, + gpointer user_data) +{ + PrintStruct *data = user_data; + YelpPage *page; + + d (g_print ("print_pager_page_cb\n")); + d (g_print (" page_id=\"%s\"\n", page_id)); + + page = (YelpPage *) yelp_pager_get_page (pager, page_id); + + if (page) { + YelpHtml *html; + GtkWidget *gtk_window; + int length, offset; + char *uri; + + d(g_print (page->contents)); + + gtk_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + html = yelp_html_new (); + gtk_container_add (GTK_CONTAINER (gtk_window), GTK_WIDGET (html)); + gtk_widget_realize (gtk_window); + gtk_widget_realize (GTK_WIDGET (html)); + + + uri = yelp_doc_info_get_uri (yelp_pager_get_doc_info (pager), + page_id, + YELP_URI_TYPE_FILE); + + d (g_print (" uri = %s\n", uri)); + + yelp_html_set_base_uri (html, uri); + g_free (uri); + + yelp_html_open_stream (html, "application/xhtml+xml"); + for (length = strlen (page->contents), offset = 0; length > 0; length -= BUFFER_SIZE, offset += BUFFER_SIZE) { + d(g_print ("data: %.*s\n", MIN (length, BUFFER_SIZE), page->contents + offset)); + yelp_html_write (html, page->contents + offset, MIN (length, BUFFER_SIZE)); + } + yelp_html_close (html); + + yelp_html_print (html); + + print_disconnect (data); + + /* This needs to be done at some point, but we need to wait until printing is done. */ + /* gtk_widget_destroy (gtk_window); */ + } +} + +static void +print_pager_error_cb (YelpPager *pager, + gpointer user_data) +{ + PrintStruct *data = user_data; + /* GError *error = yelp_pager_get_error (pager);*/ + + d (g_print ("print_pager_error_cb\n")); + + print_disconnect (data); +} + +static void +print_pager_cancel_cb (YelpPager *pager, + gpointer user_data) +{ + PrintStruct *data = user_data; + d (g_print ("print_pager_cancel_cb\n")); + + print_disconnect (data); +} + +static void +print_pager_finish_cb (YelpPager *pager, + gpointer user_data) +{ + PrintStruct *data = user_data; + + d (g_print ("print_pager_finish_cb\n")); + + print_disconnect (data); +} + +static void +window_print_document_cb (GtkAction *action, YelpWindow *window) +{ + PrintStruct *data; + YelpPager *pager; + + if (!window->priv->current_doc) + return; + + pager = yelp_db_print_pager_new (window->priv->current_doc); + + if (!pager) { + return; + } + + data = g_new0 (PrintStruct, 1); + data->pager = pager; + + data->page_handler = + g_signal_connect (data->pager, + "page", + G_CALLBACK (print_pager_page_cb), + data); + data->error_handler = + g_signal_connect (data->pager, + "error", + G_CALLBACK (print_pager_error_cb), + data); + data->cancel_handler = + g_signal_connect (data->pager, + "error", + G_CALLBACK (print_pager_cancel_cb), + data); + data->finish_handler = + g_signal_connect (data->pager, + "finish", + G_CALLBACK (print_pager_finish_cb), + data); + + /* handled = */ yelp_pager_start (data->pager); +} + +static void +window_print_page_cb (GtkAction *action, YelpWindow *window) +{ + yelp_html_print (window->priv->html_view); } static void --=-9ORf8ZtCi7oCmctsklwp Content-Disposition: attachment; filename=yelp-toctree.patch Content-Type: text/x-patch; name=yelp-toctree.patch; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 7bit Index: data/yelp.js =================================================================== RCS file: /cvs/gnome/yelp/data/yelp.js,v retrieving revision 1.3 diff -u -p -r1.3 yelp.js --- data/yelp.js 28 Oct 2005 20:37:36 -0000 1.3 +++ data/yelp.js 31 Oct 2005 19:05:14 -0000 @@ -87,6 +87,50 @@ window.addEventListener("load",slt.init, window.addEventListener("DOMContentLoaded",slt.init,false); window.addEventListener("resize",slt.init,false); +function createCookie(name,value,days) +{ + if (days) + { + var date = new Date(); + date.setTime(date.getTime()+(days*24*60*60*1000)); + var expires = "; expires="+date.toGMTString(); + } + else var expires = ""; + document.cookie = name+"="+value+expires+"; path=/"; +} + +function load_hidden () +{ + var ca = document.cookie.split(';'); + for (var i=0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf('display:') == 0) { + var colon = c.indexOf(':'); + var equal = c.indexOf('='); + + var id = c.substring (colon + 1, equal); + var value = c.substring (equal + 1); + + document.getElementById (id).style.display = value; + } + } +} + +function show_hide (id) +{ + var element = document.getElementById (id + '-children'); + if (element.style.display == "none") { + element.style.display = "block"; + createCookie ('display:' + id + '-children', "block", 1000); + } else { + element.style.display = "none"; + createCookie ('display:' + id + '-children', "none", 1000); + } +} + +window.addEventListener("DOMContentLoaded",load_hidden,false); + function submit_search () { window.location = "x-yelp-search:" + document.getElementById ('search-entry').value; Index: src/yelp-toc-pager.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-toc-pager.c,v retrieving revision 1.51 diff -u -p -r1.51 yelp-toc-pager.c --- src/yelp-toc-pager.c 21 Oct 2005 01:47:56 -0000 1.51 +++ src/yelp-toc-pager.c 31 Oct 2005 19:05:15 -0000 @@ -873,7 +873,7 @@ process_xslt (YelpTocPager *pager) YelpTocPagerPriv *priv = pager->priv; gchar **params = NULL; gint params_i = 0; - gint params_max = 10; + gint params_max = 14; GtkIconInfo *info; GtkIconTheme *theme = (GtkIconTheme *) yelp_settings_get_icon_theme (); @@ -899,8 +899,8 @@ process_xslt (YelpTocPager *pager) params = g_new0 (gchar *, params_max); yelp_settings_params (¶ms, ¶ms_i, ¶ms_max); - if ((params_i + 10) >= params_max - 1) { - params_max += 10; + if ((params_i + 14) >= params_max - 1) { + params_max += 14; params = g_renew (gchar *, params, params_max); } @@ -914,6 +914,11 @@ process_xslt (YelpTocPager *pager) gtk_icon_info_get_base_size (info)); gtk_icon_info_free (info); } + + params[params_i++] = "yelp.javascript"; + params[params_i++] = g_strdup_printf ("\"%s\"", DATADIR "/yelp/yelp.js"); + params[params_i++] = "yelp.topimage"; + params[params_i++] = g_strdup_printf ("\"%s\"", DATADIR "/yelp/icons/help-title.png"); params[params_i++] = NULL; Index: stylesheets/toc2html.xsl =================================================================== RCS file: /cvs/gnome/yelp/stylesheets/toc2html.xsl,v retrieving revision 1.11 diff -u -p -r1.11 toc2html.xsl --- stylesheets/toc2html.xsl 11 May 2005 18:19:20 -0000 1.11 +++ stylesheets/toc2html.xsl 31 Oct 2005 19:05:15 -0000 @@ -5,9 +5,13 @@ extension-element-prefixes="yelp" version="1.0"> + + + + @@ -35,133 +39,181 @@ <xsl:value-of select="title[1]"/> - + - + + + + + +

+ + + + +

+
+ + + +
+ + + + + + +
+
    + + +
  • + +
  • +
    +
+
+
+ +
+
+ + +
+ + + + + + + + +
+
+ +
+
+
+
+
+
-
-

- - - - -

-
-
+
+ + + +
- -
- -
-
- -
-
- - -
- - - - - - - - -
-
- -
-
-
-
-
+ + +
+ + + + + + + + + --=-9ORf8ZtCi7oCmctsklwp-- From dmalcolm@redhat.com Thu Oct 13 02:01:11 2005 Return-Path: X-Original-To: gnome-doc-devel-list@gnome.org Delivered-To: gnome-doc-devel-list@gnome.org Received: from localhost (unknown [127.0.0.1]) by menubar.gnome.org (Postfix) with ESMTP id 56E423B0B00; Thu, 13 Oct 2005 02:01:11 -0400 (EDT) Received: from menubar.gnome.org ([127.0.0.1]) by localhost (menubar.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 16458-05; Thu, 13 Oct 2005 02:01:09 -0400 (EDT) Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31]) by menubar.gnome.org (Postfix) with ESMTP id DAF5B3B0AAA; Thu, 13 Oct 2005 02:01:08 -0400 (EDT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j9D618OG002300; Thu, 13 Oct 2005 02:01:08 -0400 Received: from mail.boston.redhat.com (mail.boston.redhat.com [172.16.76.12]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j9D618V26677; Thu, 13 Oct 2005 02:01:08 -0400 Received: from vpn83-129.boston.redhat.com (vpn83-129.boston.redhat.com [172.16.83.129]) by mail.boston.redhat.com (8.12.8/8.12.8) with ESMTP id j9D617fb012113; Thu, 13 Oct 2005 02:01:07 -0400 From: Dave Malcolm To: gnome-doc-devel-list@gnome.org Content-Type: multipart/mixed; boundary="=-CUDRMlybahnrJETYCNyI" Date: Thu, 13 Oct 2005 02:05:26 -0400 Message-Id: <1129183526.6821.14.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.4 (2.0.4-6) X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Status: No, score=-1.9 tagged_above=-999 required=2 tests=[BAYES_00, HTML_MESSAGE] X-Spam-Score: -1.9 X-Spam-Level: Cc: dogtail-devel-list@gnome.org Subject: Script for generating parodies of bad documentation X-BeenThere: gnome-doc-devel-list@gnome.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about development of yelp, gnome-doc-utils, and other documentation-related utilities" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2005 06:01:11 -0000 --=-CUDRMlybahnrJETYCNyI Content-Type: text/plain Content-Transfer-Encoding: 7bit I've been a bad, bad, person and written this dogtail [1] script: http://cvs.gnome.org/viewcvs/dogtail/examples/no-help-at-all.py?view=markup You pass it the accessible name of a running application, and it scours that application's GUI, reading it back to you in DocBook form. The idea is (i) to parody some of the unhelpful user documentation I've seen over the years - please don't write documentation that looks like this! This was inspired in part by reading Shaun McCance's Project Mallard notes here: http://www.gnome.org/~shaunm/quack/mallard.xml (ii) to provide a source of test data for help viewers, such as Yelp, and for stylesheet authors Attached is an example of the output when I pointed the script at gedit. My apologies... [1] http://people.redhat.com/zcerza/dogtail/index.html --=-CUDRMlybahnrJETYCNyI Content-Disposition: attachment; filename=not-the-gedit-manual.xml Content-Type: text/xml; name=not-the-gedit-manual.xml; charset=UTF-8 Content-Transfer-Encoding: 7bit
The Totally Definitive No-Nonsense Unhelpful Complete Guide to <application>gedit</application> for Mannequins in 40 Days - Unleashed! Introduction Do not take these instructions seriously. They are a parody of unhelpful help files found on many computer systems, and were autogenerated by no-help-at-all You can start gedit by opening a terminal and typing the gedit command. The <guimenu>File</guimenu> menu Use the File menu to work with files Newing a file To new a file, choose File > New Open...ing a file To open... a file, choose File > Open... Open Location...ing a file To open location... a file, choose File > Open Location... Saveing a file To save a file, choose File > Save Save As...ing a file To save as... a file, choose File > Save As... Reverting a file To revert a file, choose File > Revert Page Setuping a file To page setup a file, choose File > Page Setup Print Preview...ing a file To print preview... a file, choose File > Print Preview... Print...ing a file To print... a file, choose File > Print... 1. No-Help-At-All.Pying a file To 1. no-help-at-all.py a file, choose File > 1. no-help-at-all.py 2. Tmp.Xmling a file To 2. tmp.xml a file, choose File > 2. tmp.xml 3. Tree.Pying a file To 3. tree.py a file, choose File > 3. tree.py 4. Test-Docbook.Xmling a file To 4. test-docbook.xml a file, choose File > 4. test-docbook.xml 5. Abiword-Test.Pying a file To 5. abiword-test.py a file, choose File > 5. abiword-test.py Closeing a file To close a file, choose File > Close Quiting a file To quit a file, choose File > Quit The <guimenu>Edit</guimenu> menu Use the Edit menu to work with edits Undoing a edit To undo a edit, choose Edit > Undo Redoing a edit To redo a edit, choose Edit > Redo Cuting a edit To cut a edit, choose Edit > Cut Copying a edit To copy a edit, choose Edit > Copy Pasteing a edit To paste a edit, choose Edit > Paste Deleteing a edit To delete a edit, choose Edit > Delete Select Alling a edit To select all a edit, choose Edit > Select All Preferencesing a edit To preferences a edit, choose Edit > Preferences The <guimenu>View</guimenu> menu Use the View menu to work with views The <guimenu>Customise Toolbar</guimenu> menu Use the Customise Toolbar menu to work with customise toolbars The <guimenu>Highlight Mode</guimenu> menu Use the Highlight Mode menu to work with highlight modes The <guimenu>Sources</guimenu> menu Use the Sources menu to work with sourcess The <guimenu>Scripts</guimenu> menu Use the Scripts menu to work with scriptss The <guimenu>Markup</guimenu> menu Use the Markup menu to work with markups The <guimenu>Others</guimenu> menu Use the Others menu to work with otherss The <guimenu>Search</guimenu> menu Use the Search menu to work with searchs Find...ing a search To find... a search, choose Search > Find... Find Nexting a search To find next a search, choose Search > Find Next Find Previousing a search To find previous a search, choose Search > Find Previous Replace...ing a search To replace... a search, choose Search > Replace... Go To Line...ing a search To go to line... a search, choose Search > Go to Line... The <guimenu>Tools</guimenu> menu Use the Tools menu to work with toolss Check Spellinging a tools To check spelling a tools, choose Tools > Check Spelling Set Languageing a tools To set language a tools, choose Tools > Set Language The <guimenu>Documents</guimenu> menu Use the Documents menu to work with documentss Save Alling a documents To save all a documents, choose Documents > Save All Close Alling a documents To close all a documents, choose Documents > Close All Move To New Windowing a documents To move to new window a documents, choose Documents > Move to New Window Gedit-Test-Results.Txting a documents To gedit-test-results.txt a documents, choose Documents > gedit-test-results.txt Test-Docbook.Xmling a documents To test-docbook.xml a documents, choose Documents > test-docbook.xml Tmp.Xmling a documents To tmp.xml a documents, choose Documents > tmp.xml Tree.Pying a documents To tree.py a documents, choose Documents > tree.py No-Help-At-All.Pying a documents To no-help-at-all.py a documents, choose Documents > no-help-at-all.py The <guimenu>Help</guimenu> menu Use the Help menu to work with helps Contentsing a help To contents a help, choose Help > Contents Abouting a help To about a help, choose Help > About
--=-CUDRMlybahnrJETYCNyI-- From zcerza@redhat.com Thu Oct 13 10:51:47 2005 Return-Path: X-Original-To: gnome-doc-devel-list@gnome.org Delivered-To: gnome-doc-devel-list@gnome.org Received: from localhost (unknown [127.0.0.1]) by menubar.gnome.org (Postfix) with ESMTP id 6EF7E3B0906; Thu, 13 Oct 2005 10:51:47 -0400 (EDT) Received: from menubar.gnome.org ([127.0.0.1]) by localhost (menubar.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 20683-08; Thu, 13 Oct 2005 10:51:45 -0400 (EDT) Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31]) by menubar.gnome.org (Postfix) with ESMTP id 320173B0697; Thu, 13 Oct 2005 10:51:45 -0400 (EDT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j9DEpihX003828; Thu, 13 Oct 2005 10:51:44 -0400 Received: from mail.boston.redhat.com (mail.boston.redhat.com [172.16.76.12]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j9DEpiV15189; Thu, 13 Oct 2005 10:51:44 -0400 Received: from [172.16.83.8] (dhcp83-8.boston.redhat.com [172.16.83.8]) by mail.boston.redhat.com (8.12.8/8.12.8) with ESMTP id j9DEphfb012648; Thu, 13 Oct 2005 10:51:43 -0400 Message-ID: <434E7489.9090503@redhat.com> Date: Thu, 13 Oct 2005 10:51:53 -0400 From: Zack Cerza User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051010) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dave Malcolm References: <1129183526.6821.14.camel@localhost.localdomain> In-Reply-To: <1129183526.6821.14.camel@localhost.localdomain> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Status: No, score=-4.9 tagged_above=-999 required=2 tests=[BAYES_00] X-Spam-Score: -4.9 X-Spam-Level: X-Mailman-Approved-At: Thu, 13 Oct 2005 10:53:13 -0400 Cc: dogtail-devel-list@gnome.org, gnome-doc-devel-list@gnome.org Subject: Re: dogtail-devel Script for generating parodies of bad documentation X-BeenThere: gnome-doc-devel-list@gnome.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about development of yelp, gnome-doc-utils, and other documentation-related utilities" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2005 14:51:47 -0000 Dave Malcolm wrote: > I've been a bad, bad, person and written this dogtail [1] script: > http://cvs.gnome.org/viewcvs/dogtail/examples/no-help-at-all.py?view=markup > > You pass it the accessible name of a running application, and it scours > that application's GUI, reading it back to you in DocBook form. > > The idea is (i) to parody some of the unhelpful user documentation I've > seen over the years - please don't write documentation that looks like > this! This was inspired in part by reading Shaun McCance's Project > Mallard notes here: http://www.gnome.org/~shaunm/quack/mallard.xml > (ii) to provide a source of test data for help viewers, such as Yelp, > and for stylesheet authors > > Attached is an example of the output when I pointed the script at gedit. > My apologies... > > [1] http://people.redhat.com/zcerza/dogtail/index.html Hah. That's awesome. You evil, evil man. Zack From ash@contact.bg Fri Oct 21 04:41:03 2005 Return-Path: X-Original-To: gnome-doc-devel-list@gnome.org Delivered-To: gnome-doc-devel-list@gnome.org Received: from localhost (unknown [127.0.0.1]) by menubar.gnome.org (Postfix) with ESMTP id 06F043B4F7B; Fri, 21 Oct 2005 04:41:03 -0400 (EDT) Received: from menubar.gnome.org ([127.0.0.1]) by localhost (menubar.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 20510-04; Fri, 21 Oct 2005 04:41:01 -0400 (EDT) Received: from mail.rightnet.net (palpatine.rightnet.net [62.204.159.2]) by menubar.gnome.org (Postfix) with ESMTP id C9AF53B4F79; Fri, 21 Oct 2005 04:41:00 -0400 (EDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.rightnet.net (Postfix) with ESMTP id 0F6B01802A3; Fri, 21 Oct 2005 11:39:59 +0300 (EEST) Received: from mail.rightnet.net ([127.0.0.1]) by localhost (palpatine [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 14225-09; Fri, 21 Oct 2005 11:39:56 +0300 (EEST) Received: from [172.29.69.70] (unknown [172.29.69.70]) by mail.rightnet.net (Postfix) with ESMTP id 31A5E180271; Fri, 21 Oct 2005 11:39:56 +0300 (EEST) From: Alexander Shopov To: gnome-doc-list@gnome.org Content-Type: text/plain Date: Fri, 21 Oct 2005 11:42:03 +0300 Message-Id: <1129884123.18684.10.camel@kochinka.spectrum.local> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at rightnet.net X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Status: No, score=-4.9 tagged_above=-999 required=2 tests=[BAYES_00] X-Spam-Score: -4.9 X-Spam-Level: Cc: gnome-doc-devel-list@gnome.org Subject: Introduction of Alexander Shopov X-BeenThere: gnome-doc-devel-list@gnome.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about development of yelp, gnome-doc-utils, and other documentation-related utilities" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Oct 2005 08:41:03 -0000 Hi everybody, My name is Alexander Shopov and I am the leader of the Bulgarian Gnome translation team. We have already finished the translation of the core interface and we are gradually starting to look at the documentation. In the following months I expect us to finish the tranlastion of the documentation of several modules and converting the ready translations to the Gnome docbook format. I have subscribed to gnome-doc-list to be in touch with the documentation changes and I have subscribed to gnome-doc-devel-list to look at the changes in the tools. I hope to be able to make some commits during next week but I cannot promise that. I have still not read everything on Gnome site about documentation translations and if there are resources I need to take in mind i'll be thankful if you lead me to them. Best regards: al_shopov From sri@aracnet.com Fri Oct 21 12:27:37 2005 Return-Path: X-Original-To: gnome-doc-devel-list@gnome.org Delivered-To: gnome-doc-devel-list@gnome.org Received: from localhost (unknown [127.0.0.1]) by menubar.gnome.org (Postfix) with ESMTP id 3B8AC3B0F74; Fri, 21 Oct 2005 12:27:36 -0400 (EDT) Received: from menubar.gnome.org ([127.0.0.1]) by localhost (menubar.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 23012-05; Fri, 21 Oct 2005 12:27:33 -0400 (EDT) Received: from onyx.spiritone.com (onyx.spiritone.com [216.99.193.114]) by menubar.gnome.org (Postfix) with ESMTP id D1AEA3B0F31; Fri, 21 Oct 2005 12:26:49 -0400 (EDT) Received: from onyx.spiritone.com (onyx.spiritone.com [127.0.0.1]) by onyx.spiritone.com (8.12.8/8.12.8) with ESMTP id j9LGQhBC018667; Fri, 21 Oct 2005 09:26:43 -0700 Received: (from sri@localhost) by onyx.spiritone.com (8.12.8/8.12.8/Submit) id j9LGQgxr018665; Fri, 21 Oct 2005 09:26:42 -0700 Date: Fri, 21 Oct 2005 09:26:42 -0700 From: Sriram Ramkrishna To: Alexander Shopov Message-ID: <20051021162642.GI30669@aracnet.com> References: <1129884123.18684.10.camel@kochinka.spectrum.local> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1129884123.18684.10.camel@kochinka.spectrum.local> User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Status: No, score=-4.9 tagged_above=-999 required=2 tests=[BAYES_00] X-Spam-Score: -4.9 X-Spam-Level: Cc: gnome-doc-devel-list@gnome.org, gnome-doc-list@gnome.org Subject: Re: Introduction of Alexander Shopov X-BeenThere: gnome-doc-devel-list@gnome.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about development of yelp, gnome-doc-utils, and other documentation-related utilities" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Oct 2005 16:27:37 -0000 Welcome, Al! :) sri On Fri, Oct 21, 2005 at 11:42:03AM +0300, Alexander Shopov wrote: > Hi everybody, > > My name is Alexander Shopov and I am the leader of the Bulgarian Gnome > translation team. We have already finished the translation of the core > interface and we are gradually starting to look at the documentation. > In the following months I expect us to finish the tranlastion of the > documentation of several modules and converting the ready translations > to the Gnome docbook format. > I have subscribed to gnome-doc-list to be in touch with the > documentation changes and I have subscribed to gnome-doc-devel-list to > look at the changes in the tools. > I hope to be able to make some commits during next week but I cannot > promise that. > I have still not read everything on Gnome site about documentation > translations and if there are resources I need to take in mind i'll be > thankful if you lead me to them. > > Best regards: > al_shopov > > _______________________________________________ > gnome-doc-list mailing list > gnome-doc-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gnome-doc-list -- From shaunm@gnome.org Sat Oct 22 15:00:44 2005 Return-Path: X-Original-To: gnome-doc-devel-list@gnome.org Delivered-To: gnome-doc-devel-list@gnome.org Received: from localhost (unknown [127.0.0.1]) by menubar.gnome.org (Postfix) with ESMTP id CFB8A3B314F; Sat, 22 Oct 2005 15:00:44 -0400 (EDT) Received: from menubar.gnome.org ([127.0.0.1]) by localhost (menubar.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 18056-01; Sat, 22 Oct 2005 15:00:43 -0400 (EDT) Received: from mx1.wolfram.com (relay.wolfram.com [140.177.205.5]) by menubar.gnome.org (Postfix) with ESMTP id B4FEF3B3148; Sat, 22 Oct 2005 15:00:42 -0400 (EDT) Received: from cornholio.housenet.network (12-208-67-103.client.insightBB.com [12.208.67.103]) (authenticated bits=0) by mx1.wolfram.com (8.12.11/8.12.11) with ESMTP id j9MJ0fZs004145 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT); Sat, 22 Oct 2005 14:00:41 -0500 From: Shaun McCance To: gnome-doc-devel-list@gnome.org, gnome-i18n@gnome.org Content-Type: text/plain Date: Sat, 22 Oct 2005 14:00:40 -0500 Message-Id: <1130007641.17733.21.camel@cornholio.housenet.network> Mime-Version: 1.0 X-Mailer: Evolution 2.4.0 Content-Transfer-Encoding: 7bit Received-SPF: pass (mx1.wolfram.com: authenticated connection) receiver=mx1.wolfram.com; client-ip=12.208.67.103; helo=cornholio.housenet.network; envelope-from=shaunm@gnome.org; x-software=spfmilter 0.97 http://www.acme.com/software/spfmilter/ with libspf2-1.0.0; X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Status: No, score=-4.8 tagged_above=-999 required=2 tests=[BAYES_00, RCVD_IN_SORBS] X-Spam-Score: -4.8 X-Spam-Level: Cc: Subject: Digit formatters in gnome-doc-utils X-BeenThere: gnome-doc-devel-list@gnome.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about development of yelp, gnome-doc-utils, and other documentation-related utilities" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Oct 2005 19:00:45 -0000 Currently, to format the number for a section, the section.number localization is called up, which might look like this: . This formats the parent number, whatever that may be, and the "digit" for the section, which is just the position of that section in its parent. The digit formatting is then controlled by the section.digit localization, which is just a single-character thing saying what numbering system to use to format it. If a section is a top-level, the section.number localization is bypassed and section.digit is called directly. The problem is that at least the French team needs to do formatting on the digit: http://bugzilla.gnome.org/show_bug.cgi?id=315190 This particular case involves wrapping the digit in some markup, which you can't do reliably with the current system. You could wrap the call to in the number formatter, but that won't help you when the number formatter is bypassed for top-level things. Here's some possible solutions: 1) Get rid of the single character digit things, and instead put attributes on any call to digit. This, you'd have something like this: . I would then remove the current digit formatter localizations, but I'd have to add localizations for top-level things. Net result is the same number of localized strings. This could also potentially be a tad faster, as template depth gets reduced. 2) Do the same thing, but instead of attributes, use special named elements, like so: . So we'd have digitI, digiti, digitA, digita, and digit1. This annoys me, though it could potentially emphasize more the need to mark the formatter. It has the same advantages as the first option. 3) Keep number formatters just as they are, but turn digit formatters into things that can have markup. So section.number would still just be . But section.digit would become Where n would have to become some meaningful element name. This has the advantage that only digit formatters have to be changed, and the change can be done automatically. I could even adjust all the PO files, if translators wanted me to. The other advantage is that you still only need to specify the digit formatting in a single place. It does, on the whole, seem cleaner to me. On the other hand, it means I have to come up with yet another element name, I think. Due to the way XSLT works, and the way my i18n system works in XSLT, I probably can't just re-use "digit" or "number" as element names here. And I'm sort of at a loss for another element name to convey the meaning. Thoughts? -- Shaun From clahey@ximian.com Mon Oct 31 14:23:37 2005 Return-Path: X-Original-To: gnome-doc-devel-list@gnome.org Delivered-To: gnome-doc-devel-list@gnome.org Received: from localhost (unknown [127.0.0.1]) by menubar.gnome.org (Postfix) with ESMTP id B83523B27A2 for ; Mon, 31 Oct 2005 14:23:37 -0500 (EST) Received: from menubar.gnome.org ([127.0.0.1]) by localhost (menubar.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 28212-03 for ; Mon, 31 Oct 2005 14:23:35 -0500 (EST) Received: from peabody.ximian.com (peabody.ximian.com [130.57.169.10]) by menubar.gnome.org (Postfix) with ESMTP id 610F53B279E for ; Mon, 31 Oct 2005 14:23:33 -0500 (EST) Received: (qmail 18517 invoked from network); 31 Oct 2005 19:23:32 -0000 Received: from outbound.ximian.com (HELO rigger.boston.ximian.com) (130.57.170.250) by peabody.ximian.com with SMTP; 31 Oct 2005 19:23:32 -0000 From: Christopher James Lahey To: gnome-doc-devel-list@gnome.org Content-Type: multipart/mixed; boundary="=-9ORf8ZtCi7oCmctsklwp" Date: Mon, 31 Oct 2005 14:25:26 -0500 Message-Id: <1130786726.5961.28.camel@rigger.boston.ximian.com> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Status: No, score=1.439 tagged_above=-999 required=2 tests=[BAYES_00, HTML_MESSAGE, HTML_TITLE_EMPTY, TW_BG, TW_BX, TW_GT, TW_IB] X-Spam-Score: 1.439 X-Spam-Level: * X-Mailman-Approved-At: Mon, 31 Oct 2005 16:59:07 -0500 Subject: yelp patches X-BeenThere: gnome-doc-devel-list@gnome.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about development of yelp, gnome-doc-utils, and other documentation-related utilities" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2005 19:23:38 -0000 --=-9ORf8ZtCi7oCmctsklwp Content-Type: text/plain Content-Transfer-Encoding: 7bit I've been working on adding some features to yelp and wish to work on getting them upstreamed. Included are 4 yelp patches. The first, yelp-helpuri.patch, enables yelp to recognize help: uris as used by KDE. It will also find things in some gnome directories (with the same behavior as the patch I added to khelpcenter for SuSE a while back.) I've written up a standard, but it needs some discussion. This could go in as is to match with KDE. The second, yelp-libmenu.patch, causes yelp to use the menu system to generate its table of contents instead of using scrollkeeper. This will allow us to get rid of the installtime hit from scrollkeeper as well as make the help menu match the Applications menu. This is just reading from a .menu file, so we can have a help.menu file that includes applications.menu so we can include stuff not in the menus. The third, yelp-printing.patch, adds printing support to yelp. It will print either the page or the whole document. The fourth, yelp-toctree.patch, displays the table of contents as a tree on a single page instead of across multiple pages. All 4 patches can be applied to the same tree. Known bugs: - Printing the whole document leaks some memory because I'm not sure how to know when the printing is done so I can free the temporary mozilla window. - Having the table of contents tree remember which nodes are open across sessions requires yelp_html_initialize from yelp-printing.patch, but I didn't want to have the patches conflict too much. Enjoy, Chris --=-9ORf8ZtCi7oCmctsklwp Content-Disposition: attachment; filename=yelp-helpuri.patch Content-Type: text/x-patch; name=yelp-helpuri.patch; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 7bit Index: src/yelp-utils.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-utils.c,v retrieving revision 1.26 diff -u -p -r1.26 yelp-utils.c --- src/yelp-utils.c 28 Oct 2005 20:37:37 -0000 1.26 +++ src/yelp-utils.c 31 Oct 2005 19:10:29 -0000 @@ -68,6 +68,7 @@ struct _YelpDocInfo { static YelpDocType get_doc_type (gchar *uri); static gchar * convert_ghelp_uri (gchar *uri); +static gchar * convert_help_uri (gchar *uri); static gchar * convert_man_uri (gchar *uri); static gchar * convert_info_uri (gchar *uri); @@ -78,7 +79,7 @@ yelp_doc_info_new (const gchar *uri) YelpDocInfo *doc; gchar *doc_uri = NULL; gchar *full_uri = NULL; - YelpDocType doc_type; + YelpDocType doc_type = YELP_DOC_TYPE_EXTERNAL; YelpURIType uri_type; gchar *cur; @@ -106,6 +107,27 @@ yelp_doc_info_new (const gchar *uri) doc_type = get_doc_type (doc_uri); uri_type = YELP_URI_TYPE_GHELP; } + else if (g_str_has_prefix (full_uri, "help:")) { + doc_uri = convert_help_uri (full_uri); + if (doc_uri) + doc_type = get_doc_type (doc_uri); +#if 0 + if ((cur = strchr (doc_uri, '#'))) { + char *temp; + + if (!strchr (full_uri, '#')) { + temp = full_uri; + full_uri = g_strconcat (full_uri, "#", cur + 1, NULL); + g_free (temp); + } + + temp = doc_uri; + doc_uri = g_strndup (doc_uri, cur - doc_uri); + g_free (temp); + } +#endif + uri_type = YELP_URI_TYPE_HELP; + } else if (g_str_has_prefix (full_uri, "man:")) { doc_uri = convert_man_uri (full_uri); doc_type = YELP_DOC_TYPE_MAN; @@ -117,7 +139,7 @@ yelp_doc_info_new (const gchar *uri) uri_type = YELP_URI_TYPE_INFO; } else if (g_str_has_prefix (full_uri, "x-yelp-toc:")) { - doc_uri = g_strdup ("file://" DATADIR "/yelp/toc.xml"); + doc_uri = g_strdup ("file://" DATADIR "/yelp/xslt/toc2html.xsl"); doc_type = YELP_DOC_TYPE_TOC; uri_type = YELP_URI_TYPE_TOC; } @@ -189,7 +211,7 @@ yelp_doc_info_get (const gchar *uri) if (!doc) { doc = yelp_doc_info_new (doc_uri); if (doc && doc->type != YELP_DOC_TYPE_EXTERNAL) { - YelpDocInfo *old_doc; + YelpDocInfo *old_doc = NULL; for (i = 0; i < doc->num_uris; i++) { old_doc = g_hash_table_lookup (doc_info_table, @@ -478,6 +500,18 @@ yelp_uri_get_fragment (const gchar *uri) if (*(++cur) != '\0') frag_id = g_strdup (cur); + if (g_str_has_prefix (uri, "help:")) + if (g_str_has_suffix (uri, ".html")) { + YelpDocInfo *doc = yelp_doc_info_get (uri); + char *file_uri; + file_uri = yelp_doc_info_get_uri (doc, NULL, YELP_URI_TYPE_FILE); + if (!g_str_has_suffix (file_uri, ".html")) { + cur = strrchr (uri, '/'); + frag_id = g_strndup (cur + 1, strlen (cur + 1) - strlen (".html")); + } + g_free (file_uri); + } + if ((cur = strchr (uri, '#'))) if (*(++cur) != '\0') { if (frag_id) @@ -520,7 +554,7 @@ get_doc_type (gchar *uri) if (mime_type == NULL) return YELP_DOC_TYPE_ERROR; - if (g_str_equal (mime_type, "text/xml")) + if (g_str_equal (mime_type, "text/xml") || g_str_equal (mime_type, "application/docbook+xml")) type = YELP_DOC_TYPE_DOCBOOK_XML; else if (g_str_equal (mime_type, "text/sgml")) type = YELP_DOC_TYPE_DOCBOOK_SGML; @@ -567,6 +601,161 @@ yelp_doc_info_add_uri (YelpDocInfo *doc_ /******************************************************************************/ /** Convert fancy URIs to file URIs *******************************************/ + +static gchar * +help_uri_check_file (gchar *filename, gchar *reference) { + d(g_print ("Checking %s\n", filename)); + if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) { + gchar *full_uri; + if (reference) { + full_uri = g_strconcat ("file://", filename, NULL, "#", reference, NULL); + } else { + full_uri = g_strconcat ("file://", filename, NULL); + } + + return full_uri; + } + + return NULL; +} + +static gchar * +help_uri_check_dir (gchar *path, gchar *identifier, gchar *reference) +{ + gchar *result; + + gchar *full_path; + gchar *full_identifier; + + result = help_uri_check_file (path, reference); + if (result) + return result; + + full_path = g_build_filename (path, "index.docbook", NULL); + result = help_uri_check_file (full_path, reference); + g_free (full_path); + if (result) + return result; + + full_identifier = g_strconcat (identifier, ".xml", NULL); + full_path = g_build_filename (path, full_identifier, NULL); + result = help_uri_check_file (full_path, reference); + g_free (full_path); + g_free (full_identifier); + if (result) + return result; + + return NULL; +} + +static gchar * +help_uri_search (gchar *path, gchar *identifier, char *reference) +{ + gchar *result; + + result = help_uri_check_dir (path, identifier, reference); + if (result) + return result; + + if (strlen (path) > 5 && ! strcmp (path + strlen (path) - 5, ".html")) { + gchar *slash = strrchr (path, '/'); + if (slash != NULL) { + gchar *shortened = g_strndup (path, slash - path); + gchar *shortened_reference = g_strndup (slash + 1, strlen (slash + 1) - 5); + result = help_uri_check_dir (shortened, identifier, reference ? reference : shortened_reference); + g_free (reference); + g_free (shortened); + if (result) + return result; + } + } + return NULL; +} + +static gchar * +help_uri_expand_datadirs (gchar *path, gchar *identifier, char *reference) +{ + char const* const* data_dirs = g_get_system_data_dirs (); + int i; + char *result; + for (i = 0; data_dirs[i]; i++) { + char *full_path = g_build_filename (data_dirs[i], path, NULL); + result = help_uri_search (full_path, identifier, reference); + g_free (full_path); + if (result) + return result; + } + return NULL; +} + +static gchar * +convert_help_uri (gchar *uri) +{ + gchar *path; + gchar *file_name = NULL; + const gchar * const * langs; + gchar *result = NULL; + gchar *full_path; + int i; + gchar *reference; + + if ((path = strchr(uri, ':'))) + path++; + else + return NULL; + + while (*path == '/') + path++; + + path = g_strdup (path); + + reference = strchr (path, '#'); + if (reference) { + *reference = 0; + reference ++; + } + + /* This isn't the filename so much as the rest of the path after the first bit of the path. */ + file_name = strchr (path, '/'); + if (file_name) { + *file_name = 0; + file_name ++; + } else { + file_name = ""; + } + + langs = g_get_language_names (); + + for (i = 0; langs[i] != NULL; i++) { + full_path = g_strdup_printf ("/gnome/help/%s/%s/%s", path, langs[i], file_name); + help_uri_expand_datadirs (full_path, path, reference); + g_free (full_path); + if (result) + goto end; + + full_path = g_strdup_printf ("/doc/HTML/%s/%s/%s", langs[i], path, file_name); + help_uri_expand_datadirs (full_path, path, reference); + g_free (full_path); + if (result) + goto end; + } + + full_path = g_strdup_printf ("/gnome/help/%s/C/%s", path, file_name); + result = help_uri_expand_datadirs (full_path, path, reference); + g_free (full_path); + if (result) + goto end; + + full_path = g_strdup_printf ("/doc/HTML/en/%s/%s", path, file_name); + result = help_uri_expand_datadirs (full_path, path, reference); + g_free (full_path); + if (result) + goto end; + + end: + g_free (path); + return result; +} static gchar * locate_file_lang (gchar *path, gchar *file, const gchar *lang) Index: src/yelp-utils.h =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-utils.h,v retrieving revision 1.12 diff -u -p -r1.12 yelp-utils.h --- src/yelp-utils.h 28 Oct 2005 20:37:37 -0000 1.12 +++ src/yelp-utils.h 31 Oct 2005 19:10:29 -0000 @@ -67,6 +67,7 @@ typedef enum { YELP_URI_TYPE_TOC = 1 << 4, YELP_URI_TYPE_EXTERNAL = 1 << 5, YELP_URI_TYPE_SEARCH = 1 << 6, + YELP_URI_TYPE_HELP = 1 << 7, YELP_URI_TYPE_NO_FILE = YELP_URI_TYPE_GHELP | @@ -74,9 +75,10 @@ typedef enum { YELP_URI_TYPE_INFO | YELP_URI_TYPE_TOC | YELP_URI_TYPE_EXTERNAL | + YELP_URI_TYPE_HELP | YELP_URI_TYPE_SEARCH, YELP_URI_TYPE_ANY = - YELP_URI_TYPE_FILE | + YELP_URI_TYPE_FILE | YELP_URI_TYPE_NO_FILE } YelpURIType; --=-9ORf8ZtCi7oCmctsklwp Content-Disposition: attachment; filename=yelp-libmenu.patch Content-Type: text/x-patch; name=yelp-libmenu.patch; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 7bit Index: configure.in =================================================================== RCS file: /cvs/gnome/yelp/configure.in,v retrieving revision 1.192 diff -u -p -r1.192 configure.in --- configure.in 28 Oct 2005 20:37:36 -0000 1.192 +++ configure.in 31 Oct 2005 18:44:10 -0000 @@ -63,6 +63,7 @@ PKG_CHECK_MODULES(YELP, libxml-2.0 >= 2.6.5 libxslt >= 1.1.4 libexslt >= 0.8.1 + libgnome-menu >= 2.11.1 ]) AC_SUBST([YELP_CFLAGS]) AC_SUBST([YELP_LIBS]) Index: src/yelp-toc-pager.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-toc-pager.c,v retrieving revision 1.51 diff -u -p -r1.51 yelp-toc-pager.c --- src/yelp-toc-pager.c 21 Oct 2005 01:47:56 -0000 1.51 +++ src/yelp-toc-pager.c 31 Oct 2005 18:44:10 -0000 @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,12 @@ #include "yelp-toc-pager.h" #include "yelp-utils.h" +#define GMENU_I_KNOW_THIS_IS_UNSTABLE +#include + +#define DESKTOP_ENTRY_GROUP "Desktop Entry" +#define KDE_DESKTOP_ENTRY_GROUP "KDE Desktop Entry" + #ifdef YELP_DEBUG #define d(x) x #else @@ -96,6 +103,9 @@ struct _YelpTocPagerPriv { xsltStylesheetPtr stylesheet; xsltTransformContextPtr transformContext; + + GMenuTree *libmenu_tree; + GSList *libmenu_stack; }; struct _YelpListing { @@ -125,10 +135,14 @@ GtkTreeModel * toc_pager_get_secti static gboolean toc_process_pending (YelpTocPager *pager); -static gboolean process_read_menu (YelpTocPager *pager); +static gboolean process_libmenu (YelpTocPager *pager); +static gboolean process_libmenu_node (YelpTocPager *pager); static gboolean process_xslt (YelpTocPager *pager); +#ifdef ENABLE_SCROLLKEEPER +static gboolean process_read_menu (YelpTocPager *pager); static gboolean process_read_scrollkeeper (YelpTocPager *pager); static gboolean process_omf_pending (YelpTocPager *pager); +#endif #ifdef ENABLE_MAN static gboolean process_mandir_pending (YelpTocPager *pager); #endif @@ -137,11 +151,13 @@ static gboolean process_info_dir_pe static gboolean process_info_pending (YelpTocPager *pager); #endif +#ifdef ENABLE_SCROLLKEEPER static void toc_add_doc_info (YelpTocPager *pager, YelpDocInfo *doc_info); static void toc_remove_doc_info (YelpTocPager *pager, YelpDocInfo *doc_info); static void xml_trim_titles (xmlNodePtr node); +#endif static void xslt_yelp_document (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, @@ -213,6 +229,9 @@ toc_pager_init (YelpTocPager *pager) priv->cancel = 0; priv->pause_count = 0; priv->pending_func = NULL; + + priv->libmenu_tree = NULL; + priv->libmenu_stack = NULL; } static void @@ -320,7 +339,7 @@ toc_pager_process (YelpPager *pager) yelp_pager_set_state (pager, YELP_PAGER_STATE_RUNNING); g_signal_emit_by_name (pager, "start"); - priv->pending_func = (ProcessFunction) process_read_menu; + priv->pending_func = (ProcessFunction) process_libmenu; gtk_idle_add_priority (G_PRIORITY_LOW, (GtkFunction) toc_process_pending, @@ -351,10 +370,15 @@ toc_process_pending (YelpTocPager *pager gboolean readd; YelpTocPagerPriv *priv = pager->priv; static gpointer process_funcs[] = { + process_libmenu, + process_libmenu_node, + process_xslt, +#ifdef ENABLE_SCROLLKEEPER process_read_menu, process_read_scrollkeeper, process_omf_pending, process_xslt, +#endif #ifdef ENABLE_MAN process_mandir_pending, process_xslt, @@ -386,6 +410,204 @@ toc_process_pending (YelpTocPager *pager return FALSE; } +static void +set_icon (xmlNode *node, const char *icon) +{ + if (icon) { + GtkIconInfo *info; + GtkIconTheme *theme = + (GtkIconTheme *) yelp_settings_get_icon_theme (); + info = gtk_icon_theme_lookup_icon (theme, icon, 48, 0); + if (info) { + xmlNodePtr new = xmlNewChild (node, NULL, "icon", NULL); + xmlNewNsProp (new, NULL, "file", gtk_icon_info_get_filename (info)); + gtk_icon_info_free (info); + } + } +} + +typedef struct { + xmlNode *tree; + GSList *children; + GSList *iterator; + gboolean non_empty; +} LibmenuStackFrame; + +static void +push_stack_frame (YelpTocPager *pager, GMenuTreeDirectory *dir) +{ + LibmenuStackFrame *frame; + YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv; + + frame = g_new (LibmenuStackFrame, 1); + frame->iterator = frame->children = gmenu_tree_directory_get_contents (dir); + frame->non_empty = FALSE; + + frame->tree = xmlNewNode (NULL, "toc"); + xmlSetProp (frame->tree, "id", gmenu_tree_directory_get_menu_id (dir)); + xmlNewTextChild (frame->tree, NULL, "title", gmenu_tree_directory_get_name (dir)); + set_icon (frame->tree, gmenu_tree_directory_get_icon (dir)); + + priv->libmenu_stack = g_slist_prepend (priv->libmenu_stack, frame); +} + +static void +pop_stack_frame (YelpTocPager *pager) +{ + LibmenuStackFrame *frame; + YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv; + + frame = priv->libmenu_stack->data; + + g_slist_free (frame->children); + g_free (frame); + + priv->libmenu_stack = g_slist_delete_link (priv->libmenu_stack, priv->libmenu_stack); +} + +static GTimer *timer; +/* iterator points to next node to process and is incremented at the + end of the function. NULL means finished with this level. Parent + iterators are incremented before processing the child tree. */ +static gboolean +process_libmenu_node (YelpTocPager *pager) +{ + LibmenuStackFrame *frame; + GMenuTreeItem *item; + YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv; + gulong ms_start; + + + frame = priv->libmenu_stack->data; + + if (frame->iterator == NULL) { + if (priv->libmenu_stack->next) { + if (frame->non_empty) { + xmlNode *tree = frame->tree; + pop_stack_frame (pager); + + frame = priv->libmenu_stack->data; + xmlAddChild (frame->tree, tree); + frame->non_empty = TRUE; + } else { + xmlFreeNode (frame->tree); + pop_stack_frame(pager); + } + + return TRUE; + } else { + YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv; + xmlNode *title; + + priv->toc_doc = xmlNewDoc ("1.0"); + xmlSetProp (frame->tree, "id", "index"); + xmlDocSetRootElement (priv->toc_doc, frame->tree); + + for (title = frame->tree->children; title; title = title->next) { + if (g_str_equal (title->name, "title")) { + xmlNodeSetContent (title, _("Help Topics")); + break; + } + } + if (title == NULL) { + xmlNewTextChild (frame->tree, NULL, "title", _("Help Topics")); + } + + pop_stack_frame (pager); + + gmenu_tree_unref (priv->libmenu_tree); + priv->libmenu_tree = NULL; + + + + return FALSE; + } + } + + item = frame->iterator->data; + + switch (gmenu_tree_item_get_type (item)) { + case GMENU_TREE_ITEM_DIRECTORY: + { + push_stack_frame (pager, GMENU_TREE_DIRECTORY (item)); + } + break; + case GMENU_TREE_ITEM_ENTRY: + { + GMenuTreeEntry *entry = GMENU_TREE_ENTRY (item); + const char *path = gmenu_tree_entry_get_desktop_file_path (entry); + const char *desktop_entry_group; + char *docpath = NULL; + GKeyFile *key_file; + + key_file = g_key_file_new (); + + + if (!g_key_file_load_from_file (key_file, path, 0, NULL)) { + g_key_file_free (key_file); + break; + } + + if (g_key_file_has_group (key_file, DESKTOP_ENTRY_GROUP)) { + desktop_entry_group = DESKTOP_ENTRY_GROUP; + } else { + if (g_key_file_has_group (key_file, KDE_DESKTOP_ENTRY_GROUP)) { + desktop_entry_group = KDE_DESKTOP_ENTRY_GROUP; + } else { + g_key_file_free (key_file); + break; + } + } + + docpath = g_key_file_get_string (key_file, desktop_entry_group, "DocPath", NULL); + + if (docpath) { + xmlNode *new = xmlNewChild (frame->tree, NULL, "doc", NULL); + if (strchr(docpath, ':')) { + xmlNewNsProp (new, NULL, "href", docpath); + } else { + char *href = g_strdup_printf ("help:%s", docpath); + xmlNewNsProp (new, NULL, "href", href); + g_free (href); + } + + xmlNewTextChild (new, NULL, "title", gmenu_tree_entry_get_name (entry)); + xmlNewTextChild (new, NULL, "description", gmenu_tree_entry_get_comment (entry)); + set_icon (new, gmenu_tree_entry_get_icon (entry)); + + frame->non_empty = TRUE; + + g_free (docpath); + } + } + break; + default: + /* Ignore */ + break; + } + + + frame->iterator = frame->iterator->next; + return TRUE; +} + + +static gboolean +process_libmenu (YelpTocPager *pager) +{ + YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv; + + + priv->libmenu_tree = gmenu_tree_lookup ("applications.menu", + GMENU_TREE_FLAGS_NONE); + + push_stack_frame (pager, gmenu_tree_get_root_directory (priv->libmenu_tree)); + + return FALSE; +} + +#ifdef ENABLE_SCROLLKEEPER + /** process_read_scrollkeeper *************************************************/ static void @@ -559,6 +781,7 @@ process_omf_pending (YelpTocPager *pager else return FALSE; } +#endif #ifdef ENABLE_MAN static gboolean @@ -752,6 +975,7 @@ process_info_pending (YelpTocPager *page } #endif /* ENABLE_INFO */ +#ifdef ENABLE_SCROLLKEEPER static gboolean process_read_menu (YelpTocPager *pager) { @@ -796,17 +1020,7 @@ process_read_menu (YelpTocPager *pager) xml_trim_titles (node); icon = xmlGetProp (node, "icon"); - if (icon) { - GtkIconInfo *info; - GtkIconTheme *theme = - (GtkIconTheme *) yelp_settings_get_icon_theme (); - info = gtk_icon_theme_lookup_icon (theme, icon, 48, 0); - if (info) { - xmlNodePtr new = xmlNewChild (node, NULL, "icon", NULL); - xmlNewNsProp (new, NULL, "file", gtk_icon_info_get_filename (info)); - gtk_icon_info_free (info); - } - } + set_icon (node, icon); xmlFree (icon); } @@ -864,12 +1078,13 @@ process_read_menu (YelpTocPager *pager) return FALSE; } +#endif static gboolean process_xslt (YelpTocPager *pager) { GError *error = NULL; - xmlDocPtr outdoc; + xmlDocPtr outdoc = NULL; YelpTocPagerPriv *priv = pager->priv; gchar **params = NULL; gint params_i = 0; @@ -948,6 +1163,7 @@ process_xslt (YelpTocPager *pager) return FALSE; } +#ifdef ENABLE_SCROLLKEEPER static void toc_add_doc_info (YelpTocPager *pager, YelpDocInfo *doc_info) { @@ -1002,6 +1218,8 @@ toc_remove_doc_info (YelpTocPager *pager #endif } +#endif + static void xslt_yelp_document (xsltTransformContextPtr ctxt, xmlNodePtr node, @@ -1122,6 +1340,7 @@ xslt_yelp_document (xsltTransformContext xsltFreeStylesheet (style); } +#ifdef ENABLE_SCROLLKEEPER static void xml_trim_titles (xmlNodePtr node) { @@ -1171,3 +1390,4 @@ xml_trim_titles (xmlNodePtr node) } xmlFree (keep_lang); } +#endif --=-9ORf8ZtCi7oCmctsklwp Content-Disposition: attachment; filename=yelp-printing.patch Content-Type: text/x-patch; name=yelp-printing.patch; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit ? document.ps ? page.ps Index: data/ui/yelp-ui.xml =================================================================== RCS file: /cvs/gnome/yelp/data/ui/yelp-ui.xml,v retrieving revision 1.11 diff -u -p -r1.11 yelp-ui.xml --- data/ui/yelp-ui.xml 28 Oct 2005 20:37:37 -0000 1.11 +++ data/ui/yelp-ui.xml 31 Oct 2005 18:33:36 -0000 @@ -6,6 +6,9 @@ + + +
Index: data/ui/yelp.glade =================================================================== RCS file: /cvs/gnome/yelp/data/ui/yelp.glade,v retrieving revision 1.11 diff -u -p -r1.11 yelp.glade --- data/ui/yelp.glade 15 Oct 2005 16:34:55 -0000 1.11 +++ data/ui/yelp.glade 31 Oct 2005 18:33:36 -0000 @@ -19,6 +19,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True False @@ -102,6 +103,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -173,6 +178,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -200,7 +209,7 @@ True 0.5 1 - 0.9 + 0.899999976158 0.5 0 0 @@ -233,6 +242,10 @@ 0 0 find_entry + PANGO_ELLIPSIZE_NONE + -1 + False + 0 3 @@ -340,6 +353,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True False @@ -409,6 +423,10 @@ 0 0 location_entry + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -461,6 +479,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True False @@ -521,6 +540,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -597,6 +620,10 @@ 0 0 variable_font + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -622,6 +649,10 @@ 0 0 fixed_font + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -706,6 +737,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -779,6 +814,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True False @@ -837,6 +873,10 @@ 0 0 bookmarks_view + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -920,6 +960,9 @@ False False True + False + False + False @@ -955,6 +998,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True False @@ -1036,6 +1080,10 @@ 0 0 bookmark_title_entry + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1064,6 +1112,249 @@ + + + + 0 + True + True + + + + + + + + True + Print + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + True + True + True + True + True + gtk-print + True + GTK_RELIEF_NORMAL + True + 0 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 6 + True + False + 6 + + + + True + True + GTK_RELIEF_NORMAL + True + True + False + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-file + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Print current pa_ge + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + True + False + False + True + radiobutton_page + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gnome-stock-book-blue + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Print entire _document + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + Index: src/Makefile.am =================================================================== RCS file: /cvs/gnome/yelp/src/Makefile.am,v retrieving revision 1.85 diff -u -p -r1.85 Makefile.am --- src/Makefile.am 28 Oct 2005 20:37:37 -0000 1.85 +++ src/Makefile.am 31 Oct 2005 18:33:36 -0000 @@ -9,6 +9,7 @@ yelp_SOURCES = \ yelp-bookmarks.c yelp-bookmarks.h \ yelp-cache.c yelp-cache.h \ yelp-db-pager.c yelp-db-pager.h \ + yelp-db-print-pager.c yelp-db-print-pager.h \ yelp-error.c yelp-error.h \ yelp-gecko-utils.cpp yelp-gecko-utils.h \ yelp-html.cpp yelp-html.h \ @@ -112,6 +113,7 @@ test_man_parser_LDADD = $(YELP_LIBS) $(Z test_pager_SOURCES = \ yelp-db-pager.c yelp-db-pager.h \ + yelp-db-print-pager.c yelp-db-print-pager.h \ yelp-error.c yelp-error.h \ yelp-io-channel.c yelp-io-channel.h \ yelp-man-pager.c yelp-man-pager.h \ Index: src/yelp-db-print-pager.c =================================================================== RCS file: src/yelp-db-print-pager.c diff -N src/yelp-db-print-pager.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/yelp-db-print-pager.c 31 Oct 2005 18:33:36 -0000 @@ -0,0 +1,295 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2003 Shaun McCance + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Shaun McCance + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "yelp-error.h" +#include "yelp-db-print-pager.h" +#include "yelp-toc-pager.h" +#include "yelp-settings.h" + +#ifdef YELP_DEBUG +#define d(x) x +#else +#define d(x) +#endif + +#define STYLESHEET_PATH DATADIR"/yelp/xslt/" +#define DB_STYLESHEET STYLESHEET_PATH"db2html.xsl" +#define DB_TITLE STYLESHEET_PATH"db-title.xsl" + +#define BOOK_CHUNK_DEPTH 2 +#define ARTICLE_CHUNK_DEPTH 1 + +#define EVENTS_PENDING while (yelp_pager_get_state (pager) <= YELP_PAGER_STATE_RUNNING && gtk_events_pending ()) gtk_main_iteration (); +#define CANCEL_CHECK if (!main_running || yelp_pager_get_state (pager) >= YELP_PAGER_STATE_ERROR) goto done; + +extern gboolean main_running; + +#define YELP_DB_PRINT_PAGER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), YELP_TYPE_DB_PRINT_PAGER, YelpDBPrintPagerPriv)) + +struct _YelpDBPrintPagerPriv { + gchar *root_id; +}; + +static void db_print_pager_class_init (YelpDBPrintPagerClass *klass); +static void db_print_pager_init (YelpDBPrintPager *pager); +static void db_print_pager_dispose (GObject *gobject); + +static void db_print_pager_cancel (YelpPager *pager); +static xmlDocPtr db_print_pager_parse (YelpPager *pager); +static gchar ** db_print_pager_params (YelpPager *pager); + +static const gchar * db_print_pager_resolve_frag (YelpPager *pager, + const gchar *frag_id); +static GtkTreeModel * db_print_pager_get_sections (YelpPager *pager); + +static YelpPagerClass *parent_class; + +GType +yelp_db_print_pager_get_type (void) +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo info = { + sizeof (YelpDBPrintPagerClass), + NULL, + NULL, + (GClassInitFunc) db_print_pager_class_init, + NULL, + NULL, + sizeof (YelpDBPrintPager), + 0, + (GInstanceInitFunc) db_print_pager_init, + }; + type = g_type_register_static (YELP_TYPE_XSLT_PAGER, + "YelpDBPrintPager", + &info, 0); + } + return type; +} + +static void +db_print_pager_class_init (YelpDBPrintPagerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + YelpPagerClass *pager_class = YELP_PAGER_CLASS (klass); + YelpXsltPagerClass *xslt_class = YELP_XSLT_PAGER_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + object_class->dispose = db_print_pager_dispose; + + pager_class->cancel = db_print_pager_cancel; + + pager_class->resolve_frag = db_print_pager_resolve_frag; + + xslt_class->parse = db_print_pager_parse; + xslt_class->params = db_print_pager_params; + + xslt_class->stylesheet = DB_STYLESHEET; + + g_type_class_add_private (klass, sizeof (YelpDBPrintPagerPriv)); +} + +static void +db_print_pager_init (YelpDBPrintPager *pager) +{ + YelpDBPrintPagerPriv *priv; + + pager->priv = priv = YELP_DB_PRINT_PAGER_GET_PRIVATE (pager); + + pager->priv->root_id = NULL; +} + +static void +db_print_pager_dispose (GObject *object) +{ + YelpDBPrintPager *pager = YELP_DB_PRINT_PAGER (object); + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +/******************************************************************************/ + +YelpPager * +yelp_db_print_pager_new (YelpDocInfo *doc_info) +{ + YelpDBPrintPager *pager; + + g_return_val_if_fail (doc_info != NULL, NULL); + + pager = (YelpDBPrintPager *) g_object_new (YELP_TYPE_DB_PRINT_PAGER, + "document-info", doc_info, + NULL); + + return (YelpPager *) pager; +} + +static xmlDocPtr +db_print_pager_parse (YelpPager *pager) +{ + YelpDBPrintPagerPriv *priv; + YelpDocInfo *doc_info; + gchar *filename = NULL; + + xmlParserCtxtPtr parserCtxt = NULL; + xmlDocPtr doc = NULL; + + xmlChar *id; + GError *error = NULL; + + d (g_print ("db_print_pager_parse\n")); + + doc_info = yelp_pager_get_doc_info (pager); + + g_return_val_if_fail (pager != NULL, NULL); + g_return_val_if_fail (YELP_IS_DB_PRINT_PAGER (pager), NULL); + priv = YELP_DB_PRINT_PAGER (pager)->priv; + + g_object_ref (pager); + + if (yelp_pager_get_state (pager) >= YELP_PAGER_STATE_ERROR) + goto done; + + filename = yelp_doc_info_get_filename (doc_info); + + parserCtxt = xmlNewParserCtxt (); + doc = xmlCtxtReadFile (parserCtxt, + (const char *) filename, NULL, + XML_PARSE_DTDLOAD | XML_PARSE_NOCDATA | + XML_PARSE_NOENT | XML_PARSE_NONET ); + if (doc == NULL) { + g_set_error (&error, YELP_ERROR, YELP_ERROR_NO_DOC, + _("The file ā€˜%s’ could not be parsed. Either the file " + "does not exist, or it is not well-formed XML."), + filename); + yelp_pager_error (pager, error); + goto done; + } + + xmlXIncludeProcessFlags (doc, + XML_PARSE_DTDLOAD | XML_PARSE_NOCDATA | + XML_PARSE_NOENT | XML_PARSE_NONET ); + + + priv->root_id = g_strdup ("index"); + + EVENTS_PENDING; + CANCEL_CHECK; + + done: + g_free (filename); + + if (parserCtxt) + xmlFreeParserCtxt (parserCtxt); + + g_object_unref (pager); + + return doc; +} + +static gchar ** +db_print_pager_params (YelpPager *pager) +{ + YelpDBPrintPagerPriv *priv; + YelpDocInfo *doc_info; + gchar **params; + gint params_i = 0; + gint params_max = 20; + + d (g_print ("db_print_pager_process\n")); + + doc_info = yelp_pager_get_doc_info (pager); + + g_return_val_if_fail (pager != NULL, FALSE); + g_return_val_if_fail (YELP_IS_DB_PRINT_PAGER (pager), FALSE); + priv = YELP_DB_PRINT_PAGER (pager)->priv; + + if (yelp_pager_get_state (pager) >= YELP_PAGER_STATE_ERROR) + return NULL; + + params = g_new0 (gchar *, params_max); + + yelp_settings_params (¶ms, ¶ms_i, ¶ms_max); + + if ((params_i + 10) >= params_max - 1) { + params_max += 20; + params = g_renew (gchar *, params, params_max); + } + params[params_i++] = "db.chunk.extension"; + params[params_i++] = g_strdup ("\"\""); + params[params_i++] = "db.chunk.info_basename"; + params[params_i++] = g_strdup ("\"index\""); + params[params_i++] = "db.chunk.max_depth"; + params[params_i++] = g_strdup_printf ("0"); + params[params_i++] = "yelp.javascript"; + params[params_i++] = g_strdup_printf ("\"%s\"", DATADIR "/yelp/yelp.js"); + + params[params_i] = NULL; + + return params; +} + +static void +db_print_pager_cancel (YelpPager *pager) +{ + YelpDBPrintPagerPriv *priv = YELP_DB_PRINT_PAGER (pager)->priv; + + d (g_print ("db_print_pager_cancel\n")); + + yelp_pager_set_state (pager, YELP_PAGER_STATE_INVALID); + + g_free (priv->root_id); + priv->root_id = NULL; + + YELP_PAGER_CLASS (parent_class)->cancel (pager); +} + +static const gchar * +db_print_pager_resolve_frag (YelpPager *pager, const gchar *frag_id) +{ + YelpDBPrintPager *db_print_pager; + + g_return_val_if_fail (pager != NULL, NULL); + g_return_val_if_fail (YELP_IS_DB_PRINT_PAGER (pager), NULL); + + db_print_pager = YELP_DB_PRINT_PAGER (pager); + + return frag_id; +} + Index: src/yelp-db-print-pager.h =================================================================== RCS file: src/yelp-db-print-pager.h diff -N src/yelp-db-print-pager.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/yelp-db-print-pager.h 31 Oct 2005 18:33:36 -0000 @@ -0,0 +1,55 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2003 Shaun McCance + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Shaun McCance + */ + +#ifndef __YELP_DB_PRINT_PAGER_H__ +#define __YELP_DB_PRINT_PAGER_H__ + +#include + +#include "yelp-pager.h" +#include "yelp-xslt-pager.h" + +#define YELP_TYPE_DB_PRINT_PAGER (yelp_db_print_pager_get_type ()) +#define YELP_DB_PRINT_PAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), YELP_TYPE_DB_PRINT_PAGER, YelpDBPrintPager)) +#define YELP_DB_PRINT_PAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), YELP_TYPE_DB_PRINT_PAGER, YelpDBPrintPagerClass)) +#define YELP_IS_DB_PRINT_PAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), YELP_TYPE_DB_PRINT_PAGER)) +#define YELP_IS_DB_PRINT_PAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), YELP_TYPE_DB_PRINT_PAGER)) +#define YELP_DB_PRINT_PAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), YELP_TYPE_DB_PRINT_PAGER, YelpDBPrintPagerClass)) + +typedef struct _YelpDBPrintPager YelpDBPrintPager; +typedef struct _YelpDBPrintPagerClass YelpDBPrintPagerClass; +typedef struct _YelpDBPrintPagerPriv YelpDBPrintPagerPriv; + +struct _YelpDBPrintPager { + YelpXsltPager parent; + + YelpDBPrintPagerPriv *priv; +}; + +struct _YelpDBPrintPagerClass { + YelpXsltPagerClass parent_class; +}; + +GType yelp_db_print_pager_get_type (void); +YelpPager * yelp_db_print_pager_new (YelpDocInfo *doc_info); + +#endif /* __YELP_DB_PRINT_PAGER_H__ */ Index: src/yelp-html.cpp =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-html.cpp,v retrieving revision 1.1 diff -u -p -r1.1 yelp-html.cpp --- src/yelp-html.cpp 16 May 2005 21:02:33 -0000 1.1 +++ src/yelp-html.cpp 31 Oct 2005 18:33:36 -0000 @@ -34,6 +34,12 @@ #include "Yelper.h" +#include "gtkmozembed_internal.h" +#include "nsIWebBrowserPrint.h" +#include "nsIInterfaceRequestorUtils.h" + +#include + #ifdef GNOME_ENABLE_DEBUG #define d(x) x #else @@ -42,6 +48,9 @@ #define YELP_HTML_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), YELP_TYPE_HTML, YelpHtmlPriv)) +#define MOZILLA_PROFILE_DIR "/mozilla" +#define MOZILLA_PROFILE_NAME "yelp" + struct _YelpHtmlPriv { Yelper *yelper; gchar *base_uri; @@ -51,6 +60,7 @@ struct _YelpHtmlPriv { static void html_set_fonts (void); static void html_set_colors (void); static void html_set_a11y (void); +static void open_new_window (GtkMozEmbed **newEmbed, guint chrome_mask); enum { URI_SELECTED, @@ -120,6 +130,14 @@ html_realize (GtkWidget *widget) } static void +html_new_window (GtkMozEmbed *embed, + GtkMozEmbed **newEmbed, + guint chrome_mask) +{ + open_new_window (newEmbed, chrome_mask); +} + +static void html_init (YelpHtml *html) { YelpHtmlPriv *priv; @@ -197,6 +215,7 @@ html_class_init (YelpHtmlClass *klass) moz_embed_class->title = html_title; moz_embed_class->dom_mouse_down = html_dom_mouse_down; moz_embed_class->open_uri = html_open_uri; + moz_embed_class->new_window = html_new_window; klass->font_handler = 0; @@ -385,6 +404,24 @@ yelp_html_select_all (YelpHtml *html) html->priv->yelper->DoCommand ("cmd_selectAll"); } +void +yelp_html_print (YelpHtml *html) +{ + nsCOMPtr webBrowser; + + gtk_moz_embed_get_nsIWebBrowser (GTK_MOZ_EMBED (html), getter_AddRefs(webBrowser)); + + if (webBrowser) { + + nsCOMPtr print(do_GetInterface(webBrowser)); + + if (print) { + /* FIXME: Deal with retval. */ + print->Print (nsnull, nsnull); + } + } +} + static void html_set_fonts (void) { @@ -421,4 +458,123 @@ html_set_a11y (void) caret = yelp_settings_get_caret (); yelp_gecko_set_caret (caret); +} + +static void +new_window_orphan_cb (GtkMozEmbedSingle *moz_single, + GtkMozEmbed **newEmbed, + guint chrome_mask, + gpointer user_data) +{ + open_new_window (newEmbed, chrome_mask); +} + +void +yelp_html_initialize (void) +{ + static gboolean initialized = FALSE; + GtkMozEmbedSingle *single; + char *profile_path; + + if (initialized) + return; + initialized = TRUE; + + /* get single */ + single = gtk_moz_embed_single_get (); + if (single == NULL) { + g_warning ("Failed to get singleton embed object!\n"); + } + + /* allow creation of orphan windows */ + g_signal_connect (G_OBJECT (single), "new_window_orphan", + G_CALLBACK (new_window_orphan_cb), + NULL); + + profile_path = g_build_filename (g_get_home_dir (), + GNOME_DOT_GNOME, + "yelp.d", + MOZILLA_PROFILE_DIR, + NULL); + gtk_moz_embed_set_profile_path (profile_path, MOZILLA_PROFILE_NAME); + g_free (profile_path); +} + +static GtkMozEmbed *new_xul_dialog (void); + +static void +xul_visibility_cb (GtkWidget *embed, gboolean visibility, GtkWidget *window) +{ + if (visibility) { + gtk_widget_show (window); + } else { + gtk_widget_hide (window); + } +} + +static void +xul_size_to_cb (GtkWidget *embed, gint width, gint height, gpointer dummy) +{ + gtk_widget_set_size_request (embed, width, height); +} + +static void +xul_new_window_cb (GtkMozEmbed *embed, + GtkMozEmbed **retval, + guint chrome_mask, + gpointer dummy) +{ + g_assert (chrome_mask & GTK_MOZ_EMBED_FLAG_OPENASCHROME); + + *retval = new_xul_dialog (); +} + +static void +xul_title_cb (GtkMozEmbed *embed, + GtkWindow *window) +{ + char *title; + + title = gtk_moz_embed_get_title (embed); + gtk_window_set_title (window, title); + g_free (title); +} + +static GtkMozEmbed * +new_xul_dialog (void) +{ + GtkWidget *window, *embed; + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + embed = gtk_moz_embed_new (); + gtk_widget_show (embed); + gtk_container_add (GTK_CONTAINER (window), embed); + + g_signal_connect_object (embed, "destroy_browser", + G_CALLBACK (gtk_widget_destroy), + window, G_CONNECT_SWAPPED); + g_signal_connect_object (embed, "visibility", + G_CALLBACK (xul_visibility_cb), + window, (GConnectFlags) 0); + g_signal_connect_object (embed, "size_to", + G_CALLBACK (xul_size_to_cb), + NULL, (GConnectFlags) 0); + g_signal_connect_object (embed, "new_window", + G_CALLBACK (xul_new_window_cb), + NULL, (GConnectFlags) 0); + g_signal_connect_object (embed, "title", + G_CALLBACK (xul_title_cb), + window, (GConnectFlags) 0); + + return GTK_MOZ_EMBED (embed); +} + +static void +open_new_window (GtkMozEmbed **newEmbed, + guint chrome_mask) +{ + if (chrome_mask & GTK_MOZ_EMBED_FLAG_OPENASCHROME) { + *newEmbed = new_xul_dialog (); + return; + } } Index: src/yelp-html.h =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-html.h,v retrieving revision 1.30 diff -u -p -r1.30 yelp-html.h --- src/yelp-html.h 16 May 2005 21:02:33 -0000 1.30 +++ src/yelp-html.h 31 Oct 2005 18:33:36 -0000 @@ -98,6 +98,10 @@ void yelp_html_copy_selection void yelp_html_select_all (YelpHtml *html); +void yelp_html_print (YelpHtml *html); + +void yelp_html_initialize (void); + G_END_DECLS #endif /* __YELP_HTML_H__ */ Index: src/yelp-main.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-main.c,v retrieving revision 1.38 diff -u -p -r1.38 yelp-main.c --- src/yelp-main.c 6 Mar 2005 20:07:11 -0000 1.38 +++ src/yelp-main.c 31 Oct 2005 18:33:36 -0000 @@ -42,6 +42,7 @@ #include "GNOME_Yelp.h" #include "yelp-window.h" #include "yelp-base.h" +#include "yelp-html.h" #define YELP_FACTORY_OAFIID "OAFIID:GNOME_Yelp_Factory" @@ -365,6 +366,8 @@ main (int argc, char **argv) if (!factory) { /* Not started, start now */ BonoboGenericFactory *factory; char *registration_id; + + yelp_html_initialize (); registration_id = bonobo_activation_make_registration_id ( YELP_FACTORY_OAFIID, Index: src/yelp-window.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-window.c,v retrieving revision 1.178 diff -u -p -r1.178 yelp-window.c --- src/yelp-window.c 28 Oct 2005 20:37:37 -0000 1.178 +++ src/yelp-window.c 31 Oct 2005 18:33:37 -0000 @@ -42,6 +42,7 @@ #include "yelp-bookmarks.h" #include "yelp-db-pager.h" +#include "yelp-db-print-pager.h" #include "yelp-error.h" #include "yelp-html.h" #include "yelp-pager.h" @@ -160,6 +161,8 @@ static void window_add_widget GtkWidget *vbox); static void window_new_window_cb (GtkAction *action, YelpWindow *window); static void window_about_document_cb (GtkAction *action, YelpWindow *window); +static void window_print_document_cb (GtkAction *action, YelpWindow *window); +static void window_print_page_cb (GtkAction *action, YelpWindow *window); static void window_open_location_cb (GtkAction *action, YelpWindow *window); static void window_close_window_cb (GtkAction *action, YelpWindow *window); static void window_copy_cb (GtkAction *action, YelpWindow *window); @@ -308,6 +311,16 @@ static const GtkActionEntry entries[] = "N", NULL, G_CALLBACK (window_new_window_cb) }, + { "PrintDocument", NULL, + N_("Print This Document"), + NULL, + NULL, + G_CALLBACK (window_print_document_cb) }, + { "PrintPage", NULL, + N_("Print This Page"), + NULL, + NULL, + G_CALLBACK (window_print_page_cb) }, { "AboutDocument", NULL, N_("About This Document"), NULL, @@ -1925,6 +1938,181 @@ window_new_window_cb (GtkAction *action, g_return_if_fail (YELP_IS_WINDOW (window)); g_signal_emit (window, signals[NEW_WINDOW_REQUESTED], 0, NULL); +} + +typedef struct { + gulong page_handler; + gulong error_handler; + gulong cancel_handler; + gulong finish_handler; + YelpPager *pager; +} PrintStruct; + +static void +print_disconnect (PrintStruct *data) +{ + d(g_print ("print disconnect\n")); + if (data->page_handler) { + g_signal_handler_disconnect (data->pager, + data->page_handler); + data->page_handler = 0; + } + if (data->error_handler) { + g_signal_handler_disconnect (data->pager, + data->error_handler); + data->error_handler = 0; + } + if (data->cancel_handler) { + g_signal_handler_disconnect (data->pager, + data->cancel_handler); + data->cancel_handler = 0; + } + if (data->finish_handler) { + g_signal_handler_disconnect (data->pager, + data->finish_handler); + data->finish_handler = 0; + } +#if 0 + if (data) { + if (data->pager) + g_object_unref (data->pager); + } +#endif + g_free (data); +} + +static void +print_pager_page_cb (YelpPager *pager, + gchar *page_id, + gpointer user_data) +{ + PrintStruct *data = user_data; + YelpPage *page; + + d (g_print ("print_pager_page_cb\n")); + d (g_print (" page_id=\"%s\"\n", page_id)); + + page = (YelpPage *) yelp_pager_get_page (pager, page_id); + + if (page) { + YelpHtml *html; + GtkWidget *gtk_window; + int length, offset; + char *uri; + + d(g_print (page->contents)); + + gtk_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + html = yelp_html_new (); + gtk_container_add (GTK_CONTAINER (gtk_window), GTK_WIDGET (html)); + gtk_widget_realize (gtk_window); + gtk_widget_realize (GTK_WIDGET (html)); + + + uri = yelp_doc_info_get_uri (yelp_pager_get_doc_info (pager), + page_id, + YELP_URI_TYPE_FILE); + + d (g_print (" uri = %s\n", uri)); + + yelp_html_set_base_uri (html, uri); + g_free (uri); + + yelp_html_open_stream (html, "application/xhtml+xml"); + for (length = strlen (page->contents), offset = 0; length > 0; length -= BUFFER_SIZE, offset += BUFFER_SIZE) { + d(g_print ("data: %.*s\n", MIN (length, BUFFER_SIZE), page->contents + offset)); + yelp_html_write (html, page->contents + offset, MIN (length, BUFFER_SIZE)); + } + yelp_html_close (html); + + yelp_html_print (html); + + print_disconnect (data); + + /* This needs to be done at some point, but we need to wait until printing is done. */ + /* gtk_widget_destroy (gtk_window); */ + } +} + +static void +print_pager_error_cb (YelpPager *pager, + gpointer user_data) +{ + PrintStruct *data = user_data; + /* GError *error = yelp_pager_get_error (pager);*/ + + d (g_print ("print_pager_error_cb\n")); + + print_disconnect (data); +} + +static void +print_pager_cancel_cb (YelpPager *pager, + gpointer user_data) +{ + PrintStruct *data = user_data; + d (g_print ("print_pager_cancel_cb\n")); + + print_disconnect (data); +} + +static void +print_pager_finish_cb (YelpPager *pager, + gpointer user_data) +{ + PrintStruct *data = user_data; + + d (g_print ("print_pager_finish_cb\n")); + + print_disconnect (data); +} + +static void +window_print_document_cb (GtkAction *action, YelpWindow *window) +{ + PrintStruct *data; + YelpPager *pager; + + if (!window->priv->current_doc) + return; + + pager = yelp_db_print_pager_new (window->priv->current_doc); + + if (!pager) { + return; + } + + data = g_new0 (PrintStruct, 1); + data->pager = pager; + + data->page_handler = + g_signal_connect (data->pager, + "page", + G_CALLBACK (print_pager_page_cb), + data); + data->error_handler = + g_signal_connect (data->pager, + "error", + G_CALLBACK (print_pager_error_cb), + data); + data->cancel_handler = + g_signal_connect (data->pager, + "error", + G_CALLBACK (print_pager_cancel_cb), + data); + data->finish_handler = + g_signal_connect (data->pager, + "finish", + G_CALLBACK (print_pager_finish_cb), + data); + + /* handled = */ yelp_pager_start (data->pager); +} + +static void +window_print_page_cb (GtkAction *action, YelpWindow *window) +{ + yelp_html_print (window->priv->html_view); } static void --=-9ORf8ZtCi7oCmctsklwp Content-Disposition: attachment; filename=yelp-toctree.patch Content-Type: text/x-patch; name=yelp-toctree.patch; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 7bit Index: data/yelp.js =================================================================== RCS file: /cvs/gnome/yelp/data/yelp.js,v retrieving revision 1.3 diff -u -p -r1.3 yelp.js --- data/yelp.js 28 Oct 2005 20:37:36 -0000 1.3 +++ data/yelp.js 31 Oct 2005 19:05:14 -0000 @@ -87,6 +87,50 @@ window.addEventListener("load",slt.init, window.addEventListener("DOMContentLoaded",slt.init,false); window.addEventListener("resize",slt.init,false); +function createCookie(name,value,days) +{ + if (days) + { + var date = new Date(); + date.setTime(date.getTime()+(days*24*60*60*1000)); + var expires = "; expires="+date.toGMTString(); + } + else var expires = ""; + document.cookie = name+"="+value+expires+"; path=/"; +} + +function load_hidden () +{ + var ca = document.cookie.split(';'); + for (var i=0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf('display:') == 0) { + var colon = c.indexOf(':'); + var equal = c.indexOf('='); + + var id = c.substring (colon + 1, equal); + var value = c.substring (equal + 1); + + document.getElementById (id).style.display = value; + } + } +} + +function show_hide (id) +{ + var element = document.getElementById (id + '-children'); + if (element.style.display == "none") { + element.style.display = "block"; + createCookie ('display:' + id + '-children', "block", 1000); + } else { + element.style.display = "none"; + createCookie ('display:' + id + '-children', "none", 1000); + } +} + +window.addEventListener("DOMContentLoaded",load_hidden,false); + function submit_search () { window.location = "x-yelp-search:" + document.getElementById ('search-entry').value; Index: src/yelp-toc-pager.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-toc-pager.c,v retrieving revision 1.51 diff -u -p -r1.51 yelp-toc-pager.c --- src/yelp-toc-pager.c 21 Oct 2005 01:47:56 -0000 1.51 +++ src/yelp-toc-pager.c 31 Oct 2005 19:05:15 -0000 @@ -873,7 +873,7 @@ process_xslt (YelpTocPager *pager) YelpTocPagerPriv *priv = pager->priv; gchar **params = NULL; gint params_i = 0; - gint params_max = 10; + gint params_max = 14; GtkIconInfo *info; GtkIconTheme *theme = (GtkIconTheme *) yelp_settings_get_icon_theme (); @@ -899,8 +899,8 @@ process_xslt (YelpTocPager *pager) params = g_new0 (gchar *, params_max); yelp_settings_params (¶ms, ¶ms_i, ¶ms_max); - if ((params_i + 10) >= params_max - 1) { - params_max += 10; + if ((params_i + 14) >= params_max - 1) { + params_max += 14; params = g_renew (gchar *, params, params_max); } @@ -914,6 +914,11 @@ process_xslt (YelpTocPager *pager) gtk_icon_info_get_base_size (info)); gtk_icon_info_free (info); } + + params[params_i++] = "yelp.javascript"; + params[params_i++] = g_strdup_printf ("\"%s\"", DATADIR "/yelp/yelp.js"); + params[params_i++] = "yelp.topimage"; + params[params_i++] = g_strdup_printf ("\"%s\"", DATADIR "/yelp/icons/help-title.png"); params[params_i++] = NULL; Index: stylesheets/toc2html.xsl =================================================================== RCS file: /cvs/gnome/yelp/stylesheets/toc2html.xsl,v retrieving revision 1.11 diff -u -p -r1.11 toc2html.xsl --- stylesheets/toc2html.xsl 11 May 2005 18:19:20 -0000 1.11 +++ stylesheets/toc2html.xsl 31 Oct 2005 19:05:15 -0000 @@ -5,9 +5,13 @@ extension-element-prefixes="yelp" version="1.0"> + + + + @@ -35,133 +39,181 @@ <xsl:value-of select="title[1]"/> - + - + + + + + +

+ + + + +

+
+ + + +
+ + + + + + +
+
    + + +
  • + +
  • +
    +
+
+
+ +
+
+ + +
+ + + + + + + + +
+
+ +
+
+
+
+
+
-
-

- - - - -

-
-
+
+ + + +
- -
- -
-
- -
-
- - -
- - - - - - - - -
-
- -
-
-
-
-
+ + +
+ + + + + + + + + --=-9ORf8ZtCi7oCmctsklwp-- From dmalcolm@redhat.com Thu Oct 13 02:01:11 2005 Return-Path: X-Original-To: gnome-doc-devel-list@gnome.org Delivered-To: gnome-doc-devel-list@gnome.org Received: from localhost (unknown [127.0.0.1]) by menubar.gnome.org (Postfix) with ESMTP id 56E423B0B00; Thu, 13 Oct 2005 02:01:11 -0400 (EDT) Received: from menubar.gnome.org ([127.0.0.1]) by localhost (menubar.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 16458-05; Thu, 13 Oct 2005 02:01:09 -0400 (EDT) Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31]) by menubar.gnome.org (Postfix) with ESMTP id DAF5B3B0AAA; Thu, 13 Oct 2005 02:01:08 -0400 (EDT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j9D618OG002300; Thu, 13 Oct 2005 02:01:08 -0400 Received: from mail.boston.redhat.com (mail.boston.redhat.com [172.16.76.12]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j9D618V26677; Thu, 13 Oct 2005 02:01:08 -0400 Received: from vpn83-129.boston.redhat.com (vpn83-129.boston.redhat.com [172.16.83.129]) by mail.boston.redhat.com (8.12.8/8.12.8) with ESMTP id j9D617fb012113; Thu, 13 Oct 2005 02:01:07 -0400 From: Dave Malcolm To: gnome-doc-devel-list@gnome.org Content-Type: multipart/mixed; boundary="=-CUDRMlybahnrJETYCNyI" Date: Thu, 13 Oct 2005 02:05:26 -0400 Message-Id: <1129183526.6821.14.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.4 (2.0.4-6) X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Status: No, score=-1.9 tagged_above=-999 required=2 tests=[BAYES_00, HTML_MESSAGE] X-Spam-Score: -1.9 X-Spam-Level: Cc: dogtail-devel-list@gnome.org Subject: Script for generating parodies of bad documentation X-BeenThere: gnome-doc-devel-list@gnome.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about development of yelp, gnome-doc-utils, and other documentation-related utilities" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2005 06:01:11 -0000 --=-CUDRMlybahnrJETYCNyI Content-Type: text/plain Content-Transfer-Encoding: 7bit I've been a bad, bad, person and written this dogtail [1] script: http://cvs.gnome.org/viewcvs/dogtail/examples/no-help-at-all.py?view=markup You pass it the accessible name of a running application, and it scours that application's GUI, reading it back to you in DocBook form. The idea is (i) to parody some of the unhelpful user documentation I've seen over the years - please don't write documentation that looks like this! This was inspired in part by reading Shaun McCance's Project Mallard notes here: http://www.gnome.org/~shaunm/quack/mallard.xml (ii) to provide a source of test data for help viewers, such as Yelp, and for stylesheet authors Attached is an example of the output when I pointed the script at gedit. My apologies... [1] http://people.redhat.com/zcerza/dogtail/index.html --=-CUDRMlybahnrJETYCNyI Content-Disposition: attachment; filename=not-the-gedit-manual.xml Content-Type: text/xml; name=not-the-gedit-manual.xml; charset=UTF-8 Content-Transfer-Encoding: 7bit
The Totally Definitive No-Nonsense Unhelpful Complete Guide to <application>gedit</application> for Mannequins in 40 Days - Unleashed! Introduction Do not take these instructions seriously. They are a parody of unhelpful help files found on many computer systems, and were autogenerated by no-help-at-all You can start gedit by opening a terminal and typing the gedit command. The <guimenu>File</guimenu> menu Use the File menu to work with files Newing a file To new a file, choose File > New Open...ing a file To open... a file, choose File > Open... Open Location...ing a file To open location... a file, choose File > Open Location... Saveing a file To save a file, choose File > Save Save As...ing a file To save as... a file, choose File > Save As... Reverting a file To revert a file, choose File > Revert Page Setuping a file To page setup a file, choose File > Page Setup Print Preview...ing a file To print preview... a file, choose File > Print Preview... Print...ing a file To print... a file, choose File > Print... 1. No-Help-At-All.Pying a file To 1. no-help-at-all.py a file, choose File > 1. no-help-at-all.py 2. Tmp.Xmling a file To 2. tmp.xml a file, choose File > 2. tmp.xml 3. Tree.Pying a file To 3. tree.py a file, choose File > 3. tree.py 4. Test-Docbook.Xmling a file To 4. test-docbook.xml a file, choose File > 4. test-docbook.xml 5. Abiword-Test.Pying a file To 5. abiword-test.py a file, choose File > 5. abiword-test.py Closeing a file To close a file, choose File > Close Quiting a file To quit a file, choose File > Quit The <guimenu>Edit</guimenu> menu Use the Edit menu to work with edits Undoing a edit To undo a edit, choose Edit > Undo Redoing a edit To redo a edit, choose Edit > Redo Cuting a edit To cut a edit, choose Edit > Cut Copying a edit To copy a edit, choose Edit > Copy Pasteing a edit To paste a edit, choose Edit > Paste Deleteing a edit To delete a edit, choose Edit > Delete Select Alling a edit To select all a edit, choose Edit > Select All Preferencesing a edit To preferences a edit, choose Edit > Preferences The <guimenu>View</guimenu> menu Use the View menu to work with views The <guimenu>Customise Toolbar</guimenu> menu Use the Customise Toolbar menu to work with customise toolbars The <guimenu>Highlight Mode</guimenu> menu Use the Highlight Mode menu to work with highlight modes The <guimenu>Sources</guimenu> menu Use the Sources menu to work with sourcess The <guimenu>Scripts</guimenu> menu Use the Scripts menu to work with scriptss The <guimenu>Markup</guimenu> menu Use the Markup menu to work with markups The <guimenu>Others</guimenu> menu Use the Others menu to work with otherss The <guimenu>Search</guimenu> menu Use the Search menu to work with searchs Find...ing a search To find... a search, choose Search > Find... Find Nexting a search To find next a search, choose Search > Find Next Find Previousing a search To find previous a search, choose Search > Find Previous Replace...ing a search To replace... a search, choose Search > Replace... Go To Line...ing a search To go to line... a search, choose Search > Go to Line... The <guimenu>Tools</guimenu> menu Use the Tools menu to work with toolss Check Spellinging a tools To check spelling a tools, choose Tools > Check Spelling Set Languageing a tools To set language a tools, choose Tools > Set Language The <guimenu>Documents</guimenu> menu Use the Documents menu to work with documentss Save Alling a documents To save all a documents, choose Documents > Save All Close Alling a documents To close all a documents, choose Documents > Close All Move To New Windowing a documents To move to new window a documents, choose Documents > Move to New Window Gedit-Test-Results.Txting a documents To gedit-test-results.txt a documents, choose Documents > gedit-test-results.txt Test-Docbook.Xmling a documents To test-docbook.xml a documents, choose Documents > test-docbook.xml Tmp.Xmling a documents To tmp.xml a documents, choose Documents > tmp.xml Tree.Pying a documents To tree.py a documents, choose Documents > tree.py No-Help-At-All.Pying a documents To no-help-at-all.py a documents, choose Documents > no-help-at-all.py The <guimenu>Help</guimenu> menu Use the Help menu to work with helps Contentsing a help To contents a help, choose Help > Contents Abouting a help To about a help, choose Help > About
--=-CUDRMlybahnrJETYCNyI-- From zcerza@redhat.com Thu Oct 13 10:51:47 2005 Return-Path: X-Original-To: gnome-doc-devel-list@gnome.org Delivered-To: gnome-doc-devel-list@gnome.org Received: from localhost (unknown [127.0.0.1]) by menubar.gnome.org (Postfix) with ESMTP id 6EF7E3B0906; Thu, 13 Oct 2005 10:51:47 -0400 (EDT) Received: from menubar.gnome.org ([127.0.0.1]) by localhost (menubar.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 20683-08; Thu, 13 Oct 2005 10:51:45 -0400 (EDT) Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31]) by menubar.gnome.org (Postfix) with ESMTP id 320173B0697; Thu, 13 Oct 2005 10:51:45 -0400 (EDT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j9DEpihX003828; Thu, 13 Oct 2005 10:51:44 -0400 Received: from mail.boston.redhat.com (mail.boston.redhat.com [172.16.76.12]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j9DEpiV15189; Thu, 13 Oct 2005 10:51:44 -0400 Received: from [172.16.83.8] (dhcp83-8.boston.redhat.com [172.16.83.8]) by mail.boston.redhat.com (8.12.8/8.12.8) with ESMTP id j9DEphfb012648; Thu, 13 Oct 2005 10:51:43 -0400 Message-ID: <434E7489.9090503@redhat.com> Date: Thu, 13 Oct 2005 10:51:53 -0400 From: Zack Cerza User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051010) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dave Malcolm References: <1129183526.6821.14.camel@localhost.localdomain> In-Reply-To: <1129183526.6821.14.camel@localhost.localdomain> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Status: No, score=-4.9 tagged_above=-999 required=2 tests=[BAYES_00] X-Spam-Score: -4.9 X-Spam-Level: X-Mailman-Approved-At: Thu, 13 Oct 2005 10:53:13 -0400 Cc: dogtail-devel-list@gnome.org, gnome-doc-devel-list@gnome.org Subject: Re: dogtail-devel Script for generating parodies of bad documentation X-BeenThere: gnome-doc-devel-list@gnome.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about development of yelp, gnome-doc-utils, and other documentation-related utilities" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2005 14:51:47 -0000 Dave Malcolm wrote: > I've been a bad, bad, person and written this dogtail [1] script: > http://cvs.gnome.org/viewcvs/dogtail/examples/no-help-at-all.py?view=markup > > You pass it the accessible name of a running application, and it scours > that application's GUI, reading it back to you in DocBook form. > > The idea is (i) to parody some of the unhelpful user documentation I've > seen over the years - please don't write documentation that looks like > this! This was inspired in part by reading Shaun McCance's Project > Mallard notes here: http://www.gnome.org/~shaunm/quack/mallard.xml > (ii) to provide a source of test data for help viewers, such as Yelp, > and for stylesheet authors > > Attached is an example of the output when I pointed the script at gedit. > My apologies... > > [1] http://people.redhat.com/zcerza/dogtail/index.html Hah. That's awesome. You evil, evil man. Zack From ash@contact.bg Fri Oct 21 04:41:03 2005 Return-Path: X-Original-To: gnome-doc-devel-list@gnome.org Delivered-To: gnome-doc-devel-list@gnome.org Received: from localhost (unknown [127.0.0.1]) by menubar.gnome.org (Postfix) with ESMTP id 06F043B4F7B; Fri, 21 Oct 2005 04:41:03 -0400 (EDT) Received: from menubar.gnome.org ([127.0.0.1]) by localhost (menubar.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 20510-04; Fri, 21 Oct 2005 04:41:01 -0400 (EDT) Received: from mail.rightnet.net (palpatine.rightnet.net [62.204.159.2]) by menubar.gnome.org (Postfix) with ESMTP id C9AF53B4F79; Fri, 21 Oct 2005 04:41:00 -0400 (EDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.rightnet.net (Postfix) with ESMTP id 0F6B01802A3; Fri, 21 Oct 2005 11:39:59 +0300 (EEST) Received: from mail.rightnet.net ([127.0.0.1]) by localhost (palpatine [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 14225-09; Fri, 21 Oct 2005 11:39:56 +0300 (EEST) Received: from [172.29.69.70] (unknown [172.29.69.70]) by mail.rightnet.net (Postfix) with ESMTP id 31A5E180271; Fri, 21 Oct 2005 11:39:56 +0300 (EEST) From: Alexander Shopov To: gnome-doc-list@gnome.org Content-Type: text/plain Date: Fri, 21 Oct 2005 11:42:03 +0300 Message-Id: <1129884123.18684.10.camel@kochinka.spectrum.local> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at rightnet.net X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Status: No, score=-4.9 tagged_above=-999 required=2 tests=[BAYES_00] X-Spam-Score: -4.9 X-Spam-Level: Cc: gnome-doc-devel-list@gnome.org Subject: Introduction of Alexander Shopov X-BeenThere: gnome-doc-devel-list@gnome.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about development of yelp, gnome-doc-utils, and other documentation-related utilities" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Oct 2005 08:41:03 -0000 Hi everybody, My name is Alexander Shopov and I am the leader of the Bulgarian Gnome translation team. We have already finished the translation of the core interface and we are gradually starting to look at the documentation. In the following months I expect us to finish the tranlastion of the documentation of several modules and converting the ready translations to the Gnome docbook format. I have subscribed to gnome-doc-list to be in touch with the documentation changes and I have subscribed to gnome-doc-devel-list to look at the changes in the tools. I hope to be able to make some commits during next week but I cannot promise that. I have still not read everything on Gnome site about documentation translations and if there are resources I need to take in mind i'll be thankful if you lead me to them. Best regards: al_shopov From sri@aracnet.com Fri Oct 21 12:27:37 2005 Return-Path: X-Original-To: gnome-doc-devel-list@gnome.org Delivered-To: gnome-doc-devel-list@gnome.org Received: from localhost (unknown [127.0.0.1]) by menubar.gnome.org (Postfix) with ESMTP id 3B8AC3B0F74; Fri, 21 Oct 2005 12:27:36 -0400 (EDT) Received: from menubar.gnome.org ([127.0.0.1]) by localhost (menubar.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 23012-05; Fri, 21 Oct 2005 12:27:33 -0400 (EDT) Received: from onyx.spiritone.com (onyx.spiritone.com [216.99.193.114]) by menubar.gnome.org (Postfix) with ESMTP id D1AEA3B0F31; Fri, 21 Oct 2005 12:26:49 -0400 (EDT) Received: from onyx.spiritone.com (onyx.spiritone.com [127.0.0.1]) by onyx.spiritone.com (8.12.8/8.12.8) with ESMTP id j9LGQhBC018667; Fri, 21 Oct 2005 09:26:43 -0700 Received: (from sri@localhost) by onyx.spiritone.com (8.12.8/8.12.8/Submit) id j9LGQgxr018665; Fri, 21 Oct 2005 09:26:42 -0700 Date: Fri, 21 Oct 2005 09:26:42 -0700 From: Sriram Ramkrishna To: Alexander Shopov Message-ID: <20051021162642.GI30669@aracnet.com> References: <1129884123.18684.10.camel@kochinka.spectrum.local> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1129884123.18684.10.camel@kochinka.spectrum.local> User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Status: No, score=-4.9 tagged_above=-999 required=2 tests=[BAYES_00] X-Spam-Score: -4.9 X-Spam-Level: Cc: gnome-doc-devel-list@gnome.org, gnome-doc-list@gnome.org Subject: Re: Introduction of Alexander Shopov X-BeenThere: gnome-doc-devel-list@gnome.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about development of yelp, gnome-doc-utils, and other documentation-related utilities" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Oct 2005 16:27:37 -0000 Welcome, Al! :) sri On Fri, Oct 21, 2005 at 11:42:03AM +0300, Alexander Shopov wrote: > Hi everybody, > > My name is Alexander Shopov and I am the leader of the Bulgarian Gnome > translation team. We have already finished the translation of the core > interface and we are gradually starting to look at the documentation. > In the following months I expect us to finish the tranlastion of the > documentation of several modules and converting the ready translations > to the Gnome docbook format. > I have subscribed to gnome-doc-list to be in touch with the > documentation changes and I have subscribed to gnome-doc-devel-list to > look at the changes in the tools. > I hope to be able to make some commits during next week but I cannot > promise that. > I have still not read everything on Gnome site about documentation > translations and if there are resources I need to take in mind i'll be > thankful if you lead me to them. > > Best regards: > al_shopov > > _______________________________________________ > gnome-doc-list mailing list > gnome-doc-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gnome-doc-list -- From shaunm@gnome.org Sat Oct 22 15:00:44 2005 Return-Path: X-Original-To: gnome-doc-devel-list@gnome.org Delivered-To: gnome-doc-devel-list@gnome.org Received: from localhost (unknown [127.0.0.1]) by menubar.gnome.org (Postfix) with ESMTP id CFB8A3B314F; Sat, 22 Oct 2005 15:00:44 -0400 (EDT) Received: from menubar.gnome.org ([127.0.0.1]) by localhost (menubar.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 18056-01; Sat, 22 Oct 2005 15:00:43 -0400 (EDT) Received: from mx1.wolfram.com (relay.wolfram.com [140.177.205.5]) by menubar.gnome.org (Postfix) with ESMTP id B4FEF3B3148; Sat, 22 Oct 2005 15:00:42 -0400 (EDT) Received: from cornholio.housenet.network (12-208-67-103.client.insightBB.com [12.208.67.103]) (authenticated bits=0) by mx1.wolfram.com (8.12.11/8.12.11) with ESMTP id j9MJ0fZs004145 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT); Sat, 22 Oct 2005 14:00:41 -0500 From: Shaun McCance To: gnome-doc-devel-list@gnome.org, gnome-i18n@gnome.org Content-Type: text/plain Date: Sat, 22 Oct 2005 14:00:40 -0500 Message-Id: <1130007641.17733.21.camel@cornholio.housenet.network> Mime-Version: 1.0 X-Mailer: Evolution 2.4.0 Content-Transfer-Encoding: 7bit Received-SPF: pass (mx1.wolfram.com: authenticated connection) receiver=mx1.wolfram.com; client-ip=12.208.67.103; helo=cornholio.housenet.network; envelope-from=shaunm@gnome.org; x-software=spfmilter 0.97 http://www.acme.com/software/spfmilter/ with libspf2-1.0.0; X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Status: No, score=-4.8 tagged_above=-999 required=2 tests=[BAYES_00, RCVD_IN_SORBS] X-Spam-Score: -4.8 X-Spam-Level: Cc: Subject: Digit formatters in gnome-doc-utils X-BeenThere: gnome-doc-devel-list@gnome.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about development of yelp, gnome-doc-utils, and other documentation-related utilities" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Oct 2005 19:00:45 -0000 Currently, to format the number for a section, the section.number localization is called up, which might look like this: . This formats the parent number, whatever that may be, and the "digit" for the section, which is just the position of that section in its parent. The digit formatting is then controlled by the section.digit localization, which is just a single-character thing saying what numbering system to use to format it. If a section is a top-level, the section.number localization is bypassed and section.digit is called directly. The problem is that at least the French team needs to do formatting on the digit: http://bugzilla.gnome.org/show_bug.cgi?id=315190 This particular case involves wrapping the digit in some markup, which you can't do reliably with the current system. You could wrap the call to in the number formatter, but that won't help you when the number formatter is bypassed for top-level things. Here's some possible solutions: 1) Get rid of the single character digit things, and instead put attributes on any call to digit. This, you'd have something like this: . I would then remove the current digit formatter localizations, but I'd have to add localizations for top-level things. Net result is the same number of localized strings. This could also potentially be a tad faster, as template depth gets reduced. 2) Do the same thing, but instead of attributes, use special named elements, like so: . So we'd have digitI, digiti, digitA, digita, and digit1. This annoys me, though it could potentially emphasize more the need to mark the formatter. It has the same advantages as the first option. 3) Keep number formatters just as they are, but turn digit formatters into things that can have markup. So section.number would still just be . But section.digit would become Where n would have to become some meaningful element name. This has the advantage that only digit formatters have to be changed, and the change can be done automatically. I could even adjust all the PO files, if translators wanted me to. The other advantage is that you still only need to specify the digit formatting in a single place. It does, on the whole, seem cleaner to me. On the other hand, it means I have to come up with yet another element name, I think. Due to the way XSLT works, and the way my i18n system works in XSLT, I probably can't just re-use "digit" or "number" as element names here. And I'm sort of at a loss for another element name to convey the meaning. Thoughts? -- Shaun From clahey@ximian.com Mon Oct 31 14:23:37 2005 Return-Path: X-Original-To: gnome-doc-devel-list@gnome.org Delivered-To: gnome-doc-devel-list@gnome.org Received: from localhost (unknown [127.0.0.1]) by menubar.gnome.org (Postfix) with ESMTP id B83523B27A2 for ; Mon, 31 Oct 2005 14:23:37 -0500 (EST) Received: from menubar.gnome.org ([127.0.0.1]) by localhost (menubar.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 28212-03 for ; Mon, 31 Oct 2005 14:23:35 -0500 (EST) Received: from peabody.ximian.com (peabody.ximian.com [130.57.169.10]) by menubar.gnome.org (Postfix) with ESMTP id 610F53B279E for ; Mon, 31 Oct 2005 14:23:33 -0500 (EST) Received: (qmail 18517 invoked from network); 31 Oct 2005 19:23:32 -0000 Received: from outbound.ximian.com (HELO rigger.boston.ximian.com) (130.57.170.250) by peabody.ximian.com with SMTP; 31 Oct 2005 19:23:32 -0000 From: Christopher James Lahey To: gnome-doc-devel-list@gnome.org Content-Type: multipart/mixed; boundary="=-9ORf8ZtCi7oCmctsklwp" Date: Mon, 31 Oct 2005 14:25:26 -0500 Message-Id: <1130786726.5961.28.camel@rigger.boston.ximian.com> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Status: No, score=1.439 tagged_above=-999 required=2 tests=[BAYES_00, HTML_MESSAGE, HTML_TITLE_EMPTY, TW_BG, TW_BX, TW_GT, TW_IB] X-Spam-Score: 1.439 X-Spam-Level: * X-Mailman-Approved-At: Mon, 31 Oct 2005 16:59:07 -0500 Subject: yelp patches X-BeenThere: gnome-doc-devel-list@gnome.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about development of yelp, gnome-doc-utils, and other documentation-related utilities" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2005 19:23:38 -0000 --=-9ORf8ZtCi7oCmctsklwp Content-Type: text/plain Content-Transfer-Encoding: 7bit I've been working on adding some features to yelp and wish to work on getting them upstreamed. Included are 4 yelp patches. The first, yelp-helpuri.patch, enables yelp to recognize help: uris as used by KDE. It will also find things in some gnome directories (with the same behavior as the patch I added to khelpcenter for SuSE a while back.) I've written up a standard, but it needs some discussion. This could go in as is to match with KDE. The second, yelp-libmenu.patch, causes yelp to use the menu system to generate its table of contents instead of using scrollkeeper. This will allow us to get rid of the installtime hit from scrollkeeper as well as make the help menu match the Applications menu. This is just reading from a .menu file, so we can have a help.menu file that includes applications.menu so we can include stuff not in the menus. The third, yelp-printing.patch, adds printing support to yelp. It will print either the page or the whole document. The fourth, yelp-toctree.patch, displays the table of contents as a tree on a single page instead of across multiple pages. All 4 patches can be applied to the same tree. Known bugs: - Printing the whole document leaks some memory because I'm not sure how to know when the printing is done so I can free the temporary mozilla window. - Having the table of contents tree remember which nodes are open across sessions requires yelp_html_initialize from yelp-printing.patch, but I didn't want to have the patches conflict too much. Enjoy, Chris --=-9ORf8ZtCi7oCmctsklwp Content-Disposition: attachment; filename=yelp-helpuri.patch Content-Type: text/x-patch; name=yelp-helpuri.patch; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 7bit Index: src/yelp-utils.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-utils.c,v retrieving revision 1.26 diff -u -p -r1.26 yelp-utils.c --- src/yelp-utils.c 28 Oct 2005 20:37:37 -0000 1.26 +++ src/yelp-utils.c 31 Oct 2005 19:10:29 -0000 @@ -68,6 +68,7 @@ struct _YelpDocInfo { static YelpDocType get_doc_type (gchar *uri); static gchar * convert_ghelp_uri (gchar *uri); +static gchar * convert_help_uri (gchar *uri); static gchar * convert_man_uri (gchar *uri); static gchar * convert_info_uri (gchar *uri); @@ -78,7 +79,7 @@ yelp_doc_info_new (const gchar *uri) YelpDocInfo *doc; gchar *doc_uri = NULL; gchar *full_uri = NULL; - YelpDocType doc_type; + YelpDocType doc_type = YELP_DOC_TYPE_EXTERNAL; YelpURIType uri_type; gchar *cur; @@ -106,6 +107,27 @@ yelp_doc_info_new (const gchar *uri) doc_type = get_doc_type (doc_uri); uri_type = YELP_URI_TYPE_GHELP; } + else if (g_str_has_prefix (full_uri, "help:")) { + doc_uri = convert_help_uri (full_uri); + if (doc_uri) + doc_type = get_doc_type (doc_uri); +#if 0 + if ((cur = strchr (doc_uri, '#'))) { + char *temp; + + if (!strchr (full_uri, '#')) { + temp = full_uri; + full_uri = g_strconcat (full_uri, "#", cur + 1, NULL); + g_free (temp); + } + + temp = doc_uri; + doc_uri = g_strndup (doc_uri, cur - doc_uri); + g_free (temp); + } +#endif + uri_type = YELP_URI_TYPE_HELP; + } else if (g_str_has_prefix (full_uri, "man:")) { doc_uri = convert_man_uri (full_uri); doc_type = YELP_DOC_TYPE_MAN; @@ -117,7 +139,7 @@ yelp_doc_info_new (const gchar *uri) uri_type = YELP_URI_TYPE_INFO; } else if (g_str_has_prefix (full_uri, "x-yelp-toc:")) { - doc_uri = g_strdup ("file://" DATADIR "/yelp/toc.xml"); + doc_uri = g_strdup ("file://" DATADIR "/yelp/xslt/toc2html.xsl"); doc_type = YELP_DOC_TYPE_TOC; uri_type = YELP_URI_TYPE_TOC; } @@ -189,7 +211,7 @@ yelp_doc_info_get (const gchar *uri) if (!doc) { doc = yelp_doc_info_new (doc_uri); if (doc && doc->type != YELP_DOC_TYPE_EXTERNAL) { - YelpDocInfo *old_doc; + YelpDocInfo *old_doc = NULL; for (i = 0; i < doc->num_uris; i++) { old_doc = g_hash_table_lookup (doc_info_table, @@ -478,6 +500,18 @@ yelp_uri_get_fragment (const gchar *uri) if (*(++cur) != '\0') frag_id = g_strdup (cur); + if (g_str_has_prefix (uri, "help:")) + if (g_str_has_suffix (uri, ".html")) { + YelpDocInfo *doc = yelp_doc_info_get (uri); + char *file_uri; + file_uri = yelp_doc_info_get_uri (doc, NULL, YELP_URI_TYPE_FILE); + if (!g_str_has_suffix (file_uri, ".html")) { + cur = strrchr (uri, '/'); + frag_id = g_strndup (cur + 1, strlen (cur + 1) - strlen (".html")); + } + g_free (file_uri); + } + if ((cur = strchr (uri, '#'))) if (*(++cur) != '\0') { if (frag_id) @@ -520,7 +554,7 @@ get_doc_type (gchar *uri) if (mime_type == NULL) return YELP_DOC_TYPE_ERROR; - if (g_str_equal (mime_type, "text/xml")) + if (g_str_equal (mime_type, "text/xml") || g_str_equal (mime_type, "application/docbook+xml")) type = YELP_DOC_TYPE_DOCBOOK_XML; else if (g_str_equal (mime_type, "text/sgml")) type = YELP_DOC_TYPE_DOCBOOK_SGML; @@ -567,6 +601,161 @@ yelp_doc_info_add_uri (YelpDocInfo *doc_ /******************************************************************************/ /** Convert fancy URIs to file URIs *******************************************/ + +static gchar * +help_uri_check_file (gchar *filename, gchar *reference) { + d(g_print ("Checking %s\n", filename)); + if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) { + gchar *full_uri; + if (reference) { + full_uri = g_strconcat ("file://", filename, NULL, "#", reference, NULL); + } else { + full_uri = g_strconcat ("file://", filename, NULL); + } + + return full_uri; + } + + return NULL; +} + +static gchar * +help_uri_check_dir (gchar *path, gchar *identifier, gchar *reference) +{ + gchar *result; + + gchar *full_path; + gchar *full_identifier; + + result = help_uri_check_file (path, reference); + if (result) + return result; + + full_path = g_build_filename (path, "index.docbook", NULL); + result = help_uri_check_file (full_path, reference); + g_free (full_path); + if (result) + return result; + + full_identifier = g_strconcat (identifier, ".xml", NULL); + full_path = g_build_filename (path, full_identifier, NULL); + result = help_uri_check_file (full_path, reference); + g_free (full_path); + g_free (full_identifier); + if (result) + return result; + + return NULL; +} + +static gchar * +help_uri_search (gchar *path, gchar *identifier, char *reference) +{ + gchar *result; + + result = help_uri_check_dir (path, identifier, reference); + if (result) + return result; + + if (strlen (path) > 5 && ! strcmp (path + strlen (path) - 5, ".html")) { + gchar *slash = strrchr (path, '/'); + if (slash != NULL) { + gchar *shortened = g_strndup (path, slash - path); + gchar *shortened_reference = g_strndup (slash + 1, strlen (slash + 1) - 5); + result = help_uri_check_dir (shortened, identifier, reference ? reference : shortened_reference); + g_free (reference); + g_free (shortened); + if (result) + return result; + } + } + return NULL; +} + +static gchar * +help_uri_expand_datadirs (gchar *path, gchar *identifier, char *reference) +{ + char const* const* data_dirs = g_get_system_data_dirs (); + int i; + char *result; + for (i = 0; data_dirs[i]; i++) { + char *full_path = g_build_filename (data_dirs[i], path, NULL); + result = help_uri_search (full_path, identifier, reference); + g_free (full_path); + if (result) + return result; + } + return NULL; +} + +static gchar * +convert_help_uri (gchar *uri) +{ + gchar *path; + gchar *file_name = NULL; + const gchar * const * langs; + gchar *result = NULL; + gchar *full_path; + int i; + gchar *reference; + + if ((path = strchr(uri, ':'))) + path++; + else + return NULL; + + while (*path == '/') + path++; + + path = g_strdup (path); + + reference = strchr (path, '#'); + if (reference) { + *reference = 0; + reference ++; + } + + /* This isn't the filename so much as the rest of the path after the first bit of the path. */ + file_name = strchr (path, '/'); + if (file_name) { + *file_name = 0; + file_name ++; + } else { + file_name = ""; + } + + langs = g_get_language_names (); + + for (i = 0; langs[i] != NULL; i++) { + full_path = g_strdup_printf ("/gnome/help/%s/%s/%s", path, langs[i], file_name); + help_uri_expand_datadirs (full_path, path, reference); + g_free (full_path); + if (result) + goto end; + + full_path = g_strdup_printf ("/doc/HTML/%s/%s/%s", langs[i], path, file_name); + help_uri_expand_datadirs (full_path, path, reference); + g_free (full_path); + if (result) + goto end; + } + + full_path = g_strdup_printf ("/gnome/help/%s/C/%s", path, file_name); + result = help_uri_expand_datadirs (full_path, path, reference); + g_free (full_path); + if (result) + goto end; + + full_path = g_strdup_printf ("/doc/HTML/en/%s/%s", path, file_name); + result = help_uri_expand_datadirs (full_path, path, reference); + g_free (full_path); + if (result) + goto end; + + end: + g_free (path); + return result; +} static gchar * locate_file_lang (gchar *path, gchar *file, const gchar *lang) Index: src/yelp-utils.h =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-utils.h,v retrieving revision 1.12 diff -u -p -r1.12 yelp-utils.h --- src/yelp-utils.h 28 Oct 2005 20:37:37 -0000 1.12 +++ src/yelp-utils.h 31 Oct 2005 19:10:29 -0000 @@ -67,6 +67,7 @@ typedef enum { YELP_URI_TYPE_TOC = 1 << 4, YELP_URI_TYPE_EXTERNAL = 1 << 5, YELP_URI_TYPE_SEARCH = 1 << 6, + YELP_URI_TYPE_HELP = 1 << 7, YELP_URI_TYPE_NO_FILE = YELP_URI_TYPE_GHELP | @@ -74,9 +75,10 @@ typedef enum { YELP_URI_TYPE_INFO | YELP_URI_TYPE_TOC | YELP_URI_TYPE_EXTERNAL | + YELP_URI_TYPE_HELP | YELP_URI_TYPE_SEARCH, YELP_URI_TYPE_ANY = - YELP_URI_TYPE_FILE | + YELP_URI_TYPE_FILE | YELP_URI_TYPE_NO_FILE } YelpURIType; --=-9ORf8ZtCi7oCmctsklwp Content-Disposition: attachment; filename=yelp-libmenu.patch Content-Type: text/x-patch; name=yelp-libmenu.patch; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 7bit Index: configure.in =================================================================== RCS file: /cvs/gnome/yelp/configure.in,v retrieving revision 1.192 diff -u -p -r1.192 configure.in --- configure.in 28 Oct 2005 20:37:36 -0000 1.192 +++ configure.in 31 Oct 2005 18:44:10 -0000 @@ -63,6 +63,7 @@ PKG_CHECK_MODULES(YELP, libxml-2.0 >= 2.6.5 libxslt >= 1.1.4 libexslt >= 0.8.1 + libgnome-menu >= 2.11.1 ]) AC_SUBST([YELP_CFLAGS]) AC_SUBST([YELP_LIBS]) Index: src/yelp-toc-pager.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-toc-pager.c,v retrieving revision 1.51 diff -u -p -r1.51 yelp-toc-pager.c --- src/yelp-toc-pager.c 21 Oct 2005 01:47:56 -0000 1.51 +++ src/yelp-toc-pager.c 31 Oct 2005 18:44:10 -0000 @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,12 @@ #include "yelp-toc-pager.h" #include "yelp-utils.h" +#define GMENU_I_KNOW_THIS_IS_UNSTABLE +#include + +#define DESKTOP_ENTRY_GROUP "Desktop Entry" +#define KDE_DESKTOP_ENTRY_GROUP "KDE Desktop Entry" + #ifdef YELP_DEBUG #define d(x) x #else @@ -96,6 +103,9 @@ struct _YelpTocPagerPriv { xsltStylesheetPtr stylesheet; xsltTransformContextPtr transformContext; + + GMenuTree *libmenu_tree; + GSList *libmenu_stack; }; struct _YelpListing { @@ -125,10 +135,14 @@ GtkTreeModel * toc_pager_get_secti static gboolean toc_process_pending (YelpTocPager *pager); -static gboolean process_read_menu (YelpTocPager *pager); +static gboolean process_libmenu (YelpTocPager *pager); +static gboolean process_libmenu_node (YelpTocPager *pager); static gboolean process_xslt (YelpTocPager *pager); +#ifdef ENABLE_SCROLLKEEPER +static gboolean process_read_menu (YelpTocPager *pager); static gboolean process_read_scrollkeeper (YelpTocPager *pager); static gboolean process_omf_pending (YelpTocPager *pager); +#endif #ifdef ENABLE_MAN static gboolean process_mandir_pending (YelpTocPager *pager); #endif @@ -137,11 +151,13 @@ static gboolean process_info_dir_pe static gboolean process_info_pending (YelpTocPager *pager); #endif +#ifdef ENABLE_SCROLLKEEPER static void toc_add_doc_info (YelpTocPager *pager, YelpDocInfo *doc_info); static void toc_remove_doc_info (YelpTocPager *pager, YelpDocInfo *doc_info); static void xml_trim_titles (xmlNodePtr node); +#endif static void xslt_yelp_document (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, @@ -213,6 +229,9 @@ toc_pager_init (YelpTocPager *pager) priv->cancel = 0; priv->pause_count = 0; priv->pending_func = NULL; + + priv->libmenu_tree = NULL; + priv->libmenu_stack = NULL; } static void @@ -320,7 +339,7 @@ toc_pager_process (YelpPager *pager) yelp_pager_set_state (pager, YELP_PAGER_STATE_RUNNING); g_signal_emit_by_name (pager, "start"); - priv->pending_func = (ProcessFunction) process_read_menu; + priv->pending_func = (ProcessFunction) process_libmenu; gtk_idle_add_priority (G_PRIORITY_LOW, (GtkFunction) toc_process_pending, @@ -351,10 +370,15 @@ toc_process_pending (YelpTocPager *pager gboolean readd; YelpTocPagerPriv *priv = pager->priv; static gpointer process_funcs[] = { + process_libmenu, + process_libmenu_node, + process_xslt, +#ifdef ENABLE_SCROLLKEEPER process_read_menu, process_read_scrollkeeper, process_omf_pending, process_xslt, +#endif #ifdef ENABLE_MAN process_mandir_pending, process_xslt, @@ -386,6 +410,204 @@ toc_process_pending (YelpTocPager *pager return FALSE; } +static void +set_icon (xmlNode *node, const char *icon) +{ + if (icon) { + GtkIconInfo *info; + GtkIconTheme *theme = + (GtkIconTheme *) yelp_settings_get_icon_theme (); + info = gtk_icon_theme_lookup_icon (theme, icon, 48, 0); + if (info) { + xmlNodePtr new = xmlNewChild (node, NULL, "icon", NULL); + xmlNewNsProp (new, NULL, "file", gtk_icon_info_get_filename (info)); + gtk_icon_info_free (info); + } + } +} + +typedef struct { + xmlNode *tree; + GSList *children; + GSList *iterator; + gboolean non_empty; +} LibmenuStackFrame; + +static void +push_stack_frame (YelpTocPager *pager, GMenuTreeDirectory *dir) +{ + LibmenuStackFrame *frame; + YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv; + + frame = g_new (LibmenuStackFrame, 1); + frame->iterator = frame->children = gmenu_tree_directory_get_contents (dir); + frame->non_empty = FALSE; + + frame->tree = xmlNewNode (NULL, "toc"); + xmlSetProp (frame->tree, "id", gmenu_tree_directory_get_menu_id (dir)); + xmlNewTextChild (frame->tree, NULL, "title", gmenu_tree_directory_get_name (dir)); + set_icon (frame->tree, gmenu_tree_directory_get_icon (dir)); + + priv->libmenu_stack = g_slist_prepend (priv->libmenu_stack, frame); +} + +static void +pop_stack_frame (YelpTocPager *pager) +{ + LibmenuStackFrame *frame; + YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv; + + frame = priv->libmenu_stack->data; + + g_slist_free (frame->children); + g_free (frame); + + priv->libmenu_stack = g_slist_delete_link (priv->libmenu_stack, priv->libmenu_stack); +} + +static GTimer *timer; +/* iterator points to next node to process and is incremented at the + end of the function. NULL means finished with this level. Parent + iterators are incremented before processing the child tree. */ +static gboolean +process_libmenu_node (YelpTocPager *pager) +{ + LibmenuStackFrame *frame; + GMenuTreeItem *item; + YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv; + gulong ms_start; + + + frame = priv->libmenu_stack->data; + + if (frame->iterator == NULL) { + if (priv->libmenu_stack->next) { + if (frame->non_empty) { + xmlNode *tree = frame->tree; + pop_stack_frame (pager); + + frame = priv->libmenu_stack->data; + xmlAddChild (frame->tree, tree); + frame->non_empty = TRUE; + } else { + xmlFreeNode (frame->tree); + pop_stack_frame(pager); + } + + return TRUE; + } else { + YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv; + xmlNode *title; + + priv->toc_doc = xmlNewDoc ("1.0"); + xmlSetProp (frame->tree, "id", "index"); + xmlDocSetRootElement (priv->toc_doc, frame->tree); + + for (title = frame->tree->children; title; title = title->next) { + if (g_str_equal (title->name, "title")) { + xmlNodeSetContent (title, _("Help Topics")); + break; + } + } + if (title == NULL) { + xmlNewTextChild (frame->tree, NULL, "title", _("Help Topics")); + } + + pop_stack_frame (pager); + + gmenu_tree_unref (priv->libmenu_tree); + priv->libmenu_tree = NULL; + + + + return FALSE; + } + } + + item = frame->iterator->data; + + switch (gmenu_tree_item_get_type (item)) { + case GMENU_TREE_ITEM_DIRECTORY: + { + push_stack_frame (pager, GMENU_TREE_DIRECTORY (item)); + } + break; + case GMENU_TREE_ITEM_ENTRY: + { + GMenuTreeEntry *entry = GMENU_TREE_ENTRY (item); + const char *path = gmenu_tree_entry_get_desktop_file_path (entry); + const char *desktop_entry_group; + char *docpath = NULL; + GKeyFile *key_file; + + key_file = g_key_file_new (); + + + if (!g_key_file_load_from_file (key_file, path, 0, NULL)) { + g_key_file_free (key_file); + break; + } + + if (g_key_file_has_group (key_file, DESKTOP_ENTRY_GROUP)) { + desktop_entry_group = DESKTOP_ENTRY_GROUP; + } else { + if (g_key_file_has_group (key_file, KDE_DESKTOP_ENTRY_GROUP)) { + desktop_entry_group = KDE_DESKTOP_ENTRY_GROUP; + } else { + g_key_file_free (key_file); + break; + } + } + + docpath = g_key_file_get_string (key_file, desktop_entry_group, "DocPath", NULL); + + if (docpath) { + xmlNode *new = xmlNewChild (frame->tree, NULL, "doc", NULL); + if (strchr(docpath, ':')) { + xmlNewNsProp (new, NULL, "href", docpath); + } else { + char *href = g_strdup_printf ("help:%s", docpath); + xmlNewNsProp (new, NULL, "href", href); + g_free (href); + } + + xmlNewTextChild (new, NULL, "title", gmenu_tree_entry_get_name (entry)); + xmlNewTextChild (new, NULL, "description", gmenu_tree_entry_get_comment (entry)); + set_icon (new, gmenu_tree_entry_get_icon (entry)); + + frame->non_empty = TRUE; + + g_free (docpath); + } + } + break; + default: + /* Ignore */ + break; + } + + + frame->iterator = frame->iterator->next; + return TRUE; +} + + +static gboolean +process_libmenu (YelpTocPager *pager) +{ + YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv; + + + priv->libmenu_tree = gmenu_tree_lookup ("applications.menu", + GMENU_TREE_FLAGS_NONE); + + push_stack_frame (pager, gmenu_tree_get_root_directory (priv->libmenu_tree)); + + return FALSE; +} + +#ifdef ENABLE_SCROLLKEEPER + /** process_read_scrollkeeper *************************************************/ static void @@ -559,6 +781,7 @@ process_omf_pending (YelpTocPager *pager else return FALSE; } +#endif #ifdef ENABLE_MAN static gboolean @@ -752,6 +975,7 @@ process_info_pending (YelpTocPager *page } #endif /* ENABLE_INFO */ +#ifdef ENABLE_SCROLLKEEPER static gboolean process_read_menu (YelpTocPager *pager) { @@ -796,17 +1020,7 @@ process_read_menu (YelpTocPager *pager) xml_trim_titles (node); icon = xmlGetProp (node, "icon"); - if (icon) { - GtkIconInfo *info; - GtkIconTheme *theme = - (GtkIconTheme *) yelp_settings_get_icon_theme (); - info = gtk_icon_theme_lookup_icon (theme, icon, 48, 0); - if (info) { - xmlNodePtr new = xmlNewChild (node, NULL, "icon", NULL); - xmlNewNsProp (new, NULL, "file", gtk_icon_info_get_filename (info)); - gtk_icon_info_free (info); - } - } + set_icon (node, icon); xmlFree (icon); } @@ -864,12 +1078,13 @@ process_read_menu (YelpTocPager *pager) return FALSE; } +#endif static gboolean process_xslt (YelpTocPager *pager) { GError *error = NULL; - xmlDocPtr outdoc; + xmlDocPtr outdoc = NULL; YelpTocPagerPriv *priv = pager->priv; gchar **params = NULL; gint params_i = 0; @@ -948,6 +1163,7 @@ process_xslt (YelpTocPager *pager) return FALSE; } +#ifdef ENABLE_SCROLLKEEPER static void toc_add_doc_info (YelpTocPager *pager, YelpDocInfo *doc_info) { @@ -1002,6 +1218,8 @@ toc_remove_doc_info (YelpTocPager *pager #endif } +#endif + static void xslt_yelp_document (xsltTransformContextPtr ctxt, xmlNodePtr node, @@ -1122,6 +1340,7 @@ xslt_yelp_document (xsltTransformContext xsltFreeStylesheet (style); } +#ifdef ENABLE_SCROLLKEEPER static void xml_trim_titles (xmlNodePtr node) { @@ -1171,3 +1390,4 @@ xml_trim_titles (xmlNodePtr node) } xmlFree (keep_lang); } +#endif --=-9ORf8ZtCi7oCmctsklwp Content-Disposition: attachment; filename=yelp-printing.patch Content-Type: text/x-patch; name=yelp-printing.patch; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit ? document.ps ? page.ps Index: data/ui/yelp-ui.xml =================================================================== RCS file: /cvs/gnome/yelp/data/ui/yelp-ui.xml,v retrieving revision 1.11 diff -u -p -r1.11 yelp-ui.xml --- data/ui/yelp-ui.xml 28 Oct 2005 20:37:37 -0000 1.11 +++ data/ui/yelp-ui.xml 31 Oct 2005 18:33:36 -0000 @@ -6,6 +6,9 @@ + + +
Index: data/ui/yelp.glade =================================================================== RCS file: /cvs/gnome/yelp/data/ui/yelp.glade,v retrieving revision 1.11 diff -u -p -r1.11 yelp.glade --- data/ui/yelp.glade 15 Oct 2005 16:34:55 -0000 1.11 +++ data/ui/yelp.glade 31 Oct 2005 18:33:36 -0000 @@ -19,6 +19,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True False @@ -102,6 +103,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -173,6 +178,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -200,7 +209,7 @@ True 0.5 1 - 0.9 + 0.899999976158 0.5 0 0 @@ -233,6 +242,10 @@ 0 0 find_entry + PANGO_ELLIPSIZE_NONE + -1 + False + 0 3 @@ -340,6 +353,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True False @@ -409,6 +423,10 @@ 0 0 location_entry + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -461,6 +479,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True False @@ -521,6 +540,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -597,6 +620,10 @@ 0 0 variable_font + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -622,6 +649,10 @@ 0 0 fixed_font + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -706,6 +737,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -779,6 +814,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True False @@ -837,6 +873,10 @@ 0 0 bookmarks_view + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -920,6 +960,9 @@ False False True + False + False + False @@ -955,6 +998,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True False @@ -1036,6 +1080,10 @@ 0 0 bookmark_title_entry + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1064,6 +1112,249 @@ + + + + 0 + True + True + + + + + + + + True + Print + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + True + True + True + True + True + gtk-print + True + GTK_RELIEF_NORMAL + True + 0 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 6 + True + False + 6 + + + + True + True + GTK_RELIEF_NORMAL + True + True + False + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-file + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Print current pa_ge + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + True + False + False + True + radiobutton_page + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gnome-stock-book-blue + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Print entire _document + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + Index: src/Makefile.am =================================================================== RCS file: /cvs/gnome/yelp/src/Makefile.am,v retrieving revision 1.85 diff -u -p -r1.85 Makefile.am --- src/Makefile.am 28 Oct 2005 20:37:37 -0000 1.85 +++ src/Makefile.am 31 Oct 2005 18:33:36 -0000 @@ -9,6 +9,7 @@ yelp_SOURCES = \ yelp-bookmarks.c yelp-bookmarks.h \ yelp-cache.c yelp-cache.h \ yelp-db-pager.c yelp-db-pager.h \ + yelp-db-print-pager.c yelp-db-print-pager.h \ yelp-error.c yelp-error.h \ yelp-gecko-utils.cpp yelp-gecko-utils.h \ yelp-html.cpp yelp-html.h \ @@ -112,6 +113,7 @@ test_man_parser_LDADD = $(YELP_LIBS) $(Z test_pager_SOURCES = \ yelp-db-pager.c yelp-db-pager.h \ + yelp-db-print-pager.c yelp-db-print-pager.h \ yelp-error.c yelp-error.h \ yelp-io-channel.c yelp-io-channel.h \ yelp-man-pager.c yelp-man-pager.h \ Index: src/yelp-db-print-pager.c =================================================================== RCS file: src/yelp-db-print-pager.c diff -N src/yelp-db-print-pager.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/yelp-db-print-pager.c 31 Oct 2005 18:33:36 -0000 @@ -0,0 +1,295 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2003 Shaun McCance + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Shaun McCance + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "yelp-error.h" +#include "yelp-db-print-pager.h" +#include "yelp-toc-pager.h" +#include "yelp-settings.h" + +#ifdef YELP_DEBUG +#define d(x) x +#else +#define d(x) +#endif + +#define STYLESHEET_PATH DATADIR"/yelp/xslt/" +#define DB_STYLESHEET STYLESHEET_PATH"db2html.xsl" +#define DB_TITLE STYLESHEET_PATH"db-title.xsl" + +#define BOOK_CHUNK_DEPTH 2 +#define ARTICLE_CHUNK_DEPTH 1 + +#define EVENTS_PENDING while (yelp_pager_get_state (pager) <= YELP_PAGER_STATE_RUNNING && gtk_events_pending ()) gtk_main_iteration (); +#define CANCEL_CHECK if (!main_running || yelp_pager_get_state (pager) >= YELP_PAGER_STATE_ERROR) goto done; + +extern gboolean main_running; + +#define YELP_DB_PRINT_PAGER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), YELP_TYPE_DB_PRINT_PAGER, YelpDBPrintPagerPriv)) + +struct _YelpDBPrintPagerPriv { + gchar *root_id; +}; + +static void db_print_pager_class_init (YelpDBPrintPagerClass *klass); +static void db_print_pager_init (YelpDBPrintPager *pager); +static void db_print_pager_dispose (GObject *gobject); + +static void db_print_pager_cancel (YelpPager *pager); +static xmlDocPtr db_print_pager_parse (YelpPager *pager); +static gchar ** db_print_pager_params (YelpPager *pager); + +static const gchar * db_print_pager_resolve_frag (YelpPager *pager, + const gchar *frag_id); +static GtkTreeModel * db_print_pager_get_sections (YelpPager *pager); + +static YelpPagerClass *parent_class; + +GType +yelp_db_print_pager_get_type (void) +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo info = { + sizeof (YelpDBPrintPagerClass), + NULL, + NULL, + (GClassInitFunc) db_print_pager_class_init, + NULL, + NULL, + sizeof (YelpDBPrintPager), + 0, + (GInstanceInitFunc) db_print_pager_init, + }; + type = g_type_register_static (YELP_TYPE_XSLT_PAGER, + "YelpDBPrintPager", + &info, 0); + } + return type; +} + +static void +db_print_pager_class_init (YelpDBPrintPagerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + YelpPagerClass *pager_class = YELP_PAGER_CLASS (klass); + YelpXsltPagerClass *xslt_class = YELP_XSLT_PAGER_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + object_class->dispose = db_print_pager_dispose; + + pager_class->cancel = db_print_pager_cancel; + + pager_class->resolve_frag = db_print_pager_resolve_frag; + + xslt_class->parse = db_print_pager_parse; + xslt_class->params = db_print_pager_params; + + xslt_class->stylesheet = DB_STYLESHEET; + + g_type_class_add_private (klass, sizeof (YelpDBPrintPagerPriv)); +} + +static void +db_print_pager_init (YelpDBPrintPager *pager) +{ + YelpDBPrintPagerPriv *priv; + + pager->priv = priv = YELP_DB_PRINT_PAGER_GET_PRIVATE (pager); + + pager->priv->root_id = NULL; +} + +static void +db_print_pager_dispose (GObject *object) +{ + YelpDBPrintPager *pager = YELP_DB_PRINT_PAGER (object); + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +/******************************************************************************/ + +YelpPager * +yelp_db_print_pager_new (YelpDocInfo *doc_info) +{ + YelpDBPrintPager *pager; + + g_return_val_if_fail (doc_info != NULL, NULL); + + pager = (YelpDBPrintPager *) g_object_new (YELP_TYPE_DB_PRINT_PAGER, + "document-info", doc_info, + NULL); + + return (YelpPager *) pager; +} + +static xmlDocPtr +db_print_pager_parse (YelpPager *pager) +{ + YelpDBPrintPagerPriv *priv; + YelpDocInfo *doc_info; + gchar *filename = NULL; + + xmlParserCtxtPtr parserCtxt = NULL; + xmlDocPtr doc = NULL; + + xmlChar *id; + GError *error = NULL; + + d (g_print ("db_print_pager_parse\n")); + + doc_info = yelp_pager_get_doc_info (pager); + + g_return_val_if_fail (pager != NULL, NULL); + g_return_val_if_fail (YELP_IS_DB_PRINT_PAGER (pager), NULL); + priv = YELP_DB_PRINT_PAGER (pager)->priv; + + g_object_ref (pager); + + if (yelp_pager_get_state (pager) >= YELP_PAGER_STATE_ERROR) + goto done; + + filename = yelp_doc_info_get_filename (doc_info); + + parserCtxt = xmlNewParserCtxt (); + doc = xmlCtxtReadFile (parserCtxt, + (const char *) filename, NULL, + XML_PARSE_DTDLOAD | XML_PARSE_NOCDATA | + XML_PARSE_NOENT | XML_PARSE_NONET ); + if (doc == NULL) { + g_set_error (&error, YELP_ERROR, YELP_ERROR_NO_DOC, + _("The file ā€˜%s’ could not be parsed. Either the file " + "does not exist, or it is not well-formed XML."), + filename); + yelp_pager_error (pager, error); + goto done; + } + + xmlXIncludeProcessFlags (doc, + XML_PARSE_DTDLOAD | XML_PARSE_NOCDATA | + XML_PARSE_NOENT | XML_PARSE_NONET ); + + + priv->root_id = g_strdup ("index"); + + EVENTS_PENDING; + CANCEL_CHECK; + + done: + g_free (filename); + + if (parserCtxt) + xmlFreeParserCtxt (parserCtxt); + + g_object_unref (pager); + + return doc; +} + +static gchar ** +db_print_pager_params (YelpPager *pager) +{ + YelpDBPrintPagerPriv *priv; + YelpDocInfo *doc_info; + gchar **params; + gint params_i = 0; + gint params_max = 20; + + d (g_print ("db_print_pager_process\n")); + + doc_info = yelp_pager_get_doc_info (pager); + + g_return_val_if_fail (pager != NULL, FALSE); + g_return_val_if_fail (YELP_IS_DB_PRINT_PAGER (pager), FALSE); + priv = YELP_DB_PRINT_PAGER (pager)->priv; + + if (yelp_pager_get_state (pager) >= YELP_PAGER_STATE_ERROR) + return NULL; + + params = g_new0 (gchar *, params_max); + + yelp_settings_params (¶ms, ¶ms_i, ¶ms_max); + + if ((params_i + 10) >= params_max - 1) { + params_max += 20; + params = g_renew (gchar *, params, params_max); + } + params[params_i++] = "db.chunk.extension"; + params[params_i++] = g_strdup ("\"\""); + params[params_i++] = "db.chunk.info_basename"; + params[params_i++] = g_strdup ("\"index\""); + params[params_i++] = "db.chunk.max_depth"; + params[params_i++] = g_strdup_printf ("0"); + params[params_i++] = "yelp.javascript"; + params[params_i++] = g_strdup_printf ("\"%s\"", DATADIR "/yelp/yelp.js"); + + params[params_i] = NULL; + + return params; +} + +static void +db_print_pager_cancel (YelpPager *pager) +{ + YelpDBPrintPagerPriv *priv = YELP_DB_PRINT_PAGER (pager)->priv; + + d (g_print ("db_print_pager_cancel\n")); + + yelp_pager_set_state (pager, YELP_PAGER_STATE_INVALID); + + g_free (priv->root_id); + priv->root_id = NULL; + + YELP_PAGER_CLASS (parent_class)->cancel (pager); +} + +static const gchar * +db_print_pager_resolve_frag (YelpPager *pager, const gchar *frag_id) +{ + YelpDBPrintPager *db_print_pager; + + g_return_val_if_fail (pager != NULL, NULL); + g_return_val_if_fail (YELP_IS_DB_PRINT_PAGER (pager), NULL); + + db_print_pager = YELP_DB_PRINT_PAGER (pager); + + return frag_id; +} + Index: src/yelp-db-print-pager.h =================================================================== RCS file: src/yelp-db-print-pager.h diff -N src/yelp-db-print-pager.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/yelp-db-print-pager.h 31 Oct 2005 18:33:36 -0000 @@ -0,0 +1,55 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2003 Shaun McCance + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Shaun McCance + */ + +#ifndef __YELP_DB_PRINT_PAGER_H__ +#define __YELP_DB_PRINT_PAGER_H__ + +#include + +#include "yelp-pager.h" +#include "yelp-xslt-pager.h" + +#define YELP_TYPE_DB_PRINT_PAGER (yelp_db_print_pager_get_type ()) +#define YELP_DB_PRINT_PAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), YELP_TYPE_DB_PRINT_PAGER, YelpDBPrintPager)) +#define YELP_DB_PRINT_PAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), YELP_TYPE_DB_PRINT_PAGER, YelpDBPrintPagerClass)) +#define YELP_IS_DB_PRINT_PAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), YELP_TYPE_DB_PRINT_PAGER)) +#define YELP_IS_DB_PRINT_PAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), YELP_TYPE_DB_PRINT_PAGER)) +#define YELP_DB_PRINT_PAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), YELP_TYPE_DB_PRINT_PAGER, YelpDBPrintPagerClass)) + +typedef struct _YelpDBPrintPager YelpDBPrintPager; +typedef struct _YelpDBPrintPagerClass YelpDBPrintPagerClass; +typedef struct _YelpDBPrintPagerPriv YelpDBPrintPagerPriv; + +struct _YelpDBPrintPager { + YelpXsltPager parent; + + YelpDBPrintPagerPriv *priv; +}; + +struct _YelpDBPrintPagerClass { + YelpXsltPagerClass parent_class; +}; + +GType yelp_db_print_pager_get_type (void); +YelpPager * yelp_db_print_pager_new (YelpDocInfo *doc_info); + +#endif /* __YELP_DB_PRINT_PAGER_H__ */ Index: src/yelp-html.cpp =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-html.cpp,v retrieving revision 1.1 diff -u -p -r1.1 yelp-html.cpp --- src/yelp-html.cpp 16 May 2005 21:02:33 -0000 1.1 +++ src/yelp-html.cpp 31 Oct 2005 18:33:36 -0000 @@ -34,6 +34,12 @@ #include "Yelper.h" +#include "gtkmozembed_internal.h" +#include "nsIWebBrowserPrint.h" +#include "nsIInterfaceRequestorUtils.h" + +#include + #ifdef GNOME_ENABLE_DEBUG #define d(x) x #else @@ -42,6 +48,9 @@ #define YELP_HTML_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), YELP_TYPE_HTML, YelpHtmlPriv)) +#define MOZILLA_PROFILE_DIR "/mozilla" +#define MOZILLA_PROFILE_NAME "yelp" + struct _YelpHtmlPriv { Yelper *yelper; gchar *base_uri; @@ -51,6 +60,7 @@ struct _YelpHtmlPriv { static void html_set_fonts (void); static void html_set_colors (void); static void html_set_a11y (void); +static void open_new_window (GtkMozEmbed **newEmbed, guint chrome_mask); enum { URI_SELECTED, @@ -120,6 +130,14 @@ html_realize (GtkWidget *widget) } static void +html_new_window (GtkMozEmbed *embed, + GtkMozEmbed **newEmbed, + guint chrome_mask) +{ + open_new_window (newEmbed, chrome_mask); +} + +static void html_init (YelpHtml *html) { YelpHtmlPriv *priv; @@ -197,6 +215,7 @@ html_class_init (YelpHtmlClass *klass) moz_embed_class->title = html_title; moz_embed_class->dom_mouse_down = html_dom_mouse_down; moz_embed_class->open_uri = html_open_uri; + moz_embed_class->new_window = html_new_window; klass->font_handler = 0; @@ -385,6 +404,24 @@ yelp_html_select_all (YelpHtml *html) html->priv->yelper->DoCommand ("cmd_selectAll"); } +void +yelp_html_print (YelpHtml *html) +{ + nsCOMPtr webBrowser; + + gtk_moz_embed_get_nsIWebBrowser (GTK_MOZ_EMBED (html), getter_AddRefs(webBrowser)); + + if (webBrowser) { + + nsCOMPtr print(do_GetInterface(webBrowser)); + + if (print) { + /* FIXME: Deal with retval. */ + print->Print (nsnull, nsnull); + } + } +} + static void html_set_fonts (void) { @@ -421,4 +458,123 @@ html_set_a11y (void) caret = yelp_settings_get_caret (); yelp_gecko_set_caret (caret); +} + +static void +new_window_orphan_cb (GtkMozEmbedSingle *moz_single, + GtkMozEmbed **newEmbed, + guint chrome_mask, + gpointer user_data) +{ + open_new_window (newEmbed, chrome_mask); +} + +void +yelp_html_initialize (void) +{ + static gboolean initialized = FALSE; + GtkMozEmbedSingle *single; + char *profile_path; + + if (initialized) + return; + initialized = TRUE; + + /* get single */ + single = gtk_moz_embed_single_get (); + if (single == NULL) { + g_warning ("Failed to get singleton embed object!\n"); + } + + /* allow creation of orphan windows */ + g_signal_connect (G_OBJECT (single), "new_window_orphan", + G_CALLBACK (new_window_orphan_cb), + NULL); + + profile_path = g_build_filename (g_get_home_dir (), + GNOME_DOT_GNOME, + "yelp.d", + MOZILLA_PROFILE_DIR, + NULL); + gtk_moz_embed_set_profile_path (profile_path, MOZILLA_PROFILE_NAME); + g_free (profile_path); +} + +static GtkMozEmbed *new_xul_dialog (void); + +static void +xul_visibility_cb (GtkWidget *embed, gboolean visibility, GtkWidget *window) +{ + if (visibility) { + gtk_widget_show (window); + } else { + gtk_widget_hide (window); + } +} + +static void +xul_size_to_cb (GtkWidget *embed, gint width, gint height, gpointer dummy) +{ + gtk_widget_set_size_request (embed, width, height); +} + +static void +xul_new_window_cb (GtkMozEmbed *embed, + GtkMozEmbed **retval, + guint chrome_mask, + gpointer dummy) +{ + g_assert (chrome_mask & GTK_MOZ_EMBED_FLAG_OPENASCHROME); + + *retval = new_xul_dialog (); +} + +static void +xul_title_cb (GtkMozEmbed *embed, + GtkWindow *window) +{ + char *title; + + title = gtk_moz_embed_get_title (embed); + gtk_window_set_title (window, title); + g_free (title); +} + +static GtkMozEmbed * +new_xul_dialog (void) +{ + GtkWidget *window, *embed; + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + embed = gtk_moz_embed_new (); + gtk_widget_show (embed); + gtk_container_add (GTK_CONTAINER (window), embed); + + g_signal_connect_object (embed, "destroy_browser", + G_CALLBACK (gtk_widget_destroy), + window, G_CONNECT_SWAPPED); + g_signal_connect_object (embed, "visibility", + G_CALLBACK (xul_visibility_cb), + window, (GConnectFlags) 0); + g_signal_connect_object (embed, "size_to", + G_CALLBACK (xul_size_to_cb), + NULL, (GConnectFlags) 0); + g_signal_connect_object (embed, "new_window", + G_CALLBACK (xul_new_window_cb), + NULL, (GConnectFlags) 0); + g_signal_connect_object (embed, "title", + G_CALLBACK (xul_title_cb), + window, (GConnectFlags) 0); + + return GTK_MOZ_EMBED (embed); +} + +static void +open_new_window (GtkMozEmbed **newEmbed, + guint chrome_mask) +{ + if (chrome_mask & GTK_MOZ_EMBED_FLAG_OPENASCHROME) { + *newEmbed = new_xul_dialog (); + return; + } } Index: src/yelp-html.h =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-html.h,v retrieving revision 1.30 diff -u -p -r1.30 yelp-html.h --- src/yelp-html.h 16 May 2005 21:02:33 -0000 1.30 +++ src/yelp-html.h 31 Oct 2005 18:33:36 -0000 @@ -98,6 +98,10 @@ void yelp_html_copy_selection void yelp_html_select_all (YelpHtml *html); +void yelp_html_print (YelpHtml *html); + +void yelp_html_initialize (void); + G_END_DECLS #endif /* __YELP_HTML_H__ */ Index: src/yelp-main.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-main.c,v retrieving revision 1.38 diff -u -p -r1.38 yelp-main.c --- src/yelp-main.c 6 Mar 2005 20:07:11 -0000 1.38 +++ src/yelp-main.c 31 Oct 2005 18:33:36 -0000 @@ -42,6 +42,7 @@ #include "GNOME_Yelp.h" #include "yelp-window.h" #include "yelp-base.h" +#include "yelp-html.h" #define YELP_FACTORY_OAFIID "OAFIID:GNOME_Yelp_Factory" @@ -365,6 +366,8 @@ main (int argc, char **argv) if (!factory) { /* Not started, start now */ BonoboGenericFactory *factory; char *registration_id; + + yelp_html_initialize (); registration_id = bonobo_activation_make_registration_id ( YELP_FACTORY_OAFIID, Index: src/yelp-window.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-window.c,v retrieving revision 1.178 diff -u -p -r1.178 yelp-window.c --- src/yelp-window.c 28 Oct 2005 20:37:37 -0000 1.178 +++ src/yelp-window.c 31 Oct 2005 18:33:37 -0000 @@ -42,6 +42,7 @@ #include "yelp-bookmarks.h" #include "yelp-db-pager.h" +#include "yelp-db-print-pager.h" #include "yelp-error.h" #include "yelp-html.h" #include "yelp-pager.h" @@ -160,6 +161,8 @@ static void window_add_widget GtkWidget *vbox); static void window_new_window_cb (GtkAction *action, YelpWindow *window); static void window_about_document_cb (GtkAction *action, YelpWindow *window); +static void window_print_document_cb (GtkAction *action, YelpWindow *window); +static void window_print_page_cb (GtkAction *action, YelpWindow *window); static void window_open_location_cb (GtkAction *action, YelpWindow *window); static void window_close_window_cb (GtkAction *action, YelpWindow *window); static void window_copy_cb (GtkAction *action, YelpWindow *window); @@ -308,6 +311,16 @@ static const GtkActionEntry entries[] = "N", NULL, G_CALLBACK (window_new_window_cb) }, + { "PrintDocument", NULL, + N_("Print This Document"), + NULL, + NULL, + G_CALLBACK (window_print_document_cb) }, + { "PrintPage", NULL, + N_("Print This Page"), + NULL, + NULL, + G_CALLBACK (window_print_page_cb) }, { "AboutDocument", NULL, N_("About This Document"), NULL, @@ -1925,6 +1938,181 @@ window_new_window_cb (GtkAction *action, g_return_if_fail (YELP_IS_WINDOW (window)); g_signal_emit (window, signals[NEW_WINDOW_REQUESTED], 0, NULL); +} + +typedef struct { + gulong page_handler; + gulong error_handler; + gulong cancel_handler; + gulong finish_handler; + YelpPager *pager; +} PrintStruct; + +static void +print_disconnect (PrintStruct *data) +{ + d(g_print ("print disconnect\n")); + if (data->page_handler) { + g_signal_handler_disconnect (data->pager, + data->page_handler); + data->page_handler = 0; + } + if (data->error_handler) { + g_signal_handler_disconnect (data->pager, + data->error_handler); + data->error_handler = 0; + } + if (data->cancel_handler) { + g_signal_handler_disconnect (data->pager, + data->cancel_handler); + data->cancel_handler = 0; + } + if (data->finish_handler) { + g_signal_handler_disconnect (data->pager, + data->finish_handler); + data->finish_handler = 0; + } +#if 0 + if (data) { + if (data->pager) + g_object_unref (data->pager); + } +#endif + g_free (data); +} + +static void +print_pager_page_cb (YelpPager *pager, + gchar *page_id, + gpointer user_data) +{ + PrintStruct *data = user_data; + YelpPage *page; + + d (g_print ("print_pager_page_cb\n")); + d (g_print (" page_id=\"%s\"\n", page_id)); + + page = (YelpPage *) yelp_pager_get_page (pager, page_id); + + if (page) { + YelpHtml *html; + GtkWidget *gtk_window; + int length, offset; + char *uri; + + d(g_print (page->contents)); + + gtk_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + html = yelp_html_new (); + gtk_container_add (GTK_CONTAINER (gtk_window), GTK_WIDGET (html)); + gtk_widget_realize (gtk_window); + gtk_widget_realize (GTK_WIDGET (html)); + + + uri = yelp_doc_info_get_uri (yelp_pager_get_doc_info (pager), + page_id, + YELP_URI_TYPE_FILE); + + d (g_print (" uri = %s\n", uri)); + + yelp_html_set_base_uri (html, uri); + g_free (uri); + + yelp_html_open_stream (html, "application/xhtml+xml"); + for (length = strlen (page->contents), offset = 0; length > 0; length -= BUFFER_SIZE, offset += BUFFER_SIZE) { + d(g_print ("data: %.*s\n", MIN (length, BUFFER_SIZE), page->contents + offset)); + yelp_html_write (html, page->contents + offset, MIN (length, BUFFER_SIZE)); + } + yelp_html_close (html); + + yelp_html_print (html); + + print_disconnect (data); + + /* This needs to be done at some point, but we need to wait until printing is done. */ + /* gtk_widget_destroy (gtk_window); */ + } +} + +static void +print_pager_error_cb (YelpPager *pager, + gpointer user_data) +{ + PrintStruct *data = user_data; + /* GError *error = yelp_pager_get_error (pager);*/ + + d (g_print ("print_pager_error_cb\n")); + + print_disconnect (data); +} + +static void +print_pager_cancel_cb (YelpPager *pager, + gpointer user_data) +{ + PrintStruct *data = user_data; + d (g_print ("print_pager_cancel_cb\n")); + + print_disconnect (data); +} + +static void +print_pager_finish_cb (YelpPager *pager, + gpointer user_data) +{ + PrintStruct *data = user_data; + + d (g_print ("print_pager_finish_cb\n")); + + print_disconnect (data); +} + +static void +window_print_document_cb (GtkAction *action, YelpWindow *window) +{ + PrintStruct *data; + YelpPager *pager; + + if (!window->priv->current_doc) + return; + + pager = yelp_db_print_pager_new (window->priv->current_doc); + + if (!pager) { + return; + } + + data = g_new0 (PrintStruct, 1); + data->pager = pager; + + data->page_handler = + g_signal_connect (data->pager, + "page", + G_CALLBACK (print_pager_page_cb), + data); + data->error_handler = + g_signal_connect (data->pager, + "error", + G_CALLBACK (print_pager_error_cb), + data); + data->cancel_handler = + g_signal_connect (data->pager, + "error", + G_CALLBACK (print_pager_cancel_cb), + data); + data->finish_handler = + g_signal_connect (data->pager, + "finish", + G_CALLBACK (print_pager_finish_cb), + data); + + /* handled = */ yelp_pager_start (data->pager); +} + +static void +window_print_page_cb (GtkAction *action, YelpWindow *window) +{ + yelp_html_print (window->priv->html_view); } static void --=-9ORf8ZtCi7oCmctsklwp Content-Disposition: attachment; filename=yelp-toctree.patch Content-Type: text/x-patch; name=yelp-toctree.patch; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 7bit Index: data/yelp.js =================================================================== RCS file: /cvs/gnome/yelp/data/yelp.js,v retrieving revision 1.3 diff -u -p -r1.3 yelp.js --- data/yelp.js 28 Oct 2005 20:37:36 -0000 1.3 +++ data/yelp.js 31 Oct 2005 19:05:14 -0000 @@ -87,6 +87,50 @@ window.addEventListener("load",slt.init, window.addEventListener("DOMContentLoaded",slt.init,false); window.addEventListener("resize",slt.init,false); +function createCookie(name,value,days) +{ + if (days) + { + var date = new Date(); + date.setTime(date.getTime()+(days*24*60*60*1000)); + var expires = "; expires="+date.toGMTString(); + } + else var expires = ""; + document.cookie = name+"="+value+expires+"; path=/"; +} + +function load_hidden () +{ + var ca = document.cookie.split(';'); + for (var i=0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf('display:') == 0) { + var colon = c.indexOf(':'); + var equal = c.indexOf('='); + + var id = c.substring (colon + 1, equal); + var value = c.substring (equal + 1); + + document.getElementById (id).style.display = value; + } + } +} + +function show_hide (id) +{ + var element = document.getElementById (id + '-children'); + if (element.style.display == "none") { + element.style.display = "block"; + createCookie ('display:' + id + '-children', "block", 1000); + } else { + element.style.display = "none"; + createCookie ('display:' + id + '-children', "none", 1000); + } +} + +window.addEventListener("DOMContentLoaded",load_hidden,false); + function submit_search () { window.location = "x-yelp-search:" + document.getElementById ('search-entry').value; Index: src/yelp-toc-pager.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-toc-pager.c,v retrieving revision 1.51 diff -u -p -r1.51 yelp-toc-pager.c --- src/yelp-toc-pager.c 21 Oct 2005 01:47:56 -0000 1.51 +++ src/yelp-toc-pager.c 31 Oct 2005 19:05:15 -0000 @@ -873,7 +873,7 @@ process_xslt (YelpTocPager *pager) YelpTocPagerPriv *priv = pager->priv; gchar **params = NULL; gint params_i = 0; - gint params_max = 10; + gint params_max = 14; GtkIconInfo *info; GtkIconTheme *theme = (GtkIconTheme *) yelp_settings_get_icon_theme (); @@ -899,8 +899,8 @@ process_xslt (YelpTocPager *pager) params = g_new0 (gchar *, params_max); yelp_settings_params (¶ms, ¶ms_i, ¶ms_max); - if ((params_i + 10) >= params_max - 1) { - params_max += 10; + if ((params_i + 14) >= params_max - 1) { + params_max += 14; params = g_renew (gchar *, params, params_max); } @@ -914,6 +914,11 @@ process_xslt (YelpTocPager *pager) gtk_icon_info_get_base_size (info)); gtk_icon_info_free (info); } + + params[params_i++] = "yelp.javascript"; + params[params_i++] = g_strdup_printf ("\"%s\"", DATADIR "/yelp/yelp.js"); + params[params_i++] = "yelp.topimage"; + params[params_i++] = g_strdup_printf ("\"%s\"", DATADIR "/yelp/icons/help-title.png"); params[params_i++] = NULL; Index: stylesheets/toc2html.xsl =================================================================== RCS file: /cvs/gnome/yelp/stylesheets/toc2html.xsl,v retrieving revision 1.11 diff -u -p -r1.11 toc2html.xsl --- stylesheets/toc2html.xsl 11 May 2005 18:19:20 -0000 1.11 +++ stylesheets/toc2html.xsl 31 Oct 2005 19:05:15 -0000 @@ -5,9 +5,13 @@ extension-element-prefixes="yelp" version="1.0"> + + + + @@ -35,133 +39,181 @@ <xsl:value-of select="title[1]"/> - + - + + + + + +

+ + + + +

+
+ + + +
+ + + + + + +
+
    + + +
  • + +
  • +
    +
+
+
+ +
+
+ + +
+ + + + + + + + +
+
+ +
+
+
+
+
+
-
-

- - - - -

-
-
+
+ + + +
- -
- -
-
- -
-
- - -
- - - - - - - - -
-
- -
-
-
-
-
+ + +
+ + + + + + + + + --=-9ORf8ZtCi7oCmctsklwp--