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 @@ ...@@ -2,6 +2,9 @@
* src/highlighting.c, doc/geany.txt, doc/geany.html: * src/highlighting.c, doc/geany.txt, doc/geany.html:
Allow translations for color scheme [theme_info] keys. 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> 2011-05-02 Colomban Wendling <colomban(at)geany(dot)org>
......
...@@ -2259,7 +2259,7 @@ static void show_build_commands_dialog(void) ...@@ -2259,7 +2259,7 @@ static void show_build_commands_dialog(void)
} }
prefdsts.nonfileregexstr = &regex_pref; prefdsts.nonfileregexstr = &regex_pref;
if (build_read_commands(&prefdsts, table_data, response) && ft != NULL) 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_free_fields(table_data);
build_menu_update(doc); build_menu_update(doc);
......
...@@ -63,7 +63,7 @@ GSList *filetypes_by_title = NULL; ...@@ -63,7 +63,7 @@ GSList *filetypes_by_title = NULL;
static void create_radio_menu_item(GtkWidget *menu, GeanyFiletype *ftype); 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); static void read_filetype_config(void);
...@@ -1235,7 +1235,7 @@ static void add_keys(GKeyFile *dest, const gchar *group, GKeyFile *src) ...@@ -1235,7 +1235,7 @@ static void add_keys(GKeyFile *dest, const gchar *group, GKeyFile *src)
static gchar *filetypes_get_filename(GeanyFiletype *ft, gboolean user) 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; gchar *f;
if (user) if (user)
...@@ -1372,16 +1372,15 @@ void filetypes_load_config(gint ft_id, gboolean reload) ...@@ -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; gchar *result;
GeanyFiletype *ft = filetypes[filetype_idx];
if (ft->priv->custom) if (ft->priv->custom)
return g_strconcat(ft->name, ".conf", NULL); return g_strconcat(ft->name, ".conf", NULL);
/* Handle any special extensions different from lowercase filetype->name */ /* 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_CPP: result = g_strdup("cpp"); break;
case GEANY_FILETYPES_CS: result = g_strdup("cs"); break; case GEANY_FILETYPES_CS: result = g_strdup("cs"); break;
...@@ -1397,29 +1396,20 @@ static gchar *filetypes_get_conf_extension(gint filetype_idx) ...@@ -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; GKeyFile *config_home;
gchar *fname, *data;
for (i = 0; i < filetypes_array->len; i++)
{
GKeyFile *config_home;
gchar *fname, *data;
GeanyFiletype *ft = filetypes[i];
if (ft->home_save_needed) fname = filetypes_get_filename(ft, TRUE);
{ config_home = g_key_file_new();
fname = filetypes_get_filename(ft, TRUE); g_key_file_load_from_file(config_home, fname, G_KEY_FILE_KEEP_COMMENTS, NULL);
config_home = g_key_file_new(); build_save_menu(config_home, ft, GEANY_BCS_HOME_FT);
g_key_file_load_from_file(config_home, fname, G_KEY_FILE_KEEP_COMMENTS, NULL); data = g_key_file_to_data(config_home, NULL, NULL);
build_save_menu(config_home, ft, GEANY_BCS_HOME_FT); utils_write_file(fname, data);
data = g_key_file_to_data(config_home, NULL, NULL); g_free(data);
utils_write_file(fname, data); g_key_file_free(config_home);
g_free(data); g_free(fname);
g_key_file_free(config_home);
g_free(fname);
}
}
} }
...@@ -1723,9 +1713,6 @@ void filetypes_reload(void) ...@@ -1723,9 +1713,6 @@ void filetypes_reload(void)
guint i; guint i;
GeanyDocument *current_doc; GeanyDocument *current_doc;
/* save possibly changed commands before re-reading them */
filetypes_save_commands();
/* reload filetype configs */ /* reload filetype configs */
for (i = 0; i < filetypes_array->len; i++) for (i = 0; i < filetypes_array->len; i++)
{ {
......
...@@ -151,7 +151,6 @@ struct GeanyFiletype ...@@ -151,7 +151,6 @@ struct GeanyFiletype
gint project_list_entry; gint project_list_entry;
gchar *projerror_regex_string; gchar *projerror_regex_string;
gchar *homeerror_regex_string; gchar *homeerror_regex_string;
gboolean home_save_needed;
#endif #endif
}; };
...@@ -195,7 +194,7 @@ void filetypes_free_types(void); ...@@ -195,7 +194,7 @@ void filetypes_free_types(void);
void filetypes_load_config(gint ft_id, gboolean reload); 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); void filetypes_select_radio_item(const GeanyFiletype *ft);
......
...@@ -1171,7 +1171,6 @@ void main_quit() ...@@ -1171,7 +1171,6 @@ void main_quit()
navqueue_free(); navqueue_free();
keybindings_free(); keybindings_free();
filetypes_save_commands();
highlighting_free_styles(); highlighting_free_styles();
templates_free_templates(); templates_free_templates();
msgwin_finalize(); 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