Re: Multiple documents



Hi,

Thank you for this. I have now got a basic MDI working with separate windows for each view of each document. It still needs a lot of work, but I am very happy with the basic functionality I have.

Thank you all for your time and suggestions!

Chris.


From: Patrice St-Gelais <patrice st-gelais oricom ca>
To: Chris Garrett <garrett91 hotmail com>,gtk-app-devel-list gnome org
Subject: Re: Multiple documents
Date: Wed, 27 Aug 2003 22:44:19 +0000

Hi,

I've developped something similar for an heightfield editor.

I chose a multiple window interface a la GIMP because I didn't want to
repeat the menus and the toolbox for each document.

My layout contains a menu bar at the top and a toolbox at left.
Document windows are "top level" and stacked at the immediate right of
the toolbox and bottom of the menubar.  A document window contains the
pixmap display and a GL preview, with some scale / rotate / translate
controls.

Documents are stored in a linked list.

Coordinating multiple instances of document windows with one instance of
the menubar and the toolbox was actually a challenge. The toolbox is
used for editing, and there are some changes that need to be committed
or rolled back.  I had the choice of using modal dialogs, or carefully
managing the state of the document windows.  This means, for instance,
automatically committing or rolling back changes when the focused
document changes, or when the user hides the current document, or when
the user chooses another tool. I'm not sure if the result is always
consistent - users will tell, but it's usable.

The coordination is made by using pointers of pointers as callback data.
 I mean:  callbacks from the toolbox are defined on a class of
documents, not on a particular document.  I put the current document
pointer in a "bucket", whose pointer is linked to the callback.  I must
swap the content of the bucket when the focused window change.

About structures, I wanted independency between the interface and the
logic of the application.  I also wanted to separate the generic part of
the application (managing the common structures between a whole range of
applications I could want to develop in the future...) from the
particular application I wanted to develop.

So my structures are grossly:
--- An application, which manages
------ a list of document types (file types), which describe
--------- the individual documents

There are generic open / create / save / undo-redo ... methods linked to
the document type class (function pointers).  The generic fucntions call
specific ones, depending on the file type (other function pointers).

I have a generic document structure with things like the filename and
the undo / redo stack.

I'm not sure I've made the best choices, naturally. It was a trial and
error adventure.  I had a lot to learn about GTK, GDK, glib, even C, a
few years ago.

I think MDI with GTK is a domain which could benefit from some "best
practices" advice, or some tutorial fostering standardization, if it
doesn't exist yet.

I used GTK 1.2.x, I haven't translated the software to GTK 2.x yet.
Choices could have been different with the latter, I don't know.

My code can be downloaded from here, if you are curious, and there is a screenshot:

http://www.oricom.ca/patrice.st-gelais/geomorph_en.html

Unfortunately, there is no technical documentation, except a lot of C comments.

[src/app contains the generic application structure, src/hf contains the code for managing heightfields, src/app/thisappinit.c fills the generic structure with data and functions related to hf management - this is the link].

Best regards,
Patrice St-Gelais



___________________________________________________________________________
Chris Garrett a écrit:
> Hi,
>
> That is pretty much the way I thought I would have to do it.  However, I
> am experiencing some confusion about how to ensure that callbacks from
> the canvas end up resulting in changes on the correct image.  I havent
> written any code for multiple documents yet, since I am still thinking
> about the design of the structures etc.
>
> I also need to consider a way for multiple views of the same document to
> be updated whenever changes are made...  I think the structs will have a
> lot of links in them so it is easy to pull out the ones needed in any
> given circumstance!
>
> Is there any chance you could point me in the direction of your code so
> I can see how the callbacks are working?  This is the area I am having
> difficulty with (probably because I am still new to GTK).  I am making a
> pixel-based drawing program myself, but I dont intend it to compete with
> the GIMP - it would have more of a focus on image creation rather than
> image manipulation.
>
> As far as the type of MDI I aim to use, it will be pretty-much like the
> GIMP in style - ie. no tabs and no WiW.  Ideology aside, I find WiW
> claustrophopic and I am not 100% sure that tabs are suitable for images.
>
> Best regards,
>
> Chris.
>
>
>> From: Jim Parker <hopeye cfl rr com>
>> To: Chris Garrett <garrett91 hotmail com>
>> CC: gtk-app-devel-list gnome org
>> Subject: Re: Multiple documents
>> Date: Mon, 25 Aug 2003 15:00:19 -0400
>>
>> G'Day !
>>
>> I do not know if this is the best way, but I am using a linked list of
>> struts, with each strut containing the information needed by each
>> document (BTW I'm doing a vector drawing program).
>>
>> Works well for small numbers of documents, never tested for large sets
>> ...
>>
>> cheers,
>> Jim Parker
>>
>>
>> On 2003.08.25 14:22 Chris Garrett wrote:
>>
>>> Hi all,
>>>
>>> Is there a standard / recommended way to write an application that
>>> can open more than one document at a time, and that allows more than
>>> one view of each document (ala GIMP)?
>>>
>>> If so, is there a nice, small, simple example I can look at to get
>>> started?  The source code to the GIMP is too large for my tired brain
>>> at the moment :o(
>>>
>>> BTW, I am using GTK2.2
>>>
>>> Best regards,
>>>
>>> Chris.
>>>
>>> _________________________________________________________________
>>> Use MSN Messenger to send music and pics to your friends
>>> http://www.msn.co.uk/messenger
>>>
>>> _______________________________________________
>>> gtk-app-devel-list mailing list
>>> gtk-app-devel-list gnome org
>>> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>>
>
> _________________________________________________________________
> Stay in touch with absent friends - get MSN Messenger
> http://www.msn.co.uk/messenger
>
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>




_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today! http://www.msn.co.uk/messenger




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]