[gnome-taquin] Add unfullscreen button.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-taquin] Add unfullscreen button.
- Date: Thu, 21 Feb 2019 16:32:46 +0000 (UTC)
commit d29909cef17af48249328c358947fb8c64864203
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu Feb 21 17:26:48 2019 +0100
Add unfullscreen button.
data/base-window.ui | 29 +++++++++++++++++++++++++++--
data/taquin.css | 4 ++++
src/adaptative-window.vala | 7 +++++++
src/base-window.vala | 15 ++++++++++++++-
4 files changed, 52 insertions(+), 3 deletions(-)
---
diff --git a/data/base-window.ui b/data/base-window.ui
index 22e39e3..87931be 100644
--- a/data/base-window.ui
+++ b/data/base-window.ui
@@ -21,9 +21,34 @@
<property name="visible">False</property>
<signal name="key-press-event" handler="on_key_press_event"/>
<child>
- <object class="GtkGrid" id="main_grid">
+ <object class="GtkOverlay">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkGrid" id="main_grid">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ </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">base.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>
diff --git a/data/taquin.css b/data/taquin.css
index daecc7e..4a0482b 100644
--- a/data/taquin.css
+++ b/data/taquin.css
@@ -17,6 +17,10 @@
@import url("base-window.css");
+button.unfullscreen-button {
+ margin:6px;
+}
+
/* hack: fix the double spacing around the centerwidget box, on extra-thin window (visible with big moves
count) */
.extra-thin-window.thin-window button.new-game-button { margin-right:-6px; }
diff --git a/src/adaptative-window.vala b/src/adaptative-window.vala
index 3f85b65..e182c5f 100644
--- a/src/adaptative-window.vala
+++ b/src/adaptative-window.vala
@@ -229,8 +229,13 @@ private abstract class AdaptativeWindow : ApplicationWindow
window_is_maximized = (event.new_window_state & Gdk.WindowState.MAXIMIZED) != 0;
/* fullscreen: saved as maximized */
+ 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 ();
/* tiled: not saved, but should not change saved window size */
Gdk.WindowState tiled_state = Gdk.WindowState.TILED
@@ -243,6 +248,8 @@ private abstract class AdaptativeWindow : ApplicationWindow
return false;
}
+ protected abstract void on_fullscreen ();
+ protected abstract void on_unfullscreen ();
[GtkCallback]
private void on_size_allocate (Allocation allocation)
diff --git a/src/base-window.vala b/src/base-window.vala
index 52b0613..3d69ec5 100644
--- a/src/base-window.vala
+++ b/src/base-window.vala
@@ -73,12 +73,23 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
\*/
[GtkChild] private Grid main_grid;
+ [GtkChild] private Button unfullscreen_button;
protected void add_to_main_grid (Widget widget)
{
main_grid.add (widget);
}
+ protected override void on_fullscreen ()
+ {
+ unfullscreen_button.show ();
+ }
+
+ protected override void on_unfullscreen ()
+ {
+ unfullscreen_button.hide ();
+ }
+
/*\
* * action entries
\*/
@@ -105,7 +116,9 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
{ "show-default-view", show_default_view },
{ "help", help },
- { "about", about }
+ { "about", about },
+
+ { "unfullscreen", unfullscreen }
};
/*\
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]