Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Color scheme and filedef version checking
diff --git a/data/colorschemes/alt.conf b/data/colorschemes/alt.conf
index 6d0e3dd..a4e8ae8 100644
--- a/data/colorschemes/alt.conf
+++ b/data/colorschemes/alt.conf
@@ -1,9 +1,10 @@
[theme_info]
name=Alternate
description=Alternate Geany color scheme with styles like the Geany <= 0.19 Python/script defaults with gray comments.
-version=0.01
-author=
+author=The Geany Team
url=
+scheme_version=0
+geany_version=1.22
[named_styles]
diff --git a/data/filetypes.Cython.conf b/data/filetypes.Cython.conf
index 5d8a14d..09bd100 100644
--- a/data/filetypes.Cython.conf
+++ b/data/filetypes.Cython.conf
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
[styling=Python]
[keywords]
diff --git a/data/filetypes.Genie.conf b/data/filetypes.Genie.conf
index 617a4bc..a39f80b 100644
--- a/data/filetypes.Genie.conf
+++ b/data/filetypes.Genie.conf
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling=C]
diff --git a/data/filetypes.Scala.conf b/data/filetypes.Scala.conf
index 0193e19..d32fced 100644
--- a/data/filetypes.Scala.conf
+++ b/data/filetypes.Scala.conf
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# Based on file by werg
# For complete documentation of this file, please see Geany's main documentation
[styling=C]
diff --git a/data/filetypes.abc b/data/filetypes.abc
index 97a0deb..1187d7e 100644
--- a/data/filetypes.abc
+++ b/data/filetypes.abc
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# no syntax highlighting yet
diff --git a/data/filetypes.actionscript b/data/filetypes.actionscript
index d9cbee4..e66a5d5 100644
--- a/data/filetypes.actionscript
+++ b/data/filetypes.actionscript
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling=C]
diff --git a/data/filetypes.ada b/data/filetypes.ada
index 1b05717..8283009 100644
--- a/data/filetypes.ada
+++ b/data/filetypes.ada
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.asm b/data/filetypes.asm
index 3ba4961..ac71c32 100644
--- a/data/filetypes.asm
+++ b/data/filetypes.asm
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.c b/data/filetypes.c
index ef95fd3..7bb5056 100644
--- a/data/filetypes.c
+++ b/data/filetypes.c
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.caml b/data/filetypes.caml
index f966c7b..b9662de 100644
--- a/data/filetypes.caml
+++ b/data/filetypes.caml
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.cmake b/data/filetypes.cmake
index 6442dc5..c02484e 100644
--- a/data/filetypes.cmake
+++ b/data/filetypes.cmake
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# foreground;background;bold;italic
diff --git a/data/filetypes.cobol b/data/filetypes.cobol
index 4bcbe07..d641fb9 100644
--- a/data/filetypes.cobol
+++ b/data/filetypes.cobol
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.common b/data/filetypes.common
index 95c474b..c0f6813 100644
--- a/data/filetypes.common
+++ b/data/filetypes.common
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# use foreground;background;bold;italic or named_style,bold,italic
@@ -98,6 +102,17 @@ calltips=call_tips
# should always include space and tab (\s\t)
whitespace_chars=\s\t!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~
+#-------------------------------------------------------------------------------
+# Default Color Scheme
+#-------------------------------------------------------------------------------
+[theme_info]
+name=Default
+description=Geany's default color scheme
+author=The Geany Team
+url=
+scheme_version=0
+geany_version=1.22
+
[named_styles]
# This is the Default "built-in" color scheme
default=0x000000;0xffffff;false;false
diff --git a/data/filetypes.conf b/data/filetypes.conf
index 9b66179..e49ad53 100644
--- a/data/filetypes.conf
+++ b/data/filetypes.conf
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.cpp b/data/filetypes.cpp
index ffbc1af..592df7d 100644
--- a/data/filetypes.cpp
+++ b/data/filetypes.cpp
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling=C]
diff --git a/data/filetypes.cs b/data/filetypes.cs
index 42b3460..548dba6 100644
--- a/data/filetypes.cs
+++ b/data/filetypes.cs
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling=C]
diff --git a/data/filetypes.css b/data/filetypes.css
index 62060d2..dd38962 100644
--- a/data/filetypes.css
+++ b/data/filetypes.css
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.d b/data/filetypes.d
index 29654e8..fec4b2f 100644
--- a/data/filetypes.d
+++ b/data/filetypes.d
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.diff b/data/filetypes.diff
index 732d1d5..79b3c38 100644
--- a/data/filetypes.diff
+++ b/data/filetypes.diff
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.docbook b/data/filetypes.docbook
index 0930e55..cf5c3f4 100644
--- a/data/filetypes.docbook
+++ b/data/filetypes.docbook
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling=XML]
diff --git a/data/filetypes.erlang b/data/filetypes.erlang
index c1eea76..d45dfe1 100644
--- a/data/filetypes.erlang
+++ b/data/filetypes.erlang
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
[styling]
# Edit these in the colorscheme .conf file instead
default=default
diff --git a/data/filetypes.f77 b/data/filetypes.f77
index 7f0fe03..25b452f 100644
--- a/data/filetypes.f77
+++ b/data/filetypes.f77
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.ferite b/data/filetypes.ferite
index db5b622..14ac09e 100644
--- a/data/filetypes.ferite
+++ b/data/filetypes.ferite
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling=C]
diff --git a/data/filetypes.forth b/data/filetypes.forth
index 4654576..137d1fe 100644
--- a/data/filetypes.forth
+++ b/data/filetypes.forth
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.fortran b/data/filetypes.fortran
index 7a5c058..400f91f 100644
--- a/data/filetypes.fortran
+++ b/data/filetypes.fortran
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling=F77]
diff --git a/data/filetypes.freebasic b/data/filetypes.freebasic
index fcde7f0..1ea867c 100644
--- a/data/filetypes.freebasic
+++ b/data/filetypes.freebasic
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.glsl b/data/filetypes.glsl
index 597d238..61e013c 100644
--- a/data/filetypes.glsl
+++ b/data/filetypes.glsl
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling=C]
diff --git a/data/filetypes.haskell b/data/filetypes.haskell
index 3d9d921..41f8cc5 100644
--- a/data/filetypes.haskell
+++ b/data/filetypes.haskell
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.haxe b/data/filetypes.haxe
index 56919c7..f7adad6 100644
--- a/data/filetypes.haxe
+++ b/data/filetypes.haxe
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling=C]
diff --git a/data/filetypes.html b/data/filetypes.html
index 70f500a..038c24d 100644
--- a/data/filetypes.html
+++ b/data/filetypes.html
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.java b/data/filetypes.java
index 7cab8e7..12403fc 100644
--- a/data/filetypes.java
+++ b/data/filetypes.java
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling=C]
diff --git a/data/filetypes.javascript b/data/filetypes.javascript
index 477853d..81c83c6 100644
--- a/data/filetypes.javascript
+++ b/data/filetypes.javascript
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling=C]
diff --git a/data/filetypes.latex b/data/filetypes.latex
index 1a465dc..3e1315b 100644
--- a/data/filetypes.latex
+++ b/data/filetypes.latex
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.lisp b/data/filetypes.lisp
index 7ec277e..7211f42 100644
--- a/data/filetypes.lisp
+++ b/data/filetypes.lisp
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.lua b/data/filetypes.lua
index 44322e3..e7c6d28 100644
--- a/data/filetypes.lua
+++ b/data/filetypes.lua
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.makefile b/data/filetypes.makefile
index e131acc..2670794 100644
--- a/data/filetypes.makefile
+++ b/data/filetypes.makefile
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.markdown b/data/filetypes.markdown
index bc21ad0..feba35d 100644
--- a/data/filetypes.markdown
+++ b/data/filetypes.markdown
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.matlab b/data/filetypes.matlab
index d566adc..740c53a 100644
--- a/data/filetypes.matlab
+++ b/data/filetypes.matlab
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.nsis b/data/filetypes.nsis
index e9b8429..e6cc13d 100644
--- a/data/filetypes.nsis
+++ b/data/filetypes.nsis
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.objectivec b/data/filetypes.objectivec
index 8cc04d4..87dc2be 100644
--- a/data/filetypes.objectivec
+++ b/data/filetypes.objectivec
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling=C]
diff --git a/data/filetypes.pascal b/data/filetypes.pascal
index cd67f0d..d64a36e 100644
--- a/data/filetypes.pascal
+++ b/data/filetypes.pascal
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.perl b/data/filetypes.perl
index 158a4ee..4b76665 100644
--- a/data/filetypes.perl
+++ b/data/filetypes.perl
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.php b/data/filetypes.php
index 3aadd84..a44af28 100644
--- a/data/filetypes.php
+++ b/data/filetypes.php
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling=HTML]
diff --git a/data/filetypes.po b/data/filetypes.po
index b613f4c..52b12bc 100644
--- a/data/filetypes.po
+++ b/data/filetypes.po
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.python b/data/filetypes.python
index 04349b0..e42a324 100644
--- a/data/filetypes.python
+++ b/data/filetypes.python
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.r b/data/filetypes.r
index 0514a1f..9b44b49 100644
--- a/data/filetypes.r
+++ b/data/filetypes.r
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.restructuredtext b/data/filetypes.restructuredtext
index c9375f4..c0cf4a9 100644
--- a/data/filetypes.restructuredtext
+++ b/data/filetypes.restructuredtext
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# no syntax highlighting yet
diff --git a/data/filetypes.ruby b/data/filetypes.ruby
index fb8f049..0ead822 100644
--- a/data/filetypes.ruby
+++ b/data/filetypes.ruby
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.sh b/data/filetypes.sh
index 07b2957..2ccc879 100644
--- a/data/filetypes.sh
+++ b/data/filetypes.sh
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.sql b/data/filetypes.sql
index 5e82e61..ecba534 100644
--- a/data/filetypes.sql
+++ b/data/filetypes.sql
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.tcl b/data/filetypes.tcl
index 74ce271..016a263 100644
--- a/data/filetypes.tcl
+++ b/data/filetypes.tcl
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file; please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.txt2tags b/data/filetypes.txt2tags
index c56a5ed..4595665 100644
--- a/data/filetypes.txt2tags
+++ b/data/filetypes.txt2tags
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.vala b/data/filetypes.vala
index c493f6d..2e095d9 100644
--- a/data/filetypes.vala
+++ b/data/filetypes.vala
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling=C]
diff --git a/data/filetypes.verilog b/data/filetypes.verilog
index dbda702..377e515 100644
--- a/data/filetypes.verilog
+++ b/data/filetypes.verilog
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.vhdl b/data/filetypes.vhdl
index a756b0a..bf3e923 100644
--- a/data/filetypes.vhdl
+++ b/data/filetypes.vhdl
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/data/filetypes.xml b/data/filetypes.xml
index 9496356..e40d118 100644
--- a/data/filetypes.xml
+++ b/data/filetypes.xml
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling=HTML]
diff --git a/data/filetypes.yaml b/data/filetypes.yaml
index b50fa39..1886fa8 100644
--- a/data/filetypes.yaml
+++ b/data/filetypes.yaml
@@ -1,3 +1,7 @@
+[ft_info]
+ft_version=0
+geany_version=1.22
+
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
diff --git a/src/filetypes.c b/src/filetypes.c
index 322d1f9..97228f3 100644
--- a/src/filetypes.c
+++ b/src/filetypes.c
@@ -1393,8 +1393,14 @@ void filetypes_load_config(guint ft_id, gboolean reload)
f = filetypes_get_filename(ft, FALSE);
load_system_keyfile(config, f, G_KEY_FILE_KEEP_COMMENTS, ft);
+ utils_check_filedef_version(f, config);
+
SETPTR(f, filetypes_get_filename(ft, TRUE));
- g_key_file_load_from_file(config_home, f, G_KEY_FILE_KEEP_COMMENTS, NULL);
+ if (g_key_file_load_from_file(config_home, f, G_KEY_FILE_KEEP_COMMENTS, NULL))
+ {
+ utils_check_filedef_version(f, config_home);
+ }
+
g_free(f);
}
/* Copy keys for any groups with [group=C] from system keyfile */
diff --git a/src/geany.h b/src/geany.h
index 1108f91..860be44 100644
--- a/src/geany.h
+++ b/src/geany.h
@@ -56,6 +56,14 @@
#define GEANY_WINDOW_DEFAULT_HEIGHT 600
+/* For checking color scheme and filedef compatibility. Increment whenever
+ * either one breaks compatibility with old versions to cause an error message
+ * to be displayed to the user. Note: this isn't strictly tied to the Geany
+ * version, however it's convenient to use the Geany version number at the
+ * time of the compatibility break. */
+#define GEANY_FILEDEFS_VERSION 1.22
+#define GEANY_COLORSCHEMES_VERSION 1.22
+
/* Common forward declarations */
typedef struct GeanyDocument GeanyDocument;
diff --git a/src/highlighting.c b/src/highlighting.c
index ebcf393..482411d 100644
--- a/src/highlighting.c
+++ b/src/highlighting.c
@@ -41,6 +41,7 @@
#include "main.h"
#include "support.h"
#include "sciwrappers.h"
+#include "dialogs.h"
#include "highlightingmappings.h"
@@ -534,6 +535,9 @@ static GKeyFile *utils_key_file_new(const gchar *filename)
GKeyFile *config = g_key_file_new();
g_key_file_load_from_file(config, filename, G_KEY_FILE_KEEP_COMMENTS, NULL);
+
+ utils_check_color_scheme_version(filename, config);
+
return config;
}
diff --git a/src/utils.c b/src/utils.c
index 531a27f..0c67484 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -2094,3 +2094,73 @@ gchar **utils_strv_join(gchar **first, gchar **second)
g_free(second);
return strv;
}
+
+
+static gboolean utils_check_keyfile_version(GKeyFile *kf, const gchar *group,
+ const gchar *key, gdouble version)
+{
+ gboolean free_kf = FALSE;
+ gboolean ret_value = FALSE;
+ gchar *str_value = NULL;
+ gdouble double_value;
+
+ g_return_val_if_fail(kf != NULL, FALSE);
+ g_return_val_if_fail(group != NULL, FALSE);
+ g_return_val_if_fail(key != NULL, FALSE);
+
+ str_value = g_key_file_get_string(kf, group, key, NULL);
+ if (str_value)
+ {
+ errno = 0;
+ double_value = g_strtod(str_value, NULL);
+ if (errno == 0)
+ {
+ if (double_value >= version)
+ ret_value = TRUE;
+ }
+ }
+
+ g_free(str_value);
+
+ return ret_value;
+}
+
+
+static utils_warn_config_version(const gchar *filename, const gchar *conf_type)
+{
+ gchar *prob = _("Incompatible config file detected");
+ gchar *msg = g_strdup_printf(_("The %s '%s' is not compatible with this "
+ "version of Geany. Please remove or update this %s to ensure "
+ "reliable operation."), conf_type, filename, conf_type);
+ dialogs_show_msgbox_with_secondary(GTK_MESSAGE_ERROR, prob, msg);
+ g_warning("%s: %s", prob, msg);
+ g_free(msg);
+}
+
+
+void utils_check_color_scheme_version(const gchar *filename, GKeyFile *keyfile)
+{
+ gboolean version_ok;
+
+ g_return_if_fail(filename != NULL);
+
+ version_ok = utils_check_keyfile_version(keyfile, "theme_info", "geany_version",
+ GEANY_COLORSCHEMES_VERSION);
+
+ if (!version_ok)
+ utils_warn_config_version(filename, _("color scheme"));
+}
+
+
+void utils_check_filedef_version(const gchar *filename, GKeyFile *keyfile)
+{
+ gboolean version_ok;
+
+ g_return_if_fail(filename != NULL);
+
+ version_ok = utils_check_keyfile_version(keyfile, "ft_info", "geany_version",
+ GEANY_FILEDEFS_VERSION);
+
+ if (!version_ok)
+ utils_warn_config_version(filename, _("filetype definition"));
+}
diff --git a/src/utils.h b/src/utils.h
index 64834be..6d28f0b 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -276,4 +276,8 @@ gchar *utils_str_remove_chars(gchar *string, const gchar *chars);
gchar **utils_copy_environment(const gchar **exclude_vars, const gchar *first_varname, ...) G_GNUC_NULL_TERMINATED;
+void utils_check_color_scheme_version(const gchar *filename, GKeyFile *keyfile);
+
+void utils_check_filedef_version(const gchar *filename, GKeyFile *keyfile);
+
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment