* NEW: If one GUI component fails to load, try the other one.
* NEW: Abort if no GUI component is found.
* NEW: Define the GB_GUI environment variable with the GUI component 
  actually loaded.

[GB.GUI.OPENGL]
* NEW: Always load the OpenGL support component associated with what lies
  in the GB_GUI environment variable.


git-svn-id: svn://localhost/gambas/trunk@5925 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2013-11-01 13:18:47 +00:00
parent 46ee39c5a1
commit b9930f0701
2 changed files with 35 additions and 21 deletions

View file

@ -50,16 +50,9 @@ int EXPORT GB_INIT(void)
if (!comp) if (!comp)
{ {
comp = "gb.gtk.opengl"; // GB_GUI should be set by gb.gui
fprintf(stderr, "gb.gui.opengl: error: no component specified in GB_GUI environment variable");
env = getenv("KDE_FULL_SESSION"); exit(1);
if (env && !strcmp(env, "true"))
{
env = getenv("KDE_SESSION_VERSION");
if (env && !strcmp(env, "4"))
comp = "gb.qt4.opengl";
}
} }
if (GB.Component.Load(comp)) if (GB.Component.Load(comp))

View file

@ -25,6 +25,10 @@
#include "main.h" #include "main.h"
#define USE_NOTHING 0
#define USE_GB_QT4 1
#define USE_GB_GTK 2
GB_INTERFACE GB EXPORT; GB_INTERFACE GB EXPORT;
// Prevents gbi3 from complaining // Prevents gbi3 from complaining
@ -38,21 +42,23 @@ char *GB_INCLUDE EXPORT = "gb.qt4";
int EXPORT GB_INIT(void) int EXPORT GB_INIT(void)
{ {
const char *comp = NULL; int use = USE_NOTHING;
char *env; char *env;
const char *comp;
const char *comp2;
env = getenv("GB_GUI"); env = getenv("GB_GUI");
if (env) if (env)
{ {
if (!strcmp(env, "gb.qt4")) if (strcmp(env, "gb.qt4") == 0)
comp = "gb.qt4"; use = USE_GB_QT4;
else if (!strcmp(env, "gb.gtk")) else if (strcmp(env, "gb.gtk") == 0)
comp = "gb.gtk"; use = USE_GB_GTK;
} }
if (!comp) if (use == USE_NOTHING)
{ {
comp = "gb.gtk"; use = USE_GB_GTK;
env = getenv("KDE_FULL_SESSION"); env = getenv("KDE_FULL_SESSION");
@ -60,13 +66,28 @@ int EXPORT GB_INIT(void)
{ {
env = getenv("KDE_SESSION_VERSION"); env = getenv("KDE_SESSION_VERSION");
if (env && !strcmp(env, "4")) if (env && !strcmp(env, "4"))
comp = "gb.qt4"; use = USE_GB_QT4;
} }
} }
comp = use == USE_GB_QT4 ? "gb.qt4" : "gb.gtk";
if (GB.Component.Load(comp)) if (GB.Component.Load(comp))
fprintf(stderr, "gb.gui: unable to load '%s' component\n", comp); {
comp2 = use == USE_GB_QT4 ? "gb.gtk" : "gb.qt4";
if (GB.Component.Load(comp2))
{
fprintf(stderr, "gb.gui: error: unable to find any GUI component. Please install the 'gb.qt4' or 'gb.gtk' component\n");
exit(1);
}
fprintf(stderr, "gb.gui: warning: '%s' component not found, using '%s' instead\n", comp, comp2);
comp = comp2;
}
setenv("GB_GUI", comp, TRUE);
return 0; return 0;
} }