Opening recent projects: Don't ask whether to close current project
[geany-mirror.git] / src / build.h
blobf9d720d06a34befb72cd17e7e7c4c36dcb942a5e
1 /*
2 * build.h - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2005 The Geany contributors
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 along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 /** @file build.h Interface to the Build menu functionality. */
23 #ifndef GEANY_BUILD_H
24 #define GEANY_BUILD_H 1
26 #include "document.h"
27 #include "filetypes.h"
29 #include "gtkcompat.h"
31 G_BEGIN_DECLS
33 /** Groups of Build menu items. */
34 typedef enum
36 GEANY_GBG_FT, /**< filetype items */
37 GEANY_GBG_NON_FT, /**< non filetype items.*/
38 GEANY_GBG_EXEC, /**< execute items */
39 GEANY_GBG_COUNT /**< count of groups. */
40 } GeanyBuildGroup;
42 /** Build menu item sources in increasing priority */
43 typedef enum
45 GEANY_BCS_DEF, /**< Default values. */
46 GEANY_BCS_FT, /**< System filetype values. */
47 GEANY_BCS_HOME_FT, /**< Filetypes in ~/.config/geany/filedefs */
48 GEANY_BCS_PREF, /**< Preferences file ~/.config/geany/geany.conf */
49 GEANY_BCS_PROJ_FT, /**< Project file filetype command */
50 GEANY_BCS_PROJ, /**< Project file if open. */
51 GEANY_BCS_COUNT /**< Count of sources. */
52 } GeanyBuildSource;
54 /** The entries of a command for a menu item */
55 typedef enum GeanyBuildCmdEntries
57 GEANY_BC_LABEL, /**< The menu item label, _ marks mnemonic */
58 GEANY_BC_COMMAND, /**< The command to run. */
59 GEANY_BC_WORKING_DIR, /**< The directory to run in */
60 GEANY_BC_CMDENTRIES_COUNT /**< Count of entries */
61 } GeanyBuildCmdEntries;
63 void build_activate_menu_item(const GeanyBuildGroup grp, const guint cmd);
65 const gchar *build_get_current_menu_item(const GeanyBuildGroup grp, const guint cmd,
66 const GeanyBuildCmdEntries field);
68 void build_remove_menu_item(const GeanyBuildSource src, const GeanyBuildGroup grp, const gint cmd);
70 void build_set_menu_item(const GeanyBuildSource src, const GeanyBuildGroup grp,
71 const guint cmd, const GeanyBuildCmdEntries field, const gchar *value);
73 guint build_get_group_count(const GeanyBuildGroup grp);
76 #ifdef GEANY_PRIVATE
78 /* include the fixed widgets in an array indexed by groups */
79 #define GBG_FIXED GEANY_GBG_COUNT
81 enum GeanyBuildFixedMenuItems
83 GBF_NEXT_ERROR,
84 GBF_PREV_ERROR,
85 GBF_COMMANDS,
86 GBF_SEP_1,
87 GBF_SEP_2,
88 GBF_SEP_3,
89 GBF_SEP_4,
90 GBF_COUNT
93 typedef struct GeanyBuildInfo
95 GeanyBuildGroup grp;
96 guint cmd;
97 GPid pid; /* process id of the spawned process */
98 gchar *dir;
99 guint file_type_id;
100 gchar *custom_target;
101 gint message_count;
102 } GeanyBuildInfo;
104 extern GeanyBuildInfo build_info;
106 /* * The command for a menu item. */
107 typedef struct GeanyBuildCommand
109 /* * Pointers to g_string values of the command entries.
110 * Must be freed if the pointer is changed. */
111 gchar *label; /* *< Menu item label */
112 gchar *command; /* *< Command to run */
113 gchar *working_dir; /* *< working directory */
114 gboolean exists; /* *< If the entries have valid values. */
115 gboolean changed; /* *< Save on exit if @c changed, remove if not @c exist. */
116 gboolean old; /* *< Converted from old format. */
117 } GeanyBuildCommand;
119 typedef struct BuildMenuItems
121 GtkWidget *menu;
122 GtkWidget **menu_item[GEANY_GBG_COUNT + 1]; /* +1 for fixed items */
123 } BuildMenuItems;
125 /* a structure defining the destinations for a set of groups of commands & regex */
126 typedef struct BuildDestination
128 GeanyBuildCommand **dst[GEANY_GBG_COUNT];
129 gchar **fileregexstr;
130 gchar **nonfileregexstr;
131 } BuildDestination;
133 /* opaque pointers returned from build functions and passed back to them */
134 typedef struct BuildTableFields *BuildTableData;
137 void build_init(void);
139 void build_finalize(void);
141 /* menu configuration dialog functions */
142 GtkWidget *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, BuildTableData *data, GeanyFiletype *ft);
144 void build_read_project(GeanyFiletype *ft, BuildTableData build_properties);
146 void build_free_fields(BuildTableData data);
148 /* build response decode assistance function */
149 gboolean build_parse_make_dir(const gchar *string, gchar **prefix);
151 /* build menu functions */
153 void build_menu_update(GeanyDocument *doc);
155 void build_toolbutton_build_clicked(GtkAction *action, gpointer user_data);
157 GeanyBuildCommand *build_get_menu_item(const GeanyBuildSource src, const GeanyBuildGroup grp, const guint cmd);
159 BuildMenuItems *build_get_menu_items(gint filetype_idx);
161 /* load and store menu configuration */
162 void build_load_menu(GKeyFile *config, GeanyBuildSource dst, gpointer ptr);
164 void build_save_menu(GKeyFile *config, gpointer ptr, GeanyBuildSource src);
166 void build_set_group_count(GeanyBuildGroup grp, gint count);
168 gchar **build_get_regex(GeanyBuildGroup grp, GeanyFiletype *ft, guint *from);
170 gboolean build_keybinding(guint key_id);
172 #endif /* GEANY_PRIVATE */
174 G_END_DECLS
176 #endif /* GEANY_BUILD_H */