1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 Copyright (C) Dragos Dena 2010
6 This program 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 2 of the License, or
9 (at your option) any later version.
11 This program 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.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301 USA
22 #ifndef __SNIPPETS_DB_H__
23 #define __SNIPPETS_DB_H__
27 #include <glib-object.h>
30 #include "snippets-group.h"
31 #include <libanjuta/anjuta-shell.h>
35 typedef struct _SnippetsDB SnippetsDB
;
36 typedef struct _SnippetsDBPrivate SnippetsDBPrivate
;
37 typedef struct _SnippetsDBClass SnippetsDBClass
;
39 #define ANJUTA_TYPE_SNIPPETS_DB (snippets_db_get_type ())
40 #define ANJUTA_SNIPPETS_DB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_SNIPPETS_DB, SnippetsDB))
41 #define ANJUTA_SNIPPETS_DB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ANJUTA_TYPE_SNIPPETS_DB, SnippetsDBClass))
42 #define ANJUTA_IS_SNIPPETS_DB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANJUTA_TYPE_SNIPPETS_DB))
43 #define ANJUTA_IS_SNIPPETS_DB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ANJUTA_TYPE_SNIPPETS_DB))
46 * @SNIPPETS_DB_MODEL_COL_CUR_OBJECT: An #AnjutaSnippet or #AnjutaSnippetsGroup object.
47 * @SNIPPETS_DB_MODEL_COL_NAME: The name of the #AnjutaSnippet or #AnjutaSnippetsGroup.
48 * @SNIPPETS_DB_MODEL_COL_TRIGGER: The trigger of the #AnjutaSnippet or "".
49 * @SNIPPETS_DB_MODEL_COL_LANGUAGES: The supported languages of the #AnjutaSnippet or "".
51 * SnippetsDB Tree Model columns.
56 SNIPPETS_DB_MODEL_COL_CUR_OBJECT
= 0,
57 SNIPPETS_DB_MODEL_COL_NAME
,
58 SNIPPETS_DB_MODEL_COL_TRIGGER
,
59 SNIPPETS_DB_MODEL_COL_LANGUAGES
,
60 SNIPPETS_DB_MODEL_COL_N
65 GLOBAL_VARS_MODEL_COL_NAME
= 0,
66 GLOBAL_VARS_MODEL_COL_VALUE
,
67 GLOBAL_VARS_MODEL_COL_IS_COMMAND
,
68 GLOBAL_VARS_MODEL_COL_IS_INTERNAL
,
69 GLOBAL_VARS_MODEL_COL_N
76 AnjutaShell
* anjuta_shell
;
81 SnippetsDBPrivate
* priv
;
84 struct _SnippetsDBClass
97 GType
snippets_db_get_type (void) G_GNUC_CONST
;
98 SnippetsDB
* snippets_db_new (void);
100 void snippets_db_load (SnippetsDB
*snippets_db
);
101 void snippets_db_close (SnippetsDB
*snippets_db
);
103 GtkTreePath
* snippets_db_get_path_at_object (SnippetsDB
*snippets_db
,
105 void snippets_db_save_snippets (SnippetsDB
*snippets_db
);
106 void snippets_db_save_global_vars (SnippetsDB
*snippets_db
);
107 void snippets_db_debug (SnippetsDB
*snippets_db
);
109 /* Snippet handling methods */
110 gboolean
snippets_db_add_snippet (SnippetsDB
* snippets_db
,
111 AnjutaSnippet
* added_snippet
,
112 const gchar
* group_name
);
113 gboolean
snippets_db_has_snippet (SnippetsDB
*snippets_db
,
114 AnjutaSnippet
*snippet
);
115 AnjutaSnippet
* snippets_db_get_snippet (SnippetsDB
* snippets_db
,
116 const gchar
* trigger_key
,
117 const gchar
* language
);
118 gboolean
snippets_db_remove_snippet (SnippetsDB
* snippets_db
,
119 const gchar
* trigger_key
,
120 const gchar
* language
,
121 gboolean remove_all_languages_support
);
123 /* SnippetsGroup handling methods */
124 gboolean
snippets_db_add_snippets_group (SnippetsDB
* snippets_db
,
125 AnjutaSnippetsGroup
* snippets_group
,
126 gboolean overwrite_group
);
127 AnjutaSnippetsGroup
* snippets_db_get_snippets_group (SnippetsDB
* snippets_db
,
128 const gchar
* group_name
);
129 gboolean
snippets_db_remove_snippets_group (SnippetsDB
* snippets_db
,
130 const gchar
* group_name
);
131 void snippets_db_set_snippets_group_name (SnippetsDB
*snippets_db
,
132 const gchar
*old_group_name
,
133 const gchar
*new_group_name
);
134 gboolean
snippets_db_has_snippets_group_name (SnippetsDB
*snippets_db
,
135 const gchar
*group_name
);
136 GList
* snippets_db_get_snippets_groups (SnippetsDB
*snippets_db
);
138 /* Global variables handling methods */
139 gboolean
snippets_db_add_global_variable (SnippetsDB
* snippets_db
,
140 const gchar
* variable_name
,
141 const gchar
* variable_value
,
142 gboolean variable_is_command
,
144 gboolean
snippets_db_set_global_variable_name (SnippetsDB
* snippets_db
,
145 const gchar
* variable_old_name
,
146 const gchar
* variable_new_name
);
147 gboolean
snippets_db_set_global_variable_value (SnippetsDB
* snippets_db
,
148 const gchar
* variable_name
,
149 const gchar
* variable_new_value
);
150 gboolean
snippets_db_set_global_variable_type (SnippetsDB
*snippets_db
,
151 const gchar
* variable_name
,
152 gboolean is_command
);
153 gchar
* snippets_db_get_global_variable (SnippetsDB
* snippets_db
,
154 const gchar
* variable_name
);
155 gchar
* snippets_db_get_global_variable_text (SnippetsDB
* snippets_db
,
156 const gchar
* variable_name
);
157 gboolean
snippets_db_remove_global_variable (SnippetsDB
* snippets_db
,
158 const gchar
* variable_name
);
159 gboolean
snippets_db_has_global_variable (SnippetsDB
* snippets_db
,
160 const gchar
* variable_name
);
161 GtkTreeModel
* snippets_db_get_global_vars_model (SnippetsDB
* snippes_db
);
165 #endif /* __SNIPPETS_DB_H__ */