[gnome-games/wip/exalm/libhandy2: 6/21] preferences-window: Wrap titlebar into a HdyTitleBar



commit 01bf8a6349d5cf851bc0b7aece340c004fdf8d3f
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Mon Sep 17 16:16:35 2018 +0500

    preferences-window: Wrap titlebar into a HdyTitleBar
    
    Also stop setting .selection-mode style class manually, and use
    'selection-mode' property on the HdyTitleBar instead.
    
    This will allow to avoid some glitches in the subsequent commits.

 data/ui/preferences-window.ui   | 35 ++++++++++++++++++++---------------
 src/main.vala                   |  2 ++
 src/ui/gamepad-configurer.vala  |  2 --
 src/ui/keyboard-configurer.vala |  2 --
 src/ui/preferences-window.vala  |  3 +++
 5 files changed, 25 insertions(+), 19 deletions(-)
---
diff --git a/data/ui/preferences-window.ui b/data/ui/preferences-window.ui
index 938a25f1..43066663 100644
--- a/data/ui/preferences-window.ui
+++ b/data/ui/preferences-window.ui
@@ -8,24 +8,29 @@
     <property name="default-height">500</property>
     <property name="window-position">GTK_WIN_POS_CENTER_ON_PARENT</property>
     <child type="titlebar">
-      <object class="GtkBox" id="titlebar_box">
+      <object class="HdyTitleBar" id="titlebar">
         <property name="visible">True</property>
         <child>
-          <object class="GtkHeaderBar" id="left_header_bar">
-            <property name="name">left_header_bar</property>
+          <object class="GtkBox" id="titlebar_box">
             <property name="visible">True</property>
-            <property name="title" translatable="yes">Preferences</property>
-            <property name="show-close-button">True</property>
-            <property name="decoration_layout">menu</property>
-          </object>
-        </child>
-        <child>
-          <object class="GtkSeparator" id="header_separator">
-            <property name="orientation">vertical</property>
-            <property name="visible">True</property>
-            <style>
-              <class name="sidebar"/>
-            </style>
+            <child>
+              <object class="GtkHeaderBar" id="left_header_bar">
+                <property name="name">left_header_bar</property>
+                <property name="visible">True</property>
+                <property name="title" translatable="yes">Preferences</property>
+                <property name="show-close-button">True</property>
+                <property name="decoration_layout">menu</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkSeparator" id="header_separator">
+                <property name="orientation">vertical</property>
+                <property name="visible">True</property>
+                <style>
+                  <class name="sidebar"/>
+                </style>
+              </object>
+            </child>
           </object>
         </child>
       </object>
diff --git a/src/main.vala b/src/main.vala
index accb61fa..ea5640da 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -7,6 +7,8 @@ int main (string[] args) {
 
        Grl.init (ref args);
 
+       typeof (Hdy.TitleBar).ensure ();
+
        var app = new Games.Application ();
        var result = app.run (args);
 
diff --git a/src/ui/gamepad-configurer.vala b/src/ui/gamepad-configurer.vala
index d60f33c6..0fff223d 100644
--- a/src/ui/gamepad-configurer.vala
+++ b/src/ui/gamepad-configurer.vala
@@ -75,7 +75,6 @@ private class Games.GamepadConfigurer : Gtk.Box {
 
                                /* translators: testing a gamepad, %s is its name */
                                header_bar.title = _("Testing %s").printf (device.get_name ());
-                               header_bar.get_style_context ().remove_class ("selection-mode");
                                gamepad_view_stack.visible_child = tester;
                                action_bar_stack.visible_child = tester_action_bar;
 
@@ -87,7 +86,6 @@ private class Games.GamepadConfigurer : Gtk.Box {
                        case State.CONFIGURE:
                                /* translators: configuring a gamepad, %s is its name */
                                header_bar.title = _("Configuring %s").printf (device.get_name ());
-                               header_bar.get_style_context ().add_class ("selection-mode");
                                gamepad_view_stack.visible_child = mapper;
                                action_bar_stack.visible_child = mapper_action_bar;
 
diff --git a/src/ui/keyboard-configurer.vala b/src/ui/keyboard-configurer.vala
index e18588ef..449477bd 100644
--- a/src/ui/keyboard-configurer.vala
+++ b/src/ui/keyboard-configurer.vala
@@ -65,7 +65,6 @@ private class Games.KeyboardConfigurer : Gtk.Box {
                                reset_button.set_sensitive (!mapping_manager.is_default ());
 
                                header_bar.title = _("Testing Keyboard");
-                               header_bar.get_style_context ().remove_class ("selection-mode");
                                gamepad_view_stack.visible_child = tester;
                                action_bar_stack.visible_child = tester_action_bar;
 
@@ -76,7 +75,6 @@ private class Games.KeyboardConfigurer : Gtk.Box {
                                break;
                        case State.CONFIGURE:
                                header_bar.title = _("Configuring Keyboard");
-                               header_bar.get_style_context ().add_class ("selection-mode");
                                gamepad_view_stack.visible_child = mapper;
                                action_bar_stack.visible_child = mapper_action_bar;
 
diff --git a/src/ui/preferences-window.vala b/src/ui/preferences-window.vala
index 6a89c1e2..33acaf1a 100644
--- a/src/ui/preferences-window.vala
+++ b/src/ui/preferences-window.vala
@@ -2,6 +2,8 @@
 
 [GtkTemplate (ui = "/org/gnome/Games/ui/preferences-window.ui")]
 private class Games.PreferencesWindow : Gtk.Window {
+       [GtkChild]
+       private Hdy.TitleBar titlebar;
        [GtkChild]
        private Gtk.Box titlebar_box;
        [GtkChild]
@@ -33,6 +35,7 @@ private class Games.PreferencesWindow : Gtk.Window {
        public bool immersive_mode {
                get { return _immersive_mode; }
                set {
+                       titlebar.selection_mode = value;
                        header_separator.visible = !value;
                        left_header_bar.visible = !value;
                        separator.visible = !value;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]