18
18
19
19
#include " ezgl/application.hpp"
20
20
21
+ // GLib deprecated G_APPLICATION_FLAGS_NONE and replaced it with G_APPLICATION_DEFAULT_FLAGS,
22
+ // however, this enum was not introduced until GLib 2.74. These lines of code allow EZGL
23
+ // to be backwards compatible with older versions of GLib, while not using the deprecated
24
+ // enum.
25
+ #if GLIB_CHECK_VERSION(2, 74, 0)
26
+ static constexpr GApplicationFlags EZGL_APPLICATION_DEFAULT_FLAGS = G_APPLICATION_DEFAULT_FLAGS;
27
+ #else
28
+ static constexpr GApplicationFlags EZGL_APPLICATION_DEFAULT_FLAGS = G_APPLICATION_FLAGS_NONE;
29
+ #endif
30
+
21
31
namespace ezgl {
22
32
23
33
// A flag to disable event loop (default is false)
@@ -86,7 +96,7 @@ application::application(application::settings s)
86
96
, m_window_id(s.window_identifier)
87
97
, m_canvas_id(s.canvas_identifier)
88
98
, m_application_id(s.application_identifier)
89
- , m_application(gtk_application_new(s.application_identifier.c_str(), G_APPLICATION_FLAGS_NONE ))
99
+ , m_application(gtk_application_new(s.application_identifier.c_str(), EZGL_APPLICATION_DEFAULT_FLAGS ))
90
100
, m_builder(gtk_builder_new())
91
101
, m_register_callbacks(s.setup_callbacks)
92
102
{
@@ -205,7 +215,7 @@ int application::run(setup_callback_fn initial_setup_user_callback,
205
215
g_object_unref (m_builder);
206
216
207
217
// Reconstruct the GTK application
208
- m_application = (gtk_application_new (m_application_id.c_str (), G_APPLICATION_FLAGS_NONE ));
218
+ m_application = (gtk_application_new (m_application_id.c_str (), EZGL_APPLICATION_DEFAULT_FLAGS ));
209
219
m_builder = (gtk_builder_new ());
210
220
g_signal_connect (m_application, " startup" , G_CALLBACK (startup), this );
211
221
g_signal_connect (m_application, " activate" , G_CALLBACK (activate), this );
@@ -478,4 +488,4 @@ void set_disable_event_loop(bool new_setting)
478
488
{
479
489
disable_event_loop = new_setting;
480
490
}
481
- }
491
+ }
0 commit comments