[Xfce4-commits] [apps/mousepad] 01/01: Infer filetype from shebang line (Bug #10514)
noreply at xfce.org
noreply at xfce.org
Thu Mar 26 00:24:06 CET 2020
This is an automated email from the git hooks/post-receive script.
a n d r e p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/mousepad.
commit f41614cc3ecd1032de632d21a89024ccafae209b
Author: Andre Miranda <andreldm at xfce.org>
Date: Wed Mar 25 20:22:53 2020 -0300
Infer filetype from shebang line (Bug #10514)
Credits to: James M Campbell
Based on gEdit code
---
mousepad/mousepad-file.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/mousepad/mousepad-file.c b/mousepad/mousepad-file.c
index 453d48a..795d561 100644
--- a/mousepad/mousepad-file.c
+++ b/mousepad/mousepad-file.c
@@ -462,15 +462,24 @@ mousepad_file_guess_language (MousepadFile *file)
gchar *basename;
gboolean result_uncertain;
GtkSourceLanguage *language;
+ gchar *data;
+ GtkTextIter start;
+ GtkTextIter end;
g_return_val_if_fail ((file->filename != NULL), NULL);
- content_type = g_content_type_guess (file->filename, NULL, 0, &result_uncertain);
+ gtk_text_buffer_get_start_iter (file->buffer, &start);
+ end = start;
+ gtk_text_iter_forward_chars (&end, 255);
+ data = gtk_text_buffer_get_text (file->buffer, &start, &end, TRUE);
+
+ content_type = g_content_type_guess (file->filename, (const guchar *)data, strlen (data), &result_uncertain);
basename = g_path_get_basename (file->filename);
language = gtk_source_language_manager_guess_language (gtk_source_language_manager_get_default (),
basename,
result_uncertain ? NULL : content_type);
+ g_free (data);
g_free (basename);
g_free (content_type);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list