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

commit e6997a63a010fb589e88761e2e5435b4e029ca01
Author: James Buren <r...@frugalware.org>
Date:   Sun Apr 4 09:40:36 2010 -0500

save_action.c
* add action for saving files

diff --git a/src/save_action.c b/src/save_action.c
index de75dd5..b0bbbb3 100644
--- a/src/save_action.c
+++ b/src/save_action.c
@@ -20,5 +20,38 @@

#include "exports.h"

-void save_action(GtkToolButton *btn,SharedInfo *info) {
+void save_action(GtkToolButton *button,SharedInfo *info) {
+  gchar *filename;
+  GtkTextIter begin, end;
+  gchar *contents;
+  GError *error = NULL;
+
+  filename = (info->filename) ? g_strdup(info->filename) : 
get_filename(info->parent,FALSE);
+
+  if(!filename)
+    return;
+
+  gtk_text_buffer_get_start_iter(GTK_TEXT_BUFFER(info->buffer),&begin);
+
+  gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(info->buffer),&end);
+
+  contents = 
gtk_text_buffer_get_text(GTK_TEXT_BUFFER(info->buffer),&begin,&end,TRUE);
+
+  if(!g_file_set_contents(filename,contents,-1,&error)) {
+    display_error(info,error->message);
+    g_error_free(error);
+    g_free(filename);
+    g_free(contents);
+    return;
+  }
+
+  update_action(info,GTK_STOCK_SAVE,"Saved file %s",filename);
+
+  g_free(contents);
+
+  g_free(info->filename);
+
+  info->filename = filename;
+
+  update_syntax(info);
}
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to