1#include <gio/gio.h> 2#include <glib-object.h> 3 4void schema_id_literal() { 5 GSettings *settings; 6 settings = g_settings_new("org.gnome.evolution-data-server.addressbook"); 7 g_object_unref(settings); 8} 9 10#define SELF_UID_PATH_ID "org.gnome.evolution-data-server.addressbook" 11int schema_id_from_constant() { 12 GSettings *settings; 13 settings = g_settings_new(SELF_UID_PATH_ID); 14 g_object_unref(settings); 15} 16 17void schema_id_autoptr() { 18 g_autoptr(GSettings) settings = NULL; 19 settings = g_settings_new("org.gnome.evolution.calendar"); 20} 21 22void schema_id_with_backend() { 23 GSettings *settings; 24 settings = g_settings_new_with_backend("org.gnome.evolution-data-server.addressbook", g_settings_backend_get_default()); 25 g_object_unref(settings); 26} 27 28void schema_id_with_backend_and_path() { 29 GSettings *settings; 30 settings = g_settings_new_with_backend_and_path("org.gnome.seahorse.nautilus.window", g_settings_backend_get_default(), "/org/gnome/seahorse/nautilus/windows/123/"); 31 g_object_unref(settings); 32} 33 34void schema_id_with_path() { 35 GSettings *settings; 36 settings = g_settings_new_with_path("org.gnome.seahorse.nautilus.window", "/org/gnome/seahorse/nautilus/windows/123/"); 37 g_object_unref(settings); 38} 39 40void exists_fn_guard() { 41 if (!e_ews_common_utils_gsettings_schema_exists("org.gnome.evolution.calendar")) { 42 return; 43 } 44 45 g_autoptr(GSettings) settings = NULL; 46 settings = g_settings_new("org.gnome.evolution.calendar"); 47} 48 49void exists_fn_nested() { 50 if (e_ews_common_utils_gsettings_schema_exists("org.gnome.evolution.calendar")) { 51 g_autoptr(GSettings) settings = NULL; 52 settings = g_settings_new("org.gnome.evolution.calendar"); 53 } 54} 55 56void exists_fn_unknown() { 57 if (e_ews_common_utils_gsettings_schema_exists("org.gnome.foo")) { 58 g_autoptr(GSettings) settings = NULL; 59 settings = g_settings_new("org.gnome.evolution.calendar"); 60 } 61} 62 63int main() { 64 schema_id_literal(); 65 schema_id_from_constant(); 66 schema_id_autoptr(); 67 schema_id_with_backend(); 68 schema_id_with_backend_and_path(); 69 schema_id_with_path(); 70 exists_fn_guard(); 71 exists_fn_nested(); 72 exists_fn_unknown(); 73 74 return 0; 75}