Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Split up build_load_menu() #2272

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 27 additions & 20 deletions src/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ static void show_build_result_message(gboolean failure);
static void process_build_output_line(gchar *msg, gint color);
static void show_build_commands_dialog(void);
static void on_build_menu_item(GtkWidget *w, gpointer user_data);
static void load_old_menu(GKeyFile *config, GeanyBuildSource src, gpointer p);

void build_finalize(void)
{
Expand Down Expand Up @@ -2291,31 +2292,13 @@ static void build_load_menu_grp(GKeyFile *config, GeanyBuildCommand **dst, gint
}


/* set GeanyBuildCommand if it doesn't already exist and there is a command */
static void assign_cmd(GeanyBuildCommand *type, guint id,
const gchar *label, gchar *value)
{
if (!EMPTY(value) && ! type[GBO_TO_CMD(id)].exists)
{
type[GBO_TO_CMD(id)].exists = TRUE;
SETPTR(type[GBO_TO_CMD(id)].label, g_strdup(label));
SETPTR(type[GBO_TO_CMD(id)].command, value);
SETPTR(type[GBO_TO_CMD(id)].working_dir, NULL);
type[GBO_TO_CMD(id)].old = TRUE;
}
else
g_free(value);
}

/* 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 settings, not done perfectly but better than ignoring them */
void build_load_menu(GKeyFile *config, GeanyBuildSource src, gpointer p)
{
GeanyFiletype *ft;
GeanyProject *pj;
gchar **ftlist;
gchar *value, *basedir, *makebasedir;
gboolean bvalue = FALSE;

if (g_key_file_has_group(config, build_grp_name))
{
Expand Down Expand Up @@ -2380,8 +2363,32 @@ void build_load_menu(GKeyFile *config, GeanyBuildSource src, gpointer p)
break;
}
}

/* load old [build_settings] values if there is no value defined by [build-menu] */
load_old_menu(config, src, p);
}


/* set GeanyBuildCommand if it doesn't already exist and there is a command */
static void assign_cmd(GeanyBuildCommand *type, guint id,
const gchar *label, gchar *value)
{
if (!EMPTY(value) && ! type[GBO_TO_CMD(id)].exists)
{
type[GBO_TO_CMD(id)].exists = TRUE;
SETPTR(type[GBO_TO_CMD(id)].label, g_strdup(label));
SETPTR(type[GBO_TO_CMD(id)].command, value);
SETPTR(type[GBO_TO_CMD(id)].working_dir, NULL);
type[GBO_TO_CMD(id)].old = TRUE;
}
else
g_free(value);
}

static void load_old_menu(GKeyFile *config, GeanyBuildSource src, gpointer p)
{
GeanyFiletype *ft;
gchar *value, *basedir, *makebasedir;
gboolean bvalue = FALSE;

switch (src)
{
Expand Down