[glib/ebassi/application-flags: 1/3] Introduce G_APPLICATION_DEFAULT_FLAGS




commit 79a12af6bcada8d02bc98c651672f72e13a309be
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Sun Jul 24 16:10:33 2022 +0100

    Introduce G_APPLICATION_DEFAULT_FLAGS
    
    Enumeration members should either have the name of the type as their
    prefix, or they should all have the same prefix.
    
    The "default flags" enumeration member for GApplicationFlags is
    unfortunately named G_APPLICATION_FLAGS_NONE, while every other member
    of the same type has a G_APPLICATION prefix. The result is that the nick
    name of the enumeration member is "flags-none", and that language
    bindings will have to use something like
    Gio.ApplicationFlags.FLAGS_NONE.
    
    To fix this API wart, we can deprecate the FLAGS_NONE member, and add a
    new DEFAULT_FLAGS.

 gio/gapplication.c          |  2 +-
 gio/gioenums.h              |  9 ++++++---
 gio/gioenumtypes.c.template |  2 ++
 gio/tests/gapplication.c    | 16 ++++++++--------
 gio/tests/gnotification.c   |  2 +-
 5 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/gio/gapplication.c b/gio/gapplication.c
index 77fde804a5..1d602c763d 100644
--- a/gio/gapplication.c
+++ b/gio/gapplication.c
@@ -1486,7 +1486,7 @@ g_application_class_init (GApplicationClass *class)
     g_param_spec_flags ("flags",
                         P_("Application flags"),
                         P_("Flags specifying the behaviour of the application"),
-                        G_TYPE_APPLICATION_FLAGS, G_APPLICATION_FLAGS_NONE,
+                        G_TYPE_APPLICATION_FLAGS, G_APPLICATION_DEFAULT_FLAGS,
                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
   g_object_class_install_property (object_class, PROP_RESOURCE_BASE_PATH,
diff --git a/gio/gioenums.h b/gio/gioenums.h
index fb59449964..e19774c3c9 100644
--- a/gio/gioenums.h
+++ b/gio/gioenums.h
@@ -1480,7 +1480,9 @@ typedef enum
 
 /**
  * GApplicationFlags:
- * @G_APPLICATION_FLAGS_NONE: Default
+ * @G_APPLICATION_FLAGS_NONE: Default. Deprecated in 2.74, use
+ *   %G_APPLICATION_DEFAULT_FLAGS instead
+ * @G_APPLICATION_DEFAULT_FLAGS: Default flags. Since: 2.74
  * @G_APPLICATION_IS_SERVICE: Run as a service. In this mode, registration
  *      fails if the service is already running, and the application
  *      will initially wait up to 10 seconds for an initial activation
@@ -1522,9 +1524,10 @@ typedef enum
  *
  * Since: 2.28
  **/
-typedef enum
+typedef enum /*< prefix=G_APPLICATION >*/
 {
-  G_APPLICATION_FLAGS_NONE,
+  G_APPLICATION_FLAGS_NONE GLIB_DEPRECATED_ENUMERATOR_IN_2_74_FOR (G_APPLICATION_DEFAULT_FLAGS),
+  G_APPLICATION_DEFAULT_FLAGS GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 0,
   G_APPLICATION_IS_SERVICE  =          (1 << 0),
   G_APPLICATION_IS_LAUNCHER =          (1 << 1),
 
diff --git a/gio/gioenumtypes.c.template b/gio/gioenumtypes.c.template
index 95340f9ecf..ff9b63b68a 100644
--- a/gio/gioenumtypes.c.template
+++ b/gio/gioenumtypes.c.template
@@ -20,6 +20,8 @@
  * Authors: Matthias Clasen <mclasen redhat com>
  */
 
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
 #include "config.h"
 #include "gioenumtypes.h"
 #include <gio.h>
diff --git a/gio/tests/gapplication.c b/gio/tests/gapplication.c
index b017e437ff..bf0395cdba 100644
--- a/gio/tests/gapplication.c
+++ b/gio/tests/gapplication.c
@@ -391,7 +391,7 @@ properties (void)
                 NULL);
 
   g_assert_cmpstr (id, ==, "org.gtk.TestApplication");
-  g_assert_cmpint (flags, ==, G_APPLICATION_FLAGS_NONE);
+  g_assert_cmpint (flags, ==, G_APPLICATION_DEFAULT_FLAGS);
   g_assert (!registered);
   g_assert_cmpint (timeout, ==, 0);
 
@@ -487,7 +487,7 @@ test_nodbus (void)
   gchar *argv[] = { binpath, NULL };
   GApplication *app;
 
-  app = g_application_new ("org.gtk.Unimportant", G_APPLICATION_FLAGS_NONE);
+  app = g_application_new ("org.gtk.Unimportant", G_APPLICATION_DEFAULT_FLAGS);
   g_signal_connect (app, "activate", G_CALLBACK (nodbus_activate), NULL);
   g_application_run (app, 1, argv);
   g_object_unref (app);
@@ -517,7 +517,7 @@ test_noappid (void)
   gchar *argv[] = { binpath, NULL };
   GApplication *app;
 
-  app = g_application_new (NULL, G_APPLICATION_FLAGS_NONE);
+  app = g_application_new (NULL, G_APPLICATION_DEFAULT_FLAGS);
   g_signal_connect (app, "activate", G_CALLBACK (noappid_activate), NULL);
   g_application_run (app, 1, argv);
   g_object_unref (app);
@@ -561,7 +561,7 @@ test_quit (void)
   c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
 
   app = g_application_new ("org.gtk.Unimportant",
-                           G_APPLICATION_FLAGS_NONE);
+                           G_APPLICATION_DEFAULT_FLAGS);
   activated = FALSE;
   quitted = FALSE;
   g_signal_connect (app, "activate", G_CALLBACK (quit_activate), NULL);
@@ -613,7 +613,7 @@ test_registered (void)
   RegisteredData registered_data = { FALSE, NULL };
   GApplication *app;
 
-  app = g_application_new (NULL, G_APPLICATION_FLAGS_NONE);
+  app = g_application_new (NULL, G_APPLICATION_DEFAULT_FLAGS);
   g_signal_connect (app, "activate", G_CALLBACK (noappid_activate), NULL);
   g_signal_connect (app, "shutdown", G_CALLBACK (on_registered_shutdown), &registered_data);
   g_signal_connect (app, "notify::is-registered", G_CALLBACK (on_registered_notify), &registered_data);
@@ -693,7 +693,7 @@ test_local_actions (void)
   GApplication *app;
 
   app = g_application_new ("org.gtk.Unimportant",
-                           G_APPLICATION_FLAGS_NONE);
+                           G_APPLICATION_DEFAULT_FLAGS);
   g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL);
   g_application_run (app, 1, argv);
   g_object_unref (app);
@@ -748,7 +748,7 @@ test_local_command_line (void)
 
   app = g_object_new (test_loc_cmd_app_get_type (),
                       "application-id", "org.gtk.Unimportant",
-                      "flags", G_APPLICATION_FLAGS_NONE,
+                      "flags", G_APPLICATION_DEFAULT_FLAGS,
                       NULL);
   g_application_run (app, 1, argv);
   g_object_unref (app);
@@ -1166,7 +1166,7 @@ test_replace (gconstpointer data)
       bus = g_test_dbus_new (0);
       g_test_dbus_up (bus);
 
-      app = g_application_new ("org.gtk.TestApplication.Replace", allow ? G_APPLICATION_ALLOW_REPLACEMENT : 
G_APPLICATION_FLAGS_NONE);
+      app = g_application_new ("org.gtk.TestApplication.Replace", allow ? G_APPLICATION_ALLOW_REPLACEMENT : 
G_APPLICATION_DEFAULT_FLAGS);
       g_application_set_inactivity_timeout (app, 500);
       g_signal_connect (app, "name-lost", G_CALLBACK (name_was_lost), &name_lost);
       g_signal_connect (app, "startup", G_CALLBACK (startup_cb), &data);
diff --git a/gio/tests/gnotification.c b/gio/tests/gnotification.c
index 2f7f36ee3c..41cbb3d330 100644
--- a/gio/tests/gnotification.c
+++ b/gio/tests/gnotification.c
@@ -123,7 +123,7 @@ server_notify_is_running (GObject    *object,
     {
       GApplication *app;
 
-      app = g_application_new ("org.gtk.TestApplication", G_APPLICATION_FLAGS_NONE);
+      app = g_application_new ("org.gtk.TestApplication", G_APPLICATION_DEFAULT_FLAGS);
       g_signal_connect (app, "activate", G_CALLBACK (activate_app), NULL);
 
       g_application_run (app, 0, NULL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]