Improve construction of the no-engine info bar
This reparenting strategy was pretty wild.
This commit is contained in:
parent
f918814c9e
commit
eb7f2636c5
2 changed files with 14 additions and 32 deletions
|
@ -137,6 +137,11 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkInfoBar" id="info_bar">
|
||||||
|
<property name="visible">False</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="view_box">
|
<object class="GtkBox" id="view_box">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
|
@ -20,6 +20,7 @@ public class ChessApplication : Gtk.Application
|
||||||
|
|
||||||
private Settings settings;
|
private Settings settings;
|
||||||
private Gtk.ApplicationWindow window;
|
private Gtk.ApplicationWindow window;
|
||||||
|
private Gtk.InfoBar info_bar;
|
||||||
private Gtk.Container view_container;
|
private Gtk.Container view_container;
|
||||||
private ChessScene scene;
|
private ChessScene scene;
|
||||||
private ChessView view;
|
private ChessView view;
|
||||||
|
@ -122,17 +123,14 @@ Copyright © 2015–2016 Sahil Sareen""";
|
||||||
|
|
||||||
private void display_no_engine_info_bar ()
|
private void display_no_engine_info_bar ()
|
||||||
{
|
{
|
||||||
Gtk.InfoBar? no_engine_info_bar = null;
|
var label = new Gtk.Label (_("No chess engine is installed. You will not be able to play against the computer."));
|
||||||
Gtk.Label? no_engine_error_label = null;
|
label.show ();
|
||||||
// Info bar to indicate no chess engines are installed
|
|
||||||
add_info_bar_to_bin (window, out no_engine_info_bar, out no_engine_error_label);
|
|
||||||
|
|
||||||
no_engine_error_label.set_text (_("No chess engine is installed. " +
|
info_bar.get_content_area ().add (label);
|
||||||
"You will not be able to play against the computer."));
|
info_bar.set_message_type (Gtk.MessageType.ERROR);
|
||||||
no_engine_info_bar.set_message_type (Gtk.MessageType.ERROR);
|
info_bar.set_show_close_button (true);
|
||||||
no_engine_info_bar.show ();
|
info_bar.response.connect (() => info_bar.destroy ());
|
||||||
no_engine_info_bar.set_show_close_button (true);
|
info_bar.show ();
|
||||||
no_engine_info_bar.response.connect (() => no_engine_info_bar.hide ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void startup ()
|
public override void startup ()
|
||||||
|
@ -151,6 +149,7 @@ Copyright © 2015–2016 Sahil Sareen""";
|
||||||
window.size_allocate.connect (size_allocate_cb);
|
window.size_allocate.connect (size_allocate_cb);
|
||||||
window.window_state_event.connect (window_state_event_cb);
|
window.window_state_event.connect (window_state_event_cb);
|
||||||
|
|
||||||
|
info_bar = (Gtk.InfoBar) builder.get_object ("info_bar");
|
||||||
pause_resume_button = (Gtk.Button) builder.get_object ("pause_button");
|
pause_resume_button = (Gtk.Button) builder.get_object ("pause_button");
|
||||||
first_move_button = (Gtk.Widget) builder.get_object ("first_move_button");
|
first_move_button = (Gtk.Widget) builder.get_object ("first_move_button");
|
||||||
prev_move_button = (Gtk.Widget) builder.get_object ("prev_move_button");
|
prev_move_button = (Gtk.Widget) builder.get_object ("prev_move_button");
|
||||||
|
@ -2239,28 +2238,6 @@ Copyright © 2015–2016 Sahil Sareen""";
|
||||||
about_dialog = null;
|
about_dialog = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add_info_bar_to_bin (Gtk.Bin bin, out Gtk.InfoBar info_bar, out Gtk.Label label)
|
|
||||||
{
|
|
||||||
var vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
|
|
||||||
vbox.show ();
|
|
||||||
|
|
||||||
info_bar = new Gtk.InfoBar ();
|
|
||||||
var content_area = (Gtk.Container) info_bar.get_content_area ();
|
|
||||||
vbox.pack_start (info_bar, false, true, 0);
|
|
||||||
|
|
||||||
label = new Gtk.Label ("");
|
|
||||||
content_area.add (label);
|
|
||||||
label.show ();
|
|
||||||
|
|
||||||
var child = (Gtk.Container) bin.get_child ();
|
|
||||||
child.reparent (vbox);
|
|
||||||
child.border_width = bin.border_width;
|
|
||||||
bin.border_width = 0;
|
|
||||||
|
|
||||||
vbox.set_child_packing (child, true, true, 0, Gtk.PackType.START);
|
|
||||||
bin.add (vbox);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void update_pgn_time_remaining ()
|
private void update_pgn_time_remaining ()
|
||||||
{
|
{
|
||||||
if (game.clock != null)
|
if (game.clock != null)
|
||||||
|
|
Loading…
Reference in a new issue