[gnome-games/wip/abhinavsingh/gamepad-config: 12/25] ui: Allow preferences page to show custom headers
- From: Abhinav Singh <abhinavsingh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/abhinavsingh/gamepad-config: 12/25] ui: Allow preferences page to show custom headers
- Date: Wed, 21 Jun 2017 00:34:37 +0000 (UTC)
commit ffad1738c09935ea93dc7dd087dc323218623805
Author: theawless <theawless gmail com>
Date: Sat Jun 3 13:20:05 2017 +0530
ui: Allow preferences page to show custom headers
src/ui/preferences-page-gamepads.vala | 9 +++++++--
src/ui/preferences-page-plugins.vala | 9 +++++++--
src/ui/preferences-page-video.vala | 9 +++++++--
src/ui/preferences-page.vala | 2 +-
src/ui/preferences-window.vala | 12 ++++++------
5 files changed, 28 insertions(+), 13 deletions(-)
---
diff --git a/src/ui/preferences-page-gamepads.vala b/src/ui/preferences-page-gamepads.vala
index 2485ac8..47d45ea 100644
--- a/src/ui/preferences-page-gamepads.vala
+++ b/src/ui/preferences-page-gamepads.vala
@@ -2,8 +2,10 @@
[GtkTemplate (ui = "/org/gnome/Games/ui/preferences-page-gamepads.ui")]
private class Games.PreferencesPageGamepads: Gtk.Bin, PreferencesPage {
- public string title {
- get { return _("Gamepads"); }
+ private Gtk.Widget _header_content;
+ public Gtk.Widget header_content {
+ get { return _header_content; }
+ protected set { _header_content = value; }
}
[GtkChild]
@@ -11,6 +13,9 @@ private class Games.PreferencesPageGamepads: Gtk.Bin, PreferencesPage {
private GamepadMonitor gamepad_monitor;
construct {
+ header_content = new Gtk.Label (_("Gamepads"));
+ header_content.visible = true;
+
gamepad_monitor = GamepadMonitor.get_instance ();
gamepad_monitor.gamepad_unplugged.connect (rebuild_gamepad_list);
diff --git a/src/ui/preferences-page-plugins.vala b/src/ui/preferences-page-plugins.vala
index 16500b8..c0e8e8d 100644
--- a/src/ui/preferences-page-plugins.vala
+++ b/src/ui/preferences-page-plugins.vala
@@ -2,14 +2,19 @@
[GtkTemplate (ui = "/org/gnome/Games/ui/preferences-page-plugins.ui")]
private class Games.PreferencesPagePlugins: Gtk.Bin, PreferencesPage {
- public string title {
- get { return _("Extensions"); }
+ private Gtk.Widget _header_content;
+ public Gtk.Widget header_content {
+ get { return _header_content; }
+ protected set { _header_content = value; }
}
[GtkChild]
private Gtk.ListBox list_box;
construct {
+ header_content = new Gtk.Label (_("Extensions"));
+ header_content.visible = true;
+
var register = PluginRegister.get_register ();
foreach (var plugin_registrar in register)
add_plugin_registrar (plugin_registrar);
diff --git a/src/ui/preferences-page-video.vala b/src/ui/preferences-page-video.vala
index 7754e59..e01efde 100644
--- a/src/ui/preferences-page-video.vala
+++ b/src/ui/preferences-page-video.vala
@@ -2,8 +2,10 @@
[GtkTemplate (ui = "/org/gnome/Games/ui/preferences-page-video.ui")]
private class Games.PreferencesPageVideo: Gtk.Bin, PreferencesPage {
- public string title {
- get { return _("Video"); }
+ private Gtk.Widget _header_content;
+ public Gtk.Widget header_content {
+ get { return _header_content; }
+ protected set { _header_content = value; }
}
private string _filter_active;
@@ -30,6 +32,9 @@ private class Games.PreferencesPageVideo: Gtk.Bin, PreferencesPage {
private Settings settings;
construct {
+ header_content = new Gtk.Label (_("Video"));
+ header_content.visible = true;
+
foreach (var filter_display_name in filter_display_names) {
var checkmark_item = new CheckmarkItem (filter_display_name);
filter_list_box.add (checkmark_item);
diff --git a/src/ui/preferences-page.vala b/src/ui/preferences-page.vala
index 14b2170..c010998 100644
--- a/src/ui/preferences-page.vala
+++ b/src/ui/preferences-page.vala
@@ -1,5 +1,5 @@
// This file is part of GNOME Games. License: GPL-3.0+.
private interface Games.PreferencesPage: Gtk.Widget {
- public abstract string title { get; }
+ public abstract Gtk.Widget header_content { get; protected set; }
}
diff --git a/src/ui/preferences-window.vala b/src/ui/preferences-window.vala
index 3d1bc0b..32d350a 100644
--- a/src/ui/preferences-window.vala
+++ b/src/ui/preferences-window.vala
@@ -9,15 +9,15 @@ private class Games.PreferencesWindow : Gtk.Window {
public PreferencesWindow () {
stack.foreach ((child) => {
- var page = child as PreferencesPage;
- page.notify["title"].connect (update_title);
+ var page = (PreferencesPage) child;
+ page.notify["header-content"].connect (update_right_header);
});
- stack.notify["visible-child-name"].connect (update_title);
- update_title ();
+ stack.notify["visible-child-name"].connect (update_right_header);
+ update_right_header ();
}
- private void update_title () {
+ private void update_right_header () {
var page = (PreferencesPage) stack.get_visible_child ();
- right_header_bar.title = (page == null) ? "" : page.title;
+ right_header_bar.set_custom_title (page.header_content);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]