Revision: 2737 http://geany.svn.sourceforge.net/geany/?rev=2737&view=rev Author: eht16 Date: 2008-06-30 08:59:00 -0700 (Mon, 30 Jun 2008)
Log Message: ----------- In templates_free_templates() destroy also file template menu items. Add reload argument to filetypes_load_config() to allow re-reading of the settings.
Modified Paths: -------------- trunk/ChangeLog trunk/src/filetypes.c trunk/src/filetypes.h trunk/src/highlighting.c trunk/src/templates.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2008-06-30 15:20:50 UTC (rev 2736) +++ trunk/ChangeLog 2008-06-30 15:59:00 UTC (rev 2737) @@ -3,6 +3,11 @@ * waf, wscript: Update waf to its latest SVN rev which makes it 20 KB smaller. Update waf script to reflect waf API changes. + * src/filetypes.c, src/filetypes.h, src/highlighting.c, + src/templates.c: + In templates_free_templates() destroy also file template menu items. + Add reload argument to filetypes_load_config() to allow re-reading + of the settings.
2008-06-30 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/filetypes.c =================================================================== --- trunk/src/filetypes.c 2008-06-30 15:20:50 UTC (rev 2736) +++ trunk/src/filetypes.c 2008-06-30 15:59:00 UTC (rev 2737) @@ -891,15 +891,20 @@ /* Load the configuration file for the associated filetype id. * This should only be called when the filetype is needed, to save loading * 20+ configuration files all at once. */ -void filetypes_load_config(gint ft_id) +void filetypes_load_config(gint ft_id, gboolean reload) { GKeyFile *config, *config_home; FullFileType *fft = (FullFileType*)filetypes[ft_id];
g_return_if_fail(ft_id >= 0 && ft_id < (gint) filetypes_array->len);
- if (fft->keyfile_loaded) + /* when reloading, proceed only if the settings were already loaded */ + if (reload && ! fft->keyfile_loaded) return; + + /* when not reloading, load the settings only once */ + if (! reload && fft->keyfile_loaded) + return; fft->keyfile_loaded = TRUE;
config = g_key_file_new(); @@ -921,7 +926,9 @@ }
load_settings(ft_id, config, config_home); - highlighting_init_styles(ft_id, config, config_home); + if (! reload) + /* reloading highlighting settings not yet supported */ + highlighting_init_styles(ft_id, config, config_home);
g_key_file_free(config); g_key_file_free(config_home);
Modified: trunk/src/filetypes.h =================================================================== --- trunk/src/filetypes.h 2008-06-30 15:20:50 UTC (rev 2736) +++ trunk/src/filetypes.h 2008-06-30 15:59:00 UTC (rev 2737) @@ -147,7 +147,7 @@ /* frees the array and all related pointers */ void filetypes_free_types(void);
-void filetypes_load_config(gint ft_id); +void filetypes_load_config(gint ft_id, gboolean reload);
void filetypes_save_commands(void);
Modified: trunk/src/highlighting.c =================================================================== --- trunk/src/highlighting.c 2008-06-30 15:20:50 UTC (rev 2736) +++ trunk/src/highlighting.c 2008-06-30 15:59:00 UTC (rev 2737) @@ -1112,10 +1112,10 @@ { /* Used by several filetypes */ if (style_sets[GEANY_FILETYPES_XML].styling == NULL) - filetypes_load_config(GEANY_FILETYPES_XML); + filetypes_load_config(GEANY_FILETYPES_XML, FALSE);
/* manually initialise filetype Python for use with embedded Python */ - filetypes_load_config(GEANY_FILETYPES_PYTHON); + filetypes_load_config(GEANY_FILETYPES_PYTHON, FALSE);
/* don't set keywords for plain XML */ if (set_keywords) @@ -2873,7 +2873,7 @@ { /* All stylesets depend on filetypes.common */ if (filetype_idx != GEANY_FILETYPES_NONE) - filetypes_load_config(GEANY_FILETYPES_NONE); + filetypes_load_config(GEANY_FILETYPES_NONE, FALSE);
switch (filetype_idx) { @@ -2922,7 +2922,7 @@
void highlighting_set_styles(ScintillaObject *sci, gint filetype_idx) { - filetypes_load_config(filetype_idx); /* load filetypes.ext */ + filetypes_load_config(filetype_idx, FALSE); /* load filetypes.ext */
/* load tags files (some lexers highlight global typenames) */ if (filetype_idx < GEANY_FILETYPES_NONE) @@ -2978,7 +2978,7 @@ return NULL;
if (style_sets[ft_id].styling == NULL) - filetypes_load_config(ft_id); + filetypes_load_config(ft_id, FALSE);
/** TODO style_id might not be the real array index (Scintilla styles are not always synced * with array indices) */
Modified: trunk/src/templates.c =================================================================== --- trunk/src/templates.c 2008-06-30 15:20:50 UTC (rev 2736) +++ trunk/src/templates.c 2008-06-30 15:59:00 UTC (rev 2737) @@ -663,7 +663,7 @@ filetype_id ft_id = filetype_idx; GeanyFiletype *ft = filetypes[ft_id];
- filetypes_load_config(ft_id); /* load any user extension setting */ + filetypes_load_config(ft_id, FALSE); /* load any user extension setting */
if (fname == NULL) { @@ -753,10 +753,27 @@ void templates_free_templates(void) { gint i; + GList *children, *item; + for (i = 0; i < GEANY_MAX_TEMPLATES; i++) { g_free(templates[i]); } + for (i = 0; i < GEANY_MAX_BUILT_IN_FILETYPES; i++) + { + g_free(ft_templates[i]); + } + /* destroy "New with template" sub menu items (in case we want to reload the templates) */ + children = gtk_container_get_children(GTK_CONTAINER(ui_widgets.new_file_menu)); + for (item = children; item != NULL; item = g_list_next(item)) + { + gtk_widget_destroy(GTK_WIDGET(item->data)); + } + children = gtk_container_get_children(GTK_CONTAINER(new_with_template_menu)); + for (item = children; item != NULL; item = g_list_next(item)) + { + gtk_widget_destroy(GTK_WIDGET(item->data)); + } }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.