[gnome-games/wip/exalm/rebrand: 34/124] preferences: Use HdyPreferencesWindow
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/rebrand: 34/124] preferences: Use HdyPreferencesWindow
- Date: Sat, 19 Jun 2021 14:37:44 +0000 (UTC)
commit 3003f798eed42a091aeaf023cb1367928c379b2a
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Wed Mar 24 20:43:47 2021 +0500
preferences: Use HdyPreferencesWindow
src/preferences/preferences-page-controllers.ui | 3 +-
src/preferences/preferences-page-platforms.ui | 3 +-
src/preferences/preferences-page-video.ui | 3 +-
src/preferences/preferences-window.ui | 87 ++++---------------------
src/preferences/preferences-window.vala | 38 ++---------
5 files changed, 23 insertions(+), 111 deletions(-)
---
diff --git a/src/preferences/preferences-page-controllers.ui b/src/preferences/preferences-page-controllers.ui
index 3c8ee7c0..d79b2be4 100644
--- a/src/preferences/preferences-page-controllers.ui
+++ b/src/preferences/preferences-page-controllers.ui
@@ -2,7 +2,8 @@
<interface>
<requires lib="gtk+" version="3.24"/>
<template class="GamesPreferencesPageControllers" parent="HdyPreferencesPage">
- <property name="visible">True</property>
+ <property name="title" translatable="yes">Controllers</property>
+ <property name="icon-name">applications-games-symbolic</property>
<child>
<object class="HdyPreferencesGroup" id="gamepads_group">
<property name="visible">True</property>
diff --git a/src/preferences/preferences-page-platforms.ui b/src/preferences/preferences-page-platforms.ui
index 1a91c052..26f9a490 100644
--- a/src/preferences/preferences-page-platforms.ui
+++ b/src/preferences/preferences-page-platforms.ui
@@ -2,7 +2,8 @@
<interface>
<requires lib="gtk+" version="3.24"/>
<template class="GamesPreferencesPagePlatforms" parent="HdyPreferencesPage">
- <property name="visible">True</property>
+ <property name="title" translatable="yes">Platforms</property>
+ <property name="icon-name">view-list-bullet-symbolic</property>
<child>
<object class="HdyPreferencesGroup" id="platforms_group">
<property name="visible">True</property>
diff --git a/src/preferences/preferences-page-video.ui b/src/preferences/preferences-page-video.ui
index f6ad4e36..c97636bd 100644
--- a/src/preferences/preferences-page-video.ui
+++ b/src/preferences/preferences-page-video.ui
@@ -2,7 +2,8 @@
<interface>
<requires lib="gtk+" version="3.24"/>
<template class="GamesPreferencesPageVideo" parent="HdyPreferencesPage">
- <property name="visible">True</property>
+ <property name="title" translatable="yes">Video</property>
+ <property name="icon-name">video-display-symbolic</property>
<child>
<object class="HdyPreferencesGroup" id="filter_group">
<property name="visible">True</property>
diff --git a/src/preferences/preferences-window.ui b/src/preferences/preferences-window.ui
index f7cd1b99..b19e2deb 100644
--- a/src/preferences/preferences-window.ui
+++ b/src/preferences/preferences-window.ui
@@ -1,86 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.24"/>
- <template class="GamesPreferencesWindow" parent="HdyWindow">
+ <template class="GamesPreferencesWindow" parent="HdyPreferencesWindow">
<property name="title" translatable="yes">Preferences</property>
<property name="default-width">650</property>
<property name="default-height">500</property>
- <property name="window-position">center-on-parent</property>
<child>
- <object class="HdyDeck" id="deck">
+ <object class="GamesPreferencesPageVideo">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GamesPreferencesPageControllers">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GamesPreferencesPagePlatforms">
<property name="visible">True</property>
- <signal name="notify::transition-running" handler="try_remove_subpage"/>
- <signal name="notify::visible-child" handler="try_remove_subpage"/>
- <child>
- <object class="GtkBox" id="main_box">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="HdyHeaderBar">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Preferences</property>
- <property name="show-close-button">True</property>
- <property name="centering-policy">strict</property>
- <child type="title">
- <object class="HdyViewSwitcherTitle" id="switcher_title">
- <property name="visible">True</property>
- <property name="title" bind-source="GamesPreferencesWindow" bind-property="title"/>
- <property name="stack">stack</property>
- <property name="policy">narrow</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkStack" id="stack">
- <property name="visible">True</property>
- <property name="visible-child">video_page</property>
- <property name="transition-type">crossfade</property>
- <property name="width-request">300</property>
- <child>
- <object class="GamesPreferencesPageVideo" id="video_page">
- <property name="visible">True</property>
- </object>
- <packing>
- <property name="title" translatable="yes">Video</property>
- <property name="icon-name">video-display-symbolic</property>
- </packing>
- </child>
- <child>
- <object class="GamesPreferencesPageControllers" id="controllers_page">
- <property name="visible">True</property>
- </object>
- <packing>
- <property name="title" translatable="yes">Controllers</property>
- <property name="icon-name">applications-games-symbolic</property>
- </packing>
- </child>
- <child>
- <object class="GamesPreferencesPagePlatforms" id="platforms_page">
- <property name="visible">True</property>
- </object>
- <packing>
- <property name="title" translatable="yes">Platforms</property>
- <property name="icon-name">view-list-bullet-symbolic</property>
- </packing>
- </child>
- </object>
- </child>
- <child>
- <object class="HdyViewSwitcherBar">
- <property name="visible">True</property>
- <property name="stack">stack</property>
- <property name="reveal" bind-source="switcher_title" bind-property="title-visible"/>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkBox" id="subpage_box">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- </object>
- </child>
</object>
</child>
</template>
diff --git a/src/preferences/preferences-window.vala b/src/preferences/preferences-window.vala
index 17bfc301..1d6c1f70 100644
--- a/src/preferences/preferences-window.vala
+++ b/src/preferences/preferences-window.vala
@@ -1,46 +1,18 @@
// This file is part of GNOME Games. License: GPL-3.0+.
[GtkTemplate (ui = "/org/gnome/Games/preferences/preferences-window.ui")]
-private class Games.PreferencesWindow : Hdy.Window {
- [GtkChild]
- private unowned Hdy.Deck deck;
- [GtkChild]
- private unowned Gtk.Box main_box;
- [GtkChild]
- private unowned Gtk.Box subpage_box;
-
- private PreferencesSubpage subpage;
+private class Games.PreferencesWindow : Hdy.PreferencesWindow {
private Binding swipe_back_binding;
- [GtkCallback]
- public void try_remove_subpage () {
- if (deck.transition_running ||
- deck.visible_child != main_box ||
- subpage == null)
- return;
-
- subpage_box.remove (subpage);
-
- subpage = null;
- }
-
public void open_subpage (PreferencesSubpage subpage) {
- if (this.subpage != null)
- return;
-
- this.subpage = subpage;
-
- swipe_back_binding = subpage.bind_property ("allow-back", deck,
- "can-swipe-back",
- BindingFlags.SYNC_CREATE);
-
- subpage_box.add (subpage);
+ swipe_back_binding = subpage.bind_property (
+ "allow-back", this, "can-swipe-back", BindingFlags.SYNC_CREATE);
subpage.back.connect (() => {
- deck.navigate (Hdy.NavigationDirection.BACK);
swipe_back_binding.unbind ();
+ close_subpage ();
});
- deck.navigate (Hdy.NavigationDirection.FORWARD);
+ present_subpage (subpage);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]