1818
1919#include " ezgl/application.hpp"
2020
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+
2131namespace ezgl {
2232
2333// A flag to disable event loop (default is false)
@@ -86,7 +96,7 @@ application::application(application::settings s)
8696 , m_window_id(s.window_identifier)
8797 , m_canvas_id(s.canvas_identifier)
8898 , 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 ))
90100 , m_builder(gtk_builder_new())
91101 , m_register_callbacks(s.setup_callbacks)
92102{
@@ -205,7 +215,7 @@ int application::run(setup_callback_fn initial_setup_user_callback,
205215 g_object_unref (m_builder);
206216
207217 // 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 ));
209219 m_builder = (gtk_builder_new ());
210220 g_signal_connect (m_application, " startup" , G_CALLBACK (startup), this );
211221 g_signal_connect (m_application, " activate" , G_CALLBACK (activate), this );
@@ -478,4 +488,4 @@ void set_disable_event_loop(bool new_setting)
478488{
479489 disable_event_loop = new_setting;
480490}
481- }
491+ }
0 commit comments