This patch makes Tools > Reload Configuration reload color schemes in all open documents.

It is made against last SVN revision (rev. 3920).

I don't know whether attachments are supported, so I post the patch below. Here is also a link as copying the patch from here may be inconvenient: http://pastie.org/534772 .

-------------------- 8< --------------------

diff --git a/src/document.c b/src/document.c
index 408ca53..6f37103 100644
--- a/src/document.c
+++ b/src/document.c
@@ -106,6 +106,8 @@ typedef struct
static void document_undo_clear(GeanyDocument *doc);
static void document_redo_add(GeanyDocument *doc, guint type, gpointer data);
static gboolean update_tags_from_buffer(GeanyDocument *doc);
+static void document_load_config(GeanyDocument *doc, GeanyFiletype *type,
+        gboolean filetype_changed);


/* ignore the case of filenames and paths under WIN32, causes errors if not */ @@ -2459,25 +2461,14 @@ static gboolean update_type_keywords(GeanyDocument *doc, gint lang)
    return ret;
}

-
-/** 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;

@@ -2500,6 +2491,32 @@ void document_set_filetype(GeanyDocument *doc, GeanyFiletype *type)
}


+/** 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
diff --git a/src/document.h b/src/document.h
index c560a32..66e1dd5 100644
--- a/src/document.h
+++ b/src/document.h
@@ -154,6 +154,8 @@ void document_set_text_changed(GeanyDocument *doc, gboolean changed);

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);
diff --git a/src/filetypes.c b/src/filetypes.c
index 2506714..e8914cc 100644
--- a/src/filetypes.c
+++ b/src/filetypes.c
@@ -1215,9 +1215,7 @@ void filetypes_load_config(gint ft_id, gboolean reload)
    }

    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);
diff --git a/src/main.c b/src/main.c
index 6a0cec5..f56c7dc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1210,7 +1210,7 @@ void *rpl_malloc(size_t n)
 **/
void main_reload_configuration(void)
{
-    guint i;
+    guint i, n;

    /* reload templates */
    templates_free_templates();
@@ -1233,6 +1233,13 @@ void main_reload_configuration(void)
        filetypes_load_config(i, TRUE);
    }

+ /* iterating over documents_array is not very safe, so use this method */
+    n = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
+    for (i = 0; i < n; i++)
+    {
+        document_reload_config(document_get_from_page(i));
+    }
+
    /* C tag names to ignore */
    symbols_reload_config_files();


diff --git a/src/document.c b/src/document.c
index 408ca53..6f37103 100644
--- a/src/document.c
+++ b/src/document.c
@@ -106,6 +106,8 @@ typedef struct
 static void document_undo_clear(GeanyDocument *doc);
 static void document_redo_add(GeanyDocument *doc, guint type, gpointer data);
 static gboolean update_tags_from_buffer(GeanyDocument *doc);
+static void document_load_config(GeanyDocument *doc, GeanyFiletype *type,
+		gboolean filetype_changed);
 
 
 /* ignore the case of filenames and paths under WIN32, causes errors if not */
@@ -2459,25 +2461,14 @@ static gboolean update_type_keywords(GeanyDocument *doc, gint lang)
 	return ret;
 }
 
-
-/** 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;
 
@@ -2500,6 +2491,32 @@ void document_set_filetype(GeanyDocument *doc, GeanyFiletype *type)
 }
 
 
+/** 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
diff --git a/src/document.h b/src/document.h
index c560a32..66e1dd5 100644
--- a/src/document.h
+++ b/src/document.h
@@ -154,6 +154,8 @@ void document_set_text_changed(GeanyDocument *doc, gboolean changed);
 
 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);
diff --git a/src/filetypes.c b/src/filetypes.c
index 2506714..e8914cc 100644
--- a/src/filetypes.c
+++ b/src/filetypes.c
@@ -1215,9 +1215,7 @@ void filetypes_load_config(gint ft_id, gboolean reload)
 	}
 
 	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);
diff --git a/src/main.c b/src/main.c
index 6a0cec5..f56c7dc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1210,7 +1210,7 @@ void *rpl_malloc(size_t n)
  **/
 void main_reload_configuration(void)
 {
-	guint i;
+	guint i, n;
 
 	/* reload templates */
 	templates_free_templates();
@@ -1233,6 +1233,13 @@ void main_reload_configuration(void)
 		filetypes_load_config(i, TRUE);
 	}
 
+	/* iterating over documents_array is not very safe, so use this method */
+	n = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
+	for (i = 0; i < n; i++)
+	{
+		document_reload_config(document_get_from_page(i));
+	}
+
 	/* C tag names to ignore */
 	symbols_reload_config_files();
 
_______________________________________________
Geany-devel mailing list
[email protected]
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel

Reply via email to