[gnome-chess] Better handle case where window subtitle is the filename



commit e6f28affd770f40986dc554b05ab3864c04cf1e0
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sat Dec 5 12:43:07 2020 -0600

    Better handle case where window subtitle is the filename
    
    This never looks good in narrow mode, so if we are in narrow mode, never
    set the window subtitle.
    
    But if we start in normal mode, then the user switches to narrow mode,
    it looks weird for the subtitle to disappear and not come back. So let's
    maintain it as the window subtitle. It should definitely not move to the
    info bar, like other subtitles, since that looks weird.

 src/gnome-chess.vala | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index d53faf9..ea985cf 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -68,6 +68,7 @@ public class ChessApplication : Gtk.Application
     private string autosave_filename;
     private File game_file;
     private bool game_needs_saving = false;
+    private bool subtitle_is_filename = false;
     private bool starting = true;
     private List<AIProfile> ai_profiles;
     private ChessPlayer? opponent = null;
@@ -284,7 +285,7 @@ Copyright © 2015–2016 Sahil Sareen""";
         }
         else
         {
-            if (headerbar.subtitle != null)
+            if (headerbar.subtitle != null && !subtitle_is_filename)
                 info_bar_label.label = "%s\n%s".printf (headerbar.title, headerbar.subtitle);
             else
                 info_bar_label.label = headerbar.title;
@@ -292,7 +293,9 @@ Copyright © 2015–2016 Sahil Sareen""";
             info_bar.visible = true;
 
             headerbar.title = _("Chess");
-            headerbar.subtitle = null;
+
+            if (!subtitle_is_filename)
+                headerbar.subtitle = null;
 
             navigation_box.set_orientation (Orientation.VERTICAL);
         }
@@ -505,10 +508,16 @@ Copyright © 2015–2016 Sahil Sareen""";
     {
         starting = true;
 
-        if (game_file != null && game_file.get_path () != autosave_filename)
+        if (game_file != null && game_file.get_path () != autosave_filename && layout_mode == 
LayoutMode.NORMAL)
+        {
             headerbar.set_subtitle (game_file.get_basename ());
+            subtitle_is_filename = true;
+        }
         else
+        {
             headerbar.set_subtitle (null);
+            subtitle_is_filename = false;
+        }
 
         var model = (Gtk.ListStore) history_combo.model;
         model.clear ();
@@ -1348,7 +1357,12 @@ Copyright © 2015–2016 Sahil Sareen""";
         if (layout_mode == LayoutMode.NORMAL)
         {
             headerbar.set_title (label != null ? label : compute_game_status ());
-            headerbar.set_subtitle (sublabel);
+
+            if (sublabel != null)
+            {
+                headerbar.set_subtitle (sublabel);
+                subtitle_is_filename = false;
+            }
             return;
         }
         else
@@ -2409,9 +2423,15 @@ Copyright © 2015–2016 Sahil Sareen""";
                 save_dialog = null;
 
                 pgn_game.write (game_file);
-                headerbar.set_subtitle (game_file.get_basename ());
+
                 disable_window_action (SAVE_GAME_ACTION_NAME);
                 game_needs_saving = false;
+
+                if (layout_mode == LayoutMode.NORMAL)
+                {
+                    headerbar.set_subtitle (game_file.get_basename ());
+                    subtitle_is_filename = true;
+                }
             }
             catch (Error e)
             {


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