Use AdwDialog for promotion type selector
Probably fixes #91, though I haven't been able to reproduce the problem myself.
This commit is contained in:
parent
cce143a6fa
commit
da861f1b8e
3 changed files with 146 additions and 142 deletions
|
@ -1,164 +1,170 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<template class="PromotionTypeSelectorDialog" parent="GtkDialog">
|
||||
<template class="PromotionTypeSelectorDialog" parent="AdwDialog">
|
||||
<property name="can-focus">0</property>
|
||||
<property name="title" translatable="yes">Select Promotion Type</property>
|
||||
<property name="use-header-bar">1</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="button_box">
|
||||
<property name="can-focus">0</property>
|
||||
<property name="margin-start">6</property>
|
||||
<property name="margin-end">6</property>
|
||||
<property name="margin-top">6</property>
|
||||
<property name="margin-bottom">6</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="width-request">100</property>
|
||||
<property name="height-request">120</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="use-underline">1</property>
|
||||
<signal name="clicked" handler="queen_selected_cb"/>
|
||||
<object class="AdwToolbarView">
|
||||
<child type="top">
|
||||
<object class="AdwHeaderBar"/>
|
||||
</child>
|
||||
<property name="content">
|
||||
<object class="GtkBox" id="button_box">
|
||||
<property name="can-focus">0</property>
|
||||
<property name="margin-start">6</property>
|
||||
<property name="margin-end">6</property>
|
||||
<property name="margin-top">6</property>
|
||||
<property name="margin-bottom">6</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="can-focus">0</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<object class="GtkButton">
|
||||
<property name="width-request">100</property>
|
||||
<property name="height-request">120</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="use-underline">1</property>
|
||||
<signal name="clicked" handler="queen_selected_cb"/>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<object class="GtkGrid">
|
||||
<property name="can-focus">0</property>
|
||||
<property name="label" translatable="yes">_Queen</property>
|
||||
<property name="use-underline">1</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="queen_image">
|
||||
<property name="can-focus">0</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="can-focus">0</property>
|
||||
<property name="label" translatable="yes">_Queen</property>
|
||||
<property name="use-underline">1</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="queen_image">
|
||||
<property name="can-focus">0</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="width-request">100</property>
|
||||
<property name="height-request">120</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="use-underline">1</property>
|
||||
<signal name="clicked" handler="knight_selected_cb"/>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="can-focus">0</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<object class="GtkButton">
|
||||
<property name="width-request">100</property>
|
||||
<property name="height-request">120</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="use-underline">1</property>
|
||||
<signal name="clicked" handler="knight_selected_cb"/>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<object class="GtkGrid">
|
||||
<property name="can-focus">0</property>
|
||||
<property name="label" translatable="yes">_Knight</property>
|
||||
<property name="use-underline">1</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="knight_image">
|
||||
<property name="can-focus">0</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="can-focus">0</property>
|
||||
<property name="label" translatable="yes">_Knight</property>
|
||||
<property name="use-underline">1</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="knight_image">
|
||||
<property name="can-focus">0</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="width-request">100</property>
|
||||
<property name="height-request">120</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="use-underline">1</property>
|
||||
<signal name="clicked" handler="rook_selected_cb"/>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="can-focus">0</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<object class="GtkButton">
|
||||
<property name="width-request">100</property>
|
||||
<property name="height-request">120</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="use-underline">1</property>
|
||||
<signal name="clicked" handler="rook_selected_cb"/>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<object class="GtkGrid">
|
||||
<property name="can-focus">0</property>
|
||||
<property name="label" translatable="yes">_Rook</property>
|
||||
<property name="use-underline">1</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="rook_image">
|
||||
<property name="can-focus">0</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="can-focus">0</property>
|
||||
<property name="label" translatable="yes">_Rook</property>
|
||||
<property name="use-underline">1</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="rook_image">
|
||||
<property name="can-focus">0</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="width-request">100</property>
|
||||
<property name="height-request">120</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="use-underline">1</property>
|
||||
<signal name="clicked" handler="bishop_selected_cb"/>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="can-focus">0</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<object class="GtkButton">
|
||||
<property name="width-request">100</property>
|
||||
<property name="height-request">120</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="use-underline">1</property>
|
||||
<signal name="clicked" handler="bishop_selected_cb"/>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<object class="GtkGrid">
|
||||
<property name="can-focus">0</property>
|
||||
<property name="label" translatable="yes">_Bishop</property>
|
||||
<property name="use-underline">1</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="bishop_image">
|
||||
<property name="can-focus">0</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="can-focus">0</property>
|
||||
<property name="label" translatable="yes">_Bishop</property>
|
||||
<property name="use-underline">1</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="bishop_image">
|
||||
<property name="can-focus">0</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<style>
|
||||
<class name="linked"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<style>
|
||||
<class name="linked"/>
|
||||
</style>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
|
|
|
@ -1202,13 +1202,12 @@ Copyright © 2015–2016 Sahil Sareen""";
|
|||
private void show_promotion_type_selector (owned ChessScene.PromotionTypeCompletionHandler handler)
|
||||
{
|
||||
/* We cannot cache this dialog because it uses the piece color of the current player. */
|
||||
var promotion_type_selector_dialog = new PromotionTypeSelectorDialog (window,
|
||||
game.current_player.color,
|
||||
var promotion_type_selector_dialog = new PromotionTypeSelectorDialog (game.current_player.color,
|
||||
scene.theme_name,
|
||||
window.layout_mode);
|
||||
|
||||
promotion_type_selector_dialog.response.connect ((response_id) => {
|
||||
switch (response_id)
|
||||
promotion_type_selector_dialog.piece_selected.connect ((selected_type) => {
|
||||
switch (selected_type)
|
||||
{
|
||||
case PromotionTypeSelectorDialog.SelectedType.QUEEN:
|
||||
handler (PieceType.QUEEN);
|
||||
|
@ -1227,11 +1226,11 @@ Copyright © 2015–2016 Sahil Sareen""";
|
|||
break;
|
||||
}
|
||||
|
||||
promotion_type_selector_dialog.destroy ();
|
||||
promotion_type_selector_dialog.close ();
|
||||
promotion_type_selector_dialog = null;
|
||||
});
|
||||
|
||||
promotion_type_selector_dialog.show ();
|
||||
promotion_type_selector_dialog.present (window);
|
||||
}
|
||||
|
||||
private void run_invalid_pgn_dialog ()
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
*/
|
||||
|
||||
[GtkTemplate (ui = "/org/gnome/Chess/ui/promotion-type-selector.ui")]
|
||||
public class PromotionTypeSelectorDialog : Gtk.Dialog
|
||||
public class PromotionTypeSelectorDialog : Adw.Dialog
|
||||
{
|
||||
enum SelectedType
|
||||
public enum SelectedType
|
||||
{
|
||||
QUEEN,
|
||||
KNIGHT,
|
||||
|
@ -32,11 +32,10 @@ public class PromotionTypeSelectorDialog : Gtk.Dialog
|
|||
[GtkChild]
|
||||
private unowned Gtk.Image bishop_image;
|
||||
|
||||
public PromotionTypeSelectorDialog (Gtk.Window window, Color color, string theme, ChessWindow.LayoutMode layout_mode)
|
||||
{
|
||||
transient_for = window;
|
||||
modal = true;
|
||||
public signal void piece_selected (SelectedType type);
|
||||
|
||||
public PromotionTypeSelectorDialog (Color color, string theme, ChessWindow.LayoutMode layout_mode)
|
||||
{
|
||||
if (layout_mode == ChessWindow.LayoutMode.NARROW)
|
||||
button_box.orientation = Gtk.Orientation.VERTICAL;
|
||||
|
||||
|
@ -96,24 +95,24 @@ public class PromotionTypeSelectorDialog : Gtk.Dialog
|
|||
[GtkCallback]
|
||||
private void queen_selected_cb (Gtk.Button button)
|
||||
{
|
||||
response (SelectedType.QUEEN);
|
||||
piece_selected (SelectedType.QUEEN);
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
private void knight_selected_cb (Gtk.Button button)
|
||||
{
|
||||
response (SelectedType.KNIGHT);
|
||||
piece_selected (SelectedType.KNIGHT);
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
private void rook_selected_cb (Gtk.Button button)
|
||||
{
|
||||
response (SelectedType.ROOK);
|
||||
piece_selected (SelectedType.ROOK);
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
private void bishop_selected_cb (Gtk.Button button)
|
||||
{
|
||||
response (SelectedType.BISHOP);
|
||||
piece_selected (SelectedType.BISHOP);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue