[gnome-games/wip/exalm/unified-window: 17/26] display-header-bar: Merge into DisplayView
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/unified-window: 17/26] display-header-bar: Merge into DisplayView
- Date: Fri, 10 Apr 2020 18:12:19 +0000 (UTC)
commit 2ec5c6340950fff826995b05b4d24ce9114929d7
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Apr 10 18:15:29 2020 +0500
display-header-bar: Merge into DisplayView
data/org.gnome.Games.gresource.xml | 1 -
data/ui/display-header-bar.ui | 205 -------------------------------------
data/ui/display-view.ui | 202 ++++++++++++++++++++++++++++++++++--
src/meson.build | 1 -
src/ui/display-header-bar.vala | 118 ---------------------
src/ui/display-view.vala | 105 ++++++++++++++++---
src/ui/fullscreen-box.vala | 27 +----
7 files changed, 288 insertions(+), 371 deletions(-)
---
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index 4c3f2b92..2988d6f8 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -14,7 +14,6 @@
<file preprocess="xml-stripblanks">ui/checkmark-item.ui</file>
<file preprocess="xml-stripblanks">ui/collection-icon-view.ui</file>
<file preprocess="xml-stripblanks">ui/collection-view.ui</file>
- <file preprocess="xml-stripblanks">ui/display-header-bar.ui</file>
<file preprocess="xml-stripblanks">ui/display-view.ui</file>
<file preprocess="xml-stripblanks">ui/empty-collection.ui</file>
<file preprocess="xml-stripblanks">ui/empty-search.ui</file>
diff --git a/data/ui/display-view.ui b/data/ui/display-view.ui
index e726e51a..ac5330c3 100644
--- a/data/ui/display-view.ui
+++ b/data/ui/display-view.ui
@@ -4,20 +4,192 @@
<template class="GamesDisplayView" parent="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
- <signal name="notify::is-showing-snapshots" handler="update_fullscreen_box"/>
- <signal name="notify::is-fullscreen" handler="update_fullscreen_box"/>
+ <signal name="notify::is-showing-snapshots" handler="on_showing_snapshots_changed"/>
+ <signal name="notify::can-fullscreen" handler="on_fullscreen_changed"/>
+ <signal name="notify::is-fullscreen" handler="on_fullscreen_changed"/>
<child>
<object class="GamesFullscreenBox" id="fullscreen_box">
<property name="visible">True</property>
<property name="is-fullscreen" bind-source="GamesDisplayView" bind-property="is-fullscreen"
bind-flags="bidirectional"/>
<child type="titlebar">
- <object class="GamesDisplayHeaderBar" id="header_bar">
+ <object class="GtkStack" id="headerbar_stack">
<property name="visible">True</property>
- <property name="can-fullscreen" bind-source="GamesDisplayView" bind-property="can-fullscreen"
bind-flags="bidirectional"/>
- <property name="game-title" bind-source="GamesDisplayView" bind-property="game-title"
bind-flags="bidirectional"/>
- <property name="is-showing-snapshots" bind-source="GamesDisplayView"
bind-property="is-showing-snapshots" bind-flags="bidirectional"/>
- <signal name="notify::is-menu-open" handler="update_fullscreen_box"/>
- <signal name="back" handler="on_header_bar_back"/>
+ <property name="transition-type">crossfade</property>
+ <property name="transition-duration">250</property>
+ <child>
+ <object class="HdyHeaderBar" id="ingame_header_bar">
+ <property name="visible">True</property>
+ <property name="title" bind-source="GamesDisplayView" bind-property="game-title"
bind-flags="bidirectional"/>
+ <property name="show-close-button" bind-source="GamesDisplayView"
bind-property="is-fullscreen" bind-flags="bidirectional|sync-create|invert-boolean"/>
+ <style>
+ <class name="titlebar"/>
+ </style>
+ <child>
+ <object class="GtkButton" id="back">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">center</property>
+ <signal name="clicked" handler="on_back_clicked"/>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="a11y-back">
+ <property name="accessible-name" translatable="yes">Back</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage" id="back_image">
+ <property name="visible">True</property>
+ <property name="icon-name">go-previous-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="restore">
+ <property name="visible">False</property>
+ <property name="can_focus">False</property>
+ <property name="valign">center</property>
+ <signal name="clicked" handler="on_restore_clicked"/>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="a11y-restore">
+ <property name="accessible-name" translatable="yes">Restore</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage" id="restore_image">
+ <property name="visible">True</property>
+ <property name="icon-name">view-restore-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkMenuButton" id="secondary_menu_button">
+ <property name="visible">False</property>
+ <property name="valign">center</property>
+ <property name="can-focus">False</property>
+ <property name="menu-model">secondary_menu</property>
+ <signal name="notify::active" handler="update_fullscreen_box"/>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">view-more-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="fullscreen">
+ <property name="visible">False</property>
+ <property name="can_focus">False</property>
+ <property name="valign">center</property>
+ <signal name="clicked" handler="on_fullscreen_clicked"/>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="a11y-fullscreen">
+ <property name="accessible-name" translatable="yes">Fullscreen</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage" id="fullscreen_image">
+ <property name="visible">True</property>
+ <property name="icon-name">view-fullscreen-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GamesMediaMenuButton" id="media_button">
+ <signal name="notify::active" handler="update_fullscreen_box"/>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GamesInputModeSwitcher" id="input_mode_switcher">
+ <property name="visible">False</property>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyHeaderBar" id="snapshots_header_bar">
+ <property name="visible">True</property>
+ <property name="title" bind-source="GamesDisplayView" bind-property="game-title"
bind-flags="bidirectional"/>
+ <style>
+ <class name="titlebar"/>
+ </style>
+ <child>
+ <object class="GtkButton">
+ <property name="sensitive">False</property>
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <property name="use-underline">True</property>
+ <property name="label" translatable="yes">_Load</property>
+ <property name="action-name">display.load-snapshot</property>
+ <style>
+ <class name="suggested-action"/>
+ </style>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">center</property>
+ <signal name="clicked" handler="on_back_clicked"/>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="a11y-snapshots-back">
+ <property name="accessible-name" translatable="yes">Back</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">go-previous-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ </object>
+ </child>
</object>
</child>
<child>
@@ -65,4 +237,18 @@
</object>
</child>
</template>
+ <menu id="secondary_menu">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Restart</attribute>
+ <attribute name="action">display.restart</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Snapshots</attribute>
+ <attribute name="action">display.show-snapshots</attribute>
+ </item>
+ </section>
+ </menu>
</interface>
diff --git a/src/meson.build b/src/meson.build
index fa59a126..be8606fa 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -102,7 +102,6 @@ vala_sources = [
'ui/collection-icon-view.vala',
'ui/collection-view.vala',
'ui/display-bin.vala',
- 'ui/display-header-bar.vala',
'ui/display-view.vala',
'ui/empty-collection.vala',
'ui/empty-search.vala',
diff --git a/src/ui/display-view.vala b/src/ui/display-view.vala
index 3af0229a..740cd301 100644
--- a/src/ui/display-view.vala
+++ b/src/ui/display-view.vala
@@ -6,6 +6,22 @@ private class Games.DisplayView : Gtk.Box, UiView {
public signal void back ();
+ [GtkChild]
+ private Gtk.Stack headerbar_stack;
+ [GtkChild]
+ private Hdy.HeaderBar ingame_header_bar;
+ [GtkChild]
+ private Gtk.Button fullscreen;
+ [GtkChild]
+ private Gtk.Button restore;
+ [GtkChild]
+ private Gtk.MenuButton secondary_menu_button;
+ [GtkChild]
+ private Hdy.HeaderBar snapshots_header_bar;
+ [GtkChild]
+ private MediaMenuButton media_button;
+ [GtkChild]
+ private InputModeSwitcher input_mode_switcher;
[GtkChild]
private Gtk.Stack stack;
[GtkChild]
@@ -17,8 +33,6 @@ private class Games.DisplayView : Gtk.Box, UiView {
[GtkChild]
private FullscreenBox fullscreen_box;
[GtkChild]
- private DisplayHeaderBar header_bar;
- [GtkChild]
private FlashBox flash_box;
[GtkChild]
private SnapshotsList snapshots_list;
@@ -50,6 +64,7 @@ private class Games.DisplayView : Gtk.Box, UiView {
public bool can_fullscreen { get; set; }
public bool is_fullscreen { get; set; }
public bool is_showing_snapshots { get; set; }
+ public bool is_menu_open { get; set; }
public string game_title { get; set; }
private Runner _runner;
@@ -63,7 +78,6 @@ private class Games.DisplayView : Gtk.Box, UiView {
_runner = value;
remove_display ();
- header_bar.runner = runner;
if (runner == null)
return;
@@ -72,11 +86,41 @@ private class Games.DisplayView : Gtk.Box, UiView {
set_display (display);
snapshots_list.runner = value;
+ input_mode_switcher.runner = value;
+
+ if (runner != null)
+ extra_widget = runner.get_extra_widget ();
+ else
+ extra_widget = null;
+
+ secondary_menu_button.visible = runner != null && runner.is_integrated;
runner.snapshot_created.connect (flash_box.flash);
}
}
+ private HeaderBarWidget _extra_widget;
+ private HeaderBarWidget extra_widget {
+ get { return _extra_widget; }
+ set {
+ if (extra_widget == value)
+ return;
+
+ if (extra_widget != null) {
+ extra_widget.disconnect (extra_widget_notify_block_autohide_id);
+ ingame_header_bar.remove (extra_widget);
+ extra_widget_notify_block_autohide_id = 0;
+ }
+
+ _extra_widget = value;
+
+ if (extra_widget != null) {
+ extra_widget_notify_block_autohide_id =
extra_widget.notify["block-autohide"].connect (update_fullscreen_box);
+ ingame_header_bar.pack_end (extra_widget);
+ }
+ }
+ }
+
private Settings settings;
private Cancellable run_game_cancellable;
@@ -88,6 +132,8 @@ private class Games.DisplayView : Gtk.Box, UiView {
private RestartDialog restart_dialog;
private long focus_out_timeout_id;
+ private ulong extra_widget_notify_block_autohide_id;
+
private Game game;
private SimpleActionGroup action_group;
@@ -136,8 +182,9 @@ private class Games.DisplayView : Gtk.Box, UiView {
if (runner == null)
return false;
- if (is_showing_snapshots)
- return snapshots_list.on_key_press_event (keyval, event.state & default_modifiers);
+ if (is_showing_snapshots &&
+ snapshots_list.on_key_press_event (keyval, event.state & default_modifiers))
+ return true;
if (runner.key_press_event (keyval, event.state & default_modifiers))
return true;
@@ -330,7 +377,7 @@ private class Games.DisplayView : Gtk.Box, UiView {
return;
can_fullscreen = runner.can_fullscreen;
- header_bar.media_set = runner.media_set;
+ media_button.media_set = runner.media_set;
runner.crash.connect (message => {
runner.stop ();
@@ -539,7 +586,7 @@ private class Games.DisplayView : Gtk.Box, UiView {
private void reset_display_page () {
can_fullscreen = false;
runner = null;
- header_bar.media_set = null;
+ media_button.media_set = null;
update_actions ();
}
@@ -676,14 +723,48 @@ private class Games.DisplayView : Gtk.Box, UiView {
}
[GtkCallback]
- private void on_header_bar_back () {
+ private void update_fullscreen_box () {
+ var is_menu_open = media_button.active ||
+ secondary_menu_button.active ||
+ (extra_widget != null && extra_widget.block_autohide);
+
+ fullscreen_box.autohide = !is_menu_open &&
+ !is_showing_snapshots;
+ fullscreen_box.overlay = is_fullscreen && !is_showing_snapshots;
+ }
+
+ [GtkCallback]
+ private void on_fullscreen_changed () {
+ fullscreen.visible = can_fullscreen && !is_fullscreen;
+ restore.visible = can_fullscreen && is_fullscreen;
+
+ update_fullscreen_box ();
+ }
+
+ [GtkCallback]
+ private void on_showing_snapshots_changed () {
+ update_fullscreen_box ();
+
+ if (is_showing_snapshots)
+ headerbar_stack.visible_child = snapshots_header_bar;
+ else
+ headerbar_stack.visible_child = ingame_header_bar;
+ }
+
+ [GtkCallback]
+ private void on_back_clicked () {
on_display_back ();
}
[GtkCallback]
- private void update_fullscreen_box () {
- fullscreen_box.autohide = !header_bar.is_menu_open &&
- !is_showing_snapshots;
- fullscreen_box.overlay = is_fullscreen && !is_showing_snapshots;
+ private void on_fullscreen_clicked () {
+ is_fullscreen = true;
+ settings.set_boolean ("fullscreen", true);
+ }
+
+ [GtkCallback]
+ private void on_restore_clicked () {
+ is_fullscreen = false;
+ settings.set_boolean ("fullscreen", false);
}
}
diff --git a/src/ui/fullscreen-box.vala b/src/ui/fullscreen-box.vala
index 60ec5342..41f1b857 100644
--- a/src/ui/fullscreen-box.vala
+++ b/src/ui/fullscreen-box.vala
@@ -56,32 +56,9 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
}
}
- private Gtk.Widget _header_bar;
- public Gtk.Widget header_bar {
- get { return _header_bar; }
- set {
- if (header_bar == value)
- return;
-
- if (fullscreen_binding != null) {
- fullscreen_binding.unbind ();
- fullscreen_binding = null;
- }
-
- _header_bar = value;
-
- if (header_bar != null)
- fullscreen_binding = bind_property ("is-fullscreen", header_bar,
- "is-fullscreen",
- BindingFlags.BIDIRECTIONAL);
- }
- }
-
[GtkChild]
private TitlebarBox titlebar_box;
- private Binding fullscreen_binding;
-
private uint ui_timeout_id;
private uint cursor_timeout_id;
@@ -98,10 +75,8 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
return;
}
- if (type == "titlebar") {
+ if (type == "titlebar")
titlebar_box.titlebar = widget;
- header_bar = widget;
- }
else
titlebar_box.add (widget);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]