Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=grape.git;a=commitdiff;h=950b66d4f6909dd3c8040cd3c577b53dd8cdce0b

commit 950b66d4f6909dd3c8040cd3c577b53dd8cdce0b
Author: James Buren <r...@frugalware.org>
Date:   Sun Apr 4 08:44:31 2010 -0500

exports.h/load_action.c/update_syntax.c
* update syntax upon loading

diff --git a/src/exports.h b/src/exports.h
index 921cc39..0ea2876 100644
--- a/src/exports.h
+++ b/src/exports.h
@@ -43,6 +43,7 @@ GtkWidget *statusbar_new(SharedInfo *info);
SharedInfo *window_new(const gchar *filename);
gchar *get_filename(GtkWindow *window,gboolean open);
gchar *build_filename(const gchar *filename);
+void update_syntax(SharedInfo *info);
void update_action(SharedInfo *info,const gchar *stock,const gchar *format,...);
void display_error(SharedInfo *info,const gchar *format,...);
void box_pack_widgets(GtkWidget *box,gboolean expand,...);
diff --git a/src/load_action.c b/src/load_action.c
index 9284f89..f4b2c00 100644
--- a/src/load_action.c
+++ b/src/load_action.c
@@ -40,6 +40,8 @@ gboolean load_action(GtkWidget *widget,GdkEvent 
*event,SharedInfo *info) {

g_free(contents);

+  update_syntax(info);
+
update_action(info,GTK_STOCK_OPEN,"Opened file %s",info->filename);

return FALSE;
diff --git a/src/update_syntax.c b/src/update_syntax.c
new file mode 100644
index 0000000..6b6c746
--- /dev/null
+++ b/src/update_syntax.c
@@ -0,0 +1,44 @@
+// Copyright (c) 2010 James Buren
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to 
deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include <gtksourceview/gtksourcelanguagemanager.h>
+#include "exports.h"
+
+void update_syntax(SharedInfo *info) {
+  GtkSourceLanguageManager *manager;
+  gchar *content;
+  gboolean uncertain;
+  GtkSourceLanguage *language;
+
+  manager = gtk_source_language_manager_get_default();
+
+  content = g_content_type_guess(info->filename,NULL,0,&uncertain);
+
+  if(uncertain) {
+    g_free(content);
+    content = NULL;
+  }
+
+  language = 
gtk_source_language_manager_guess_language(manager,info->filename,content);
+
+  gtk_source_buffer_set_language(info->buffer,language);
+
+  g_free(content);
+}
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to