[gnome-chess/mcatanzaro/gtk4] progress
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess/mcatanzaro/gtk4] progress
- Date: Thu, 24 Dec 2020 03:37:24 +0000 (UTC)
commit a35f80909a162277414833559bd6dcfda4e52e80
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Wed Dec 23 21:09:58 2020 -0600
progress
data/promotion-type-selector.ui | 248 ++++++++++++++++++++--------------------
src/gnome-chess.vala | 80 +++++++------
2 files changed, 170 insertions(+), 158 deletions(-)
---
diff --git a/data/promotion-type-selector.ui b/data/promotion-type-selector.ui
index acd120f..393656c 100644
--- a/data/promotion-type-selector.ui
+++ b/data/promotion-type-selector.ui
@@ -5,162 +5,160 @@
<property name="can-focus">0</property>
<property name="title" translatable="yes">Select Promotion Type</property>
<property name="use-header-bar">1</property>
- <child internal-child="vbox">
- <object class="GtkBox">
- <property name="visible">0</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="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>
+ <object class="GtkButton" id="button_queen">
+ <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="GtkButton" id="button_queen">
- <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="GtkGrid">
+ <property name="can-focus">0</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
<child>
- <object class="GtkGrid">
+ <object class="GtkLabel">
<property name="can-focus">0</property>
- <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="image_queen">
- <property name="can-focus">0</property>
- <layout>
- <property name="column">0</property>
- <property name="row">0</property>
- </layout>
- </object>
- </child>
+ <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="image_queen">
+ <property name="can-focus">0</property>
+ <layout>
+ <property name="column">0</property>
+ <property name="row">0</property>
+ </layout>
</object>
</child>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_knight">
+ <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="GtkButton" id="button_knight">
- <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"/>
+ <object class="GtkGrid">
+ <property name="can-focus">0</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
<child>
- <object class="GtkGrid">
+ <object class="GtkLabel">
<property name="can-focus">0</property>
- <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="image_knight">
- <property name="can-focus">0</property>
- <layout>
- <property name="column">0</property>
- <property name="row">0</property>
- </layout>
- </object>
- </child>
+ <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="image_knight">
+ <property name="can-focus">0</property>
+ <layout>
+ <property name="column">0</property>
+ <property name="row">0</property>
+ </layout>
</object>
</child>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_rook">
+ <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="GtkButton" id="button_rook">
- <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"/>
+ <object class="GtkGrid">
+ <property name="can-focus">0</property>
+ <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="GtkGrid">
+ <object class="GtkImage" id="image_rook">
<property name="can-focus">0</property>
- <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="image_rook">
- <property name="can-focus">0</property>
- <layout>
- <property name="column">0</property>
- <property name="row">0</property>
- </layout>
- </object>
- </child>
+ <layout>
+ <property name="column">0</property>
+ <property name="row">0</property>
+ </layout>
</object>
</child>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_bishop">
+ <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="GtkButton" id="button_bishop">
- <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"/>
+ <object class="GtkGrid">
+ <property name="can-focus">0</property>
+ <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="GtkGrid">
+ <object class="GtkImage" id="image_bishop">
<property name="can-focus">0</property>
- <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="image_bishop">
- <property name="can-focus">0</property>
- <layout>
- <property name="column">0</property>
- <property name="row">0</property>
- </layout>
- </object>
- </child>
+ <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>
</object>
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 3e5d593..fd56220 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -354,7 +354,8 @@ Copyright © 2015–2016 Sahil Sareen""";
promotion_type_completion_handler (PieceType.BISHOP);
break;
default:
- assert_not_reached ();
+ promotion_type_completion_handler (null);
+ break;
}
promotion_type_selector_dialog.hide ();
@@ -367,12 +368,22 @@ Copyright © 2015–2016 Sahil Sareen""";
{
if (promotion_type_selector_dialog == null)
{
- var promotion_type_selector_builder = new Builder.from_resource
("/org/gnome/Chess/ui/promotion-type-selector.ui");
+ Builder builder = new Builder ();
+ builder.set_current_object (this);
+ try
+ {
+ builder.add_from_resource ("/org/gnome/Chess/ui/promotion-type-selector.ui");
+ }
+ catch (Error e)
+ {
+ error ("Failed to load UI resource: %s", e.message);
+ }
- promotion_type_selector_dialog = (Dialog) promotion_type_selector_builder.get_object
("dialog_promotion_type_selector");
+ promotion_type_selector_dialog = (Dialog) builder.get_object ("dialog_promotion_type_selector");
promotion_type_selector_dialog.transient_for = window;
+ promotion_type_selector_dialog.modal = true;
- var button_box = (Box) promotion_type_selector_builder.get_object ("button_box");
+ var button_box = (Box) builder.get_object ("button_box");
if (layout_mode == LayoutMode.NARROW)
button_box.orientation = Orientation.VERTICAL;
@@ -383,16 +394,16 @@ Copyright © 2015–2016 Sahil Sareen""";
color = "black";
var filename = Path.build_filename (PKGDATADIR, "pieces", scene.theme_name, "%sQueen.svg".printf
(color));
- set_piece_image ((Image) promotion_type_selector_builder.get_object ("image_queen"), filename);
+ set_piece_image ((Image) builder.get_object ("image_queen"), filename);
filename = Path.build_filename (PKGDATADIR, "pieces", scene.theme_name, "%sKnight.svg".printf
(color));
- set_piece_image ((Image) promotion_type_selector_builder.get_object ("image_knight"), filename);
+ set_piece_image ((Image) builder.get_object ("image_knight"), filename);
filename = Path.build_filename (PKGDATADIR, "pieces", scene.theme_name, "%sRook.svg".printf
(color));
- set_piece_image ((Image) promotion_type_selector_builder.get_object ("image_rook"), filename);
+ set_piece_image ((Image) builder.get_object ("image_rook"), filename);
filename = Path.build_filename (PKGDATADIR, "pieces", scene.theme_name, "%sBishop.svg".printf
(color));
- set_piece_image ((Image) promotion_type_selector_builder.get_object ("image_bishop"), filename);
+ set_piece_image ((Image) builder.get_object ("image_bishop"), filename);
promotion_type_selector_dialog.response.connect (promotion_type_selector_response_cb);
}
@@ -404,21 +415,24 @@ Copyright © 2015–2016 Sahil Sareen""";
private void set_piece_image (Image image, string filename)
{
+ const int size = 48;
+
try
{
var h = new Rsvg.Handle.from_file (filename);
- var s = new Cairo.ImageSurface (Cairo.Format.ARGB32, 64, 64);
+ var s = new Cairo.ImageSurface (Cairo.Format.ARGB32, size, size);
var c = new Cairo.Context (s);
- h.render_document (c, Rsvg.Rectangle () { width = 64, height = 64, x = 0, y = 0 });
+ h.render_document (c, Rsvg.Rectangle () { width = size, height = size, x = 0, y = 0 });
- var p = Gdk.pixbuf_get_from_surface (s, 0, 0, 64, 64);
+ var p = Gdk.pixbuf_get_from_surface (s, 0, 0, size, size);
image.set_from_pixbuf (p);
+
+ image.height_request = size;
}
catch (Error e)
{
warning ("Failed to load image %s: %s", filename, e.message);
- return;
}
}
@@ -1873,33 +1887,33 @@ Copyright © 2015–2016 Sahil Sareen""";
return;
}
- Builder preferences_builder = new Builder ();
- preferences_builder.set_current_object (this);
+ Builder builder = new Builder ();
+ builder.set_current_object (this);
try
{
- preferences_builder.add_from_resource ("/org/gnome/Chess/ui/preferences.ui");
+ builder.add_from_resource ("/org/gnome/Chess/ui/preferences.ui");
}
catch (Error e)
{
error ("Failed to load UI resource: %s", e.message);
}
- preferences_dialog = (Dialog) preferences_builder.get_object ("preferences");
+ preferences_dialog = (Dialog) builder.get_object ("preferences");
preferences_dialog.transient_for = window;
preferences_dialog.modal = true;
- settings.bind ("show-numbering", preferences_builder.get_object ("show_numbering_check"),
+ settings.bind ("show-numbering", builder.get_object ("show_numbering_check"),
"active", SettingsBindFlags.DEFAULT);
- settings.bind ("show-move-hints", preferences_builder.get_object ("show_move_hints_check"),
+ settings.bind ("show-move-hints", builder.get_object ("show_move_hints_check"),
"active", SettingsBindFlags.DEFAULT);
- side_combo = (ComboBox) preferences_builder.get_object ("side_combo");
+ side_combo = (ComboBox) builder.get_object ("side_combo");
side_combo.set_active (settings.get_enum ("play-as"));
- difficulty_combo = (ComboBox) preferences_builder.get_object ("difficulty_combo");
+ difficulty_combo = (ComboBox) builder.get_object ("difficulty_combo");
set_combo (difficulty_combo, 1, settings.get_string ("difficulty"));
- var ai_combo = (ComboBox) preferences_builder.get_object ("opponent_combo");
+ var ai_combo = (ComboBox) builder.get_object ("opponent_combo");
var ai_model = (Gtk.ListStore) ai_combo.model;
var opponent_name = settings.get_string ("opponent");
if (opponent_name == "human")
@@ -1918,16 +1932,16 @@ Copyright © 2015–2016 Sahil Sareen""";
settings.set_string ("opponent", "human");
}
- duration_combo = (ComboBox) preferences_builder.get_object ("duration_combo");
- clock_type_combo = (ComboBox) preferences_builder.get_object ("clock_type_combo");
- duration_adjustment = (Adjustment) preferences_builder.get_object ("duration_adjustment");
- timer_increment_adjustment = (Adjustment) preferences_builder.get_object
("timer_increment_adjustment");
- custom_duration_box = (Box) preferences_builder.get_object ("custom_duration_box");
- timer_increment_box = (Box) preferences_builder.get_object ("timer_increment_box");
- custom_duration_units_combo = (ComboBox) preferences_builder.get_object
("custom_duration_units_combo");
+ duration_combo = (ComboBox) builder.get_object ("duration_combo");
+ clock_type_combo = (ComboBox) builder.get_object ("clock_type_combo");
+ duration_adjustment = (Adjustment) builder.get_object ("duration_adjustment");
+ timer_increment_adjustment = (Adjustment) builder.get_object ("timer_increment_adjustment");
+ custom_duration_box = (Box) builder.get_object ("custom_duration_box");
+ timer_increment_box = (Box) builder.get_object ("timer_increment_box");
+ custom_duration_units_combo = (ComboBox) builder.get_object ("custom_duration_units_combo");
set_duration (settings.get_int ("duration"));
- timer_increment_label = (Label) preferences_builder.get_object ("timer_increment_label");
- timer_increment_units_combo = (ComboBox) preferences_builder.get_object
("timer_increment_units_combo");
+ timer_increment_label = (Label) builder.get_object ("timer_increment_label");
+ timer_increment_units_combo = (ComboBox) builder.get_object ("timer_increment_units_combo");
if (pgn_game.clock_type != null)
set_clock_type (ClockType.string_to_enum (pgn_game.clock_type));
@@ -1939,13 +1953,13 @@ Copyright © 2015–2016 Sahil Sareen""";
else
set_timer_increment (settings.get_int ("timer-increment"));
- var orientation_combo = (ComboBox) preferences_builder.get_object ("orientation_combo");
+ var orientation_combo = (ComboBox) builder.get_object ("orientation_combo");
set_combo (orientation_combo, 1, settings.get_string ("board-side"));
- var move_combo = (ComboBox) preferences_builder.get_object ("move_format_combo");
+ var move_combo = (ComboBox) builder.get_object ("move_format_combo");
set_combo (move_combo, 1, settings.get_string ("move-format"));
- var theme_combo = (ComboBox) preferences_builder.get_object ("piece_style_combo");
+ var theme_combo = (ComboBox) builder.get_object ("piece_style_combo");
set_combo (theme_combo, 1, settings.get_string ("piece-theme"));
/* Human vs. human */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]