2015-05-28 12:08:13 +02:00
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
main.c
|
|
|
|
|
2018-02-12 02:53:46 +01:00
|
|
|
(c) 2000-2017 Benoît Minisini <g4mba5@gmail.com>
|
2015-05-28 12:08:13 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
MA 02110-1301, USA.
|
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#define __MAIN_C
|
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
enum { USE_NOTHING, USE_GB_QT4, USE_GB_QT5 };
|
|
|
|
|
2019-01-05 03:57:08 +01:00
|
|
|
const GB_INTERFACE *GB_PTR EXPORT;
|
2015-05-28 12:08:13 +02:00
|
|
|
|
|
|
|
// Prevents gbi3 from complaining
|
|
|
|
|
|
|
|
GB_DESC *GB_CLASSES[] EXPORT =
|
|
|
|
{
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2017-08-29 00:38:43 +02:00
|
|
|
char *GB_INCLUDE EXPORT = "gb.qt4|gb.qt5";
|
2015-05-28 12:08:13 +02:00
|
|
|
|
2020-09-23 01:06:18 +02:00
|
|
|
static bool _debug = FALSE;
|
|
|
|
|
2019-01-05 03:57:08 +01:00
|
|
|
|
|
|
|
const char *get_name(int use)
|
|
|
|
{
|
|
|
|
switch (use)
|
|
|
|
{
|
|
|
|
case USE_GB_QT4: return "gb.qt4";
|
|
|
|
default: return "gb.qt5";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-10 18:29:05 +01:00
|
|
|
#include "gb_gui_test_temp.h"
|
2019-01-05 03:57:08 +01:00
|
|
|
|
2015-05-28 12:08:13 +02:00
|
|
|
int EXPORT GB_INIT(void)
|
|
|
|
{
|
|
|
|
int use = USE_NOTHING;
|
2019-01-05 03:57:08 +01:00
|
|
|
int use_other = USE_NOTHING;
|
2015-05-28 12:08:13 +02:00
|
|
|
char *env;
|
|
|
|
const char *comp;
|
2020-09-23 01:06:18 +02:00
|
|
|
const char *fail;
|
|
|
|
char not_found[32];
|
2015-05-28 12:08:13 +02:00
|
|
|
|
|
|
|
env = getenv("GB_GUI");
|
2015-05-30 20:03:29 +02:00
|
|
|
if (env && *env)
|
2015-05-28 12:08:13 +02:00
|
|
|
{
|
|
|
|
if (strcmp(env, "gb.qt4") == 0)
|
|
|
|
use = USE_GB_QT4;
|
|
|
|
else if (strcmp(env, "gb.qt5") == 0)
|
|
|
|
use = USE_GB_QT5;
|
2015-05-30 20:03:29 +02:00
|
|
|
else
|
2019-01-05 03:57:08 +01:00
|
|
|
fprintf(stderr, "gb.gui.qt: warning: '%s' component not supported\n", env);
|
2015-05-28 12:08:13 +02:00
|
|
|
}
|
|
|
|
|
2020-09-23 01:06:18 +02:00
|
|
|
env = getenv("GB_GUI_DEBUG");
|
|
|
|
if (env && strcmp(env, "0"))
|
|
|
|
_debug = TRUE;
|
|
|
|
|
2015-05-28 12:08:13 +02:00
|
|
|
if (use == USE_NOTHING)
|
|
|
|
{
|
2020-12-21 17:45:26 +01:00
|
|
|
use = GUI_should_use();
|
|
|
|
if (use == USE_NOTHING)
|
|
|
|
use = USE_GB_QT5;
|
2015-05-28 12:08:13 +02:00
|
|
|
}
|
|
|
|
|
2020-09-23 01:06:18 +02:00
|
|
|
if (_debug)
|
|
|
|
fprintf(stderr, "gb.gui: checking %s...\n", get_name(use));
|
|
|
|
|
|
|
|
fail = GUI_can_use(use);
|
|
|
|
if (fail)
|
2015-05-28 12:08:13 +02:00
|
|
|
{
|
2020-09-23 01:06:18 +02:00
|
|
|
strcpy(not_found, fail);
|
|
|
|
|
2019-01-05 03:57:08 +01:00
|
|
|
if (use == USE_GB_QT4)
|
|
|
|
use_other = USE_GB_QT5;
|
|
|
|
else
|
|
|
|
use_other = USE_GB_QT4;
|
|
|
|
|
2020-09-23 01:06:18 +02:00
|
|
|
if (!GUI_can_use(use_other))
|
2019-01-05 03:57:08 +01:00
|
|
|
{
|
2020-09-23 01:06:18 +02:00
|
|
|
fprintf(stderr, "gb.gui.qt: warning: '%s' component not found, using '%s' instead\n", not_found, get_name(use_other));
|
2019-01-05 03:57:08 +01:00
|
|
|
use = use_other;
|
|
|
|
}
|
|
|
|
else
|
2015-05-28 12:08:13 +02:00
|
|
|
{
|
2020-09-23 01:06:18 +02:00
|
|
|
fprintf(stderr, "gb.gui.qt: error: '%s' component not found, unable to find any QT replacement component\n", not_found);
|
2015-05-28 12:08:13 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
2019-01-05 03:57:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
comp = get_name(use);
|
|
|
|
|
|
|
|
if (GB.Component.Load(comp))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "gb.gui.qt: error: cannot load component '%s'\n", comp);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-23 01:06:18 +02:00
|
|
|
if (_debug)
|
2019-01-05 03:57:08 +01:00
|
|
|
fprintf(stderr, "gb.gui.qt: loading '%s'\n", comp);
|
2015-05-28 12:08:13 +02:00
|
|
|
}
|
2020-09-23 01:06:18 +02:00
|
|
|
|
|
|
|
setenv("GB_GUI", comp, TRUE);
|
2015-05-28 12:08:13 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EXPORT GB_EXIT()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|