Binspekt KPart for reuse in KDevelop

Some days ago I wrote a mini-tutorial how to use the Okteta KPart in Konqueror/KDevelop. With the mind turned to the Okteta KPart I after that have taken on a long waiting task and removed some code duplication by porting it to the Kasten classes, now that these are available in shared libs. Which means, with KDE 4.4 you should have the same readonly actions available with the Okteta KPart that you also have in the Okteta program (not all done yet). Even better, I have just written a first code line to turn it into a ReadWritePart, so that you could also do the editing and saving in KDevelop. More on this later hopefully.

After having done this first wrapping of Kasten classes in a KPart I did another one, to learn more about how a generic KPart Kasten module might be best designed, to get the Kasten plug&play experience I am aiming at. The other program I am writing using the Kasten framework is Binspekt, a viewer (and perhaps editor) for binary files, that is executables, libraries, object files etc. It was basically copy,paste&replace, so here see the small and dirty Binspekt KPart inside the (amazing and great BTW) KDevelop, fresh from the KDE repository:
Binspekt KPart in KDevelop

Binspekt is still prealpha (yet doesn’t crash, because it doesn’t do a lot) if you are interested. But it all has to start somewhere, no? 🙂

Minitutorial: Viewing raw data of files in Konqueror/KDevelop

Want to quickly see the raw data of files in Konqueror or KDevelop? This is possible with the KPart coming with Okteta since KDE 4.1:


Open “System Settings”, then select “File Associations” (Found under “Advanced”). Select the file type (e.g. “audio/x-wav”) you want to see the raw data of, choose the tab “Embedding”.

Within “Services Preference Order” press button “Add”, select “Embedded Binary Viewer (oktetapart)” [0] from the list, press “OK”:
File Associations - Add Service

If there are already other services listed in the services list make sure the oktetapart is the first entry by selecting it and pressing “Move Up” as often as needed. Press “Apply” and close the System Settings:
File Associations

[0] Binary Viewer is a misnomer, changed to Hex Viewer for KDE 4.4


Now start Konqueror and click with your right mouse button on a wav file. In the context menu select “Preview in Embedded Binary Viewer” and you should see the raw data of that file:
Hex View in Konqueror
In KDevelop you do as you do with text files, just select a wav file and it will be shown as hex view:
Hex View in KDevelop

Beware: This viewer is only read-only. And while using the Okteta core libs it currently does not come with any of the tools included in Okteta. This hopefully will change for KDE 4.4, but don’t hold your breath (better sit down and help with coding 🙂 ).


If you want to undo this change for the file type, go to the settings as described above, select “Embedded Binary Viewer (oktetapart)” in the list under “Services Preference Order” and press “Remove”.


Since its version 4.1 KDevelop has built-in support for viewing and editing of files as byte arrays (of course using the Okteta libraries). To open a file as byte array, use the context menu on a file in the “Filesystem”, “Projects” or “Documents” toolview (by click with the right mouse button) and chose “Open as Byte Array”. So for KDevelop using the Okteta KPart is no longer needed.

Kasten: WIP framework for composing programs

Since a few days kdeutils (from trunk) also installs some libraries, including public headers:

  • Okteta libraries
  • Kasten libraries

The Okteta libraries oktetacore and oktetagui provide some model and view classes for hex views of bytearrays. If you have some special data provider you could also subclass your own Okteta::AbstractByteArrayModel. So using the libs directly is now an option, if the KHexEdit interfaces from kdelibs don’t do it for you.

The Kasten libraries are far more interesting, at least to me. Kasten (former project title was Kakao), that is a project of mine where I try to develop a framework for composing programs from modules and interfaces by the model-view-controller pattern, with the pattern recursively applied to the view and the controller. Think KPart 2.0. So far the development was driven by the needs I had with Okteta (that program serving as the testing ground, now you know my motivation for Okteta. Byte arrays are just the most simple data structure.). The Kasten framework is still far from what I have in mind, but things at least are moving 🙂 I try to express my ideas directly in code, so the ideas meet reality as soon as possible. Might be some more years before I am done, oh well.

Both libraries are still far from elaborated, especially Kasten, given that there has been only one usecase, that is the program Okteta. But you are invited to see if you already can make use of them. Just be prepared for changes. Which could also be done for your needs 🙂

The reason I turned to install these libraries now is that I want to reuse them in another project, working title Binspekt: It is about viewing and editing of binary files, that is executables, libraries, object files etc. I always forget about the parameters of objdump, objcopy, nm & Co., so I thought a GUI variant might be nice, and here we go (of course using the very same bfd library from the GNU binutils).

Obligatory screenshot of the current state, which is pre-alpha:
First screenshot of Binspekt, version 0.1.0 pre-alpha

Find the code at playground/devtools/binspekt in the KDE repository, imported there a few hours ago.