| | 42 | |
| | 43 | |
| | 44 | #ifdef WITH_GTKSOURCEVIEW |
| | 45 | // Set source language by file extension |
| | 46 | Glib::ustring title = doc.get_title(); |
| | 47 | Glib::ustring::size_type pos = title.rfind('.'); |
| | 48 | if(pos != Glib::ustring::npos) |
| | 49 | { |
| | 50 | Glib::ustring extension = title.substr(pos + 1); |
| | 51 | MimeMap::const_iterator iter = m_mime_map.find(extension); |
| | 52 | if(iter != m_mime_map.end() ) |
| | 53 | { |
| | 54 | Glib::ustring mime = iter->second; |
| | 55 | Glib::RefPtr<Gtk::SourceLanguage> language = |
| | 56 | m_lang_manager->get_language_from_mime_type( |
| | 57 | mime |
| | 58 | ); |
| | 59 | if(language) |
| | 60 | { |
| | 61 | buf->set_language(language); |
| | 62 | } |
| | 63 | else |
| | 64 | { |
| | 65 | g_warning("Could not find syntax file for file " |
| | 66 | "extension %s (mime-type %s)", |
| | 67 | extension.c_str(), mime.c_str() ); |
| | 68 | } |
| | 69 | } |
| | 70 | else |
| | 71 | { |
| | 72 | g_warning("Could not detect file type of file " |
| | 73 | "extension '%s'", extension.c_str() ); |
| | 74 | } |
| | 75 | } |
| | 76 | |
| | 77 | buf->set_highlight(true); |
| | 78 | #endif |
| | 148 | #ifdef WITH_GTKSOURCEVIEW |
| | 149 | const Gobby::Document::MimeMap& Gobby::Document::create_mime_map() |
| | 150 | { |
| | 151 | static MimeMap map; |
| | 152 | |
| | 153 | // Translates file extension to mime type |
| | 154 | map["ada"] = "text/x-ada"; |
| | 155 | map["c"] = "text/x-c"; |
| | 156 | map["h"] = "text/x-c++"; |
| | 157 | map["hh"] = "text/c-c++"; |
| | 158 | map["cpp"] = "text/x-c++"; |
| | 159 | map["hpp"] = "text/x-c++"; |
| | 160 | map["cc"] = "text/x-c++"; |
| | 161 | map["css"] = "text/css"; |
| | 162 | map["diff"] = "text/x-diff"; |
| | 163 | map["f"] = "text/x-fortran"; |
| | 164 | map["f77"] = "text/x-fortran"; |
| | 165 | // Wi geth haskell? |
| | 166 | map["htm"] = "text/html"; |
| | 167 | map["html"] = "text/html"; |
| | 168 | map["xhtml"] = "text/html"; |
| | 169 | // Wi geth IDL? |
| | 170 | map["java"] = "text/x-java"; |
| | 171 | map["js"] = "text/x-javascript"; |
| | 172 | map["tex"] = "text/x-tex"; |
| | 173 | map["latex"] = "text/x-tex"; |
| | 174 | map["lua"] = "text/x-lua"; |
| | 175 | // Wi geth MSIL? |
| | 176 | map["dpr"] = "text/x-pascal"; |
| | 177 | // TODO: Pascal hat noch mehr Krams, oder? |
| | 178 | map["pl"] = "text/x-perl"; |
| | 179 | map["pm"] = "text/x-perl"; |
| | 180 | map["php"] = "text/x-php"; |
| | 181 | map["php3"] = "text/x-php"; |
| | 182 | map["php4"] = "text/x-php"; |
| | 183 | map["php5"] = "text/x-php"; |
| | 184 | map["po"] = "text/x-gettext-translation"; |
| | 185 | map["py"] = "text/x-python"; |
| | 186 | map["rb"] = "text/x-ruby"; |
| | 187 | map["sql"] = "text/x-sql"; |
| | 188 | // Wi geth texinfo? |
| | 189 | // Wi geth vb.NET? |
| | 190 | // Wi geth verilog? |
| | 191 | map["xml"] = "text/xml"; |
| | 192 | |
| | 193 | return map; |
| | 194 | } |
| | 195 | #endif |