1 /* ide-vcs.h
2  *
3  * Copyright 2015-2019 Christian Hergert <christian@hergert.me>
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_VCS_INSIDE) && !defined (IDE_VCS_COMPILATION)
24 # error "Only <libide-vcs.h> can be included directly."
25 #endif
26 
27 #include <libide-core.h>
28 
29 #include "ide-vcs-branch.h"
30 #include "ide-vcs-config.h"
31 
32 G_BEGIN_DECLS
33 
34 #define IDE_TYPE_VCS (ide_vcs_get_type())
35 
36 IDE_AVAILABLE_IN_3_32
37 G_DECLARE_INTERFACE (IdeVcs, ide_vcs, IDE, VCS, IdeObject)
38 
39 struct _IdeVcsInterface
40 {
41   GTypeInterface            parent_interface;
42 
43   GFile                  *(*get_workdir)               (IdeVcs               *self);
44   gboolean                (*is_ignored)                (IdeVcs               *self,
45                                                         GFile                *file,
46                                                         GError              **error);
47   gint                    (*get_priority)              (IdeVcs               *self);
48   void                    (*changed)                   (IdeVcs               *self);
49   IdeVcsConfig           *(*get_config)                (IdeVcs               *self);
50   gchar                  *(*get_branch_name)           (IdeVcs               *self);
51   void                    (*list_status_async)         (IdeVcs               *self,
52                                                         GFile                *directory_or_file,
53                                                         gboolean              include_descendants,
54                                                         gint                  io_priority,
55                                                         GCancellable         *cancellable,
56                                                         GAsyncReadyCallback   callback,
57                                                         gpointer              user_data);
58   GListModel             *(*list_status_finish)        (IdeVcs               *self,
59                                                         GAsyncResult         *result,
60                                                         GError              **error);
61   void                    (*list_branches_async)       (IdeVcs               *self,
62                                                         GCancellable         *cancellable,
63                                                         GAsyncReadyCallback   callback,
64                                                         gpointer              user_data);
65   GPtrArray              *(*list_branches_finish)      (IdeVcs               *self,
66                                                         GAsyncResult         *result,
67                                                         GError              **error);
68   void                    (*list_tags_async)           (IdeVcs               *self,
69                                                         GCancellable         *cancellable,
70                                                         GAsyncReadyCallback   callback,
71                                                         gpointer              user_data);
72   GPtrArray              *(*list_tags_finish)          (IdeVcs               *self,
73                                                         GAsyncResult         *result,
74                                                         GError              **error);
75   void                    (*switch_branch_async)       (IdeVcs               *self,
76                                                         IdeVcsBranch         *branch,
77                                                         GCancellable         *cancellable,
78                                                         GAsyncReadyCallback   callback,
79                                                         gpointer              user_data);
80   gboolean                (*switch_branch_finish)      (IdeVcs               *self,
81                                                         GAsyncResult         *result,
82                                                         GError              **error);
83   void                    (*push_branch_async)         (IdeVcs               *self,
84                                                         IdeVcsBranch         *branch,
85                                                         GCancellable         *cancellable,
86                                                         GAsyncReadyCallback   callback,
87                                                         gpointer              user_data);
88   gboolean                (*push_branch_finish)        (IdeVcs               *self,
89                                                         GAsyncResult         *result,
90                                                         GError              **error);
91 };
92 
93 IDE_AVAILABLE_IN_3_32
94 IdeVcs       *ide_vcs_from_context         (IdeContext           *context);
95 IDE_AVAILABLE_IN_3_32
96 IdeVcs       *ide_vcs_ref_from_context     (IdeContext           *context);
97 IDE_AVAILABLE_IN_3_32
98 GFile        *ide_vcs_get_workdir          (IdeVcs               *self);
99 IDE_AVAILABLE_IN_3_32
100 gboolean      ide_vcs_is_ignored           (IdeVcs               *self,
101                                             GFile                *file,
102                                             GError              **error);
103 IDE_AVAILABLE_IN_3_32
104 gboolean      ide_vcs_path_is_ignored      (IdeVcs               *self,
105                                             const gchar          *path,
106                                             GError              **error);
107 IDE_AVAILABLE_IN_3_32
108 gint          ide_vcs_get_priority         (IdeVcs               *self);
109 IDE_AVAILABLE_IN_3_32
110 void          ide_vcs_emit_changed         (IdeVcs               *self);
111 IDE_AVAILABLE_IN_3_32
112 IdeVcsConfig *ide_vcs_get_config           (IdeVcs               *self);
113 IDE_AVAILABLE_IN_3_32
114 gchar        *ide_vcs_get_branch_name      (IdeVcs               *self);
115 IDE_AVAILABLE_IN_3_32
116 void          ide_vcs_list_status_async    (IdeVcs               *self,
117                                             GFile                *directory_or_file,
118                                             gboolean              include_descendants,
119                                             gint                  io_priority,
120                                             GCancellable         *cancellable,
121                                             GAsyncReadyCallback   callback,
122                                             gpointer              user_data);
123 IDE_AVAILABLE_IN_3_32
124 GListModel   *ide_vcs_list_status_finish   (IdeVcs               *self,
125                                             GAsyncResult         *result,
126                                             GError              **error);
127 IDE_AVAILABLE_IN_3_32
128 void          ide_vcs_list_branches_async  (IdeVcs               *self,
129                                             GCancellable         *cancellable,
130                                             GAsyncReadyCallback   callback,
131                                             gpointer              user_data);
132 IDE_AVAILABLE_IN_3_32
133 GPtrArray    *ide_vcs_list_branches_finish (IdeVcs               *self,
134                                             GAsyncResult         *result,
135                                             GError              **error);
136 IDE_AVAILABLE_IN_3_32
137 void          ide_vcs_list_tags_async      (IdeVcs               *self,
138                                             GCancellable         *cancellable,
139                                             GAsyncReadyCallback   callback,
140                                             gpointer              user_data);
141 IDE_AVAILABLE_IN_3_32
142 GPtrArray    *ide_vcs_list_tags_finish     (IdeVcs               *self,
143                                             GAsyncResult         *result,
144                                             GError              **error);
145 IDE_AVAILABLE_IN_3_32
146 void          ide_vcs_switch_branch_async  (IdeVcs               *self,
147                                             IdeVcsBranch         *branch,
148                                             GCancellable         *cancellable,
149                                             GAsyncReadyCallback   callback,
150                                             gpointer              user_data);
151 IDE_AVAILABLE_IN_3_32
152 gboolean      ide_vcs_switch_branch_finish (IdeVcs               *self,
153                                             GAsyncResult         *result,
154                                             GError              **error);
155 IDE_AVAILABLE_IN_3_34
156 void          ide_vcs_push_branch_async    (IdeVcs               *self,
157                                             IdeVcsBranch         *branch,
158                                             GCancellable         *cancellable,
159                                             GAsyncReadyCallback   callback,
160                                             gpointer              user_data);
161 IDE_AVAILABLE_IN_3_34
162 gboolean      ide_vcs_push_branch_finish   (IdeVcs               *self,
163                                             GAsyncResult         *result,
164                                             GError              **error);
165 
166 G_END_DECLS
167