Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>You do this by having several available implementations of the API as dynamic libraries--one using Motif, one using GTK, one using Qt, and so on.

OK, now who's going to do this? At what level would this be implemented at? Would this be at the windows server level? Would I have to pull in GtK, motif, qt and every other library that this API will rely on just to install Wayland or xorg? Will it be at the window manager level? Will I need to pull in GfK, qt, motif etc. for every desktop environment and window manager relying on this API? Which versions of these libraries will this API rely on?

The last graphical app i wrote, I used dlangui for a GUI, should I have been forced to use Gtk or qt despite them being heavier and more complicated than what I needed?



Your program in dlangui would do something like this (but in D rather than the C-like pseudocode I'm going to use...). At the place where you want to put up a file chooser dialog, which now presumably does something like this:

  char * result = dlangui_choose_file(...)
you would do this instead:

  char * result = 0;
  char * (*standard_choose)() = get_standard_choose();
  if (standard_choose)
    result = (*standard_choose)(...);
  if (result == 0)
    result = dlangui_choose_file(...)
get_standard_choose is a small function that would:

1. Check a standard set of configuration locations to see if the system administrator or user has configured a standard file choose dialog [1].

2. If a standard file choose dialog has been configured, the configuration information includes the path to a library that implements it. get_standard_choose() loads that library, gets a pointer to the standard_choose() functions from it, and returns that pointer.

3. get_standard_choose() returns 0 if no standard choose dialog is configured or it runs into problems trying to load it.

If the user wants GTK or Qt file chooser dialogs instead of dlangui file chooser dialogs, you don't have to use GTK or Qt. The user installs a GTK or Qt file chooser library and points to it in their standard dialog configuration.

(I'd expect at some point that toolkits like dlangui would incorporate get_standard_choose() functionality themselves. After that, you'd then just write

  char * result = dlangui_choose_file(...)
and it would deal with using the user preferred dialog if available. It would be completely transparent to the programmer using dlangui).

Same idea for other common dialogs, like color picking, printing, and font selection.

[1] Probably something like check an environment variable first. If it doesn't find a match there, probably then a config file in $XDG_CONFIG_HOME. If no match, then something in /etc.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: