[gnome-chess] Rework promotion type selector dialog to not use action area
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess] Rework promotion type selector dialog to not use action area
- Date: Fri, 4 Dec 2020 22:55:00 +0000 (UTC)
commit 8e01fb40efb032d0790fe085b14ea11f49a4e37a
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Fri Dec 4 16:51:13 2020 -0600
Rework promotion type selector dialog to not use action area
Fixes #19
data/promotion-type-selector.ui | 37 +++++++++++++------------------------
src/gnome-chess.vala | 34 ++++++++++++++++++++++++++++++++--
2 files changed, 45 insertions(+), 26 deletions(-)
---
diff --git a/data/promotion-type-selector.ui b/data/promotion-type-selector.ui
index 3d0a196..6d48fca 100644
--- a/data/promotion-type-selector.ui
+++ b/data/promotion-type-selector.ui
@@ -10,17 +10,14 @@
<property name="use-header-bar">1</property>
<child internal-child="vbox">
<object class="GtkBox">
- <property name="can-focus">False</property>
- <property name="margin-left">12</property>
- <property name="margin-right">12</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">20</property>
- <child internal-child="action_area">
- <object class="GtkButtonBox">
+ <child>
+ <object class="GtkButtonBox" id="button_box">
+ <property name="visible">true</property>
<property name="can-focus">False</property>
- <property name="layout-style">center</property>
+ <property name="margin">6</property>
+ <property name="layout-style">expand</property>
<child>
- <object class="GtkToggleButton" id="togglebutton-queen">
+ <object class="GtkButton" id="button_queen">
<property name="width-request">100</property>
<property name="height-request">120</property>
<property name="visible">True</property>
@@ -28,6 +25,7 @@
<property name="receives-default">True</property>
<property name="use-underline">True</property>
<property name="image-position">top</property>
+ <signal name="clicked" handler="queen_selected_cb"/>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
@@ -70,7 +68,7 @@
</packing>
</child>
<child>
- <object class="GtkToggleButton" id="togglebutton-knight">
+ <object class="GtkButton" id="button_knight">
<property name="width-request">100</property>
<property name="height-request">120</property>
<property name="visible">True</property>
@@ -78,6 +76,7 @@
<property name="receives-default">True</property>
<property name="use-underline">True</property>
<property name="image-position">top</property>
+ <signal name="clicked" handler="knight_selected_cb"/>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
@@ -120,7 +119,7 @@
</packing>
</child>
<child>
- <object class="GtkToggleButton" id="togglebutton-rook">
+ <object class="GtkButton" id="button_rook">
<property name="width-request">100</property>
<property name="height-request">120</property>
<property name="visible">True</property>
@@ -128,6 +127,7 @@
<property name="receives-default">True</property>
<property name="use-underline">True</property>
<property name="image-position">top</property>
+ <signal name="clicked" handler="rook_selected_cb"/>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
@@ -170,7 +170,7 @@
</packing>
</child>
<child>
- <object class="GtkToggleButton" id="togglebutton-bishop">
+ <object class="GtkButton" id="button_bishop">
<property name="width-request">100</property>
<property name="height-request">120</property>
<property name="visible">True</property>
@@ -178,6 +178,7 @@
<property name="receives-default">True</property>
<property name="use-underline">True</property>
<property name="image-position">top</property>
+ <signal name="clicked" handler="bishop_selected_cb"/>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
@@ -220,20 +221,8 @@
</packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack-type">end</property>
- <property name="position">0</property>
- </packing>
</child>
</object>
</child>
- <action-widgets>
- <action-widget response="0">togglebutton-queen</action-widget>
- <action-widget response="1">togglebutton-knight</action-widget>
- <action-widget response="2">togglebutton-rook</action-widget>
- <action-widget response="3">togglebutton-bishop</action-widget>
- </action-widgets>
</object>
</interface>
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index f5f142f..aa661f6 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -61,6 +61,7 @@ public class ChessApplication : Gtk.Application
private FileChooserNative open_dialog = null;
private FileChooserNative? save_dialog = null;
private AboutDialog? about_dialog = null;
+ private Dialog? promotion_type_selector_dialog = null;
private PGNGame pgn_game;
private ChessGame game;
@@ -319,11 +320,39 @@ Copyright © 2015–2016 Sahil Sareen""";
return false;
}
+ [CCode (cname = "queen_selected_cb", instance_pos = -1)]
+ public void queen_selected_cb (Button button)
+ requires (promotion_type_selector_dialog != null)
+ {
+ promotion_type_selector_dialog.response (PromotionTypeSelected.QUEEN);
+ }
+
+ [CCode (cname = "knight_selected_cb", instance_pos = -1)]
+ public void knight_selected_cb (Button button)
+ requires (promotion_type_selector_dialog != null)
+ {
+ promotion_type_selector_dialog.response (PromotionTypeSelected.KNIGHT);
+ }
+
+ [CCode (cname = "rook_selected_cb", instance_pos = -1)]
+ public void rook_selected_cb (Button button)
+ requires (promotion_type_selector_dialog != null)
+ {
+ promotion_type_selector_dialog.response (PromotionTypeSelected.KNIGHT);
+ }
+
+ [CCode (cname = "bishop_selected_cb", instance_pos = -1)]
+ public void bishop_selected_cb (Button button)
+ requires (promotion_type_selector_dialog != null)
+ {
+ promotion_type_selector_dialog.response (PromotionTypeSelected.BISHOP);
+ }
+
public PieceType? show_promotion_type_selector ()
{
- Builder promotion_type_selector_builder = new Builder.from_resource
("/org/gnome/Chess/ui/promotion-type-selector.ui");
+ var promotion_type_selector_builder = new Builder.from_resource
("/org/gnome/Chess/ui/promotion-type-selector.ui");
- Dialog promotion_type_selector_dialog = (Dialog) promotion_type_selector_builder.get_object
("dialog_promotion_type_selector");
+ promotion_type_selector_dialog = (Dialog) promotion_type_selector_builder.get_object
("dialog_promotion_type_selector");
promotion_type_selector_dialog.transient_for = window;
string color;
@@ -364,6 +393,7 @@ Copyright © 2015–2016 Sahil Sareen""";
break;
}
promotion_type_selector_dialog.destroy ();
+ promotion_type_selector_dialog = null;
return selection;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]