Revision: 5758 http://geany.svn.sourceforge.net/geany/?rev=5758&view=rev Author: ntrel Date: 2011-05-03 16:08:23 +0000 (Tue, 03 May 2011)
Log Message: ----------- Save filetype build commands straight after editing them instead of at shutdown (patch by Dimitar Zhekov, thanks).
Modified Paths: -------------- trunk/ChangeLog trunk/src/build.c trunk/src/filetypes.c trunk/src/filetypes.h trunk/src/main.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-05-03 15:18:52 UTC (rev 5757) +++ trunk/ChangeLog 2011-05-03 16:08:23 UTC (rev 5758) @@ -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>
Modified: trunk/src/build.c =================================================================== --- trunk/src/build.c 2011-05-03 15:18:52 UTC (rev 5757) +++ trunk/src/build.c 2011-05-03 16:08:23 UTC (rev 5758) @@ -2259,7 +2259,7 @@ } prefdsts.nonfileregexstr = ®ex_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);
Modified: trunk/src/filetypes.c =================================================================== --- trunk/src/filetypes.c 2011-05-03 15:18:52 UTC (rev 5757) +++ trunk/src/filetypes.c 2011-05-03 16:08:23 UTC (rev 5758) @@ -63,7 +63,7 @@
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 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 @@ }
-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 @@ }
-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(); - 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 @@ 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++) {
Modified: trunk/src/filetypes.h =================================================================== --- trunk/src/filetypes.h 2011-05-03 15:18:52 UTC (rev 5757) +++ trunk/src/filetypes.h 2011-05-03 16:08:23 UTC (rev 5758) @@ -151,7 +151,6 @@ gint project_list_entry; gchar *projerror_regex_string; gchar *homeerror_regex_string; - gboolean home_save_needed; #endif };
@@ -195,7 +194,7 @@
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);
Modified: trunk/src/main.c =================================================================== --- trunk/src/main.c 2011-05-03 15:18:52 UTC (rev 5757) +++ trunk/src/main.c 2011-05-03 16:08:23 UTC (rev 5758) @@ -1171,7 +1171,6 @@
navqueue_free(); keybindings_free(); - filetypes_save_commands(); highlighting_free_styles(); templates_free_templates(); msgwin_finalize();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.