[gnome-games/wip/exalm/rebrand: 124/124] display-view: Use HdyFlap for the snapshots list
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/rebrand: 124/124] display-view: Use HdyFlap for the snapshots list
- Date: Sat, 19 Jun 2021 14:37:47 +0000 (UTC)
commit e93531d918d2adbefdb74070719140acee2cfde7
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sat Jun 19 19:35:33 2021 +0500
display-view: Use HdyFlap for the snapshots list
src/meson.build | 1 -
src/ui/display-bin.vala | 35 ----------
src/ui/display-view.ui | 18 +++--
src/ui/display-view.vala | 20 +++---
src/ui/snapshots-list.ui | 159 +++++++++++++++++++++------------------------
src/ui/snapshots-list.vala | 20 ++----
6 files changed, 99 insertions(+), 154 deletions(-)
---
diff --git a/src/meson.build b/src/meson.build
index d0aabac0..6b2629d9 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -163,7 +163,6 @@ vala_sources = [
'ui/collection-view.vala',
'ui/collections-main-page.vala',
'ui/collections-page.vala',
- 'ui/display-bin.vala',
'ui/display-view.vala',
'ui/error-info-bar.vala',
'ui/flash-box.vala',
diff --git a/src/ui/display-view.ui b/src/ui/display-view.ui
index 344d51c9..8800db9b 100644
--- a/src/ui/display-view.ui
+++ b/src/ui/display-view.ui
@@ -204,13 +204,21 @@
</object>
</child>
<child>
- <object class="GtkBox" id="display_box">
+ <object class="HdyFlap" id="display_flap">
<property name="visible">True</property>
- <child>
+ <property name="flap-position">end</property>
+ <property name="reveal-flap" bind-source="GamesDisplayView"
bind-property="is-showing-snapshots" bind-flags="bidirectional|sync-create"/>
+ <property name="locked">True</property>
+ <property name="swipe-to-open">False</property>
+ <property name="modal">False</property>
+ <signal name="notify::reveal-progress" handler="maybe_resume_game"/>
+ <signal name="notify::reveal-flap" handler="maybe_resume_game"/>
+ <child type="content">
<object class="GtkOverlay">
<property name="visible">True</property>
+ <property name="width-request">360</property>
<child>
- <object class="GamesDisplayBin" id="display_bin">
+ <object class="GtkEventBox" id="display_bin">
<property name="visible">True</property>
<property name="hexpand">True</property>
</object>
@@ -223,12 +231,10 @@
</child>
</object>
</child>
- <child>
+ <child type="flap">
<object class="GamesSnapshotsList" id="snapshots_list">
<property name="visible">True</property>
<property name="halign">end</property>
- <property name="is-revealed" bind-source="GamesDisplayView"
bind-property="is-showing-snapshots" bind-flags="bidirectional"/>
- <signal name="hidden" handler="on_snapshots_hidden"/>
</object>
</child>
</object>
diff --git a/src/ui/display-view.vala b/src/ui/display-view.vala
index 8261ca37..78384ce9 100644
--- a/src/ui/display-view.vala
+++ b/src/ui/display-view.vala
@@ -29,9 +29,9 @@ private class Games.DisplayView : Gtk.Box, UiView {
[GtkChild]
private unowned Gtk.Button restart_btn;
[GtkChild]
- private unowned Gtk.Box display_box;
+ private unowned Hdy.Flap display_flap;
[GtkChild]
- private unowned DisplayBin display_bin;
+ private unowned Gtk.EventBox display_bin;
[GtkChild]
private unowned FullscreenBox fullscreen_box;
[GtkChild]
@@ -82,7 +82,7 @@ private class Games.DisplayView : Gtk.Box, UiView {
if (runner == null)
return;
- stack.visible_child = display_box;
+ stack.visible_child = display_flap;
var display = runner.get_display ();
set_display (display);
@@ -620,8 +620,8 @@ private class Games.DisplayView : Gtk.Box, UiView {
}
[GtkCallback]
- private void on_snapshots_hidden () {
- if (window.is_active) {
+ private void maybe_resume_game () {
+ if (window.is_active && display_flap.reveal_progress <= 0 && !display_flap.reveal_flap) {
runner.resume ();
runner.get_display ().grab_focus ();
}
@@ -674,8 +674,10 @@ private class Games.DisplayView : Gtk.Box, UiView {
}
private void show_snapshots () {
- if (runner != null)
+ if (runner != null) {
is_showing_snapshots = true;
+ snapshots_list.reveal ();
+ }
}
private void restart () {
@@ -744,12 +746,6 @@ private class Games.DisplayView : Gtk.Box, UiView {
display_bin.remove (child);
}
- protected override void size_allocate (Gtk.Allocation allocation) {
- display_bin.child_width = allocation.width;
-
- base.size_allocate (allocation);
- }
-
[GtkCallback]
private void update_fullscreen_box () {
var is_menu_open = media_button.active ||
diff --git a/src/ui/snapshots-list.ui b/src/ui/snapshots-list.ui
index dd4199ff..45689264 100644
--- a/src/ui/snapshots-list.ui
+++ b/src/ui/snapshots-list.ui
@@ -2,118 +2,109 @@
<interface>
<requires lib="gtk+" version="3.24"/>
<template class="GamesSnapshotsList" parent="GtkBox">
- <signal name="notify::is-revealed" handler="on_revealed_changed"/>
<style>
<class name="background"/>
</style>
<child>
- <object class="GtkRevealer">
+ <object class="GtkBox">
<property name="visible">True</property>
- <property name="transition-type">slide-left</property>
- <property name="reveal-child" bind-source="GamesSnapshotsList" bind-property="is-revealed"
bind-flags="sync-create|bidirectional"/>
- <signal name="notify::child-revealed" handler="on_revealer_transition_end"/>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkBox">
+ <object class="GtkScrolledWindow" id="scrolled_window">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
+ <property name="vexpand">True</property>
+ <property name="hscrollbar-policy">never</property>
+ <property name="width-request">360</property>
<child>
- <object class="GtkScrolledWindow" id="scrolled_window">
+ <object class="GtkListBox" id="list_box">
<property name="visible">True</property>
- <property name="vexpand">True</property>
- <property name="hscrollbar-policy">never</property>
- <property name="width-request">360</property>
+ <signal name="move-cursor" after="yes" handler="on_move_cursor"/>
+ <signal name="row-activated" after="yes" handler="on_row_activated"/>
+ <style>
+ <class name="sidebar"/>
+ </style>
<child>
- <object class="GtkListBox" id="list_box">
+ <object class="GtkListBoxRow" id="new_snapshot_row">
<property name="visible">True</property>
- <signal name="move-cursor" after="yes" handler="on_move_cursor"/>
- <signal name="row-activated" after="yes" handler="on_row_activated"/>
+ <property name="selectable">False</property>
<style>
- <class name="sidebar"/>
+ <class name="snapshot-row"/>
</style>
<child>
- <object class="GtkListBoxRow" id="new_snapshot_row">
+ <object class="GtkBox">
<property name="visible">True</property>
- <property name="selectable">False</property>
- <style>
- <class name="snapshot-row"/>
- </style>
+ <property name="margin-top">2</property>
+ <property name="margin-bottom">2</property>
+ <property name="margin-start">2</property>
+ <property name="margin-end">2</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">list-add-symbolic</property>
+ <property name="pixel-size">32</property>
+ <property name="width-request">64</property>
+ <property name="height-request">64</property>
+ <property name="margin-top">7</property>
+ <property name="margin-bottom">7</property>
+ <property name="margin-start">7</property>
+ <property name="margin-end">7</property>
+ <style>
+ <class name="snapshot-thumbnail"/>
+ </style>
+ </object>
+ </child>
<child>
- <object class="GtkBox">
+ <object class="GtkLabel">
<property name="visible">True</property>
- <property name="margin-top">2</property>
- <property name="margin-bottom">2</property>
- <property name="margin-start">2</property>
- <property name="margin-end">2</property>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="icon-name">list-add-symbolic</property>
- <property name="pixel-size">32</property>
- <property name="width-request">64</property>
- <property name="height-request">64</property>
- <property name="margin-top">7</property>
- <property name="margin-bottom">7</property>
- <property name="margin-start">7</property>
- <property name="margin-end">7</property>
- <style>
- <class name="snapshot-thumbnail"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="margin-start">6</property>
- <property name="margin-top">3</property>
- <property name="margin-bottom">3</property>
- <property name="margin-end">3</property>
- <property name="label" translatable="yes">Create new snapshot</property>
- <property name="wrap">True</property>
- <style>
- <class name="snapshot-name"/>
- </style>
- </object>
- </child>
+ <property name="margin-start">6</property>
+ <property name="margin-top">3</property>
+ <property name="margin-bottom">3</property>
+ <property name="margin-end">3</property>
+ <property name="label" translatable="yes">Create new snapshot</property>
+ <property name="wrap">True</property>
+ <style>
+ <class name="snapshot-name"/>
+ </style>
</object>
</child>
</object>
</child>
- <style>
- <class name="snapshot-list"/>
- </style>
</object>
</child>
+ <style>
+ <class name="snapshot-list"/>
+ </style>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkActionBar">
+ <property name="visible">True</property>
<child>
- <object class="GtkActionBar">
+ <object class="GtkButton" id="delete_btn">
<property name="visible">True</property>
- <child>
- <object class="GtkButton" id="delete_btn">
- <property name="visible">True</property>
- <property name="use-underline">True</property>
- <property name="label" translatable="yes">_Delete</property>
- <signal name="clicked" handler="on_delete_clicked"/>
- <style>
- <class name="destructive-action"/>
- </style>
- </object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="rename_btn">
- <property name="visible">True</property>
- <property name="use-underline">True</property>
- <property name="label" translatable="yes">_Rename</property>
- <signal name="clicked" handler="on_rename_clicked"/>
- </object>
- <packing>
- <property name="pack-type">start</property>
- </packing>
- </child>
+ <property name="use-underline">True</property>
+ <property name="label" translatable="yes">_Delete</property>
+ <signal name="clicked" handler="on_delete_clicked"/>
+ <style>
+ <class name="destructive-action"/>
+ </style>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="rename_btn">
+ <property name="visible">True</property>
+ <property name="use-underline">True</property>
+ <property name="label" translatable="yes">_Rename</property>
+ <signal name="clicked" handler="on_rename_clicked"/>
</object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
</child>
</object>
</child>
diff --git a/src/ui/snapshots-list.vala b/src/ui/snapshots-list.vala
index 344b6601..b5f726f5 100644
--- a/src/ui/snapshots-list.vala
+++ b/src/ui/snapshots-list.vala
@@ -2,8 +2,6 @@
[GtkTemplate (ui = "/org/gnome/Games/ui/snapshots-list.ui")]
private class Games.SnapshotsList : Gtk.Box {
- public signal void hidden ();
-
[GtkChild]
private unowned Gtk.ListBox list_box;
[GtkChild]
@@ -26,7 +24,6 @@ private class Games.SnapshotsList : Gtk.Box {
private Snapshot selected_snapshot;
- public bool is_revealed { get; set; }
public Runner runner { get; set; }
construct {
@@ -87,19 +84,10 @@ private class Games.SnapshotsList : Gtk.Box {
}
}
- [GtkCallback]
- private void on_revealed_changed () {
- if (is_revealed) {
- runner.pause ();
- populate_list_box ();
- select_snapshot_row (null);
- }
- }
-
- [GtkCallback]
- private void on_revealer_transition_end () {
- if (!is_revealed)
- hidden ();
+ public void reveal () {
+ runner.pause ();
+ populate_list_box ();
+ select_snapshot_row (null);
}
[GtkCallback]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]