Fix warnings, build API and execute toolbutton

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/branches/build-system@4033 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Lex Trotman 2009-07-28 01:38:41 +00:00
parent e3b1c92aa8
commit 6108436176
6 changed files with 147 additions and 161 deletions

View File

@ -1,3 +1,12 @@
2009-07-28 Lex Trotman <elextr(at)gmail(dot)com>
* src/build.c, src/build.h, src/project.c, src/keyfile.c, src/filetypes.c
Fix some more warnings.
Fix commented out execute/stop toolbar code in build.c.
Add extra plugins documentation for GBO_TO_CMD and GBO_TO_GBG macros.
Changed build.h api so all functions prefixed with build_.
2009-07-27 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> 2009-07-27 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/build.c, src/build.h, src/project.c: * src/build.c, src/build.h, src/project.c:

View File

@ -113,7 +113,7 @@ static gboolean build_iofunc(GIOChannel *ioc, GIOCondition cond, gpointer data);
#endif #endif
static gboolean build_create_shellscript(const gchar *fname, const gchar *cmd, gboolean autoclose); static gboolean build_create_shellscript(const gchar *fname, const gchar *cmd, gboolean autoclose);
static GPid build_spawn_cmd(GeanyDocument *doc, const gchar *cmd, const gchar *dir); static GPid build_spawn_cmd(GeanyDocument *doc, const gchar *cmd, const gchar *dir);
/* static void set_stop_button(gboolean stop); */ static void set_stop_button(gboolean stop);
static void run_exit_cb(GPid child_pid, gint status, gpointer user_data); static void run_exit_cb(GPid child_pid, gint status, gpointer user_data);
static void on_set_build_commands_activate(GtkWidget *w, gpointer u); static void on_set_build_commands_activate(GtkWidget *w, gpointer u);
static void on_build_next_error(GtkWidget *menuitem, gpointer user_data); static void on_build_next_error(GtkWidget *menuitem, gpointer user_data);
@ -333,7 +333,7 @@ static GeanyBuildCommand *get_build_cmd(GeanyDocument *doc, gint grp, gint cmdin
#define return_nonblank_regex(src, ptr) if ((ptr)!=NULL && strlen(ptr)>0){ *fr = (src); return &(ptr); } #define return_nonblank_regex(src, ptr) if ((ptr)!=NULL && strlen(ptr)>0){ *fr = (src); return &(ptr); }
/* like get_build_cmd, but for regexen, used by filetypes */ /* like get_build_cmd, but for regexen, used by filetypes */
gchar **get_build_regex(GeanyBuildGroup grp, GeanyFiletype *ft, gint *from) gchar **build_get_regex(GeanyBuildGroup grp, GeanyFiletype *ft, gint *from)
{ {
gint sink, *fr = &sink; gint sink, *fr = &sink;
if (from!=NULL) fr=from; if (from!=NULL) fr=from;
@ -656,7 +656,7 @@ static gchar *prepare_run_script(GeanyDocument *doc, gchar **vte_cmd_nonscript,
GeanyProject *project = app->project; GeanyProject *project = app->project;
GeanyBuildCommand *cmd = NULL; GeanyBuildCommand *cmd = NULL;
gchar *executable = NULL; gchar *executable = NULL;
gchar *working_dir = NULL; gchar *working_dir = NULL, *cmd_working_dir;
gboolean autoclose = FALSE; gboolean autoclose = FALSE;
gboolean result = FALSE; gboolean result = FALSE;
gchar *tmp; gchar *tmp;
@ -672,7 +672,9 @@ static gchar *prepare_run_script(GeanyDocument *doc, gchar **vte_cmd_nonscript,
cmd_string = build_replace_placeholder(doc, buildcmd_cmd(cmd)); cmd_string = build_replace_placeholder(doc, buildcmd_cmd(cmd));
working_dir = build_replace_placeholder(doc, buildcmd_working_dir(cmd)); /* in utf-8 */ cmd_working_dir = buildcmd_working_dir(cmd);
if (!NZV(cmd_working_dir)) cmd_working_dir = "%d";
working_dir = build_replace_placeholder(doc, cmd_working_dir); /* in utf-8 */
/* only test whether working dir exists, don't change it or else Windows support will break /* only test whether working dir exists, don't change it or else Windows support will break
* (gspawn-win32-helper.exe is used by GLib and must be in $PATH which means current working * (gspawn-win32-helper.exe is used by GLib and must be in $PATH which means current working
@ -1314,7 +1316,7 @@ void build_menu_update(GeanyDocument *doc)
gint i, cmdcount, cmd, grp; gint i, cmdcount, cmd, grp;
gboolean vis=FALSE; gboolean vis=FALSE;
gboolean have_path, build_running, exec_running, have_errors, cmd_sensitivity; gboolean have_path, build_running, exec_running, have_errors, cmd_sensitivity;
gboolean can_compile, can_make; gboolean can_compile, can_make, run_sensitivity, run_running;
GeanyBuildCommand *bc; GeanyBuildCommand *bc;
if (menu_items.menu==NULL) if (menu_items.menu==NULL)
@ -1389,6 +1391,7 @@ void build_menu_update(GeanyDocument *doc)
exec_running = run_info[cmd].pid>1; exec_running = run_info[cmd].pid>1;
cmd_sensitivity = bc!=NULL || exec_running; cmd_sensitivity = bc!=NULL || exec_running;
gtk_widget_set_sensitive(menu_item, cmd_sensitivity); gtk_widget_set_sensitive(menu_item, cmd_sensitivity);
if (cmd==GBO_TO_CMD(GBO_EXEC)) run_sensitivity = cmd_sensitivity;
if (!exec_running) if (!exec_running)
{ {
image = gtk_image_new_from_stock(bs->stock_id, GTK_ICON_SIZE_MENU); image = gtk_image_new_from_stock(bs->stock_id, GTK_ICON_SIZE_MENU);
@ -1397,6 +1400,7 @@ void build_menu_update(GeanyDocument *doc)
{ {
image = gtk_image_new_from_stock(GTK_STOCK_STOP, GTK_ICON_SIZE_MENU); image = gtk_image_new_from_stock(GTK_STOCK_STOP, GTK_ICON_SIZE_MENU);
} }
if (cmd==GBO_TO_CMD(GBO_EXEC)) run_running = exec_running;
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), image); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), image);
if (bc != NULL && label != NULL if (bc != NULL && label != NULL
&& strlen(label) > 0) && strlen(label) > 0)
@ -1434,21 +1438,18 @@ void build_menu_update(GeanyDocument *doc)
gtk_action_set_sensitive(widgets.compile_action, can_compile); gtk_action_set_sensitive(widgets.compile_action, can_compile);
gtk_action_set_sensitive(widgets.build_action, can_make ); gtk_action_set_sensitive(widgets.build_action, can_make );
/* gtk_action_set_sensitive(widgets.run_action, can_run || can_stop); */ gtk_action_set_sensitive(widgets.run_action, run_sensitivity);
/* show the stop command if a program is running, otherwise show run command /* show the stop command if a program is running from execute 0 , otherwise show run command */
set_stop_button(can_stop); */ set_stop_button(run_running);
} }
/* Call build_menu_update() instead of calling this directly. */ /* Call build_menu_update() instead of calling this directly. */
#if 0
static void set_stop_button(gboolean stop) static void set_stop_button(gboolean stop)
{ {
const gchar *button_stock_id = NULL; const gchar *button_stock_id = NULL;
GtkStockItem sitem;
GtkToolButton *run_button; GtkToolButton *run_button;
GtkWidget *menuitem = build_get_menu_items(run_info.file_type_id)->item_exec;
run_button = GTK_TOOL_BUTTON(toolbar_get_widget_by_name("Run")); run_button = GTK_TOOL_BUTTON(toolbar_get_widget_by_name("Run"));
if (run_button != NULL) if (run_button != NULL)
@ -1464,33 +1465,13 @@ static void set_stop_button(gboolean stop)
{ {
if (run_button != NULL) if (run_button != NULL)
gtk_tool_button_set_stock_id(run_button, "gtk-stop"); gtk_tool_button_set_stock_id(run_button, "gtk-stop");
if (menuitem != NULL)
{
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem),
gtk_image_new_from_stock("gtk-stop", GTK_ICON_SIZE_MENU));
gtk_stock_lookup("gtk-stop", &sitem);
gtk_label_set_text_with_mnemonic(GTK_LABEL(gtk_bin_get_child(GTK_BIN(menuitem))),
sitem.label);
}
} }
else else
{ {
if (run_button != NULL) if (run_button != NULL)
gtk_tool_button_set_stock_id(run_button, "gtk-execute"); gtk_tool_button_set_stock_id(run_button, "gtk-execute");
if (menuitem != NULL)
{
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem),
gtk_image_new_from_stock("gtk-execute", GTK_ICON_SIZE_MENU));
gtk_stock_lookup("gtk-execute", &sitem);
gtk_label_set_text_with_mnemonic(GTK_LABEL(gtk_bin_get_child(GTK_BIN(menuitem))),
sitem.label);
} }
} }
}
#endif
static void on_set_build_commands_activate(GtkWidget *w, gpointer u) static void on_set_build_commands_activate(GtkWidget *w, gpointer u)
{ {
@ -1663,7 +1644,7 @@ static RowWidgets *build_add_dialog_row(GeanyDocument *doc, GtkTable *table, gin
GtkWidget *label, *clear, *clearicon; GtkWidget *label, *clear, *clearicon;
RowWidgets *roww; RowWidgets *roww;
GeanyBuildCommand *bc; GeanyBuildCommand *bc;
guint src; gint src;
enum GeanyBuildCmdEntries i; enum GeanyBuildCmdEntries i;
gint column = 0; gint column = 0;
@ -1722,7 +1703,7 @@ GtkWidget *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, TableD
GtkTable *table; GtkTable *table;
gchar **ch, *txt; gchar **ch, *txt;
gint col, row, cmdindex, cmd; gint col, row, cmdindex, cmd;
guint src; gint src;
gboolean sensitivity; gboolean sensitivity;
table = GTK_TABLE(gtk_table_new(build_items_count+12, 5, FALSE)); table = GTK_TABLE(gtk_table_new(build_items_count+12, 5, FALSE));
@ -1752,7 +1733,7 @@ GtkWidget *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, TableD
gtk_table_attach(table, label, 0, DC_ENTRIES+1, row, row+1, GTK_FILL, GTK_FILL | GTK_EXPAND, gtk_table_attach(table, label, 0, DC_ENTRIES+1, row, row+1, GTK_FILL, GTK_FILL | GTK_EXPAND,
entry_x_padding, entry_y_padding); entry_x_padding, entry_y_padding);
fields->fileregex = gtk_entry_new(); fields->fileregex = gtk_entry_new();
fields->fileregexstring = get_build_regex(GBG_FT, NULL, &src); fields->fileregexstring = build_get_regex(GBG_FT, NULL, &src);
sensitivity = ft==NULL?FALSE:TRUE; sensitivity = ft==NULL?FALSE:TRUE;
if (fields->fileregexstring!=NULL && *(fields->fileregexstring)!=NULL) if (fields->fileregexstring!=NULL && *(fields->fileregexstring)!=NULL)
{ {
@ -1785,7 +1766,7 @@ GtkWidget *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, TableD
gtk_table_attach(table, label, 0, DC_ENTRIES+1, row, row+1, GTK_FILL, GTK_FILL | GTK_EXPAND, gtk_table_attach(table, label, 0, DC_ENTRIES+1, row, row+1, GTK_FILL, GTK_FILL | GTK_EXPAND,
entry_x_padding, entry_y_padding); entry_x_padding, entry_y_padding);
fields->nonfileregex = gtk_entry_new(); fields->nonfileregex = gtk_entry_new();
fields->nonfileregexstring = get_build_regex(GBG_NON_FT, NULL, &src); fields->nonfileregexstring = build_get_regex(GBG_NON_FT, NULL, &src);
sensitivity = TRUE; sensitivity = TRUE;
if (fields->nonfileregexstring!=NULL && *(fields->nonfileregexstring)!=NULL) if (fields->nonfileregexstring!=NULL && *(fields->nonfileregexstring)!=NULL)
{ {
@ -2045,7 +2026,7 @@ static const gchar *fixedkey="xx_xx_xx";
#define set_key_cmd(key,cmd) (key[prefixlen+3]=cmd[0], key[prefixlen+4]=cmd[1]) #define set_key_cmd(key,cmd) (key[prefixlen+3]=cmd[0], key[prefixlen+4]=cmd[1])
#define set_key_fld(key,fld) (key[prefixlen+6]=fld[0], key[prefixlen+7]=fld[1]) #define set_key_fld(key,fld) (key[prefixlen+6]=fld[0], key[prefixlen+7]=fld[1])
static void load_build_menu_grp(GKeyFile *config, GeanyBuildCommand **dst, gint grp, static void build_load_menu_grp(GKeyFile *config, GeanyBuildCommand **dst, gint grp,
gchar *prefix, gboolean loc) gchar *prefix, gboolean loc)
{ {
gint cmd, prefixlen; /* NOTE prefixlen used in macros above */ gint cmd, prefixlen; /* NOTE prefixlen used in macros above */
@ -2087,7 +2068,7 @@ static void load_build_menu_grp(GKeyFile *config, GeanyBuildCommand **dst, gint
/* for the specified source load new format build menu items or try to make some sense of /* for the specified source load new format build menu items or try to make some sense of
* old format setings, not done perfectly but better than ignoring them */ * old format setings, not done perfectly but better than ignoring them */
void load_build_menu(GKeyFile *config, GeanyBuildSource src, gpointer p) void build_load_menu(GKeyFile *config, GeanyBuildSource src, gpointer p)
{ {
/* gint grp;*/ /* gint grp;*/
GeanyFiletype *ft; GeanyFiletype *ft;
@ -2103,28 +2084,28 @@ void load_build_menu(GKeyFile *config, GeanyBuildSource src, gpointer p)
case BCS_FT: case BCS_FT:
ft = (GeanyFiletype*)p; ft = (GeanyFiletype*)p;
if (ft==NULL)return; if (ft==NULL)return;
load_build_menu_grp(config, &(ft->filecmds), GBG_FT, NULL, TRUE); build_load_menu_grp(config, &(ft->filecmds), GBG_FT, NULL, TRUE);
load_build_menu_grp(config, &(ft->ftdefcmds), GBG_NON_FT, NULL, TRUE); build_load_menu_grp(config, &(ft->ftdefcmds), GBG_NON_FT, NULL, TRUE);
load_build_menu_grp(config, &(ft->execcmds), GBG_EXEC, NULL, TRUE); build_load_menu_grp(config, &(ft->execcmds), GBG_EXEC, NULL, TRUE);
setptr(ft->error_regex_string, setptr(ft->error_regex_string,
g_key_file_get_string(config, build_grp_name, "error_regex", NULL)); g_key_file_get_string(config, build_grp_name, "error_regex", NULL));
break; break;
case BCS_HOME_FT: case BCS_HOME_FT:
ft = (GeanyFiletype*)p; ft = (GeanyFiletype*)p;
if (ft==NULL)return; if (ft==NULL)return;
load_build_menu_grp(config, &(ft->homefilecmds), GBG_FT, NULL, FALSE); build_load_menu_grp(config, &(ft->homefilecmds), GBG_FT, NULL, FALSE);
load_build_menu_grp(config, &(ft->homeexeccmds), GBG_EXEC, NULL, FALSE); build_load_menu_grp(config, &(ft->homeexeccmds), GBG_EXEC, NULL, FALSE);
setptr(ft->homeerror_regex_string, setptr(ft->homeerror_regex_string,
g_key_file_get_string(config, build_grp_name, "error_regex", NULL)); g_key_file_get_string(config, build_grp_name, "error_regex", NULL));
break; break;
case BCS_PREF: case BCS_PREF:
load_build_menu_grp(config, &non_ft_pref, GBG_NON_FT, NULL, FALSE); build_load_menu_grp(config, &non_ft_pref, GBG_NON_FT, NULL, FALSE);
load_build_menu_grp(config, &exec_pref, GBG_EXEC, NULL, FALSE); build_load_menu_grp(config, &exec_pref, GBG_EXEC, NULL, FALSE);
setptr(regex_pref, g_key_file_get_string(config, build_grp_name, "error_regex", NULL)); setptr(regex_pref, g_key_file_get_string(config, build_grp_name, "error_regex", NULL));
break; break;
case BCS_PROJ: case BCS_PROJ:
load_build_menu_grp(config, &non_ft_proj, GBG_NON_FT, NULL, FALSE); build_load_menu_grp(config, &non_ft_proj, GBG_NON_FT, NULL, FALSE);
load_build_menu_grp(config, &exec_proj, GBG_EXEC, NULL, FALSE); build_load_menu_grp(config, &exec_proj, GBG_EXEC, NULL, FALSE);
setptr(regex_proj, g_key_file_get_string(config, build_grp_name, "error_regex", NULL)); setptr(regex_proj, g_key_file_get_string(config, build_grp_name, "error_regex", NULL));
pj = (GeanyProject*)p; pj = (GeanyProject*)p;
if (p==NULL)return; if (p==NULL)return;
@ -2141,7 +2122,7 @@ void load_build_menu(GKeyFile *config, GeanyBuildSource src, gpointer p)
{ {
gchar *regkey = g_strdup_printf("%serror_regex", *ftname); gchar *regkey = g_strdup_printf("%serror_regex", *ftname);
g_ptr_array_add(pj->build_filetypes_list, ft); g_ptr_array_add(pj->build_filetypes_list, ft);
load_build_menu_grp(config, &(ft->projfilecmds), GBG_FT, *ftname, FALSE); build_load_menu_grp(config, &(ft->projfilecmds), GBG_FT, *ftname, FALSE);
setptr(ft->projerror_regex_string, setptr(ft->projerror_regex_string,
g_key_file_get_string(config, build_grp_name, regkey, NULL)); g_key_file_get_string(config, build_grp_name, regkey, NULL));
g_free(regkey); g_free(regkey);
@ -2214,7 +2195,7 @@ void load_build_menu(GKeyFile *config, GeanyBuildSource src, gpointer p)
} }
} }
static gint save_build_menu_grp(GKeyFile *config, GeanyBuildCommand *src, gint grp, gchar *prefix) static gint build_save_menu_grp(GKeyFile *config, GeanyBuildCommand *src, gint grp, gchar *prefix)
{ {
gint cmd, prefixlen; /* NOTE prefixlen used in macros above */ gint cmd, prefixlen; /* NOTE prefixlen used in macros above */
gchar *key; gchar *key;
@ -2269,7 +2250,7 @@ static void foreach_project_filetype(gpointer data, gpointer user_data)
gint i=0; gint i=0;
gchar *regkey = g_strdup_printf("%serror_regex", ft->name); gchar *regkey = g_strdup_printf("%serror_regex", ft->name);
i += save_build_menu_grp(d->config, ft->projfilecmds, GBG_FT, ft->name); i += build_save_menu_grp(d->config, ft->projfilecmds, GBG_FT, ft->name);
if (ft->projerror_regex_string!=NULL && strlen(ft->projerror_regex_string)>0) if (ft->projerror_regex_string!=NULL && strlen(ft->projerror_regex_string)>0)
{ {
g_key_file_set_string(d->config, build_grp_name, regkey, ft->projerror_regex_string); g_key_file_set_string(d->config, build_grp_name, regkey, ft->projerror_regex_string);
@ -2281,7 +2262,7 @@ static void foreach_project_filetype(gpointer data, gpointer user_data)
if (i>0)g_ptr_array_add(d->ft_names, ft->name); if (i>0)g_ptr_array_add(d->ft_names, ft->name);
} }
void save_build_menu(GKeyFile *config, gpointer ptr, GeanyBuildSource src) void build_save_menu(GKeyFile *config, gpointer ptr, GeanyBuildSource src)
{ {
GeanyFiletype *ft; GeanyFiletype *ft;
GeanyProject *pj; GeanyProject *pj;
@ -2293,8 +2274,8 @@ void save_build_menu(GKeyFile *config, gpointer ptr, GeanyBuildSource src)
case BCS_HOME_FT: case BCS_HOME_FT:
ft = (GeanyFiletype*)ptr; ft = (GeanyFiletype*)ptr;
if (ft==NULL)return; if (ft==NULL)return;
save_build_menu_grp(config, ft->homefilecmds, GBG_FT, NULL); build_save_menu_grp(config, ft->homefilecmds, GBG_FT, NULL);
save_build_menu_grp(config, ft->homeexeccmds, GBG_EXEC, NULL); build_save_menu_grp(config, ft->homeexeccmds, GBG_EXEC, NULL);
regkey = g_strdup_printf("%serror_regex", ft->name); regkey = g_strdup_printf("%serror_regex", ft->name);
if (ft->homeerror_regex_string!=NULL && strlen(ft->homeerror_regex_string)>0) if (ft->homeerror_regex_string!=NULL && strlen(ft->homeerror_regex_string)>0)
g_key_file_set_string(config, build_grp_name, regkey, ft->projerror_regex_string); g_key_file_set_string(config, build_grp_name, regkey, ft->projerror_regex_string);
@ -2303,8 +2284,8 @@ void save_build_menu(GKeyFile *config, gpointer ptr, GeanyBuildSource src)
g_free(regkey); g_free(regkey);
break; break;
case BCS_PREF: case BCS_PREF:
save_build_menu_grp(config, non_ft_pref, GBG_NON_FT, NULL); build_save_menu_grp(config, non_ft_pref, GBG_NON_FT, NULL);
save_build_menu_grp(config, exec_pref, GBG_EXEC, NULL); build_save_menu_grp(config, exec_pref, GBG_EXEC, NULL);
if (regex_pref!=NULL && strlen(regex_pref)>0) if (regex_pref!=NULL && strlen(regex_pref)>0)
g_key_file_set_string(config, build_grp_name, "error_regex", regex_pref); g_key_file_set_string(config, build_grp_name, "error_regex", regex_pref);
else else
@ -2312,8 +2293,8 @@ void save_build_menu(GKeyFile *config, gpointer ptr, GeanyBuildSource src)
break; break;
case BCS_PROJ: case BCS_PROJ:
pj = (GeanyProject*)ptr; pj = (GeanyProject*)ptr;
save_build_menu_grp(config, non_ft_proj, GBG_NON_FT, NULL); build_save_menu_grp(config, non_ft_proj, GBG_NON_FT, NULL);
save_build_menu_grp(config, exec_proj, GBG_EXEC, NULL); build_save_menu_grp(config, exec_proj, GBG_EXEC, NULL);
if (regex_proj!=NULL && strlen(regex_proj)>0) if (regex_proj!=NULL && strlen(regex_proj)>0)
g_key_file_set_string(config, build_grp_name, "error_regex", regex_proj); g_key_file_set_string(config, build_grp_name, "error_regex", regex_proj);
else else
@ -2336,7 +2317,7 @@ void save_build_menu(GKeyFile *config, gpointer ptr, GeanyBuildSource src)
} }
} }
void set_build_grp_count(GeanyBuildGroup grp, gint count) void build_set_group_count(GeanyBuildGroup grp, gint count)
{ {
gint i, sum; gint i, sum;
if (count>build_groups_count[grp]) if (count>build_groups_count[grp])
@ -2345,7 +2326,7 @@ void set_build_grp_count(GeanyBuildGroup grp, gint count)
build_items_count = sum; build_items_count = sum;
} }
gint get_build_group_count(GeanyBuildGroup grp) gint build_get_group_count(GeanyBuildGroup grp)
{ {
return build_groups_count[grp]; return build_groups_count[grp];
} }

View File

@ -28,17 +28,20 @@
#define GEANY_BUILD_ERR_HIGHLIGHT_MAX 100 #define GEANY_BUILD_ERR_HIGHLIGHT_MAX 100
/* Geany Known Build Commands, currently only these can have keybindings /* Order is important (see GBO_TO_GBG, GBO_TO_CMD below) */
* Order is important (see GBO_TO_GBG, GBO_TO_CMD below) */ /** Geany Known Build Commands.
* These commands are named after their default use.
* Only these commands can currently have keybindings.
**/
typedef enum typedef enum
{ {
GBO_COMPILE, GBO_COMPILE, /**< default compile file */
GBO_BUILD, GBO_BUILD, /**< default build file */
GBO_MAKE_ALL, GBO_MAKE_ALL, /**< default make */
GBO_MAKE_CUSTOM, GBO_MAKE_CUSTOM, /**< default make user specified target */
GBO_MAKE_OBJECT, GBO_MAKE_OBJECT, /**< default make object, make %e.o */
GBO_EXEC, GBO_EXEC, /**< default execute ./%e */
GBO_COUNT /* count of how many */ GBO_COUNT /**< count of how many */
} GeanyBuildType; } GeanyBuildType;
/** Groups of Build menu items. */ /** Groups of Build menu items. */
@ -53,10 +56,33 @@ typedef enum
/* include the fixed widgets in an array indexed by groups */ /* include the fixed widgets in an array indexed by groups */
#define GBG_FIXED GBG_COUNT #define GBG_FIXED GBG_COUNT
/* convert GBO_xxx to GBG_xxx and command number /** Convert @c GeanyBuildType to @c GeanyBuildGroup .
* Note they are macros so they can be used in static initialisers */ *
#define GBO_TO_GBG(gbo) ((gbo)>GBO_EXEC?GBG_COUNT:((gbo)>=GBO_EXEC?GBG_EXEC:((gbo)>=GBO_MAKE_ALL?GBG_NON_FT:GBG_FT))) * This macro converts @c GeanyBiuildType enum values (the "known" commands)
#define GBO_TO_CMD(gbo) ((gbo)>=GBO_COUNT?(gbo)-GBO_COUNT:((gbo)>=GBO_EXEC?(gbo)-GBO_EXEC:((gbo)>=GBO_MAKE_ALL?(gbo)-GBO_MAKE_ALL:(gbo)))) * to the group they are part of.
*
* @param gbo the @c GeanyBuildType value.
*
* @return the @c GeanyBuildGroup group that @a gbo is in.
*
* Note this is a macro so that it can be used in static initialisers
**/
#define GBO_TO_GBG(gbo) ((gbo)>GBO_EXEC?GBG_COUNT:((gbo)>=GBO_EXEC?GBG_EXEC: \
((gbo)>=GBO_MAKE_ALL?GBG_NON_FT:GBG_FT)))
/** Convert @c GeanyBuildType to command index.
*
* This macro converts @c GeanyBuildType enum values (the "known" commands)
* to the index within the group.
*
* @param gbo the @c GeanyBuildType value.
*
* @return the index of the @a gbo command in its group.
*
* Note this is a macro so that it can be used in static initialisers
**/
#define GBO_TO_CMD(gbo) ((gbo)>=GBO_COUNT?(gbo)-GBO_COUNT:((gbo)>=GBO_EXEC?(gbo)-GBO_EXEC: \
((gbo)>=GBO_MAKE_ALL?(gbo)-GBO_MAKE_ALL:(gbo))))
enum GeanyBuildFixedMenuItems enum GeanyBuildFixedMenuItems
{ {
@ -230,14 +256,14 @@ GeanyBuildCommand *build_get_current_menu_item(GeanyBuildGroup grp, gint cmd, gi
BuildMenuItems *build_get_menu_items(gint filetype_idx); BuildMenuItems *build_get_menu_items(gint filetype_idx);
/* load and store menu configuration */ /* load and store menu configuration */
void load_build_menu( GKeyFile *config, GeanyBuildSource dst, gpointer ptr); void build_load_menu( GKeyFile *config, GeanyBuildSource dst, gpointer ptr);
void save_build_menu( GKeyFile *config, gpointer ptr, GeanyBuildSource src); void build_save_menu( GKeyFile *config, gpointer ptr, GeanyBuildSource src);
void set_build_grp_count(GeanyBuildGroup grp, gint count); void build_set_group_count(GeanyBuildGroup grp, gint count);
gint get_build_group_count(GeanyBuildGroup grp); gint build_get_group_count(GeanyBuildGroup grp);
gchar **get_build_regex(GeanyBuildGroup grp, GeanyFiletype *ft, gint *from); gchar **build_get_regex(GeanyBuildGroup grp, GeanyFiletype *ft, gint *from);
#endif #endif

View File

@ -1126,8 +1126,8 @@ static void load_settings(gint ft_id, GKeyFile *config, GKeyFile *configh)
} }
/* read build settings */ /* read build settings */
load_build_menu( config, BCS_FT, (gpointer)ft ); build_load_menu( config, BCS_FT, (gpointer)ft );
load_build_menu( configh, BCS_HOME_FT, (gpointer)ft ); build_load_menu( configh, BCS_HOME_FT, (gpointer)ft );
} }
@ -1226,7 +1226,7 @@ void filetypes_save_commands(void)
g_free(ext); g_free(ext);
config_home = g_key_file_new(); config_home = g_key_file_new();
g_key_file_load_from_file(config_home, fname, G_KEY_FILE_KEEP_COMMENTS, NULL); g_key_file_load_from_file(config_home, fname, G_KEY_FILE_KEEP_COMMENTS, NULL);
save_build_menu(config_home, (gpointer)(filetypes[i]), BCS_HOME_FT); build_save_menu(config_home, (gpointer)(filetypes[i]), BCS_HOME_FT);
data = g_key_file_to_data(config_home, NULL, NULL); data = g_key_file_to_data(config_home, NULL, NULL);
utils_write_file(fname, data); utils_write_file(fname, data);
g_free(data); g_free(data);
@ -1346,7 +1346,7 @@ gboolean filetypes_parse_error_message(GeanyFiletype *ft, const gchar *message,
doc = document_get_current(); doc = document_get_current();
if(doc!=NULL)ft = doc->file_type; if(doc!=NULL)ft = doc->file_type;
} }
tmp = get_build_regex(build_info.grp, ft, NULL); tmp = build_get_regex(build_info.grp, ft, NULL);
if (tmp==NULL) return FALSE; if (tmp==NULL) return FALSE;
regstr = *tmp; regstr = *tmp;
#ifndef HAVE_REGCOMP #ifndef HAVE_REGCOMP

View File

@ -407,7 +407,7 @@ static void save_dialog_prefs(GKeyFile *config)
g_key_file_set_string(config, PACKAGE, "context_action_cmd", tool_prefs.context_action_cmd); g_key_file_set_string(config, PACKAGE, "context_action_cmd", tool_prefs.context_action_cmd);
/* build menu */ /* build menu */
save_build_menu( config, NULL, BCS_PREF ); build_save_menu( config, NULL, BCS_PREF );
/* printing */ /* printing */
g_key_file_set_string(config, "printing", "print_cmd", printing_prefs.external_print_cmd ? printing_prefs.external_print_cmd : ""); g_key_file_set_string(config, "printing", "print_cmd", printing_prefs.external_print_cmd ? printing_prefs.external_print_cmd : "");
@ -773,10 +773,10 @@ static void load_dialog_prefs(GKeyFile *config)
tool_prefs.context_action_cmd = utils_get_setting_string(config, PACKAGE, "context_action_cmd", ""); tool_prefs.context_action_cmd = utils_get_setting_string(config, PACKAGE, "context_action_cmd", "");
/* build menu */ /* build menu */
set_build_grp_count( GBG_FT, utils_get_setting_integer( config, "build-menu", "number_ft_menu_items", 0 )); build_set_group_count( GBG_FT, utils_get_setting_integer( config, "build-menu", "number_ft_menu_items", 0 ));
set_build_grp_count( GBG_NON_FT, utils_get_setting_integer( config, "build-menu", "number_non_ft_menu_items", 0 )); build_set_group_count( GBG_NON_FT, utils_get_setting_integer( config, "build-menu", "number_non_ft_menu_items", 0 ));
set_build_grp_count( GBG_EXEC, utils_get_setting_integer( config, "build-menu", "number_exec_menu_items", 0 )); build_set_group_count( GBG_EXEC, utils_get_setting_integer( config, "build-menu", "number_exec_menu_items", 0 ));
load_build_menu( config, BCS_PREF, NULL ); build_load_menu( config, BCS_PREF, NULL );
/* printing */ /* printing */
tmp_string2 = g_find_program_in_path(GEANY_DEFAULT_TOOLS_PRINTCMD); tmp_string2 = g_find_program_in_path(GEANY_DEFAULT_TOOLS_PRINTCMD);

View File

@ -86,7 +86,6 @@ typedef struct _PropertyDialogElements
static gboolean update_config(const PropertyDialogElements *e); static gboolean update_config(const PropertyDialogElements *e);
static void on_file_save_button_clicked(GtkButton *button, PropertyDialogElements *e); static void on_file_save_button_clicked(GtkButton *button, PropertyDialogElements *e);
static void on_file_open_button_clicked(GtkButton *button, PropertyDialogElements *e);
static gboolean load_config(const gchar *filename); static gboolean load_config(const gchar *filename);
static gboolean write_config(gboolean emit_signal); static gboolean write_config(gboolean emit_signal);
static void on_name_entry_changed(GtkEditable *editable, PropertyDialogElements *e); static void on_name_entry_changed(GtkEditable *editable, PropertyDialogElements *e);
@ -868,35 +867,6 @@ static void on_file_save_button_clicked(GtkButton *button, PropertyDialogElement
} }
static void on_file_open_button_clicked(GtkButton *button, PropertyDialogElements *e)
{
#ifdef G_OS_WIN32
gchar *path = win32_show_project_open_dialog(e->dialog, _("Choose Project Run Command"),
gtk_entry_get_text(GTK_ENTRY(e->run_cmd)), FALSE, FALSE);
if (path != NULL)
{
gtk_entry_set_text(GTK_ENTRY(e->run_cmd), path);
g_free(path);
}
#else
GtkWidget *dialog;
/* initialise the dialog */
dialog = gtk_file_chooser_dialog_new(_("Choose Project Run Command"), NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
gtk_widget_set_name(dialog, "GeanyDialog");
gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), TRUE);
gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
run_dialog(dialog, e->run_cmd);
#endif
}
/* sets the project base path and the project file name according to the project name */ /* sets the project base path and the project file name according to the project name */
static void on_name_entry_changed(GtkEditable *editable, PropertyDialogElements *e) static void on_name_entry_changed(GtkEditable *editable, PropertyDialogElements *e)
{ {
@ -999,7 +969,7 @@ static gboolean load_config(const gchar *filename)
p->run_cmd = utils_get_setting_string(config, "project", "run_cmd", ""); p->run_cmd = utils_get_setting_string(config, "project", "run_cmd", "");
p->file_patterns = g_key_file_get_string_list(config, "project", "file_patterns", NULL, NULL); p->file_patterns = g_key_file_get_string_list(config, "project", "file_patterns", NULL, NULL);
load_build_menu( config, BCS_PROJ, (gpointer)p ); build_load_menu( config, BCS_PROJ, (gpointer)p );
if (project_prefs.project_session) if (project_prefs.project_session)
{ {
/* save current (non-project) session (it could has been changed since program startup) */ /* save current (non-project) session (it could has been changed since program startup) */
@ -1056,7 +1026,7 @@ static gboolean write_config(gboolean emit_signal)
/* store the session files into the project too */ /* store the session files into the project too */
if (project_prefs.project_session) if (project_prefs.project_session)
configuration_save_session_files(config); configuration_save_session_files(config);
save_build_menu( config, (gpointer)p, BCS_PROJ ); build_save_menu( config, (gpointer)p, BCS_PROJ );
if (emit_signal) if (emit_signal)
{ {
g_signal_emit_by_name(geany_object, "project-save", config); g_signal_emit_by_name(geany_object, "project-save", config);