project-wizard: bgo #732672 - Suggestion to use a Glade prompted handler name rather...
[anjuta.git] / plugins / project-wizard / file.c
blob35dcd90eacfdfccb68c29a599d8c866a5bbf7207
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 file.c
4 Copyright (C) 2004 Sebastien Granjoux
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, Boston, MA 02110-1301 USA
22 * File data read in .wiz file
24 *---------------------------------------------------------------------------*/
26 #include <config.h>
28 #include "file.h"
30 /*---------------------------------------------------------------------------*/
32 struct _NPWFile {
33 NPWFileType type;
34 gchar* source;
35 gchar* destination;
36 gint attribute;
39 typedef enum {
40 NPW_EXECUTE_FILE = 1 << 0,
41 NPW_PROJECT_FILE = 1 << 1,
42 NPW_AUTOGEN_SET = 1 << 2,
43 NPW_AUTOGEN_FILE = 1 << 3
44 } NPWFileAttributes;
46 /* File object
47 *---------------------------------------------------------------------------*/
49 NPWFile*
50 npw_file_new_file (const gchar *destination, const gchar *source)
52 NPWFile *file;
54 g_return_val_if_fail (destination && source, NULL);
56 file = g_slice_new(NPWFile);
57 file->type = NPW_FILE;
58 file->destination = g_strdup (destination);
59 file->source = g_strdup (source);
60 file->attribute = 0;
62 return file;
65 void
66 npw_file_free (NPWFile* file)
68 g_free (file->destination);
69 g_free (file->source);
70 g_slice_free (NPWFile, file);
73 NPWFileType
74 npw_file_get_type (const NPWFile* file)
76 return file->type;
79 const gchar*
80 npw_file_get_destination (const NPWFile* file)
82 return file->destination;
85 const gchar*
86 npw_file_get_source (const NPWFile* file)
88 return file->source;
91 void
92 npw_file_set_execute (NPWFile* file, gboolean value)
94 if (value)
96 file->attribute |= NPW_EXECUTE_FILE;
98 else
100 file->attribute &= ~NPW_EXECUTE_FILE;
104 gboolean
105 npw_file_get_execute (const NPWFile* file)
107 return file->attribute & NPW_EXECUTE_FILE;
110 void
111 npw_file_set_project (NPWFile* file, gboolean value)
113 if (value)
115 file->attribute |= NPW_PROJECT_FILE;
117 else
119 file->attribute &= ~NPW_PROJECT_FILE;
123 gboolean
124 npw_file_get_project (const NPWFile* file)
126 return file->attribute & NPW_PROJECT_FILE;
129 void
130 npw_file_set_autogen (NPWFile* file, NPWFileBooleanValue value)
132 switch (value)
134 case NPW_FILE_TRUE:
135 file->attribute |= NPW_AUTOGEN_FILE | NPW_AUTOGEN_SET;
136 break;
137 case NPW_FILE_FALSE:
138 file->attribute |= NPW_AUTOGEN_SET;
139 file->attribute &= ~NPW_AUTOGEN_FILE;
140 break;
141 case NPW_FILE_DEFAULT:
142 file->attribute &= ~(NPW_AUTOGEN_SET | NPW_AUTOGEN_FILE);
143 break;
147 NPWFileBooleanValue
148 npw_file_get_autogen (const NPWFile* file)
150 return file->attribute & NPW_AUTOGEN_SET ? (file->attribute & NPW_AUTOGEN_FILE ? NPW_FILE_TRUE : NPW_FILE_FALSE) : NPW_FILE_DEFAULT;