1 /* ide-context.h
2  *
3  * Copyright 2014-2019 Christian Hergert <chergert@redhat.com>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  * SPDX-License-Identifier: GPL-3.0-or-later
19  */
20 
21 #pragma once
22 
23 #if !defined (IDE_CORE_INSIDE) && !defined (IDE_CORE_COMPILATION)
24 # error "Only <libide-core.h> can be included directly."
25 #endif
26 
27 #include "ide-object.h"
28 
29 G_BEGIN_DECLS
30 
31 #define IDE_TYPE_CONTEXT (ide_context_get_type())
32 
33 IDE_AVAILABLE_IN_3_32
34 G_DECLARE_FINAL_TYPE (IdeContext, ide_context, IDE, CONTEXT, IdeObject)
35 
36 IDE_AVAILABLE_IN_3_32
37 IdeContext *ide_context_new                  (void);
38 IDE_AVAILABLE_IN_3_32
39 gboolean    ide_context_has_project          (IdeContext     *self);
40 IDE_AVAILABLE_IN_3_32
41 gpointer    ide_context_peek_child_typed     (IdeContext     *self,
42                                               GType           type);
43 IDE_AVAILABLE_IN_3_32
44 gchar      *ide_context_dup_project_id       (IdeContext     *self);
45 IDE_AVAILABLE_IN_3_32
46 void        ide_context_set_project_id       (IdeContext     *self,
47                                               const gchar    *project_id);
48 IDE_AVAILABLE_IN_3_32
49 gchar      *ide_context_dup_title            (IdeContext     *self);
50 IDE_AVAILABLE_IN_3_32
51 void        ide_context_set_title            (IdeContext     *self,
52                                               const gchar    *title);
53 IDE_AVAILABLE_IN_3_32
54 GFile      *ide_context_ref_workdir          (IdeContext     *self);
55 IDE_AVAILABLE_IN_3_32
56 void        ide_context_set_workdir          (IdeContext     *self,
57                                               GFile          *workdir);
58 IDE_AVAILABLE_IN_3_32
59 GFile      *ide_context_build_file           (IdeContext     *self,
60                                               const gchar    *path);
61 IDE_AVAILABLE_IN_3_32
62 gchar      *ide_context_build_filename       (IdeContext     *self,
63                                               const gchar    *first_part,
64                                               ...) G_GNUC_NULL_TERMINATED;
65 IDE_AVAILABLE_IN_3_32
66 GFile      *ide_context_cache_file           (IdeContext     *self,
67                                               const gchar    *first_part,
68                                               ...) G_GNUC_NULL_TERMINATED;
69 IDE_AVAILABLE_IN_3_32
70 gchar      *ide_context_cache_filename       (IdeContext     *self,
71                                               const gchar    *first_part,
72                                               ...) G_GNUC_NULL_TERMINATED;
73 IDE_AVAILABLE_IN_3_32
74 GSettings  *ide_context_ref_project_settings (IdeContext     *self);
75 IDE_AVAILABLE_IN_3_32
76 IdeContext *ide_object_ref_context           (IdeObject      *self);
77 IDE_AVAILABLE_IN_3_32
78 IdeContext *ide_object_get_context           (IdeObject      *object);
79 IDE_AVAILABLE_IN_3_32
80 void        ide_object_set_context           (IdeObject      *object,
81                                               IdeContext     *context);
82 IDE_AVAILABLE_IN_3_32
83 void        ide_context_log                  (IdeContext     *self,
84                                               GLogLevelFlags  level,
85                                               const gchar    *domain,
86                                               const gchar    *message);
87 
88 #ifdef __cplusplus
89 #define ide_context_warning(instance, format, ...) \
90   ide_object_log(instance, G_LOG_LEVEL_WARNING, G_LOG_DOMAIN, format __VA_OPT__(,) __VA_ARGS__)
91 #else
92 #define ide_context_warning(instance, format, ...) \
93   ide_object_log(instance, G_LOG_LEVEL_WARNING, G_LOG_DOMAIN, format, ##__VA_ARGS__)
94 #endif
95 
96 G_END_DECLS
97