1 /* GSequencer - Advanced GTK Sequencer 2 * Copyright (C) 2005-2021 Joël Krähemann 3 * 4 * This file is part of GSequencer. 5 * 6 * GSequencer is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * GSequencer is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with GSequencer. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef __AGS_APPLICATION_CONTEXT_H__ 21 #define __AGS_APPLICATION_CONTEXT_H__ 22 23 #include <glib.h> 24 #include <glib-object.h> 25 26 #include <libxml/tree.h> 27 28 #include <ags/lib/ags_uuid.h> 29 30 #include <ags/object/ags_config.h> 31 32 #include <unistd.h> 33 34 G_BEGIN_DECLS 35 36 #define AGS_TYPE_APPLICATION_CONTEXT (ags_application_context_get_type()) 37 #define AGS_TYPE_APPLICATION_CONTEXT_FLAGS (ags_application_context_flags_get_type()) 38 #define AGS_APPLICATION_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_APPLICATION_CONTEXT, AgsApplicationContext)) 39 #define AGS_APPLICATION_CONTEXT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST(class, AGS_TYPE_APPLICATION_CONTEXT, AgsApplicationContextClass)) 40 #define AGS_IS_APPLICATION_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AGS_TYPE_APPLICATION_CONTEXT)) 41 #define AGS_IS_APPLICATION_CONTEXT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), AGS_TYPE_APPLICATION_CONTEXT)) 42 #define AGS_APPLICATION_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS(obj, AGS_TYPE_APPLICATION_CONTEXT, AgsApplicationContextClass)) 43 44 #define AGS_APPLICATION_CONTEXT_GET_OBJ_MUTEX(obj) (&(((AgsApplicationContext *) obj)->obj_mutex)) 45 46 #ifndef PACKAGE_VERSION 47 #define AGS_VERSION "3.0.0" 48 #else 49 #define AGS_VERSION PACKAGE_VERSION 50 #endif 51 52 #define AGS_BUILD_ID "Wed Nov 6 18:28:15 UTC 2019" 53 54 #define AGS_DEFAULT_DIRECTORY ".gsequencer" 55 #define AGS_DEFAULT_CONFIG "ags.conf" 56 57 typedef struct _AgsApplicationContext AgsApplicationContext; 58 typedef struct _AgsApplicationContextClass AgsApplicationContextClass; 59 60 /** 61 * AgsApplicationContextFlags: 62 * @AGS_APPLICATION_CONTEXT_ADDED_TO_REGISTRY: indicates the application context was added to #AgsRegistry 63 * @AGS_APPLICATION_CONTEXT_CONNECTED: indicates the application context was connected by calling #AgsConnectable::connect() 64 * @AGS_APPLICATION_CONTEXT_TYPES_REGISTERED: indicates the types have been registered 65 * 66 * Enum values to control the behavior or indicate internal state of #AgsApplicationContext by 67 * enable/disable as flags. 68 */ 69 typedef enum{ 70 AGS_APPLICATION_CONTEXT_ADDED_TO_REGISTRY = 1, 71 AGS_APPLICATION_CONTEXT_CONNECTED = 1 << 1, 72 AGS_APPLICATION_CONTEXT_TYPES_REGISTERED = 1 << 2, 73 }AgsApplicationContextFlags; 74 75 struct _AgsApplicationContext 76 { 77 GObject gobject; 78 79 guint flags; 80 81 GRecMutex obj_mutex; 82 83 AgsUUID *uuid; 84 85 gchar *version; 86 gchar *build_id; 87 88 int argc; 89 char **argv; 90 91 GObject *log; 92 93 gchar *domain; 94 95 AgsConfig *config; 96 97 GObject *main_loop; 98 GObject *task_launcher; 99 100 GObject *file; 101 GObject *history; 102 }; 103 104 struct _AgsApplicationContextClass 105 { 106 GObjectClass gobject; 107 108 void (*load_config)(AgsApplicationContext *application_context); 109 110 void (*prepare)(AgsApplicationContext *application_context); 111 void (*setup)(AgsApplicationContext *application_context); 112 113 void (*register_types)(AgsApplicationContext *application_context); 114 115 void (*read)(GObject *file, xmlNode *node, GObject **gobject); 116 xmlNode* (*write)(GObject *file, xmlNode *parent, GObject *gobject); 117 118 void (*quit)(AgsApplicationContext *application_context); 119 }; 120 121 GType ags_application_context_get_type(); 122 GType ags_application_context_flags_get_type(); 123 124 gboolean ags_application_context_test_flags(AgsApplicationContext *application_context, guint flags); 125 void ags_application_context_set_flags(AgsApplicationContext *application_context, guint flags); 126 void ags_application_context_unset_flags(AgsApplicationContext *application_context, guint flags); 127 128 void ags_application_context_load_config(AgsApplicationContext *application_context); 129 130 void ags_application_context_prepare(AgsApplicationContext *application_context); 131 void ags_application_context_setup(AgsApplicationContext *application_context); 132 133 void ags_application_context_register_types(AgsApplicationContext *application_context); 134 135 void ags_application_context_quit(AgsApplicationContext *application_context); 136 137 AgsApplicationContext* ags_application_context_get_instance(); 138 AgsApplicationContext* ags_application_context_new(GObject *main_loop, 139 AgsConfig *config); 140 141 G_END_DECLS 142 143 #endif /*__AGS_APPLICATION_CONTEXT_H__*/ 144