[gnome-games/wip/exalm/unified-window: 22/26] preferences-subpage: Move headerbar within the window
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/unified-window: 22/26] preferences-subpage: Move headerbar within the window
- Date: Fri, 10 Apr 2020 18:12:44 +0000 (UTC)
commit c07023ca94d45efa9bc190d8cf5da20dd9d14bd1
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Apr 10 19:03:29 2020 +0500
preferences-subpage: Move headerbar within the window
data/ui/preferences-subpage-gamepad.ui | 80 +++++++++++++++++---------------
data/ui/preferences-subpage-keyboard.ui | 80 +++++++++++++++++---------------
src/ui/preferences-subpage-gamepad.vala | 15 +++---
src/ui/preferences-subpage-keyboard.vala | 15 +++---
src/ui/preferences-subpage.vala | 2 -
src/ui/preferences-window.vala | 16 -------
6 files changed, 98 insertions(+), 110 deletions(-)
---
diff --git a/data/ui/preferences-subpage-gamepad.ui b/data/ui/preferences-subpage-gamepad.ui
index a526be79..ebe4d1de 100644
--- a/data/ui/preferences-subpage-gamepad.ui
+++ b/data/ui/preferences-subpage-gamepad.ui
@@ -4,6 +4,48 @@
<template class="GamesPreferencesSubpageGamepad" parent="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
+ <child>
+ <object class="HdyHeaderBar" id="header_bar">
+ <property name="visible">True</property>
+ <style>
+ <class name="titlebar"/>
+ </style>
+ <child>
+ <object class="GtkButton" id="back_button">
+ <property name="visible">True</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>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="cancel_button">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Cancel</property>
+ <signal name="clicked" handler="on_cancel_clicked"/>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
<child>
<object class="GtkStack" id="gamepad_view_stack">
<property name="visible">True</property>
@@ -69,42 +111,4 @@
</object>
</child>
</template>
- <object class="HdyHeaderBar" id="header_bar">
- <property name="visible">True</property>
- <property name="expand">True</property>
- <child>
- <object class="GtkButton" id="back_button">
- <property name="visible">True</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>
- <packing>
- <property name="pack-type">start</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="cancel_button">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Cancel</property>
- <signal name="clicked" handler="on_cancel_clicked"/>
- </object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
- </child>
- </object>
</interface>
diff --git a/data/ui/preferences-subpage-keyboard.ui b/data/ui/preferences-subpage-keyboard.ui
index 6cf345bb..fd196990 100644
--- a/data/ui/preferences-subpage-keyboard.ui
+++ b/data/ui/preferences-subpage-keyboard.ui
@@ -5,6 +5,48 @@
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="orientation">vertical</property>
+ <child>
+ <object class="HdyHeaderBar" id="header_bar">
+ <property name="visible">True</property>
+ <style>
+ <class name="titlebar"/>
+ </style>
+ <child>
+ <object class="GtkButton" id="back_button">
+ <property name="visible">True</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>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="cancel_button">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Cancel</property>
+ <signal name="clicked" handler="on_cancel_clicked"/>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
<child>
<object class="GtkStack" id="gamepad_view_stack">
<property name="visible">True</property>
@@ -70,42 +112,4 @@
</object>
</child>
</template>
- <object class="HdyHeaderBar" id="header_bar">
- <property name="visible">True</property>
- <property name="expand">True</property>
- <child>
- <object class="GtkButton" id="back_button">
- <property name="visible">True</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>
- <packing>
- <property name="pack-type">start</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="cancel_button">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Cancel</property>
- <signal name="clicked" handler="on_cancel_clicked"/>
- </object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
- </child>
- </object>
</interface>
diff --git a/src/ui/preferences-subpage-gamepad.vala b/src/ui/preferences-subpage-gamepad.vala
index b8633d59..c31a71b6 100644
--- a/src/ui/preferences-subpage-gamepad.vala
+++ b/src/ui/preferences-subpage-gamepad.vala
@@ -40,9 +40,13 @@ private class Games.PreferencesSubpageGamepad : Gtk.Box, PreferencesSubpage {
back_button.visible = (state == State.TEST);
cancel_button.visible = (state == State.CONFIGURE);
header_bar.show_close_button = (state == State.TEST);
- request_selection_mode = (state == State.CONFIGURE);
allow_back = (state == State.TEST);
+ if (state == State.CONFIGURE)
+ header_bar.get_style_context ().add_class ("selection-mode");
+ else
+ header_bar.get_style_context ().remove_class ("selection-mode");
+
switch (value) {
case State.TEST:
reset_button.set_sensitive (device.has_user_mapping ());
@@ -73,16 +77,11 @@ private class Games.PreferencesSubpageGamepad : Gtk.Box, PreferencesSubpage {
get { return _state; }
}
- [GtkChild (name = "header_bar")]
- private Hdy.HeaderBar _header_bar;
- public Hdy.HeaderBar header_bar {
- get { return _header_bar; }
- }
-
- public bool request_selection_mode { get; set; }
public bool allow_back { get; set; }
public string info_message { get; set; }
+ [GtkChild]
+ private Hdy.HeaderBar header_bar;
[GtkChild]
private Gtk.Stack gamepad_view_stack;
[GtkChild]
diff --git a/src/ui/preferences-subpage-keyboard.vala b/src/ui/preferences-subpage-keyboard.vala
index a98edf51..7b57dc89 100644
--- a/src/ui/preferences-subpage-keyboard.vala
+++ b/src/ui/preferences-subpage-keyboard.vala
@@ -36,9 +36,13 @@ private class Games.PreferencesSubpageKeyboard : Gtk.Box, PreferencesSubpage {
back_button.visible = (state == State.TEST);
cancel_button.visible = (state == State.CONFIGURE);
header_bar.show_close_button = (state == State.TEST);
- request_selection_mode = (state == State.CONFIGURE);
allow_back = (state == State.TEST);
+ if (state == State.CONFIGURE)
+ header_bar.get_style_context ().add_class ("selection-mode");
+ else
+ header_bar.get_style_context ().remove_class ("selection-mode");
+
switch (value) {
case State.TEST:
reset_button.set_sensitive (!mapping_manager.is_default ());
@@ -66,16 +70,11 @@ private class Games.PreferencesSubpageKeyboard : Gtk.Box, PreferencesSubpage {
}
}
- [GtkChild (name = "header_bar")]
- private Hdy.HeaderBar _header_bar;
- public Hdy.HeaderBar header_bar {
- get { return _header_bar; }
- }
-
- public bool request_selection_mode { get; set; }
public bool allow_back { get; set; }
public string info_message { get; set; }
+ [GtkChild]
+ private Hdy.HeaderBar header_bar;
[GtkChild]
private Gtk.Stack gamepad_view_stack;
[GtkChild]
diff --git a/src/ui/preferences-subpage.vala b/src/ui/preferences-subpage.vala
index 173199f1..17cf3baf 100644
--- a/src/ui/preferences-subpage.vala
+++ b/src/ui/preferences-subpage.vala
@@ -1,7 +1,5 @@
// This file is part of GNOME Games. License: GPL-3.0+.
private interface Games.PreferencesSubpage : Gtk.Widget {
- public abstract Hdy.HeaderBar header_bar { get; }
- public abstract bool request_selection_mode { get; set; }
public abstract bool allow_back { get; set; }
}
diff --git a/src/ui/preferences-window.vala b/src/ui/preferences-window.vala
index 4da7620a..533eae8c 100644
--- a/src/ui/preferences-window.vala
+++ b/src/ui/preferences-window.vala
@@ -2,13 +2,9 @@
[GtkTemplate (ui = "/org/gnome/Games/ui/preferences-window.ui")]
private class Games.PreferencesWindow : Gtk.Window {
- [GtkChild]
- private Hdy.TitleBar titlebar;
[GtkChild]
private Hdy.Leaflet titlebar_leaflet;
[GtkChild]
- private Gtk.Box titlebar_subpage_box;
- [GtkChild]
private Gtk.HeaderBar right_header_bar;
[GtkChild]
private Hdy.Deck content_deck;
@@ -36,19 +32,11 @@ private class Games.PreferencesWindow : Gtk.Window {
if (subpage != null) {
content_deck.navigate (Hdy.NavigationDirection.BACK);
- selection_mode_binding.unbind ();
swipe_back_binding.unbind ();
}
if (value != null) {
- var header_bar = value.header_bar;
-
content_subpage_box.add (value);
- titlebar_subpage_box.add (header_bar);
-
- selection_mode_binding = value.bind_property ("request-selection-mode",
- titlebar, "selection-mode",
- BindingFlags.SYNC_CREATE);
swipe_back_binding = value.bind_property ("allow-back",
content_deck, "can-swipe-back",
@@ -63,7 +51,6 @@ private class Games.PreferencesWindow : Gtk.Window {
}
private Binding subpage_binding;
- private Binding selection_mode_binding;
private Binding swipe_back_binding;
construct {
@@ -102,9 +89,6 @@ private class Games.PreferencesWindow : Gtk.Window {
foreach (var child in content_subpage_box.get_children ())
content_subpage_box.remove (child);
- foreach (var child in titlebar_subpage_box.get_children ())
- titlebar_subpage_box.remove (child);
-
subpage = null;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]