Embedded Components Tutorial - Page 7

Final Thoughts

You may have noticed that converting an application to an embedded
component is pretty easy. In fact, this tutorial could have easily
condensed the four steps into one or two with no loss of clarity.
That said, you will likely do your conversion in the four stages
outlined, so maybe that wasn't such a bad idea.

To recap, the four stages are:

Convert your application to a shared library

This requires only a change to the Makefile.am file

Add the skeleton KParts code

This requires two files to be added to the project, and two minor
changes to the Makefile.am and your application's .desktop file

Add in your own code

This is probably the hardest step.. where you integrate your
existing code into the KParts interface.

Connect GUI elements to control your code

This is where you insert items into the toolbar and edit menu to
allow the user to control your component.

Whenever you do a tutorial, the question is what of the tutorial can
you use in your own and what is specific to the app itself. Well,
you're in luck for this tutorial -- nearly all of the code in this
tutorial was boilerplate, cut-and-paste type code!

In general, you can copy over the files and just change all references
to 'aktion' and 'Aktion' to your own app naming convention.

The only thing that is totally app specific is in the AktionPart
class. Wherever you see references to the widget object,
that's where you need to insert your app specific things.

Most of the things to look out for were mentioned in the steps of the
tutorial. Two things that stand out, though, are these:

Pay attention to the .desktop file

If you wonder why Konqueror isn't embedding your app, it's almost
surely because something is wrong with your .desktop file. Pay
close attention to that section in the tutorial.

Make sure your app has a pre-existing "view" class

This is probably the most important point in this tutorial. If
you app already has a existing view class that provides a
coherent interface to your apps UI functionality, then everything
is trivial. If your code is ad-hoc, then this could be a
nightmare.