[gnome-chess/gnome-3-8] Set a default filename for the save game dialog



commit a6bd7fb247caeb7f7b3c15de9c938ca3aa9b3d48
Author: Michael Catanzaro <mike catanzaro gmail com>
Date:   Sat Jun 8 19:34:27 2013 -0500

    Set a default filename for the save game dialog
    
    This means people will save with the .pgn extension by default, yay.
    (cherry picked from commit ec1c258747e4c8e3aeed48a18e564c7caf83ced8)

 src/gnome-chess.vala |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 15b0bf7..e7b5fdb 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -49,6 +49,7 @@ public class Application : Gtk.Application
     private bool in_history;
     private File game_file;
     private bool game_needs_saving;
+    private string? saved_filename = null;
     private List<AIProfile> ai_profiles;
     private ChessPlayer? opponent = null;
     private ChessPlayer? human_player = null;
@@ -1605,6 +1606,12 @@ public class Application : Gtk.Application
         save_dialog.file_activated.connect (save_file_cb);        
         save_dialog.response.connect (save_cb);
 
+        if (saved_filename != null)
+            save_dialog.set_filename (saved_filename);
+        else
+            save_dialog.set_current_name (/* Default filename for the save game dialog */
+                                          _("Untitled Chess Game") + ".pgn");
+
         /* Filter out non PGN files by default */
         var pgn_filter = new Gtk.FileFilter ();
         gtk_file_filter_set_name (pgn_filter,
@@ -1652,6 +1659,7 @@ public class Application : Gtk.Application
             try
             {
                 pgn_game.write (save_dialog.get_file ());
+                saved_filename = save_dialog.get_filename ();
             }
             catch (Error e)
             {
@@ -1719,6 +1727,7 @@ public class Application : Gtk.Application
             {
                 in_history = false;
                 load_game (open_dialog.get_file ());
+                saved_filename = open_dialog.get_filename ();
             }
             catch (Error e)
             {


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