Re: gnome bug 135093

David Malcolm <[email protected]> Tue, 19 Apr 2005 17:06:06 -0400
Newsgroups gmane.editors.conglomerate.devel
Message-ID <[email protected]>
On Tue, 2005-04-19 at 16:10 -0400, Thierry Moisan wrote:
> Hi, I'm a new developper and I'd like to fix gnome bug 135093. I tough 
> someone could give me some hints and URL of what to do to start to 
> create this word count function.

Hi - welcome aboard!

There are two parts to implementing the word count feature:  the
frontend/GUI part (displaying the result) and the backend (actually
counting the words)

For the frontend, the File->Properties dialog is created using libglade,
which loads a UI file built using glade-2.  Run glade-2
glade/cong-file-properties.glade and try editing the dialog.  Note that
IIRC you need to do a "make install" after editing a glade file, or
Conglomerate will be using the old version of the glade file.
 
You can then wire up the dialog by editing the code in
src/cong-file-properties.c

Give the widget a name in Glade, you can then look it up and fill in its
value in the C code.

For the backend, I'd suggest simply calculating the wordcount when the
property dialog is first created.  Eventually you'll want to hook things
up so that the value changes as the document is edited, but we can leave
that for a later email.

To actually calculate the wordcount, have a look for the function
cong_document_for_each_node.  Call this on the document, and give it a
callback function that checks the type of the node, and for text nodes,
get the word count, and add it to some accumulated value (maybe pass a
pointer to this integer as the user_data to the callback).

Good luck!  Please feel free to ask more questions on this list if you
get stuck.

Dave