[gnome-chess] Remove the menubar, add an app menu, and expand the toolbar
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess] Remove the menubar, add an app menu, and expand the toolbar
- Date: Sat, 6 Jul 2013 19:57:58 +0000 (UTC)
commit 039bfe06e56fb8a85ba807355c14dd10bd4f88da
Author: Michael Catanzaro <mike catanzaro gmail com>
Date: Sat Jul 6 13:53:39 2013 -0500
Remove the menubar, add an app menu, and expand the toolbar
Not necessarily the final design. All the other games have New Game in
the app menu. But I hesitate to put it there without Open and Save.
These are all very much window-specific options anyway.
Maybe it's OK to have window-specific options there, if the app is
single instance. I'm not sure anyone really knows.
And maybe we want Chess to allow multiple instances again. So not
necessarily the final design.
data/Makefile.am | 3 +-
data/gnome-chess.ui | 347 ++++++++++++++------------------------------------
data/menu.ui | 28 ++++
po/POTFILES.in | 1 +
src/gnome-chess.vala | 104 +++++++++-------
5 files changed, 185 insertions(+), 298 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index e663783..87d275c 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -9,7 +9,8 @@ uidir = $(datadir)/gnome-chess
ui_DATA = \
gnome-chess.ui \
preferences.ui \
- promotion-type-selector.ui
+ promotion-type-selector.ui \
+ menu.ui
gsettings_SCHEMAS = org.gnome.gnome-chess.gschema.xml
@INTLTOOL_XML_NOMERGE_RULE@
diff --git a/data/gnome-chess.ui b/data/gnome-chess.ui
index 2f1bcb4..b618bbc 100644
--- a/data/gnome-chess.ui
+++ b/data/gnome-chess.ui
@@ -1,15 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <requires lib="gtk+" version="2.16"/>
- <!-- interface-naming-policy toplevel-contextual -->
- <object class="GtkAccelGroup" id="accelgroup"/>
- <object class="GtkWindow" id="gnome_chess_app">
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkListStore" id="history_model">
+ <columns>
+ <!-- column-name label -->
+ <column type="gchararray"/>
+ <!-- column-name move-number -->
+ <column type="gint"/>
+ </columns>
+ </object>
+ <object class="GtkApplicationWindow" id="gnome_chess_app">
<property name="can_focus">False</property>
<property name="title">Chess</property>
- <property name="default_width">400</property>
- <accel-groups>
- <group name="accelgroup"/>
- </accel-groups>
+ <property name="default_width">700</property>
<signal name="window-state-event" handler="gnome_chess_app_window_state_event_cb" swapped="no"/>
<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"/>
@@ -18,239 +21,61 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkMenuBar" id="menubar">
+ <object class="GtkToolbar" id="toolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <style>
+ <class name="primary-toolbar"/>
+ </style>
<child>
- <object class="GtkMenuItem" id="game_menu_item">
+ <object class="GtkToolButton" id="new_game_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="label" translatable="yes" comments="Game menu name">_Game</property>
+ <property name="tooltip_text" translatable="yes" comments="Tooltip for start new game
toolbar button">Start a new game</property>
+ <property name="label" translatable="yes" comments="The New Game toolbar
button">New</property>
<property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu" id="game_menu">
- <property name="can_focus">False</property>
- <child>
- <object class="GtkImageMenuItem" id="new_menu_item">
- <property name="label">gtk-new</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <property name="accel_group">accelgroup</property>
- <signal name="activate" handler="new_game_cb" swapped="no"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="open_menu_item">
- <property name="label">gtk-open</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <property name="accel_group">accelgroup</property>
- <signal name="activate" handler="open_game_cb" swapped="no"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="menu_save_item">
- <property name="label">gtk-save</property>
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <property name="accel_group">accelgroup</property>
- <signal name="activate" handler="save_game_cb" swapped="no"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="menu_save_as_item">
- <property name="label">gtk-save-as</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <property name="accel_group">accelgroup</property>
- <signal name="activate" handler="save_game_as_cb" swapped="no"/>
- </object>
- </child>
- <child>
- <object class="GtkSeparatorMenuItem" id="separator1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="undo_move_item">
- <property name="label" translatable="yes" comments="Undo move menu item">_Undo
Move</property>
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="image">undo_move_image</property>
- <property name="use_stock">False</property>
- <property name="accel_group">accelgroup</property>
- <accelerator key="Z" signal="activate" modifiers="GDK_CONTROL_MASK"/>
- <signal name="activate" handler="undo_move_cb" swapped="no"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="resign_item">
- <property name="label" translatable="yes" comments="Save menu
item">_Resign</property>
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="image">warning_image</property>
- <property name="use_stock">False</property>
- <property name="accel_group">accelgroup</property>
- <signal name="activate" handler="resign_cb" swapped="no"/>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem" id="claim_draw_item">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="label" translatable="yes" comments="Claim draw menu item">Claim
_Draw</property>
- <property name="use_underline">True</property>
- <signal name="activate" handler="claim_draw_cb" swapped="no"/>
- </object>
- </child>
- <child>
- <object class="GtkSeparatorMenuItem" id="separatormenuitem1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="quit_item">
- <property name="label">gtk-quit</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <property name="accel_group">accelgroup</property>
- <signal name="activate" handler="quit_cb" swapped="no"/>
- </object>
- </child>
- </object>
- </child>
+ <property name="stock_id">gtk-new</property>
+ <signal name="clicked" handler="new_game_cb" swapped="no"/>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
</child>
<child>
- <object class="GtkMenuItem" id="settings_menu_item">
+ <object class="GtkToolButton" id="open_game_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="label" translatable="yes" comments="Settings menu item">_Settings</property>
+ <property name="tooltip_text" translatable="yes">Open a saved game</property>
+ <property name="label" translatable="yes">Open</property>
<property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu" id="settings_menu">
- <property name="can_focus">False</property>
- <child>
- <object class="GtkImageMenuItem" id="fullscreen_item">
- <property name="label">gtk-fullscreen</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <property name="accel_group">accelgroup</property>
- <accelerator key="F11" signal="activate"/>
- <signal name="activate" handler="toggle_fullscreen_cb" swapped="no"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="preferences_item">
- <property name="label">gtk-preferences</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <property name="accel_group">accelgroup</property>
- <signal name="activate" handler="preferences_cb" swapped="no"/>
- </object>
- </child>
- </object>
- </child>
+ <property name="stock_id">gtk-open</property>
+ <signal name="clicked" handler="open_game_cb" swapped="no"/>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
</child>
<child>
- <object class="GtkMenuItem" id="help_menu_item">
+ <object class="GtkToolButton" id="save_game_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="label" translatable="yes" comments="Help menu item">_Help</property>
+ <property name="tooltip_text" translatable="yes">Save the current game</property>
+ <property name="label" translatable="yes">Save</property>
<property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu" id="help_menu">
- <property name="can_focus">False</property>
- <child>
- <object class="GtkImageMenuItem" id="help_item">
- <property name="label" translatable="yes" comments="Help contents menu
item">_Contents</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="image">help_image</property>
- <property name="use_stock">False</property>
- <property name="accel_group">accelgroup</property>
- <accelerator key="F1" signal="activate"/>
- <signal name="activate" handler="help_cb" swapped="no"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="about_item">
- <property name="label">gtk-about</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <property name="accel_group">accelgroup</property>
- <signal name="activate" handler="about_cb" swapped="no"/>
- </object>
- </child>
- </object>
- </child>
+ <property name="stock_id">gtk-save</property>
+ <signal name="clicked" handler="save_game_cb" swapped="no"/>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
</child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolbar" id="toolbar">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <style>
- <class name="primary-toolbar"/>
- </style>
<child>
- <object class="GtkToolButton" id="new_game_button">
+ <object class="GtkSeparatorToolItem" id="sep1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="tooltip_text" translatable="yes" comments="Tooltip for start new game
toolbar button">Start a new game</property>
- <property name="use_action_appearance">False</property>
- <property name="is_important">True</property>
- <property name="label" translatable="yes" comments="The New Game toolbar button">New
Game</property>
- <property name="use_underline">True</property>
- <property name="stock_id">gtk-new</property>
- <signal name="clicked" handler="new_game_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@@ -262,7 +87,7 @@
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
+ <property name="tooltip_text" translatable="yes">Undo your most recent move</property>
<property name="is_important">True</property>
<property name="label" translatable="yes" comments="The undo move toolbar button">Undo
Move</property>
<property name="use_underline">True</property>
@@ -275,15 +100,39 @@
</packing>
</child>
<child>
+ <object class="GtkSeparatorToolItem" id="sep2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="claim_draw_button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="is_important">True</property>
+ <property name="label" translatable="yes">Claim Draw</property>
+ <property name="use_underline">True</property>
+ <property name="icon_name">face-plain</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkToolButton" id="resign_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
+ <property name="tooltip_text" translatable="yes">Resign</property>
<property name="is_important">True</property>
<property name="label" translatable="yes" comments="The tooltip for the Resign toolbar
button">Resign</property>
<property name="use_underline">True</property>
- <property name="stock_id">gtk-dialog-warning</property>
+ <property name="icon_name">face-sad</property>
<signal name="clicked" handler="resign_cb" swapped="no"/>
</object>
<packing>
@@ -291,6 +140,31 @@
<property name="homogeneous">True</property>
</packing>
</child>
+ <child>
+ <object class="GtkSeparatorToolItem" id="sep3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="fullscreen_button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Fullscreen</property>
+ <property name="label" translatable="yes">Fullscreen</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-fullscreen</property>
+ <signal name="clicked" handler="toggle_fullscreen_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -320,7 +194,6 @@
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes" comments="Tooltip on the show first
move (i.e. game start) navigation button">Rewind to the game start</property>
- <property name="use_action_appearance">False</property>
<signal name="clicked" handler="history_start_clicked_cb" swapped="no"/>
<child>
<object class="GtkImage" id="first_move_image">
@@ -344,7 +217,6 @@
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes" comments="Tooltip on the show
previous move navigation button">Show the previous move</property>
- <property name="use_action_appearance">False</property>
<signal name="clicked" handler="history_previous_clicked_cb" swapped="no"/>
<child>
<object class="GtkImage" id="prev_move_image">
@@ -367,7 +239,6 @@
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes" comments="Tooltip on the show next
move navigation button">Show the next move</property>
- <property name="use_action_appearance">False</property>
<signal name="clicked" handler="history_next_clicked_cb" swapped="no"/>
<child>
<object class="GtkImage" id="next_move_image">
@@ -390,7 +261,6 @@
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes" comments="Tooltip on the show
current move navigation button">Show the current move</property>
- <property name="use_action_appearance">False</property>
<signal name="clicked" handler="history_latest_clicked_cb" swapped="no"/>
<child>
<object class="GtkImage" id="last_move_image">
@@ -503,36 +373,11 @@
</object>
</child>
</object>
- <object class="GtkImage" id="help_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-help</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkListStore" id="history_model">
- <columns>
- <!-- column-name label -->
- <column type="gchararray"/>
- <!-- column-name move-number -->
- <column type="gint"/>
- </columns>
- </object>
- <object class="GtkImage" id="undo_move_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-undo</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkImage" id="warning_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-dialog-warning</property>
- <property name="icon-size">1</property>
- </object>
<object class="GtkSizeGroup" id="nav_bar_sizegroup">
<widgets>
<widget name="right_nav_box"/>
<widget name="left_nav_box"/>
+ <widget name="toolbar"/>
</widgets>
</object>
</interface>
diff --git a/data/menu.ui b/data/menu.ui
new file mode 100644
index 0000000..4bc1f5b
--- /dev/null
+++ b/data/menu.ui
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <menu id="appmenu">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Preferences</attribute>
+ <attribute name="action">app.preferences</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Help</attribute>
+ <attribute name="action">app.help</attribute>
+ <attribute name="accel">F1</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">About</attribute>
+ <attribute name="action">app.about</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Quit</attribute>
+ <attribute name="action">app.quit</attribute>
+ <attribute name="accel"><Primary>q</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0bf2606..c7e7548 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,6 +3,7 @@
[encoding: UTF-8]
data/glchess.desktop.in.in
[type: gettext/glade]data/gnome-chess.ui
+[type: gettext/glade]data/menu.ui
data/org.gnome.gnome-chess.gschema.xml.in
[type: gettext/glade]data/preferences.ui
[type: gettext/glade]data/promotion-type-selector.ui
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 3294ed1..4cbe69d 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -8,20 +8,17 @@ public class Application : Gtk.Application
private Gtk.Builder builder;
private Gtk.Builder preferences_builder;
private Gtk.Window window;
- private Gtk.Widget save_menu;
- private Gtk.Widget save_as_menu;
- private Gtk.MenuItem fullscreen_menu;
private Gtk.InfoBar info_bar;
private Gtk.Label info_title_label;
private Gtk.Label info_label;
private Gtk.Container view_container;
private ChessScene scene;
private ChessView view;
- private Gtk.Widget undo_menu;
+ private Gtk.Widget save_button;
private Gtk.Widget undo_button;
- private Gtk.Widget resign_menu;
+ private Gtk.Widget claim_draw_button;
private Gtk.Widget resign_button;
- private Gtk.Widget claim_draw_menu;
+ private Gtk.Widget fullscreen_button;
private Gtk.Widget first_move_button;
private Gtk.Widget prev_move_button;
private Gtk.Widget next_move_button;
@@ -54,6 +51,15 @@ public class Application : Gtk.Application
private ChessPlayer? opponent = null;
private ChessPlayer? human_player = null;
private ChessEngine? opponent_engine = null;
+ private bool is_fullscreen = false;
+
+ private const ActionEntry[] app_entries =
+ {
+ { "preferences", preferences_cb },
+ { "help", help_cb },
+ { "about", about_cb },
+ { "quit", quit_cb },
+ };
public Application (File? game_file)
{
@@ -72,7 +78,22 @@ public class Application : Gtk.Application
history = new History (data_dir);
+ add_action_entries (app_entries, this);
+
builder = new Gtk.Builder ();
+
+ try
+ {
+ builder.add_from_file (Path.build_filename (PKGDATADIR, "menu.ui", null));
+ }
+ catch (Error e)
+ {
+ error ("Error loading menu UI: %s", e.message);
+ }
+
+ var menu = builder.get_object ("appmenu") as MenuModel;
+ set_app_menu (menu);
+
try
{
builder.add_from_file (Path.build_filename (PKGDATADIR, "gnome-chess.ui", null));
@@ -82,14 +103,11 @@ public class Application : Gtk.Application
warning ("Could not load UI: %s", e.message);
}
window = (Gtk.Window) builder.get_object ("gnome_chess_app");
- save_menu = (Gtk.Widget) builder.get_object ("menu_save_item");
- save_as_menu = (Gtk.Widget) builder.get_object ("menu_save_as_item");
- fullscreen_menu = (Gtk.MenuItem) builder.get_object ("fullscreen_item");
- undo_menu = (Gtk.Widget) builder.get_object ("undo_move_item");
+ save_button = (Gtk.Widget) builder.get_object ("save_game_button");
undo_button = (Gtk.Widget) builder.get_object ("undo_move_button");
- resign_menu = (Gtk.Widget) builder.get_object ("resign_item");
+ claim_draw_button = (Gtk.Widget) builder.get_object ("claim_draw_button");
resign_button = (Gtk.Widget) builder.get_object ("resign_button");
- claim_draw_menu = (Gtk.Widget) builder.get_object ("claim_draw_item");
+ fullscreen_button = (Gtk.Widget) builder.get_object ("fullscreen_button");
first_move_button = (Gtk.Widget) builder.get_object ("first_move_button");
prev_move_button = (Gtk.Widget) builder.get_object ("prev_move_button");
next_move_button = (Gtk.Widget) builder.get_object ("next_move_button");
@@ -167,10 +185,17 @@ public class Application : Gtk.Application
}
window.set_default_size (settings.get_int ("width"), settings.get_int ("height"));
+
if (settings.get_boolean ("fullscreen"))
+ {
window.fullscreen ();
+ is_fullscreen = true;
+ }
else if (settings.get_boolean ("maximized"))
+ {
window.maximize ();
+ }
+
show ();
}
@@ -426,8 +451,7 @@ public class Application : Gtk.Application
scene.game = game;
info_bar.hide ();
- save_menu.sensitive = false;
- save_as_menu.sensitive = false;
+ save_button.sensitive = false;
update_history_panel ();
update_control_buttons ();
@@ -492,7 +516,7 @@ public class Application : Gtk.Application
}
game_needs_saving = in_history;
- save_menu.sensitive = in_history;
+ save_button.sensitive = in_history;
game.start ();
if (moves.length > 0 && game.clock != null)
@@ -825,8 +849,7 @@ public class Application : Gtk.Application
if (move.number == game.n_moves && scene.move_number == -1)
history_combo.set_active_iter (iter);
- save_menu.sensitive = true;
- save_as_menu.sensitive = true;
+ save_button.sensitive = true;
update_history_panel ();
update_control_buttons ();
@@ -861,13 +884,12 @@ public class Application : Gtk.Application
if (game.n_moves > 0)
{
game_needs_saving = true;
- save_menu.sensitive = true;
+ save_button.sensitive = true;
}
else
{
game_needs_saving = false;
- save_menu.sensitive = false;
- save_as_menu.sensitive = false;
+ save_button.sensitive = false;
}
update_history_panel ();
@@ -877,24 +899,24 @@ public class Application : Gtk.Application
private void update_control_buttons ()
{
var can_resign = game.n_moves > 0;
- resign_menu.sensitive = resign_button.sensitive = can_resign;
+ resign_button.sensitive = can_resign;
/* Claim draw only allowed on your own turn */
- claim_draw_menu.sensitive = can_resign && game.current_player != opponent;
+ claim_draw_button.sensitive = can_resign && game.current_player != opponent;
/* Can undo once the human player has made a move */
var can_undo = game.n_moves > 0;
if (opponent != null && opponent.color == Color.WHITE)
can_undo = game.n_moves > 1;
- undo_menu.sensitive = undo_button.sensitive = can_undo;
+ undo_button.sensitive = can_undo;
}
private void game_end_cb (ChessGame game)
{
- resign_menu.sensitive = resign_button.sensitive = false;
- undo_menu.sensitive = undo_button.sensitive = false;
- claim_draw_menu.sensitive = false;
+ resign_button.sensitive = false;
+ undo_button.sensitive = false;
+ claim_draw_button.sensitive = false;
game_needs_saving = true;
@@ -1016,9 +1038,8 @@ public class Application : Gtk.Application
}
if ((event.changed_mask & Gdk.WindowState.FULLSCREEN) != 0)
{
- bool is_fullscreen = (event.new_window_state & Gdk.WindowState.FULLSCREEN) != 0;
+ is_fullscreen = (event.new_window_state & Gdk.WindowState.FULLSCREEN) != 0;
settings.set_boolean ("fullscreen", is_fullscreen);
- fullscreen_menu.label = is_fullscreen ? Gtk.Stock.LEAVE_FULLSCREEN : Gtk.Stock.FULLSCREEN;
}
return false;
@@ -1086,8 +1107,7 @@ public class Application : Gtk.Application
game.opponent.undo ();
}
- [CCode (cname = "G_MODULE_EXPORT quit_cb", instance_pos = -1)]
- public void quit_cb (Gtk.Widget widget)
+ public void quit_cb ()
{
quit_game ();
}
@@ -1203,14 +1223,13 @@ public class Application : Gtk.Application
[CCode (cname = "G_MODULE_EXPORT toggle_fullscreen_cb", instance_pos = -1)]
public void toggle_fullscreen_cb (Gtk.Widget widget)
{
- if (fullscreen_menu.label == Gtk.Stock.FULLSCREEN)
- window.fullscreen ();
- else
+ if (is_fullscreen)
window.unfullscreen ();
+ else
+ window.fullscreen ();
}
- [CCode (cname = "G_MODULE_EXPORT preferences_cb", instance_pos = -1)]
- public void preferences_cb (Gtk.Widget widget)
+ public void preferences_cb ()
{
if (preferences_dialog != null)
{
@@ -1537,8 +1556,7 @@ public class Application : Gtk.Application
settings.set_string ("board-side", get_combo (combo, 1));
}
- [CCode (cname = "G_MODULE_EXPORT help_cb", instance_pos = -1)]
- public void help_cb (Gtk.Widget widget)
+ public void help_cb ()
{
try
{
@@ -1553,8 +1571,7 @@ public class Application : Gtk.Application
private const string[] authors = { "Robert Ancell <robert ancell gmail com>", null };
private const string[] artists = { "John-Paul Gignac (3D Models)", "Max Froumentin (2D Models)", "Hylke
Bons <h bons student rug nl> (icon)", null };
- [CCode (cname = "G_MODULE_EXPORT about_cb", instance_pos = -1)]
- public void about_cb (Gtk.Widget widget)
+ public void about_cb ()
{
if (about_dialog != null)
{
@@ -1586,12 +1603,6 @@ public class Application : Gtk.Application
about_dialog = null;
}
- [CCode (cname = "G_MODULE_EXPORT save_game_as_cb", instance_pos = -1)]
- public void save_game_as_cb (Gtk.Widget widget)
- {
- save_game ();
- }
-
[CCode (cname = "G_MODULE_EXPORT save_game_cb", instance_pos = -1)]
public void save_game_cb (Gtk.Widget widget)
{
@@ -1692,7 +1703,7 @@ public class Application : Gtk.Application
{
pgn_game.write (save_dialog.get_file ());
saved_filename = save_dialog.get_filename ();
- save_menu.sensitive = false;
+ save_button.sensitive = false;
game_needs_saving = false;
}
catch (Error e)
@@ -1816,6 +1827,7 @@ public class Application : Gtk.Application
pgn_game.white_level = engine_level;
}
}
+
start_game ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]