[gnome-chess] Use a GtkHeaderBar



commit 21eb3a7dc434da82cd0795f7308b0b13726ebb23
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sun Jan 5 20:59:26 2014 -0600

    Use a GtkHeaderBar

 data/gnome-chess.ui  |   11 +++++++++--
 src/gnome-chess.vala |   32 +++++++++++++++++++++++++++-----
 2 files changed, 36 insertions(+), 7 deletions(-)
---
diff --git a/data/gnome-chess.ui b/data/gnome-chess.ui
index 574e806..2349027 100644
--- a/data/gnome-chess.ui
+++ b/data/gnome-chess.ui
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <!-- interface-requires gtk+ 3.0 -->
+  <!-- interface-requires gtk+ 3.10 -->
   <object class="GtkListStore" id="history_model">
     <columns>
       <!-- column-name label -->
@@ -11,11 +11,18 @@
   </object>
   <object class="GtkApplicationWindow" id="gnome_chess_app">
     <property name="can_focus">False</property>
-    <property name="title">Chess</property>
     <property name="default_width">700</property>
     <signal name="configure-event" handler="gnome_chess_app_configure_event_cb" swapped="no"/>
     <signal name="delete-event" handler="gnome_chess_app_delete_event_cb" swapped="no"/>
     <signal name="window-state-event" handler="gnome_chess_app_window_state_event_cb" swapped="no"/>
+    <child type="titlebar">
+      <object class="GtkHeaderBar" id="headerbar">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="show_close_button">True</property>
+        <property name="title" translatable="yes">Chess</property>
+      </object>
+    </child>
     <child>
       <object class="GtkBox" id="main_vbox">
         <property name="visible">True</property>
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index ce5d176..0527965 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -36,6 +36,7 @@ public class Application : Gtk.Application
     private Gtk.ComboBox history_combo;
     private Gtk.Widget white_time_label;
     private Gtk.Widget black_time_label;
+    private Gtk.HeaderBar headerbar;
 
     private Gtk.Dialog? preferences_dialog = null;
     private Gtk.ComboBox side_combo;
@@ -87,6 +88,27 @@ public class Application : Gtk.Application
         { "quit", quit_cb },
     };
 
+    private const string NEW_GAME_ACTION_NAME = "new";
+    private const string OPEN_GAME_ACTION_NAME = "open";
+    private const string SAVE_GAME_ACTION_NAME = "save";
+    private const string SAVE_GAME_AS_ACTION_NAME = "save-as";
+    private const string UNDO_MOVE_ACTION_NAME = "undo";
+    private const string CLAIM_DRAW_ACTION_NAME = "claim-draw";
+    private const string RESIGN_ACTION_NAME = "resign";
+    private const string PAUSE_RESUME_ACTION_NAME = "pause-resume";
+
+    private const ActionEntry[] window_entries =
+    {
+        { NEW_GAME_ACTION_NAME, new_game_cb },
+        { OPEN_GAME_ACTION_NAME, open_game_cb },
+        { SAVE_GAME_ACTION_NAME, save_game_cb },
+        { SAVE_GAME_AS_ACTION_NAME, save_game_as_cb },
+        { UNDO_MOVE_ACTION_NAME, undo_move_cb },
+        { CLAIM_DRAW_ACTION_NAME, claim_draw_cb },
+        { RESIGN_ACTION_NAME, resign_cb },
+        { PAUSE_RESUME_ACTION_NAME, pause_resume_cb },
+    };
+
     public Application (File? game_file)
     {
         Object (application_id: "org.gnome.gnome-chess", flags: ApplicationFlags.FLAGS_NONE);
@@ -158,11 +180,13 @@ public class Application : Gtk.Application
         black_time_label = (Gtk.Widget) builder.get_object ("black_time_label");
         var view_box = (Gtk.Box) builder.get_object ("view_box");
         view_container = (Gtk.Container) builder.get_object ("view_container");
+        headerbar = (Gtk.HeaderBar) builder.get_object ("headerbar");
         builder.connect_signals (this);
 
         add_window (window);
         window.focus_out_event.connect (on_window_focus_out);
         window.focus_in_event.connect (on_window_focus_in);
+        window.icon_name = "gnome-chess";
 
         info_bar = new Gtk.InfoBar ();
         var content_area = (Gtk.Container) info_bar.get_content_area ();
@@ -437,15 +461,13 @@ public class Application : Gtk.Application
     {
         if (in_history || game_file == null)
         {
-            window.title = /* Title of the main window */
-                           _("Chess");
+            /* Title of the main window */
+            headerbar.set_title (_("Chess"));
         }
         else
         {
             var path = game_file.get_path ();
-            window.title = /* Title of the window when explicitly loaded a file. The argument is the
-                            * base name of the file (e.g. test.pgn) */
-                           _("Chess - %1$s").printf (Path.get_basename (path));
+            headerbar.set_title (Path.get_basename (path));
         }
 
         var model = (Gtk.ListStore) history_combo.model;


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