Commit b4bfa324 authored by Andrey Kutejko's avatar Andrey Kutejko

Rework main menu. Use ListBox

parent 85054513
Pipeline #202270 passed with stages
in 6 minutes and 56 seconds
......@@ -180,12 +180,48 @@
<property name="width-request">350</property>
<property name="height-request">350</property>
<child>
<object class="GtkButton">
<object class="GtkFrame">
<property name="visible">True</property>
<property name="use-underline">True</property>
<property name="label" translatable="yes">_Easy</property>
<property name="action-name">app.start-game</property>
<property name="action-target">1</property> <!-- 1 corresponds to enum DifficultyCategory.EASY -->
<property name="shadow-type">GTK_SHADOW_IN</property>
<child>
<object class="SudokuMainMenu">
<child>
<object class="SudokuMainMenuItem">
<property name="label" translatable="yes">_Easy</property>
<property name="action-name">app.start-game</property>
<property name="action-target">1</property> <!-- 1 corresponds to enum DifficultyCategory.EASY -->
</object>
</child>
<child>
<object class="SudokuMainMenuItem">
<property name="label" translatable="yes">_Medium</property>
<property name="action-name">app.start-game</property>
<property name="action-target">2</property> <!-- 2 corresponds to enum DifficultyCategory.MEDIUM -->
</object>
</child>
<child>
<object class="SudokuMainMenuItem">
<property name="label" translatable="yes">_Hard</property>
<property name="action-name">app.start-game</property>
<property name="action-target">3</property> <!-- 3 corresponds to enum DifficultyCategory.HARD -->
</object>
</child>
<child>
<object class="SudokuMainMenuItem">
<property name="label" translatable="yes">_Very Hard</property>
<property name="action-name">app.start-game</property>
<property name="action-target">4</property> <!-- 4 corresponds to enum DifficultyCategory.VERY_HARD -->
</object>
</child>
<child>
<object class="SudokuMainMenuItem">
<property name="label" translatable="yes">_Create your own puzzle</property>
<property name="action-name">app.create-game</property>
<property name="has-separator">True</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
......@@ -193,62 +229,6 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="use-underline">True</property>
<property name="label" translatable="yes">_Medium</property>
<property name="action-name">app.start-game</property>
<property name="action-target">2</property> <!-- 2 corresponds to enum DifficultyCategory.MEDIUM -->
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="use-underline">True</property>
<property name="label" translatable="yes">_Hard</property>
<property name="action-name">app.start-game</property>
<property name="action-target">3</property> <!-- 3 corresponds to enum DifficultyCategory.HARD -->
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="use-underline">True</property>
<property name="label" translatable="yes">_Very Hard</property>
<property name="action-name">app.start-game</property>
<property name="action-target">4</property> <!-- 4 corresponds to enum DifficultyCategory.VERY_HARD -->
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="use-underline">True</property>
<property name="margin-top">30</property>
<property name="label" translatable="yes">_Create your own puzzle</property>
<property name="action-name">app.create-game</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
</object> <!-- End of start_box -->
<packing>
<property name="name">start_box</property>
......
......@@ -101,6 +101,9 @@ public class Sudoku : Gtk.Application
Object (application_id: "org.gnome.Sudoku", flags: ApplicationFlags.FLAGS_NONE);
add_main_option_entries (option_entries);
typeof (SudokuMainMenu).ensure ();
typeof (SudokuMainMenuItem).ensure ();
}
protected override int handle_local_options (GLib.VariantDict options)
......
/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright © 2020 Andrii Kuteiko
*
* This file is part of GNOME Sudoku.
*
* GNOME Sudoku is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GNOME Sudoku is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNOME Sudoku. If not, see <http://www.gnu.org/licenses/>.
*/
using Gtk;
using Gdk;
private class SudokuMainMenu : ListBox
{
construct
{
visible = true;
can_focus = false;
set_header_func ((row) => {
var mi = row as SudokuMainMenuItem;
if (mi != null && mi.has_separator)
{
var separator = new Separator (Orientation.HORIZONTAL);
mi.set_header (separator);
}
});
}
}
private class SudokuMainMenuItem : ListBoxRow
{
public string label { get; set construct; }
public bool has_separator { get; set construct; }
construct
{
height_request = 80;
visible = true;
can_focus = true;
var label_widget = new Label (this.label);
label_widget.visible = true;
label_widget.can_focus = false;
label_widget.use_underline = true;
add (label_widget);
}
}
......@@ -6,6 +6,7 @@ gnome_sudoku_vala_args = [
gnome_sudoku_sources = [
'config.vapi',
'gnome-sudoku.vala',
'main-menu.vala',
'number-picker.vala',
'print-dialog.vala',
'sudoku-printer.vala',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment