-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainrps_gtk.cc
109 lines (95 loc) · 3.34 KB
/
mainrps_gtk.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// file RefPerSys/gtk4gui-refpersys/mainrps_gtk.cc
// SPDX-License-Identifier: MIT
/******
* © Copyright 2023 - 2024 Basile STARYNKEVITCH and Abishek CHAKRAVARTI
*
* A GTK4mm toolkit graphical interface (see fox-toolkit.org)
* to the RefPerSys open source (GPLv3+ licensed) inference engine
*
* see gnome.pages.gitlab.gnome.org/gtkmm-documentation/
*
* See refpersys.org and code on https://github.com/RefPerSys/
*
******/
#include "gtkrps.hh"
#include "gtkmm/version.h"
const char*gtkrps_progname;
const char gtkrps_git_id[] = GIT_ID;
const char gtkrps_shortgit_id[] = SHORTGIT_ID;
const char gtkrps_buildhost[]= GTKRPS_HOST;
const char gtkrps_arch[] = GTKRPS_ARCH;
const char gtkrps_opersys[] = GTKRPS_OPERSYS;
const char gtkrps_timestamp[] = __DATE__ "@" __TIME__;
extern "C" const char guirefpersys_ui[];
char gtkrps_myhostname[80];
void* gtkrps_dlhandle;
bool gtkrps_stderr_istty;
static void
gtkrps_show_version(void)
{
printf("%s version information\n", gtkrps_progname);
printf("\t full git %s\n", gtkrps_git_id);
printf("\t short git %s\n", gtkrps_shortgit_id);
printf("\t build host %s\n", gtkrps_buildhost);
printf("\t arch: %s\n", gtkrps_arch);
printf("\t OS: %s\n", gtkrps_opersys);
printf("\t built: %s\n", gtkrps_timestamp);
/// for some reason, don't work!
#if 0 && bad
printf("\t GTKmm version: %d.%d.%d\n",
gtkmm_major_version, gtkmm_minor_version, gtkmm_micro_version);
#endif
} // end gtkrps_show_version
void
gtkrps_fatal_stop_at(const char*fil, int lin)
{
fprintf(stderr, "%s FATAL STOP (%s:%d) pid %d shortgit %s\n",
gtkrps_progname,
fil, lin,
(int)getpid(), gtkrps_shortgit_id);
abort();
} // end gtkrps_fatal_stop_at
extern "C" const char gtkrpsui_guirefpersys[];
Glib::RefPtr<Gtk::Application> gtkrps_app;
Gtk::Window*gtkrps_mainwin;
int
main(int argc, char**argv)
{
assert(argc>0);
gtkrps_progname = argv[0];
gtkrps_dlhandle = dlopen(nullptr, RTLD_NOW| RTLD_GLOBAL);
if (!gtkrps_dlhandle)
GTKRPS_FATALOUT("failed to dlopen main program: " << dlerror());
gtkrps_stderr_istty = isatty(STDERR_FILENO);
memset (gtkrps_myhostname, 0, sizeof(gtkrps_myhostname));
gethostname(gtkrps_myhostname, sizeof(gtkrps_myhostname)-4);
if (argc > 1 && !strcmp(argv[1], "--version"))
{
gtkrps_show_version();
exit (EXIT_SUCCESS);
};
gtkrps_app = Gtk::Application::create ("org.refpersys.gtk4gui");
#warning help needed here to parse program arguments
#if 0 && badcode
gtkrps_app->add_main_option_entry(Gtk::OPTION_TYPE_BOOL, "version", 'V',
("Print version"), "");
gtkrps_app->add_main_option_entry(Gtk::Application::OPTION_TYPE_STRING, "fifo-prefix", 'F',
("set the prefix of FIFO used for communication"),
"");
#endif
Glib::ustring builder_str(gtkrpsui_guirefpersys);
auto builder = Gtk::Builder::create_from_string(builder_str);
gtkrps_app->signal_activate().connect([&] ()
{
gtkrps_mainwin = builder->get_widget<Gtk::Window>("app_window");
gtkrps_app->add_window(*gtkrps_mainwin);
gtkrps_mainwin->show();
});
return gtkrps_app->run(argc, argv);
} // end main
/****************
** for Emacs...
** Local Variables: ;;
** compile-command: "make guigtkrps" ;;
** End: ;;
****************/