antiright-devel
[Top][All Lists]
Advanced

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

[Antiright-devel] antiright/gtkshell add_options.c text.c


From: Jeffrey Bedard
Subject: [Antiright-devel] antiright/gtkshell add_options.c text.c
Date: Mon, 13 Aug 2007 08:24:29 +0000

CVSROOT:        /sources/antiright
Module name:    antiright
Changes by:     Jeffrey Bedard <jefbed> 07/08/13 08:24:29

Modified files:
        gtkshell       : add_options.c text.c 

Log message:
        Set GSH_IN_SECONDARY_WIN when new window created.
        Split file save procedure for case where filename already set.
        Check for empty filename on open, restore old filename in this case.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/add_options.c?cvsroot=antiright&r1=1.45&r2=1.46
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/text.c?cvsroot=antiright&r1=1.35&r2=1.36

Patches:
Index: add_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/add_options.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -b -r1.45 -r1.46
--- add_options.c       25 Jul 2007 04:42:39 -0000      1.45
+++ add_options.c       13 Aug 2007 08:24:28 -0000      1.46
@@ -55,6 +55,7 @@
        $(gsh, add.window);
        gsh->rows->current=1;
        $(gsh, init);
+       GSH_SET(GSH_IN_SECONDARY_WIN);
 }
 
 static void

Index: text.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/text.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- text.c      11 Jun 2007 21:32:44 -0000      1.35
+++ text.c      13 Aug 2007 08:24:28 -0000      1.36
@@ -174,37 +174,47 @@
        return gtk_text_buffer_get_text(buffer, &start, &end, TRUE);
 }
 
-void
-gsh_editor_save(struct GSH * gsh)
+static void
+save_to_opened_file(GSH * gsh)
 {
-       TEST_EDITOR_EXISTS(gsh);
-       /* Choose action based on whether or not file has been chosen.*/
-       if(gsh->editor.filename)
-       {
                gchar * text;
 
                text=get_text(gsh->editor.widget);
                AR_TEXT_TO_FILE(gsh->editor.filename, text);
                g_free(text);
-       }
+}
+
+void
+gsh_editor_save(struct GSH * gsh)
+{
+       TEST_EDITOR_EXISTS(gsh);
+       /* Choose action based on whether or not file has been chosen.*/
+       if(gsh->editor.filename)
+               save_to_opened_file(gsh);
        else
                gsh_editor_save_as(gsh);
 }
 
 #define PROMPT_FILENAME() antiright_pipe_read("gtkshell -df")
+#define FILENAME_NOT_EMPTY strcmp(gsh->editor.filename, "")
 
 static void
 get_filename(struct GSH * gsh)
 {
+       gchar * tmp_filename;
+
        /* Make sure that FILENAME is freed if previously used.  */
        if(gsh->editor.filename)
                g_free(gsh->editor.filename);
        /* Get the filename.  */
+       tmp_filename=gsh->editor.filename;
        gsh->editor.filename=PROMPT_FILENAME();
+       /* Restore filename if empty, in case of open file, so that
+          file will not have to be reopened/reselected on save.  */
+       if(!FILENAME_NOT_EMPTY)
+               gsh->editor.filename=tmp_filename;
 }
 
-#define FILENAME_NOT_EMPTY strcmp(gsh->editor.filename, "")
-
 void
 gsh_editor_save_as(struct GSH * gsh)
 {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]