You are not logged in.
It sounds impossible, but I want to try.
I'm thinking that a start might be reading the root window atoms in addition to the process list, but I'm not too sure what else.
This goes beyond "the user's running {KDE,GNOME}"; I don't really want to figure out the windowmanager, I want to use deduction so as to figure out what toolkit the user would prefer something to use. The idea is then to compile both Qt and GTK toolkit calls into whatever given program along with a simple abstraction layer and the detection stuff, so I can from there figure out which toolkit to use at startup.
I don't expect perfect detection, but it'd be fun to figure out.
Ideas, anyone?
My first stab at detecting a "GTK preference" is checking if the user is running gnome-session-manager. I'm not too sure what processes set "KDE session" apart from "a Qt-based program is running" because Qt has this tendancy to load 3874692725 things when anything starts and leave them preloaded for the next app. Nice idea, but not for low-RAM machines like mine. Only reason I haven't ravaged bits of KDE and stuffed them into my openbox desktop configuration
-dav7
Last edited by dav7 (2008-10-29 17:46:03)
Windows was made for looking at success from a distance through a wall of oversimplicity. Linux removes the wall, so you can just walk up to success and make it your own.
--
Reinventing the wheel is fun. You get to redefine pi.
Offline
why not use qt and let it change the style to be as the DE?
or use gtk and hope that if the user really preffers qt he will have qtk-qt or whatever it's called
apart from curiosity about how to do it, of course
-$: file /dev/zero
/dev/zero: symbolic link to '/dev/brain'
Offline
That would work, but I'm aiming for more of a generalized, globalized solution.
-dav7
Windows was made for looking at success from a distance through a wall of oversimplicity. Linux removes the wall, so you can just walk up to success and make it your own.
--
Reinventing the wheel is fun. You get to redefine pi.
Offline
The simplest heuristic that covers most cases would be:
if kde_running() then use_qt() else use_gtk()
Gnome and XFCE of course use GTK, and the vast majority of WM-only or hand-rolled DE setups I've seen use primarily GTK apps when there's a choice.
Offline
Why not a one time startup dialog that asks the question?
Offline
I wouldn't waste the time on implementing both. You're just creating a pain for yourself and a terribly complicated code base.
Pick one and focus on the application itself.
Offline
Oh I'm not actually focusing on anything in particular at the moment. I'm just getting a feel for C, and doing various and sundry things like writing stuff in pure Xlib, making rendering engines, figuring out how to make an app pack in both Qt and GTK, etc.
-dav7
Last edited by dav7 (2008-10-29 23:43:33)
Windows was made for looking at success from a distance through a wall of oversimplicity. Linux removes the wall, so you can just walk up to success and make it your own.
--
Reinventing the wheel is fun. You get to redefine pi.
Offline
Why not a one time startup dialog that asks the question?
I'm not sure if you mean one time as in - one time on the first application launch, or one time as in the first time you launch an app for a session.
If you mean the latter, i would personally be driven insane by it. A once and down prompt is a relatively nice solution though IMO. Provided there is an option in settings to revert down the road.
Offline
Well, I would mean the first time and only the first time the app is ran, the user is asked and the preference is stored. This would also provide a means for switching back and forth since the selection would have to be stored somewhere anyhow.
Offline
Oh I'm not actually focusing on anything in particular at the moment. I'm just getting a feel for C, and doing various and sundry things like writing stuff in pure Xlib, making rendering engines, figuring out how to make an app pack in both Qt and GTK, etc.
Just pointing out that if you are using C, then it is going to be GTK. Qt is a C++ beast (AFAIK). Even with GTK, I would recommend the gtkmm (C++) interface.
Offline
How about a environmental variable?
You could have something like this is your .bashrc
export MYTOOLKIT=qt
or
export MYTOOLKIT=gtk
Then in your c-program you do something like this:
char *toolkit;
if ((toolkit = getenv("MYTOOLKIT")) == NULL) {
fprintf(stderr, "-- 'MYTOOLKIT' not defined - required for this application (argv[0])\n");
exit(1);
}
if (!strcasecmp(toolkit, "qt")) {
; // qt-part
} else if (!strcasecmp(toolkit, "gtk")) {
; // gtk-part
}
edit: forgot a curly brace - duh!
Last edited by perbh (2009-01-05 05:24:47)
Offline