Kaydet (Commit) b36ebf0a authored tarafından Nick Treleaven's avatar Nick Treleaven

Save filetype build commands straight after editing them instead of

at shutdown (patch by Dimitar Zhekov, thanks).



git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5758 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 003a11c5
......@@ -2,6 +2,9 @@
* src/highlighting.c, doc/geany.txt, doc/geany.html:
Allow translations for color scheme [theme_info] keys.
* src/build.c, src/filetypes.c, src/filetypes.h, src/main.c:
Save filetype build commands straight after editing them instead of
at shutdown (patch by Dimitar Zhekov, thanks).
2011-05-02 Colomban Wendling <colomban(at)geany(dot)org>
......
......@@ -2259,7 +2259,7 @@ static void show_build_commands_dialog(void)
}
prefdsts.nonfileregexstr = &regex_pref;
if (build_read_commands(&prefdsts, table_data, response) && ft != NULL)
ft->home_save_needed = TRUE;
filetypes_save_commands(ft);
build_free_fields(table_data);
build_menu_update(doc);
......
......@@ -63,7 +63,7 @@ GSList *filetypes_by_title = NULL;
static void create_radio_menu_item(GtkWidget *menu, GeanyFiletype *ftype);
static gchar *filetypes_get_conf_extension(gint filetype_idx);
static gchar *filetypes_get_conf_extension(const GeanyFiletype *ft);
static void read_filetype_config(void);
......@@ -1235,7 +1235,7 @@ static void add_keys(GKeyFile *dest, const gchar *group, GKeyFile *src)
static gchar *filetypes_get_filename(GeanyFiletype *ft, gboolean user)
{
gchar *ext = filetypes_get_conf_extension(ft->id);
gchar *ext = filetypes_get_conf_extension(ft);
gchar *f;
if (user)
......@@ -1372,16 +1372,15 @@ void filetypes_load_config(gint ft_id, gboolean reload)
}
static gchar *filetypes_get_conf_extension(gint filetype_idx)
static gchar *filetypes_get_conf_extension(const GeanyFiletype *ft)
{
gchar *result;
GeanyFiletype *ft = filetypes[filetype_idx];
if (ft->priv->custom)
return g_strconcat(ft->name, ".conf", NULL);
/* Handle any special extensions different from lowercase filetype->name */
switch (filetype_idx)
switch (ft->id)
{
case GEANY_FILETYPES_CPP: result = g_strdup("cpp"); break;
case GEANY_FILETYPES_CS: result = g_strdup("cs"); break;
......@@ -1397,29 +1396,20 @@ static gchar *filetypes_get_conf_extension(gint filetype_idx)
}
void filetypes_save_commands(void)
void filetypes_save_commands(GeanyFiletype *ft)
{
guint i;
for (i = 0; i < filetypes_array->len; i++)
{
GKeyFile *config_home;
gchar *fname, *data;
GeanyFiletype *ft = filetypes[i];
GKeyFile *config_home;
gchar *fname, *data;
if (ft->home_save_needed)
{
fname = filetypes_get_filename(ft, TRUE);
config_home = g_key_file_new();
g_key_file_load_from_file(config_home, fname, G_KEY_FILE_KEEP_COMMENTS, NULL);
build_save_menu(config_home, ft, GEANY_BCS_HOME_FT);
data = g_key_file_to_data(config_home, NULL, NULL);
utils_write_file(fname, data);
g_free(data);
g_key_file_free(config_home);
g_free(fname);
}
}
fname = filetypes_get_filename(ft, TRUE);
config_home = g_key_file_new();
g_key_file_load_from_file(config_home, fname, G_KEY_FILE_KEEP_COMMENTS, NULL);
build_save_menu(config_home, ft, GEANY_BCS_HOME_FT);
data = g_key_file_to_data(config_home, NULL, NULL);
utils_write_file(fname, data);
g_free(data);
g_key_file_free(config_home);
g_free(fname);
}
......@@ -1723,9 +1713,6 @@ void filetypes_reload(void)
guint i;
GeanyDocument *current_doc;
/* save possibly changed commands before re-reading them */
filetypes_save_commands();
/* reload filetype configs */
for (i = 0; i < filetypes_array->len; i++)
{
......
......@@ -151,7 +151,6 @@ struct GeanyFiletype
gint project_list_entry;
gchar *projerror_regex_string;
gchar *homeerror_regex_string;
gboolean home_save_needed;
#endif
};
......@@ -195,7 +194,7 @@ void filetypes_free_types(void);
void filetypes_load_config(gint ft_id, gboolean reload);
void filetypes_save_commands(void);
void filetypes_save_commands(GeanyFiletype *ft);
void filetypes_select_radio_item(const GeanyFiletype *ft);
......
......@@ -1171,7 +1171,6 @@ void main_quit()
navqueue_free();
keybindings_free();
filetypes_save_commands();
highlighting_free_styles();
templates_free_templates();
msgwin_finalize();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment