diff --git a/data/filetypes.Go.conf b/data/filetypes.Go.conf index 9ecbe5bf..4ad48020 100644 --- a/data/filetypes.Go.conf +++ b/data/filetypes.Go.conf @@ -13,9 +13,13 @@ docComment=a addindex addtogroup anchor arg attention author authors b brief bug [lexer_properties=C] [settings] +lexer_filetype=C + # default extension used when saving files extension=go -lexer_filetype=C + +# MIME type +mime_type=text/x-go # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.Graphviz.conf b/data/filetypes.Graphviz.conf index 61739f59..92ab9a47 100644 --- a/data/filetypes.Graphviz.conf +++ b/data/filetypes.Graphviz.conf @@ -18,6 +18,9 @@ lexer_filetype=C # default extension used when saving files extension=gv +# MIME type +mime_type=text/vnd.graphviz + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.Scala.conf b/data/filetypes.Scala.conf index e631b784..0a903fdc 100644 --- a/data/filetypes.Scala.conf +++ b/data/filetypes.Scala.conf @@ -18,6 +18,9 @@ lexer_filetype=C # default extension used when saving files extension=scala +# MIME type +mime_type=text/x-scala + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.abc b/data/filetypes.abc index 97a0deb7..6d783a1f 100644 --- a/data/filetypes.abc +++ b/data/filetypes.abc @@ -6,4 +6,6 @@ # default extension used when saving files extension=abc +# MIME type +mime_type=text/vnd.abc diff --git a/data/filetypes.actionscript b/data/filetypes.actionscript index d9cbee40..c5361d71 100644 --- a/data/filetypes.actionscript +++ b/data/filetypes.actionscript @@ -11,6 +11,9 @@ classes=ArgumentError Array Boolean Class Date DefinitionError Error EvalError F # default extension used when saving files extension=as +# MIME type +mime_type=application/ecmascript + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.ada b/data/filetypes.ada index 063462f2..c5958c24 100644 --- a/data/filetypes.ada +++ b/data/filetypes.ada @@ -23,6 +23,9 @@ primary=abort abs abstract accept access aliased all and array at begin body cas # default extension used when saving files extension=adb +# MIME type +mime_type=text/x-adasrc + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.c b/data/filetypes.c index 2f1e5c68..c5d1c682 100644 --- a/data/filetypes.c +++ b/data/filetypes.c @@ -48,6 +48,9 @@ preprocessor.end.$(file.patterns.cpp)=endif # default extension used when saving files extension=c +# MIME type +mime_type=text/x-csrc + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.caml b/data/filetypes.caml index f966c7b5..5572d804 100644 --- a/data/filetypes.caml +++ b/data/filetypes.caml @@ -28,6 +28,9 @@ keywords_optional=option Some None ignore ref # default extension used when saving files extension=ml +# MIME type +mime_type=text/x-ocaml + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.cmake b/data/filetypes.cmake index 6442dc5c..0eb3fc8d 100644 --- a/data/filetypes.cmake +++ b/data/filetypes.cmake @@ -28,6 +28,9 @@ userdefined= # default extension used when saving files extension=cmake +# MIME type +mime_type=text/x-cmake + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.cobol b/data/filetypes.cobol index 4bcbe078..6e6b0c09 100644 --- a/data/filetypes.cobol +++ b/data/filetypes.cobol @@ -22,6 +22,9 @@ keywords=accept access add address advancing after alphabet alphabetic alphabeti # default extension used when saving files extension=cob +# MIME type +mime_type=text/x-cobol + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.cpp b/data/filetypes.cpp index 12c4b2ba..dfb57dab 100644 --- a/data/filetypes.cpp +++ b/data/filetypes.cpp @@ -22,6 +22,9 @@ lexer_filetype=C # default extension used when saving files extension=cpp +# MIME type +mime_type=text/x-c++src + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.cs b/data/filetypes.cs index 42b34601..3d59b480 100644 --- a/data/filetypes.cs +++ b/data/filetypes.cs @@ -22,6 +22,9 @@ lexer_filetype=C # default extension used when saving files extension=cs +# MIME type +mime_type=text/x-csharp + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.css b/data/filetypes.css index c1ee36e7..7167bb18 100644 --- a/data/filetypes.css +++ b/data/filetypes.css @@ -43,6 +43,9 @@ browser_pseudo_elements=^-ms- ^-apple- ^-epub- ^-moz- ^-o- ^-wap- ^-webkit- ^-xv # default extension used when saving files extension=css +# MIME type +mime_type=text/css + # the following characters are these which a "word" can contains, see documentation #wordchars=_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.d b/data/filetypes.d index 03f4021c..4f148dcd 100644 --- a/data/filetypes.d +++ b/data/filetypes.d @@ -35,6 +35,9 @@ fold.d.comment.explicit=0 # default extension used when saving files extension=d +# MIME type +mime_type=text/x-dsrc + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.diff b/data/filetypes.diff index 732d1d5f..62bd9e8d 100644 --- a/data/filetypes.diff +++ b/data/filetypes.diff @@ -15,6 +15,9 @@ changed=line_changed # default extension used when saving files extension=diff +# MIME type +mime_type=text/x-patch + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.docbook b/data/filetypes.docbook index a5fb93b1..54262cfc 100644 --- a/data/filetypes.docbook +++ b/data/filetypes.docbook @@ -45,6 +45,9 @@ fold.html.preprocessor=1 # default extension used when saving files extension=docbook +# MIME type +mime_type=application/docbook+xml + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.erlang b/data/filetypes.erlang index c1eea768..d7acf7a1 100644 --- a/data/filetypes.erlang +++ b/data/filetypes.erlang @@ -45,6 +45,9 @@ doc_macro=@date @docRoot @link @module @package @section @time @type @version # default extension used when saving files extension=erl +# MIME type +mime_type=text/x-erlang + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.f77 b/data/filetypes.f77 index c146e26a..51662fae 100644 --- a/data/filetypes.f77 +++ b/data/filetypes.f77 @@ -28,6 +28,9 @@ user_functions=cdabs cdcos cdexp cdlog cdsin cdsqrt cotan cotand dcmplx dconjg d # default extension used when saving files extension=f +# MIME type +mime_type=text/x-fortran + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.fortran b/data/filetypes.fortran index 80082fdc..bfc39ee4 100644 --- a/data/filetypes.fortran +++ b/data/filetypes.fortran @@ -12,6 +12,9 @@ user_functions=cdabs cdcos cdexp cdlog cdsin cdsqrt cotan cotand dcmplx dconjg d # default extension used when saving files extension=f90 +# MIME type +mime_type=text/x-fortran + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.haskell b/data/filetypes.haskell index 65baa82e..85292236 100644 --- a/data/filetypes.haskell +++ b/data/filetypes.haskell @@ -44,6 +44,9 @@ fold.haskell.imports=0 # default extension used when saving files extension=hs +# MIME type +mime_type=text/x-haskell + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.html b/data/filetypes.html index 5429103b..399eb67b 100644 --- a/data/filetypes.html +++ b/data/filetypes.html @@ -96,6 +96,9 @@ sgml=ELEMENT DOCTYPE ATTLIST ENTITY NOTATION # default extension used when saving files extension=html +# MIME type +mime_type=text/html + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.java b/data/filetypes.java index ea355c6f..618ec8ae 100644 --- a/data/filetypes.java +++ b/data/filetypes.java @@ -13,6 +13,9 @@ typedefs= # default extension used when saving files extension=java +# MIME type +mime_type=text/x-java + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.javascript b/data/filetypes.javascript index 477853d1..0fd5e72c 100644 --- a/data/filetypes.javascript +++ b/data/filetypes.javascript @@ -10,6 +10,9 @@ secondary=Array Boolean Date Function Math Number Object String RegExp EvalError # default extension used when saving files extension=js +# MIME type +mime_type=application/javascript + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.latex b/data/filetypes.latex index ccc1acce..f5a3d8bb 100644 --- a/data/filetypes.latex +++ b/data/filetypes.latex @@ -25,6 +25,9 @@ primary=above abovedisplayshortskip abovedisplayskip abovewithdelims accent adjd # default extension used when saving files extension=tex +# MIME type +mime_type=text/x-tex + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.lua b/data/filetypes.lua index 44322e3b..370e1c06 100644 --- a/data/filetypes.lua +++ b/data/filetypes.lua @@ -42,6 +42,9 @@ user4= # default extension used when saving files extension=lua +# MIME type +mime_type=text/x-lua + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.makefile b/data/filetypes.makefile index e0509f24..61252e47 100644 --- a/data/filetypes.makefile +++ b/data/filetypes.makefile @@ -13,6 +13,9 @@ ideol=type # default extension used when saving files extension=mak +# MIME type +mime_type=text/x-makefile + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.markdown b/data/filetypes.markdown index bc21ad05..b5fe588a 100644 --- a/data/filetypes.markdown +++ b/data/filetypes.markdown @@ -23,6 +23,9 @@ codebk=attribute_unknown # default extension used when saving files extension=mdml +# MIME type +mime_type=text/x-markdown + # sort tags by appearance symbol_list_sort_mode=1 diff --git a/data/filetypes.matlab b/data/filetypes.matlab index 70ff453d..d5481a9b 100644 --- a/data/filetypes.matlab +++ b/data/filetypes.matlab @@ -19,6 +19,9 @@ primary=break case catch classdef continue else elseif end enumeration events fo # default extension used when saving files extension=m +# MIME type +mime_type=text/x-matlab + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.objectivec b/data/filetypes.objectivec index 8cc04d4d..586023ca 100644 --- a/data/filetypes.objectivec +++ b/data/filetypes.objectivec @@ -14,6 +14,9 @@ docComment=attention author brief bug class code date def enum example exception # default extension used when saving files extension=m +# MIME type +mime_type=text/x-objc + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.pascal b/data/filetypes.pascal index c6e18fc8..621b70f5 100644 --- a/data/filetypes.pascal +++ b/data/filetypes.pascal @@ -30,6 +30,9 @@ lexer.pascal.smart.highlighting=1 # default extension used when saving files extension=pas +# MIME type +mime_type=text/x-pascal + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.perl b/data/filetypes.perl index 55b4c158..0b0c7446 100644 --- a/data/filetypes.perl +++ b/data/filetypes.perl @@ -61,6 +61,9 @@ styling.within.preprocessor=1 # default extension used when saving files extension=pl +# MIME type +mime_type=application/x-perl + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.php b/data/filetypes.php index 3aadd841..472374fd 100644 --- a/data/filetypes.php +++ b/data/filetypes.php @@ -10,6 +10,9 @@ phpscript.mode=1 # default extension used when saving files extension=php +# MIME type +mime_type=application/x-php + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.po b/data/filetypes.po index 06271737..0e037852 100644 --- a/data/filetypes.po +++ b/data/filetypes.po @@ -22,6 +22,9 @@ error=error # default extension used when saving files extension=po +# MIME type +mime_type=text/x-gettext-translation + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.python b/data/filetypes.python index f9fd28b0..18b69a3a 100644 --- a/data/filetypes.python +++ b/data/filetypes.python @@ -33,6 +33,9 @@ fold.quotes.python=1 # default extension used when saving files extension=py +# MIME type +mime_type=text/x-python + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.restructuredtext b/data/filetypes.restructuredtext index ce70288d..3a8ce7ab 100644 --- a/data/filetypes.restructuredtext +++ b/data/filetypes.restructuredtext @@ -6,6 +6,9 @@ # default extension used when saving files extension=rst +# MIME type +mime_type=text/x-rst + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.ruby b/data/filetypes.ruby index fb8f0494..a173ba4f 100644 --- a/data/filetypes.ruby +++ b/data/filetypes.ruby @@ -45,6 +45,9 @@ primary=__FILE__ load define_method attr_accessor attr_writer attr_reader and de # default extension used when saving files extension=rb +# MIME type +mime_type=application/x-ruby + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.rust b/data/filetypes.rust index 6f26173e..4997bacd 100644 --- a/data/filetypes.rust +++ b/data/filetypes.rust @@ -34,6 +34,9 @@ lexer.cpp.track.preprocessor=0 # default extension used when saving files extension=rs +# MIME type +mime_type=text/x-rustsrc + # single comments, like # in this file comment_single=// # multiline comments diff --git a/data/filetypes.sh b/data/filetypes.sh index 6cd8cd70..4dc10a5f 100644 --- a/data/filetypes.sh +++ b/data/filetypes.sh @@ -24,6 +24,9 @@ primary=break case continue do done elif else esac eval exit export fi for funct # default extension used when saving files extension=sh +# MIME type +mime_type=application/x-shellscript + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.sql b/data/filetypes.sql index dac0c723..1f2f885a 100644 --- a/data/filetypes.sql +++ b/data/filetypes.sql @@ -29,6 +29,9 @@ keywords=absolute action add admin after aggregate alias all allocate alter and # default extension used when saving files extension=sql +# MIME type +mime_type=text/x-sql + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.tcl b/data/filetypes.tcl index 74ce271d..bd2770f5 100644 --- a/data/filetypes.tcl +++ b/data/filetypes.tcl @@ -33,6 +33,9 @@ expand= # default extension used when saving files extension=tcl +# MIME type +mime_type=text/x-tcl + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.txt2tags b/data/filetypes.txt2tags index c56a5edc..23003a71 100644 --- a/data/filetypes.txt2tags +++ b/data/filetypes.txt2tags @@ -28,6 +28,9 @@ postproc=preprocessor # default extension used when saving files extension=txt2tags +# MIME type +mime_type=text/x-txt2tags + # sort tags by appearance symbol_list_sort_mode=1 diff --git a/data/filetypes.vala b/data/filetypes.vala index 2e54be8b..0f6bbd38 100644 --- a/data/filetypes.vala +++ b/data/filetypes.vala @@ -23,6 +23,9 @@ lexer_filetype=C # default extension used when saving files extension=vala +# MIME type +mime_type=text/x-vala + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.verilog b/data/filetypes.verilog index dbda7025..abc550ec 100644 --- a/data/filetypes.verilog +++ b/data/filetypes.verilog @@ -26,6 +26,9 @@ word3=real integer time reg wire input output inout # default extension used when saving files extension=v +# MIME type +mime_type=text/x-verilog + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.vhdl b/data/filetypes.vhdl index a756b0a1..b98aaba2 100644 --- a/data/filetypes.vhdl +++ b/data/filetypes.vhdl @@ -31,6 +31,9 @@ userwords= # default extension used when saving files extension=vhd +# MIME type +mime_type=text/x-vhdl + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.xml b/data/filetypes.xml index 9496356f..bdff104e 100644 --- a/data/filetypes.xml +++ b/data/filetypes.xml @@ -7,6 +7,9 @@ # default extension used when saving files extension=xml +# MIME type +mime_type=application/xml + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/data/filetypes.yaml b/data/filetypes.yaml index b50fa399..fece13ac 100644 --- a/data/filetypes.yaml +++ b/data/filetypes.yaml @@ -21,6 +21,9 @@ keywords=true false yes no # default extension used when saving files extension=yaml +# MIME type +mime_type=application/x-yaml + # the following characters are these which a "word" can contains, see documentation #wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 diff --git a/doc/geany.txt b/doc/geany.txt index cdd17cf8..6d866c2f 100644 --- a/doc/geany.txt +++ b/doc/geany.txt @@ -4211,6 +4211,10 @@ xml_indent_tags to filetypes for which the HTML or XML lexer is used. Such filetypes have this setting in their system configuration files. +mime_type + The MIME type for this file type, e.g. "text/x-csrc". This is used + for example to chose the icon to display for this file type. + [indentation] section ````````````````````` diff --git a/src/dialogs.c b/src/dialogs.c index 7586ad12..d72c63ab 100644 --- a/src/dialogs.c +++ b/src/dialogs.c @@ -1146,7 +1146,6 @@ void dialogs_show_file_properties(GeanyDocument *doc) GtkWidget *dialog, *label, *image, *check; gchar *file_size, *title, *base_name, *time_changed, *time_modified, *time_accessed, *enctext; gchar *short_name; - GdkPixbuf *pixbuf; #ifdef HAVE_SYS_TYPES_H struct stat st; off_t filesize; @@ -1222,9 +1221,8 @@ void dialogs_show_file_properties(GeanyDocument *doc) gtk_label_set_text(GTK_LABEL(label), base_name); image = ui_lookup_widget(dialog, "file_type_image"); - pixbuf = ui_get_mime_icon(doc->file_type->mime_type, GTK_ICON_SIZE_BUTTON); - gtk_image_set_from_pixbuf(GTK_IMAGE(image), pixbuf); - g_object_unref(pixbuf); + gtk_image_set_from_gicon(GTK_IMAGE(image), doc->file_type->icon, + GTK_ICON_SIZE_BUTTON); label = ui_lookup_widget(dialog, "file_type_label"); gtk_label_set_text(GTK_LABEL(label), doc->file_type->title); diff --git a/src/filetypes.c b/src/filetypes.c index 4650c2b2..7796aa71 100644 --- a/src/filetypes.c +++ b/src/filetypes.c @@ -103,22 +103,20 @@ static gchar *filetype_make_title(const char *name, enum TitleType type) /* name argument (ie filetype name) must not be translated as it is used for * filetype lookup. Use filetypes_get_display_name() instead.*/ static void ft_init(filetype_id ft_id, int lang, const char *name, - const char *title_name, enum TitleType title_type, const char *mime_type, + const char *title_name, enum TitleType title_type, GeanyFiletypeGroupID group_id) { GeanyFiletype *ft = filetypes[ft_id]; ft->lang = lang; ft->name = g_strdup(name); ft->title = filetype_make_title((title_name != NULL) ? title_name : ft->name, title_type); - if (mime_type != NULL) - SETPTR(ft->mime_type, g_strdup(mime_type)); ft->group = group_id; } /* Evil macro to save typing and make init_builtin_filetypes() more readable */ -#define FT_INIT(ft_id, parser_id, name, title_name, title_type, mime_type, group_id) \ +#define FT_INIT(ft_id, parser_id, name, title_name, title_type, group_id) \ ft_init(GEANY_FILETYPES_##ft_id, TM_PARSER_##parser_id, name, title_name, \ - TITLE_##title_type, mime_type, GEANY_FILETYPE_GROUP_##group_id) + TITLE_##title_type, GEANY_FILETYPE_GROUP_##group_id) /* Note: remember to update HACKING if this function is renamed. */ @@ -130,68 +128,67 @@ static void init_builtin_filetypes(void) * [2] = Non-translated filetype name (*not* label for display) * [3] = Translatable human filetype title prefix or NULL to use [2] * [4] = Title type (TITLE_*) constant (ex. TITLE_SOURCE_FILE is 'source file' suffix) - * [5] = Mime type or NULL for none/unknown - * [6] = The filetype group constant (GEANY_FILETYPE_GROUP_*) + * [5] = The filetype group constant (GEANY_FILETYPE_GROUP_*) * -------------------------------------------------------------------------------------------------------------------------- - * [0] [1] [2] [3] [4] [5] [6] */ - FT_INIT( NONE, NONE, "None", _("None"), NONE, NULL, NONE ); - FT_INIT( C, C, "C", NULL, SOURCE_FILE, "text/x-csrc", COMPILED ); - FT_INIT( CPP, CPP, "C++", NULL, SOURCE_FILE, "text/x-c++src", COMPILED ); - FT_INIT( OBJECTIVEC, OBJC, "Objective-C", NULL, SOURCE_FILE, "text/x-objc", COMPILED ); - FT_INIT( CS, CSHARP, "C#", NULL, SOURCE_FILE, "text/x-csharp", COMPILED ); - FT_INIT( VALA, VALA, "Vala", NULL, SOURCE_FILE, "text/x-vala", COMPILED ); - FT_INIT( D, D, "D", NULL, SOURCE_FILE, "text/x-dsrc", COMPILED ); - FT_INIT( JAVA, JAVA, "Java", NULL, SOURCE_FILE, "text/x-java", COMPILED ); - FT_INIT( PASCAL, PASCAL, "Pascal", NULL, SOURCE_FILE, "text/x-pascal", COMPILED ); - FT_INIT( ASM, ASM, "ASM", "Assembler", SOURCE_FILE, NULL, COMPILED ); - FT_INIT( BASIC, FREEBASIC, "FreeBasic", NULL, SOURCE_FILE, NULL, COMPILED ); - FT_INIT( FORTRAN, FORTRAN, "Fortran", "Fortran (F90)", SOURCE_FILE, "text/x-fortran", COMPILED ); - FT_INIT( F77, F77, "F77", "Fortran (F77)", SOURCE_FILE, "text/x-fortran", COMPILED ); - FT_INIT( GLSL, GLSL, "GLSL", NULL, SOURCE_FILE, NULL, COMPILED ); - FT_INIT( CAML, NONE, "CAML", "(O)Caml", SOURCE_FILE, "text/x-ocaml", COMPILED ); - FT_INIT( PERL, PERL, "Perl", NULL, SOURCE_FILE, "application/x-perl", SCRIPT ); - FT_INIT( PHP, PHP, "PHP", NULL, SOURCE_FILE, "application/x-php", SCRIPT ); - FT_INIT( JS, JAVASCRIPT, "Javascript", NULL, SOURCE_FILE, "application/javascript", SCRIPT ); - FT_INIT( PYTHON, PYTHON, "Python", NULL, SOURCE_FILE, "text/x-python", SCRIPT ); - FT_INIT( RUBY, RUBY, "Ruby", NULL, SOURCE_FILE, "application/x-ruby", SCRIPT ); - FT_INIT( TCL, TCL, "Tcl", NULL, SOURCE_FILE, "text/x-tcl", SCRIPT ); - FT_INIT( LUA, LUA, "Lua", NULL, SOURCE_FILE, "text/x-lua", SCRIPT ); - FT_INIT( FERITE, FERITE, "Ferite", NULL, SOURCE_FILE, NULL, SCRIPT ); - FT_INIT( HASKELL, HASKELL, "Haskell", NULL, SOURCE_FILE, "text/x-haskell", COMPILED ); - FT_INIT( MARKDOWN, MARKDOWN, "Markdown", NULL, SOURCE_FILE, "text/x-markdown", MARKUP ); - FT_INIT( TXT2TAGS, TXT2TAGS, "Txt2tags", NULL, SOURCE_FILE, "text/x-txt2tags", MARKUP ); - FT_INIT( ABC, ABC, "Abc", NULL, FILE, NULL, MISC ); - FT_INIT( SH, SH, "Sh", _("Shell"), SCRIPT, "application/x-shellscript", SCRIPT ); - FT_INIT( MAKE, MAKEFILE, "Make", _("Makefile"), NONE, "text/x-makefile", SCRIPT ); - FT_INIT( XML, NONE, "XML", NULL, DOCUMENT, "application/xml", MARKUP ); - FT_INIT( DOCBOOK, DOCBOOK, "Docbook", NULL, DOCUMENT, "application/docbook+xml", MARKUP ); - FT_INIT( HTML, HTML, "HTML", NULL, DOCUMENT, "text/html", MARKUP ); - FT_INIT( CSS, CSS, "CSS", _("Cascading Stylesheet"), NONE, "text/css", MARKUP ); /* not really markup but fit quite well to HTML */ - FT_INIT( SQL, SQL, "SQL", NULL, FILE, "text/x-sql", MISC ); - FT_INIT( COBOL, COBOL, "COBOL", NULL, SOURCE_FILE, "text/x-cobol", COMPILED ); - FT_INIT( LATEX, LATEX, "LaTeX", NULL, SOURCE_FILE, "text/x-tex", MARKUP ); - FT_INIT( VHDL, VHDL, "VHDL", NULL, SOURCE_FILE, "text/x-vhdl", COMPILED ); - FT_INIT( VERILOG, VERILOG, "Verilog", NULL, SOURCE_FILE, "text/x-verilog", COMPILED ); - FT_INIT( DIFF, DIFF, "Diff", NULL, FILE, "text/x-patch", MISC ); - FT_INIT( LISP, NONE, "Lisp", NULL, SOURCE_FILE, NULL, SCRIPT ); - FT_INIT( ERLANG, NONE, "Erlang", NULL, SOURCE_FILE, "text/x-erlang", COMPILED ); - FT_INIT( CONF, CONF, "Conf", _("Config"), FILE, NULL, MISC ); - FT_INIT( PO, NONE, "Po", _("Gettext translation"), FILE, "text/x-gettext-translation", MISC ); - FT_INIT( HAXE, HAXE, "Haxe", NULL, SOURCE_FILE, NULL, COMPILED ); - FT_INIT( AS, ACTIONSCRIPT, "ActionScript", NULL, SOURCE_FILE, "application/ecmascript", SCRIPT ); - FT_INIT( R, R, "R", NULL, SOURCE_FILE, NULL, SCRIPT ); - FT_INIT( REST, REST, "reStructuredText", NULL, SOURCE_FILE, NULL, MARKUP ); - FT_INIT( MATLAB, MATLAB, "Matlab/Octave", NULL, SOURCE_FILE, "text/x-matlab", SCRIPT ); - FT_INIT( YAML, NONE, "YAML", NULL, FILE, "application/x-yaml", MISC ); - FT_INIT( CMAKE, NONE, "CMake", NULL, SOURCE_FILE, "text/x-cmake", SCRIPT ); - FT_INIT( NSIS, NSIS, "NSIS", NULL, SOURCE_FILE, NULL, SCRIPT ); - FT_INIT( ADA, NONE, "Ada", NULL, SOURCE_FILE, "text/x-adasrc", COMPILED ); - FT_INIT( FORTH, NONE, "Forth", NULL, SOURCE_FILE, NULL, SCRIPT ); - FT_INIT( ASCIIDOC, ASCIIDOC, "Asciidoc", NULL, SOURCE_FILE, NULL, MARKUP ); - FT_INIT( ABAQUS, ABAQUS, "Abaqus", NULL, SOURCE_FILE, NULL, SCRIPT ); - FT_INIT( BATCH, NONE, "Batch", NULL, SCRIPT, NULL, SCRIPT ); - FT_INIT( POWERSHELL, NONE, "PowerShell", NULL, SOURCE_FILE, NULL, SCRIPT ); - FT_INIT( RUST, RUST, "Rust", NULL, SOURCE_FILE, "text/x-rustsrc", COMPILED ); + * [0] [1] [2] [3] [4] [5] */ + FT_INIT( NONE, NONE, "None", _("None"), NONE, NONE ); + FT_INIT( C, C, "C", NULL, SOURCE_FILE, COMPILED ); + FT_INIT( CPP, CPP, "C++", NULL, SOURCE_FILE, COMPILED ); + FT_INIT( OBJECTIVEC, OBJC, "Objective-C", NULL, SOURCE_FILE, COMPILED ); + FT_INIT( CS, CSHARP, "C#", NULL, SOURCE_FILE, COMPILED ); + FT_INIT( VALA, VALA, "Vala", NULL, SOURCE_FILE, COMPILED ); + FT_INIT( D, D, "D", NULL, SOURCE_FILE, COMPILED ); + FT_INIT( JAVA, JAVA, "Java", NULL, SOURCE_FILE, COMPILED ); + FT_INIT( PASCAL, PASCAL, "Pascal", NULL, SOURCE_FILE, COMPILED ); + FT_INIT( ASM, ASM, "ASM", "Assembler", SOURCE_FILE, COMPILED ); + FT_INIT( BASIC, FREEBASIC, "FreeBasic", NULL, SOURCE_FILE, COMPILED ); + FT_INIT( FORTRAN, FORTRAN, "Fortran", "Fortran (F90)", SOURCE_FILE, COMPILED ); + FT_INIT( F77, F77, "F77", "Fortran (F77)", SOURCE_FILE, COMPILED ); + FT_INIT( GLSL, GLSL, "GLSL", NULL, SOURCE_FILE, COMPILED ); + FT_INIT( CAML, NONE, "CAML", "(O)Caml", SOURCE_FILE, COMPILED ); + FT_INIT( PERL, PERL, "Perl", NULL, SOURCE_FILE, SCRIPT ); + FT_INIT( PHP, PHP, "PHP", NULL, SOURCE_FILE, SCRIPT ); + FT_INIT( JS, JAVASCRIPT, "Javascript", NULL, SOURCE_FILE, SCRIPT ); + FT_INIT( PYTHON, PYTHON, "Python", NULL, SOURCE_FILE, SCRIPT ); + FT_INIT( RUBY, RUBY, "Ruby", NULL, SOURCE_FILE, SCRIPT ); + FT_INIT( TCL, TCL, "Tcl", NULL, SOURCE_FILE, SCRIPT ); + FT_INIT( LUA, LUA, "Lua", NULL, SOURCE_FILE, SCRIPT ); + FT_INIT( FERITE, FERITE, "Ferite", NULL, SOURCE_FILE, SCRIPT ); + FT_INIT( HASKELL, HASKELL, "Haskell", NULL, SOURCE_FILE, COMPILED ); + FT_INIT( MARKDOWN, MARKDOWN, "Markdown", NULL, SOURCE_FILE, MARKUP ); + FT_INIT( TXT2TAGS, TXT2TAGS, "Txt2tags", NULL, SOURCE_FILE, MARKUP ); + FT_INIT( ABC, ABC, "Abc", NULL, FILE, MISC ); + FT_INIT( SH, SH, "Sh", _("Shell"), SCRIPT, SCRIPT ); + FT_INIT( MAKE, MAKEFILE, "Make", _("Makefile"), NONE, SCRIPT ); + FT_INIT( XML, NONE, "XML", NULL, DOCUMENT, MARKUP ); + FT_INIT( DOCBOOK, DOCBOOK, "Docbook", NULL, DOCUMENT, MARKUP ); + FT_INIT( HTML, HTML, "HTML", NULL, DOCUMENT, MARKUP ); + FT_INIT( CSS, CSS, "CSS", _("Cascading Stylesheet"), NONE, MARKUP ); /* not really markup but fit quite well to HTML */ + FT_INIT( SQL, SQL, "SQL", NULL, FILE, MISC ); + FT_INIT( COBOL, COBOL, "COBOL", NULL, SOURCE_FILE, COMPILED ); + FT_INIT( LATEX, LATEX, "LaTeX", NULL, SOURCE_FILE, MARKUP ); + FT_INIT( VHDL, VHDL, "VHDL", NULL, SOURCE_FILE, COMPILED ); + FT_INIT( VERILOG, VERILOG, "Verilog", NULL, SOURCE_FILE, COMPILED ); + FT_INIT( DIFF, DIFF, "Diff", NULL, FILE, MISC ); + FT_INIT( LISP, NONE, "Lisp", NULL, SOURCE_FILE, SCRIPT ); + FT_INIT( ERLANG, NONE, "Erlang", NULL, SOURCE_FILE, COMPILED ); + FT_INIT( CONF, CONF, "Conf", _("Config"), FILE, MISC ); + FT_INIT( PO, NONE, "Po", _("Gettext translation"), FILE, MISC ); + FT_INIT( HAXE, HAXE, "Haxe", NULL, SOURCE_FILE, COMPILED ); + FT_INIT( AS, ACTIONSCRIPT, "ActionScript", NULL, SOURCE_FILE, SCRIPT ); + FT_INIT( R, R, "R", NULL, SOURCE_FILE, SCRIPT ); + FT_INIT( REST, REST, "reStructuredText", NULL, SOURCE_FILE, MARKUP ); + FT_INIT( MATLAB, MATLAB, "Matlab/Octave", NULL, SOURCE_FILE, SCRIPT ); + FT_INIT( YAML, NONE, "YAML", NULL, FILE, MISC ); + FT_INIT( CMAKE, NONE, "CMake", NULL, SOURCE_FILE, SCRIPT ); + FT_INIT( NSIS, NSIS, "NSIS", NULL, SOURCE_FILE, SCRIPT ); + FT_INIT( ADA, NONE, "Ada", NULL, SOURCE_FILE, COMPILED ); + FT_INIT( FORTH, NONE, "Forth", NULL, SOURCE_FILE, SCRIPT ); + FT_INIT( ASCIIDOC, ASCIIDOC, "Asciidoc", NULL, SOURCE_FILE, MARKUP ); + FT_INIT( ABAQUS, ABAQUS, "Abaqus", NULL, SOURCE_FILE, SCRIPT ); + FT_INIT( BATCH, NONE, "Batch", NULL, SCRIPT, SCRIPT ); + FT_INIT( POWERSHELL, NONE, "PowerShell", NULL, SOURCE_FILE, SCRIPT ); + FT_INIT( RUST, RUST, "Rust", NULL, SOURCE_FILE, COMPILED ); } @@ -261,9 +258,6 @@ static void filetype_add(GeanyFiletype *ft) /* list will be sorted later */ filetypes_by_title = g_slist_prepend(filetypes_by_title, ft); - - if (!ft->mime_type) - ft->mime_type = g_strdup("text/plain"); } @@ -431,16 +425,7 @@ static void create_set_filetype_menu(void) void filetypes_init(void) { - GSList *node; - filetypes_init_types(); - - /* this has to be here as GTK isn't initialized in filetypes_init_types(). */ - foreach_slist(node, filetypes_by_title) - { - GeanyFiletype *ft = node->data; - ft->icon = ui_get_mime_icon(ft->mime_type, GTK_ICON_SIZE_MENU); - } create_set_filetype_menu(); setup_config_file_menus(); } @@ -883,6 +868,10 @@ static void load_settings(guint ft_id, GKeyFile *config, GKeyFile *configh) SETPTR(filetypes[ft_id]->extension, result); } + /* MIME type */ + result = utils_get_setting(string, configh, config, "settings", "mime_type", "text/plain"); + SETPTR(filetypes[ft_id]->mime_type, result); + /* read comment notes */ result = utils_get_setting(string, configh, config, "settings", "comment_open", NULL); if (result != NULL) @@ -1110,6 +1099,10 @@ void filetypes_load_config(guint ft_id, gboolean reload) load_settings(ft_id, config, config_home); highlighting_init_styles(ft_id, config, config_home); + if (ft->icon) + g_object_unref(ft->icon); + ft->icon = ui_get_mime_icon(ft->mime_type); + g_key_file_free(config); g_key_file_free(config_home); } diff --git a/src/filetypes.h b/src/filetypes.h index 2161f8b0..09faba22 100644 --- a/src/filetypes.h +++ b/src/filetypes.h @@ -140,7 +140,7 @@ struct GeanyFiletype gchar *error_regex_string; GeanyFiletype *lexer_filetype; gchar *mime_type; - GdkPixbuf *icon; + GIcon *icon; gchar *comment_single; /* single-line comment */ /* filetype indent settings, -1 if not set */ gint indent_type; diff --git a/src/main.c b/src/main.c index 0d952bc4..bf5cb831 100644 --- a/src/main.c +++ b/src/main.c @@ -1040,6 +1040,10 @@ gint main(gint argc, gchar **argv) gint config_dir_result; const gchar *locale; +#if ! GLIB_CHECK_VERSION(2, 36, 0) + g_type_init(); +#endif + log_handlers_init(); app = g_new0(GeanyApp, 1); diff --git a/src/sidebar.c b/src/sidebar.c index 46d1b01e..21533cb8 100644 --- a/src/sidebar.c +++ b/src/sidebar.c @@ -276,7 +276,7 @@ static void prepare_openfiles(void) /* store the icon and the short filename to show, and the index as reference, * the colour (black/red/green) and the full name for the tooltip */ - store_openfiles = gtk_tree_store_new(5, GDK_TYPE_PIXBUF, G_TYPE_STRING, + store_openfiles = gtk_tree_store_new(5, G_TYPE_ICON, G_TYPE_STRING, G_TYPE_POINTER, GDK_TYPE_COLOR, G_TYPE_STRING); gtk_tree_view_set_model(GTK_TREE_VIEW(tv.tree_openfiles), GTK_TREE_MODEL(store_openfiles)); @@ -287,11 +287,12 @@ static void prepare_openfiles(void) GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); icon_renderer = gtk_cell_renderer_pixbuf_new(); + g_object_set(icon_renderer, "stock-size", GTK_ICON_SIZE_MENU, NULL); text_renderer = gtk_cell_renderer_text_new(); g_object_set(text_renderer, "ellipsize", PANGO_ELLIPSIZE_MIDDLE, NULL); column = gtk_tree_view_column_new(); gtk_tree_view_column_pack_start(column, icon_renderer, FALSE); - gtk_tree_view_column_set_attributes(column, icon_renderer, "pixbuf", DOCUMENTS_ICON, NULL); + gtk_tree_view_column_set_attributes(column, icon_renderer, "gicon", DOCUMENTS_ICON, NULL); gtk_tree_view_column_pack_start(column, text_renderer, TRUE); gtk_tree_view_column_set_attributes(column, text_renderer, "text", DOCUMENTS_SHORTNAME, "foreground-gdk", DOCUMENTS_COLOR, NULL); @@ -413,7 +414,7 @@ static GtkTreeIter *get_doc_parent(GeanyDocument *doc) gchar *dirname = NULL; static GtkTreeIter parent; GtkTreeModel *model = GTK_TREE_MODEL(store_openfiles); - static GdkPixbuf *dir_icon = NULL; + static GIcon *dir_icon = NULL; if (!documents_show_paths) return NULL; @@ -436,7 +437,7 @@ static GtkTreeIter *get_doc_parent(GeanyDocument *doc) } /* no match, add dir parent */ if (!dir_icon) - dir_icon = ui_get_mime_icon("inode/directory", GTK_ICON_SIZE_MENU); + dir_icon = ui_get_mime_icon("inode/directory"); gtk_tree_store_append(store_openfiles, &parent, NULL); gtk_tree_store_set(store_openfiles, &parent, DOCUMENTS_ICON, dir_icon, @@ -457,7 +458,7 @@ void sidebar_openfiles_add(GeanyDocument *doc) GtkTreeIter *parent = get_doc_parent(doc); gchar *basename; const GdkColor *color = document_get_status_color(doc); - static GdkPixbuf *file_icon = NULL; + static GIcon *file_icon = NULL; gtk_tree_store_append(store_openfiles, iter, parent); @@ -472,7 +473,7 @@ void sidebar_openfiles_add(GeanyDocument *doc) gtk_tree_path_free(path); } if (!file_icon) - file_icon = ui_get_mime_icon("text/plain", GTK_ICON_SIZE_MENU); + file_icon = ui_get_mime_icon("text/plain"); basename = g_path_get_basename(DOC_FILENAME(doc)); gtk_tree_store_set(store_openfiles, iter, @@ -507,7 +508,7 @@ void sidebar_openfiles_update(GeanyDocument *doc) { /* just update color and the icon */ const GdkColor *color = document_get_status_color(doc); - GdkPixbuf *icon = doc->file_type->icon; + GIcon *icon = doc->file_type->icon; gtk_tree_store_set(store_openfiles, iter, DOCUMENTS_COLOR, color, -1); if (icon) diff --git a/src/ui_utils.c b/src/ui_utils.c index 7da41c6b..b358099b 100644 --- a/src/ui_utils.c +++ b/src/ui_utils.c @@ -2680,7 +2680,7 @@ void ui_menu_add_document_items_sorted(GtkMenu *menu, GeanyDocument *active, base_name = g_path_get_basename(DOC_FILENAME(doc)); menu_item = gtk_image_menu_item_new_with_label(base_name); - image = gtk_image_new_from_pixbuf(doc->file_type->icon); + image = gtk_image_new_from_gicon(doc->file_type->icon, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), image); gtk_widget_show(menu_item); @@ -2758,60 +2758,24 @@ void ui_editable_insert_text_callback(GtkEditable *editable, gchar *new_text, /* gets the icon that applies to a particular MIME type */ -GdkPixbuf *ui_get_mime_icon(const gchar *mime_type, GtkIconSize size) +GIcon *ui_get_mime_icon(const gchar *mime_type) { - GdkPixbuf *icon = NULL; + GIcon *icon = NULL; gchar *ctype; - GIcon *gicon; - GtkIconInfo *info; - GtkIconTheme *theme; - gint real_size; - if (!gtk_icon_size_lookup(size, &real_size, NULL)) - { - g_return_val_if_reached(NULL); - } ctype = g_content_type_from_mime_type(mime_type); - if (ctype != NULL) - { - gicon = g_content_type_get_icon(ctype); - theme = gtk_icon_theme_get_default(); - info = gtk_icon_theme_lookup_by_gicon(theme, gicon, real_size, 0); - g_object_unref(gicon); - g_free(ctype); + if (ctype) + icon = g_content_type_get_icon(ctype); - if (info != NULL) - { - icon = gtk_icon_info_load_icon(info, NULL); - gtk_icon_info_free(info); - } - } - - /* fallback for builds with GIO < 2.18 or if icon lookup failed, like it might happen on Windows */ - if (icon == NULL) + /* fallback if icon lookup failed, like it might happen on Windows (?) */ + if (! icon) { const gchar *stock_id = GTK_STOCK_FILE; - GtkIconSet *icon_set; if (strstr(mime_type, "directory")) stock_id = GTK_STOCK_DIRECTORY; - icon_set = gtk_icon_factory_lookup_default(stock_id); - if (icon_set) - { -#if GTK_CHECK_VERSION(3, 0, 0) - GtkStyleContext *ctx = gtk_style_context_new(); - GtkWidgetPath *path = gtk_widget_path_new(); - gtk_style_context_set_path(ctx, path); - gtk_widget_path_unref(path); - icon = gtk_icon_set_render_icon_pixbuf(icon_set, ctx, size); - g_object_unref(ctx); -#else - icon = gtk_icon_set_render_icon(icon_set, gtk_widget_get_default_style(), - gtk_widget_get_default_direction(), - GTK_STATE_NORMAL, size, NULL, NULL); -#endif - } + icon = g_themed_icon_new(stock_id); } return icon; } diff --git a/src/ui_utils.h b/src/ui_utils.h index a70dcbea..8dcffd5a 100644 --- a/src/ui_utils.h +++ b/src/ui_utils.h @@ -337,7 +337,7 @@ gboolean ui_is_keyval_enter_or_return(guint keyval); gint ui_get_gtk_settings_integer(const gchar *property_name, gint default_value); -GdkPixbuf *ui_get_mime_icon(const gchar *mime_type, GtkIconSize size); +GIcon *ui_get_mime_icon(const gchar *mime_type); void ui_focus_current_document(void);