Revision: 4972 http://geany.svn.sourceforge.net/geany/?rev=4972&view=rev Author: statc Date: 2010-05-31 09:24:43 +0000 (Mon, 31 May 2010)
Log Message: ----------- Apply patch by Dimitar Zhekov to avoid saving filetype files on exit.
Modified Paths: -------------- branches/sm/ChangeLog.sm branches/sm/src/filetypes.c branches/sm/src/filetypes.h branches/sm/src/main.c
Modified: branches/sm/ChangeLog.sm =================================================================== --- branches/sm/ChangeLog.sm 2010-05-31 09:24:21 UTC (rev 4971) +++ branches/sm/ChangeLog.sm 2010-05-31 09:24:43 UTC (rev 4972) @@ -6,6 +6,8 @@ * src/keyfile.c, src/keyfile.h, src/main.c, src/prefs.c, src/project.c: Apply patches by Dimitar Zhekov to not save settings edited in the Preferences Dialog to geany.conf on exit. + * src/filetypes.c, src/filetypes.h, src/main.c: + Apply patch by Dimitar Zhekov to avoid saving filetype files on exit.
2010-02-23 Eugene Arshinov <earshinov(at)gmail(dot)com>
Modified: branches/sm/src/filetypes.c =================================================================== --- branches/sm/src/filetypes.c 2010-05-31 09:24:21 UTC (rev 4971) +++ branches/sm/src/filetypes.c 2010-05-31 09:24:43 UTC (rev 4972) @@ -1343,16 +1343,15 @@ }
-gchar *filetypes_get_conf_extension(gint filetype_idx) +static gchar *get_filetype_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; @@ -1363,33 +1362,29 @@ }
-void filetypes_save_commands(void) +gchar *filetypes_get_conf_extension(gint filetype_idx) { - gchar *conf_prefix = g_strconcat(app->configdir, - G_DIR_SEPARATOR_S GEANY_FILEDEFS_SUBDIR G_DIR_SEPARATOR_S "filetypes.", NULL); - guint i; + return get_filetype_conf_extension(filetypes[filetype_idx]); +}
- for (i = 1; i < filetypes_array->len; i++) - { - GKeyFile *config_home; - gchar *fname, *ext, *data;
- if (filetypes[i]->home_save_needed) - { - ext = filetypes_get_conf_extension(i); - fname = g_strconcat(conf_prefix, ext, NULL); - g_free(ext); - 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, (gpointer)(filetypes[i]), 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); - } - } - g_free(conf_prefix); +void filetypes_save_commands(const GeanyFiletype *ft) +{ + gchar *ext = get_filetype_conf_extension(ft); + gchar *fname = g_strconcat(app->configdir, + G_DIR_SEPARATOR_S GEANY_FILEDEFS_SUBDIR G_DIR_SEPARATOR_S "filetypes.", ext, NULL); + GKeyFile *config_home; + gchar *data; + + 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, (gpointer)(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); + g_free(ext); }
@@ -1635,9 +1630,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++) { @@ -1654,5 +1646,3 @@ /* process the current document at last */ document_reload_config(current_doc); } - -
Modified: branches/sm/src/filetypes.h =================================================================== --- branches/sm/src/filetypes.h 2010-05-31 09:24:21 UTC (rev 4971) +++ branches/sm/src/filetypes.h 2010-05-31 09:24:43 UTC (rev 4972) @@ -179,7 +179,7 @@
void filetypes_load_config(gint ft_id, gboolean reload);
-void filetypes_save_commands(void); +void filetypes_save_commands(const GeanyFiletype *ft);
void filetypes_select_radio_item(const GeanyFiletype *ft);
Modified: branches/sm/src/main.c =================================================================== --- branches/sm/src/main.c 2010-05-31 09:24:21 UTC (rev 4971) +++ branches/sm/src/main.c 2010-05-31 09:24:43 UTC (rev 4972) @@ -1226,7 +1226,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.