[gnome-latex: 11/205] new file



commit 7b6cfd22a718f092af2efdc1ddad50f77f13391b
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date:   Mon Aug 3 15:30:13 2009 +0200

    new file

 TODO            |  2 +-
 src/callbacks.c | 10 ++++++++++
 src/callbacks.h |  1 +
 src/main.c      |  2 +-
 4 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/TODO b/TODO
index 299dd21..41b25ad 100644
--- a/TODO
+++ b/TODO
@@ -8,8 +8,8 @@ Jul 31, 2009 to Aug 7, 2009
        x open
        x save 
        x save as
+       x new
        - close
-       - new
        - tabs
 
 [-] GtkSourceView
diff --git a/src/callbacks.c b/src/callbacks.c
index e9a8807..7dacc06 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -12,6 +12,16 @@ static void open_file (const gchar *file_name, GtkTextView *text_view);
 static void save_as_dialog (widgets_t *widgets);
 static void file_save (void);
 
+void
+cb_new (GtkAction *action, widgets_t *widgets)
+{
+       docs.active->path = NULL;
+       docs.active->saved = TRUE;
+
+       GtkTextBuffer *text_buffer = gtk_text_view_get_buffer (docs.active->text_view);
+       gtk_text_buffer_set_text (text_buffer, "", -1);
+}
+
 void
 cb_open (GtkAction *action, widgets_t *widgets)
 {
diff --git a/src/callbacks.h b/src/callbacks.h
index f116ef3..3e4dc91 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -1,6 +1,7 @@
 #ifndef CALLBACKS_H
 #define CALLBACKS_H
 
+void cb_new (GtkAction *action, widgets_t *widgets);
 void cb_open (GtkAction *action, widgets_t *widgets);
 void cb_save (GtkAction *action, widgets_t *widgets);
 void cb_save_as (GtkAction *action, widgets_t *widgets);
diff --git a/src/main.c b/src/main.c
index 16a8fbb..676bc6d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -44,7 +44,7 @@ main (int argc, char *argv[])
        {
                {"File", NULL, _("File"), NULL, NULL, NULL},
                {"FileNew", GTK_STOCK_NEW, _("New"), "<Control>N",
-                       _("New file"), NULL},
+                       _("New file"), G_CALLBACK (cb_new)},
                {"FileOpen", GTK_STOCK_OPEN, _("Open..."), "<Control>O",
                        _("Open a file"), G_CALLBACK (cb_open)},
                {"FileSave", GTK_STOCK_SAVE, _("Save..."), "<Control>S",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]