[geany/geany] 563249: Warn user if current filetype might not support color schemes

Nick Treleaven git-noreply at xxxxx
Tue May 29 17:05:56 UTC 2012


Branch:      refs/heads/master
Author:      Nick Treleaven <nick.treleaven at btinternet.com>
Committer:   Nick Treleaven <nick.treleaven at btinternet.com>
Date:        Tue, 29 May 2012 17:05:56
Commit:      563249f7c6659ea2c6436f38af5977da4c5723c9
             https://github.com/geany/geany/commit/563249f7c6659ea2c6436f38af5977da4c5723c9

Log Message:
-----------
Warn user if current filetype might not support color schemes

If the 'default' style isn't set to a named style, then probably the
filetype styles have been overridden with manual colors and may not
work properly with color schemes.

Note: HTML-based filetypes won't show a warning because they don't
have a 'default' style (they use 'html_default' instead).

This is a simple heuristic, but is worth having to avoid some
spurious bug reports when using the color schemes dialog.


Modified Paths:
--------------
    src/filetypesprivate.h
    src/highlighting.c

Modified: src/filetypesprivate.h
1 files changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -35,6 +35,7 @@
 	gint		symbol_list_sort_mode;
 	gboolean	xml_indent_tags; /* XML tag autoindentation, for HTML and XML filetypes */
 	GSList		*tag_files;
+	gboolean	warn_color_scheme;
 }
 GeanyFiletypePrivate;
 


Modified: src/highlighting.c
17 files changed, 17 insertions(+), 0 deletions(-)
===================================================================
@@ -41,6 +41,9 @@
 #include "main.h"
 #include "support.h"
 #include "sciwrappers.h"
+#include "document.h"
+#include "dialogs.h"
+#include "filetypesprivate.h"
 
 #include "highlightingmappings.h"
 
@@ -979,6 +982,7 @@ void highlighting_init_styles(guint filetype_idx, GKeyFile *config, GKeyFile *co
 {
 	GeanyFiletype *ft = filetypes[filetype_idx];
 	guint lexer_id = get_lexer_filetype(ft);
+	gchar *default_str;
 
 	if (!style_sets)
 		style_sets = g_new0(StyleSet, filetypes_array->len);
@@ -987,6 +991,12 @@ void highlighting_init_styles(guint filetype_idx, GKeyFile *config, GKeyFile *co
 	free_styleset(filetype_idx);
 
 	read_properties(ft, config, configh);
+	/* If a default style exists, check it uses a named style
+	 * Note: almost all filetypes have a "default" style, except HTML ones */
+	default_str = utils_get_setting(string, configh, config,
+		"styling", "default", "default");
+	ft->priv->warn_color_scheme = !g_ascii_isalpha(*default_str);
+	g_free(default_str);
 
 	/* None filetype handled specially */
 	if (filetype_idx == GEANY_FILETYPES_NONE)
@@ -1318,6 +1328,13 @@ void highlighting_show_color_scheme_dialog(void)
 	GtkTreeViewColumn *column;
 	GtkTreeSelection *treesel;
 	GtkWidget *vbox, *swin, *tree;
+	GeanyDocument *doc;
+
+	doc = document_get_current();
+	if (doc && doc->file_type->priv->warn_color_scheme)
+		dialogs_show_msgbox_with_secondary(GTK_MESSAGE_WARNING,
+			_("The current filetype overrides the default style."),
+			_("This may cause color schemes to display incorrectly."));
 
 	scheme_tree = tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
 	g_object_unref(store);


@@ Diff output truncated at 100000 characters. @@


--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).



More information about the Commits mailing list