SF.net SVN: geany:[3955] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Mon Jul 13 11:58:21 UTC 2009
Revision: 3955
http://geany.svn.sourceforge.net/geany/?rev=3955&view=rev
Author: ntrel
Date: 2009-07-13 11:58:21 +0000 (Mon, 13 Jul 2009)
Log Message:
-----------
Apply patch from Eugene Arshinov to reload color schemes via menu
(thanks).
Modified Paths:
--------------
trunk/THANKS
trunk/src/about.c
trunk/src/document.c
trunk/src/document.h
trunk/src/filetypes.c
trunk/src/highlighting.c
trunk/src/main.c
Modified: trunk/THANKS
===================================================================
--- trunk/THANKS 2009-07-13 11:39:37 UTC (rev 3954)
+++ trunk/THANKS 2009-07-13 11:58:21 UTC (rev 3955)
@@ -65,6 +65,7 @@
Simon Treny <simon(dot)treny(at)free(dot)fr> - Documents sidebar stock icons patch
Elias Pschernig <elias(at)users(dot)sourceforge(dot)net> - Recent Projects menu patch
Jesse Mayes <plasmasheep(at)gmail(dot)com> - Tango'ish Save All icon
+Eugene Arshinov <earshinov(at)gmail(dot)com> - Reload color schemes via menu patch
Translators:
------------
Modified: trunk/src/about.c
===================================================================
--- trunk/src/about.c 2009-07-13 11:39:37 UTC (rev 3954)
+++ trunk/src/about.c 2009-07-13 11:58:21 UTC (rev 3955)
@@ -81,7 +81,7 @@
static const gchar *contributors =
"Alexander Rodin, Andrew Rowland, Anh Phạm, blackdog, Bo Lorentsen, Bob Doan, Bronisław Białek, Catalin Marinas, "
"Chris Macksey, Christoph Berg, Colomban Wendling, Conrad Steenberg, Daniel Richard G., Dave Moore, Dirk Weber, "
-"Elias Pschernig, Felipe Pena, François Cami, "
+"Elias Pschernig, Eugene Arshinov, Felipe Pena, François Cami, "
"Giuseppe Torelli, Guillaume de Rorthais, Guillaume Hoffmann, Herbert Voss, Jason Oster, Jean-François Wauthy, Jeff Pohlmeyer, "
"Jesse Mayes, John Gabriele, Josef Whiter, Kevin Ellwood, Kristoffer A. Tjernås, Marko Peric, Matti Mårds, Moritz Barsnick, "
"Peter Strand, Philipp Gildein, Pierre Joye, Rob van der Linde, Robert McGinley, Roland Baudin, S Jagannathan, Saleem Abdulrasool, "
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2009-07-13 11:39:37 UTC (rev 3954)
+++ trunk/src/document.c 2009-07-13 11:58:21 UTC (rev 3955)
@@ -2392,24 +2392,14 @@
}
-/** Sets the filetype of the document (which controls syntax highlighting and tags)
- * @param doc The document to use.
- * @param type The filetype. */
-void document_set_filetype(GeanyDocument *doc, GeanyFiletype *type)
+static void document_load_config(GeanyDocument *doc, GeanyFiletype *type,
+ gboolean filetype_changed)
{
- gboolean ft_changed;
-
g_return_if_fail(doc);
if (type == NULL)
type = filetypes[GEANY_FILETYPES_NONE];
- geany_debug("%s : %s (%s)",
- (doc->file_name != NULL) ? doc->file_name : "unknown",
- (type->name != NULL) ? type->name : "unknown",
- (doc->encoding != NULL) ? doc->encoding : "unknown");
-
- ft_changed = (doc->file_type != type);
- if (ft_changed) /* filetype has changed */
+ if (filetype_changed)
{
doc->file_type = type;
@@ -2432,6 +2422,33 @@
}
+/** Sets the filetype of the document (which controls syntax highlighting and tags)
+ * @param doc The document to use.
+ * @param type The filetype. */
+void document_set_filetype(GeanyDocument *doc, GeanyFiletype *type)
+{
+ gboolean ft_changed;
+
+ g_return_if_fail(doc);
+ if (type == NULL)
+ type = filetypes[GEANY_FILETYPES_NONE];
+
+ geany_debug("%s : %s (%s)",
+ (doc->file_name != NULL) ? doc->file_name : "unknown",
+ (type->name != NULL) ? type->name : "unknown",
+ (doc->encoding != NULL) ? doc->encoding : "unknown");
+
+ ft_changed = (doc->file_type != type); /* filetype has changed */
+ document_load_config(doc, type, ft_changed);
+}
+
+
+void document_reload_config(GeanyDocument *doc)
+{
+ document_load_config(doc, doc->file_type, TRUE);
+}
+
+
/**
* Sets the encoding of a %document.
* This function only set the encoding of the %document, it does not any conversions. The new
Modified: trunk/src/document.h
===================================================================
--- trunk/src/document.h 2009-07-13 11:39:37 UTC (rev 3954)
+++ trunk/src/document.h 2009-07-13 11:58:21 UTC (rev 3955)
@@ -154,6 +154,8 @@
void document_set_filetype(GeanyDocument *doc, GeanyFiletype *type);
+void document_reload_config(GeanyDocument *doc);
+
void document_rename_file(GeanyDocument *doc, const gchar *new_filename);
GeanyDocument *document_index(gint idx);
Modified: trunk/src/filetypes.c
===================================================================
--- trunk/src/filetypes.c 2009-07-13 11:39:37 UTC (rev 3954)
+++ trunk/src/filetypes.c 2009-07-13 11:58:21 UTC (rev 3955)
@@ -1215,9 +1215,7 @@
}
load_settings(ft_id, config, config_home);
- if (! reload)
- /* reloading highlighting settings not yet supported */
- highlighting_init_styles(ft_id, config, config_home);
+ highlighting_init_styles(ft_id, config, config_home);
g_key_file_free(config);
g_key_file_free(config_home);
Modified: trunk/src/highlighting.c
===================================================================
--- trunk/src/highlighting.c 2009-07-13 11:39:37 UTC (rev 3954)
+++ trunk/src/highlighting.c 2009-07-13 11:58:21 UTC (rev 3955)
@@ -132,6 +132,21 @@
}
+static void styleset_free(gint file_type_id)
+{
+ StyleSet *style_ptr;
+ style_ptr = &style_sets[file_type_id];
+
+ style_ptr->count = 0;
+ g_free(style_ptr->styling);
+ style_ptr->styling = NULL;
+ g_strfreev(style_ptr->keywords);
+ style_ptr->keywords = NULL;
+ g_free(style_ptr->wordchars);
+ style_ptr->wordchars = NULL;
+}
+
+
static void get_keyfile_keywords(GKeyFile *config, GKeyFile *configh,
const gchar *key, gint ft_id, gint pos, const gchar *default_value)
{
@@ -420,16 +435,8 @@
gint i;
for (i = 0; i < GEANY_MAX_BUILT_IN_FILETYPES; i++)
- {
- StyleSet *style_ptr;
- style_ptr = &style_sets[i];
+ styleset_free(i);
- style_ptr->count = 0;
- g_free(style_ptr->styling);
- g_strfreev(style_ptr->keywords);
- g_free(style_ptr->wordchars);
- }
-
if (named_style_hash)
g_hash_table_destroy(named_style_hash);
}
@@ -520,14 +527,11 @@
static void styleset_common_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{
- static gboolean common_style_set_valid = FALSE;
-
- if (common_style_set_valid)
- return;
- common_style_set_valid = TRUE; /* ensure filetypes.common is only loaded once */
-
/* named styles */
- named_style_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+ if (named_style_hash)
+ g_hash_table_remove_all(named_style_hash); /* reloading */
+ else
+ named_style_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
/* first set default to the "default" named style */
add_named_style(config, "default");
@@ -3558,6 +3562,9 @@
/* Called by filetypes_load_config(). */
void highlighting_init_styles(gint filetype_idx, GKeyFile *config, GKeyFile *configh)
{
+ /* Clear old information if necessary - e.g. reloading config */
+ styleset_free(filetype_idx);
+
/* All stylesets depend on filetypes.common */
if (filetype_idx != GEANY_FILETYPES_NONE)
filetypes_load_config(GEANY_FILETYPES_NONE, FALSE);
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2009-07-13 11:39:37 UTC (rev 3954)
+++ trunk/src/main.c 2009-07-13 11:58:21 UTC (rev 3955)
@@ -1233,6 +1233,13 @@
filetypes_load_config(i, TRUE);
}
+ for (i = 0; i < documents_array->len; i++)
+ {
+ GeanyDocument *doc = documents[i];
+ if (doc->is_valid)
+ document_reload_config(doc);
+ }
+
/* C tag names to ignore */
symbols_reload_config_files();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list