[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: Getting Started (long post)
From:       David Faure <david () mandrakesoft ! com>
Date:       2002-07-26 8:25:54
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 26 July 2002 06:55, Eric R. Turner wrote:
> On Wednesday 24 July 2002 11:37 pm, Carsten Pfeiffer wrote:
> 
> > You can either pass the application name to KApplication or to the
> > KAboutData object. In KWord's case, see kwaboutdata.h (KAboutData should be
> > used in almost any other application as well.)
> 
> Let me see if I get this straight. Working with the example KOffice program:
> 
> The first thing in main() is a call to the static method KCmdLineArgs::init(
> argc, argv, newExampleAboutData())
> 
> The newExampleAboutData() function creates an instance of KAboutData, which is
> stored (via a pointer) in the KCmdLineArgs class (not in an object of the
> class because we haven't instantiated one, right?).
Yes.

> One of the arguments to KAboutData's constructor is the program name
> "example". Will this be used later to actually run the example program?
Err no, this is all WITHIN the example program already.
The program name given here is in fact the "instance name", which is used to
locate the application's own data, (  /share/apps/example/... ) and many other
things.

> KCmdLineArgs::init() strips the path off of argv[0] (the program path and
> name?), gets the current working directory, keeps a pointer to the KAboutData
> object, and calls KApplication::addCmdLineOptions (which adds some other Qt
> and KDE options to KCmdLineArgs).

Yes - I wonder why you're digging into that part though, that all works fine ;)

> Then main() adds these options to KCmdLineArgs: "+[file]", I18N_NOOP("File to
> Open"), and 0. What is the "+[file]" all about? Why that format? What's it
> do?

See kcmdlineargs.h, it's all explained there.
It means "any number of 'file' arguments"

> Ok, so we have this static KCmdLineArgs class that knows a bunch of stuff
> about the example program because it has a KAboutData object filled with
> example-specific data.
The about data is then used much more generally than that. It's stored in the
kapplication object (since it's a KInstance).

> Now we declare a KoApplication object. Several things are done in the
> constructor, including the creation of a KoApplicationInterface object which
> I assume is how other applications can use DCOP to interact with this
> application.
Yes

> (Anyone want to explain to me what the first four method calls
> do in the constructor?)
Which? KoApplication? There are comments before each line (which is pretty rare ;)

> Back in main(), the app attaches to the DCOP server and registers itself so
> that other processes can communicate with the app.

Hmm this looks unnecessary nowadays, I think it's automatically done. Bah.

> Now the fun part begins. The app calls it's start() method. Start does a
> number of things:
> 
>      1. start() looks up the native mime type for this application, and then
> creates a KoDocumentEntry. The comment says that start() is finding the
> desktop file. What is this desktop file? 

<instancename>.desktop, so example.desktop in this case.
It's the .desktop file that is responsible for the menu entry, standard KDE stuff.
But in koffice we add a few useful tags to it, in particular the "native mimetype"
of this component (application/x-kword for kword, etc.)

> Is it generated by hand or by an app? 
By hand. It's part of the sources, see e.g. koffice/kword/kword.desktop

> What's a KoDocumentEntry? I couldn't find it in lib/kofficecore.
Describes a koffice component (i.e. it's a representation in memory of the data contained
in the .desktop file). It's in kofficecore/koQueryTrader.h

>      2. Assuming there were arguments obtained from KCmdLineArgs, start()
> creates a KoDocument and a KoMainWindow for each argument (are the arguments
> names of files to open?).
Well, yes - try any koffice app on the command line ;)

> When the show() method of KoMainWindow is called,
> is this when the application actually appears to the user? 
Right.

> I'm still having
> difficulties seeing how KoMainWindow->show() brings up the correct
> application (how does it know we want to show the "example" app versus any
> other apps?). 
The mainwindow is the same for all. But the KoDocumentEntry was created from
the "example" data, and koQueryTrader dlopens the library containing this component.
The very same mechanism is used to 1) embed other components
inside the app, 2) create any kind of koffice document, e.g. in koshell.

Note that the example app doesn't even contain the code of the example part.
It needs to dlopen it. All the koffice applications are in fact very small wrappers
that simply dlopen their own component - with the code in kofficecore, which can
also dlopen ANY component.

> Also, the KoApplication object doesn't store pointers to the
> KoDocument and KoMainWindow objects... do these objects communicate with each
> other later on, and if so, is that done through DCOP?

The mainwindow knows about the document[s] inside it.
The mainwindows are in a static linked list, if one really wants to iterate over all
windows in the application, but this is rarely needed.

You also have to bring "views" (KoView) in the mix ;)
(standard document/view model).

> Ok, I'll stop. Sorry about the long post. I just <em>really</em> want to
> understand how this whole thing works! Perhaps it would be good to write a
> tutorial document. I promise that if I actually ever understand this well
> enough, I'll write it!

Yes, now that I've spent the time to answer this, I'd appreciate if you could simply
format the questions and answers into a Q&A document, to be added as
koffice/lib/kofficecore/DESIGN

- -- 
David FAURE, david@mandrakesoft.com, faure@kde.org
http://people.mandrakesoft.com/~david/
Contributing to: http://www.konqueror.org/, http://www.koffice.org/
KOffice 1.2 RC1 is slightly delayed. Stay tuned.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9QQeS72KcVAmwbhARAhxlAJ9AG8URSNw5DxXnGvCJDDJ7fIY3cQCgrSdS
X2cvFpoJ9FRG9jGe2Z0d27s=
=O1Ft
-----END PGP SIGNATURE-----

_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic