[gnome-klotski] Add Unfullscreen button.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-klotski] Add Unfullscreen button.
- Date: Mon, 10 Feb 2020 17:19:25 +0000 (UTC)
commit f138b92bc9c0a2150da3823e7746f987a134d77a
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Mon Feb 10 15:07:36 2020 +0100
Add Unfullscreen button.
data/klotski.css | 4 ++++
data/klotski.ui | 32 ++++++++++++++++++++++++++++++--
src/klotski-window.vala | 40 ++++++++++++++++++++++++++--------------
3 files changed, 60 insertions(+), 16 deletions(-)
---
diff --git a/data/klotski.css b/data/klotski.css
index 7499d20..7c21881 100644
--- a/data/klotski.css
+++ b/data/klotski.css
@@ -15,6 +15,10 @@
with GNOME Klotski. If not, see <https://www.gnu.org/licenses/>.
*/
+button.unfullscreen-button {
+ margin:6px;
+}
+
popover#puzzles-popover {
padding: 10px;
}
diff --git a/data/klotski.ui b/data/klotski.ui
index a450a15..0a7ce14 100644
--- a/data/klotski.ui
+++ b/data/klotski.ui
@@ -313,7 +313,6 @@
<!-- <initial-focus name=""/> -->
<property name="width-request">600</property>
<property name="height-request">400</property>
- <property name="border-width">25</property> <!-- TODO a view margin -->
<signal name="size_allocate" handler="on_size_allocate"/>
<signal name="window_state_event" handler="on_window_state_event"/>
<signal name="destroy" handler="on_destroy"/>
@@ -376,7 +375,36 @@
</object>
</child>
<child>
- <placeholder/>
+ <object class="GtkOverlay" id="main_overlay">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkGrid" id="main_grid">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="margin">25</property> <!-- TODO use CSS -->
+ </object>
+ </child>
+ <child type="overlay">
+ <object class="GtkButton" id="unfullscreen_button">
+ <property name="visible">False</property>
+ <property name="halign">end</property>
+ <property name="valign">start</property>
+ <property name="action-name">win.unfullscreen</property>
+ <style>
+ <class name="image-button"/>
+ <class name="unfullscreen-button"/>
+ <class name="flat"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">view-restore-symbolic</property>
+ <property name="visible">True</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
</child>
</template>
</interface>
diff --git a/src/klotski-window.vala b/src/klotski-window.vala
index 96ff447..6df0bc8 100644
--- a/src/klotski-window.vala
+++ b/src/klotski-window.vala
@@ -54,6 +54,9 @@ private class KlotskiWindow : ApplicationWindow
[GtkChild] private TreeView treeview_challenge;
[GtkChild] private TreeView treeview_skill;
+ [GtkChild] private Grid main_grid;
+ [GtkChild] private Button unfullscreen_button;
+
/* Actions, to disable or enable */
private SimpleAction prev_pack;
private SimpleAction next_pack;
@@ -456,12 +459,13 @@ private class KlotskiWindow : ApplicationWindow
private const GLib.ActionEntry win_actions [] =
{
- { "show-scores", show_scores },
- { "prev-pack", prev_pack_cb },
- { "next-pack", next_pack_cb },
- { "prev-puzzle", prev_puzzle_cb },
- { "next-puzzle", next_puzzle_cb },
- { "start-game", start_puzzle_cb }
+ { "show-scores", show_scores },
+ { "prev-pack", prev_pack_cb },
+ { "next-pack", next_pack_cb },
+ { "prev-puzzle", prev_puzzle_cb },
+ { "next-puzzle", next_puzzle_cb },
+ { "start-game", start_puzzle_cb },
+ { "unfullscreen", unfullscreen }
};
private static string normalize_map_name (string name)
@@ -595,7 +599,9 @@ private class KlotskiWindow : ApplicationWindow
view.halign = Align.FILL;
view.can_focus = true;
view.show ();
- add (view);
+ view.hexpand = true;
+ view.vexpand = true;
+ main_grid.add (view);
load_solved_state (); // TODO use GSettings, or the history…
@@ -631,13 +637,13 @@ private class KlotskiWindow : ApplicationWindow
window_is_maximized = (event.new_window_state & Gdk.WindowState.MAXIMIZED) != 0;
/* fullscreen: saved as maximized */
- // bool window_was_fullscreen = window_is_fullscreen;
+ bool window_was_fullscreen = window_is_fullscreen;
if ((event.changed_mask & Gdk.WindowState.FULLSCREEN) != 0)
window_is_fullscreen = (event.new_window_state & Gdk.WindowState.FULLSCREEN) != 0;
- // if (window_was_fullscreen && !window_is_fullscreen)
- // on_unfullscreen ();
- // else if (!window_was_fullscreen && window_is_fullscreen)
- // on_fullscreen ();
+ if (window_was_fullscreen && !window_is_fullscreen)
+ on_unfullscreen ();
+ else if (!window_was_fullscreen && window_is_fullscreen)
+ on_fullscreen ();
/* tiled: not saved, but should not change saved window size */
Gdk.WindowState tiled_state = Gdk.WindowState.TILED;
@@ -650,8 +656,14 @@ private class KlotskiWindow : ApplicationWindow
return false;
}
- // protected void on_fullscreen () {}
- // protected void on_unfullscreen () {}
+ protected void on_fullscreen ()
+ {
+ unfullscreen_button.show ();
+ }
+ protected void on_unfullscreen ()
+ {
+ unfullscreen_button.hide ();
+ }
[GtkCallback]
private void on_destroy ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]