About c-functions that make UI calls. [qt-rewrite]

Dirk Hohndel dirk at hohndel.org
Wed Apr 3 10:39:41 PDT 2013


Tomaz Canabrava <tcanabrava at kde.org> writes:

> Sure.
>
> My idea was to separate all the code logic code into a static library (
> core.a ),  with no call to the interface at all. Right now there's a file
> named 'dive.h' that has quite a few interface-defined functions there, and
> it's used everywhere, like in main.c ( why the main.c file calls a function
> that's interface-related, I don't know ).

Fundamentally? Because we didn't think of this the way you do - neither
Linus nor I have a background of developing UI applications... I spent
most of my time as developer working on things like the X server or
developer tools. I have no idea what he did all those years... I think
he mostly flames people on mailing lists...

So the code grew organically and things got added to header files and
calls were made "where we needed them". 

I did a project to isolate all Gtk related things in one header file
(display-gtk.h) and to separate the UI from logic (that's why there is a
gtk-gui.c file), but that was more or less undone with tons of additions
everywhere over time.

Now divelist.c, download-dialog.c, equipment.c, gps.c, info.c, profile.c,
print.c, planner.c, statistics.c, webservice.c ... they all have UI code
mixed into them :-(

> So, moving all of the interface-code ( putting a lot of //WARNINGS: in the
> code explaining what's broken and such ) from the sources, making it a
> static-library ( doesn't need to be shared, since the only purpose of this
> move is to be able to create more than one ui, for mobile and desktop
> platforms )

That's quite a task, but yes, this does sound like a solid idea.

> then all of the interface - related code whould be acessible only from the
> interface sources, but this one will talk to the corelib  that whould be
> linked together making the binary.

Cool. This will give us a chance to clean up the corelib code as well
(we changed our data structures over time, wrote new accessors, etc.,
but haven't always been consistent in updating all parts of the code.

So I'll take this opportunity to clean up that part of the code as well.

/D


More information about the subsurface mailing list