Merge branch 'wip/configurable-mime-type--gicon' into wip/configurable-mime-type-gicon

This commit is contained in:
Colomban Wendling 2014-04-14 20:21:40 +02:00
commit 3ec0369f47
54 changed files with 238 additions and 136 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -6,4 +6,6 @@
# default extension used when saving files
extension=abc
# MIME type
mime_type=text/vnd.abc

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
`````````````````````

View File

@ -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);

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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)

View File

@ -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;
}

View File

@ -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);