[four-in-a-row/arnaudb/wip/gtk4: 20/27] GtkRevealer is not subclassable anymore.



commit 2eed0b0d2e55c24af8fff2cdd8c069bd6ad3bff5
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sun Apr 19 23:49:56 2020 +0200

    GtkRevealer is not subclassable anymore.

 data/ui/game-actionbar-placeholder.ui | 11 ++++++-----
 data/ui/game-actionbar.ui             | 22 +++++++++++-----------
 src/game-actionbar.vala               | 26 ++++++++++++++++++++------
 3 files changed, 37 insertions(+), 22 deletions(-)
---
diff --git a/data/ui/game-actionbar-placeholder.ui b/data/ui/game-actionbar-placeholder.ui
index 2b69eee..67beb24 100644
--- a/data/ui/game-actionbar-placeholder.ui
+++ b/data/ui/game-actionbar-placeholder.ui
@@ -18,12 +18,13 @@
    with this application.  If not, see <https://www.gnu.org/licenses/>.
 -->
 <interface>
-  <requires lib="gtk+" version="3.12"/>
-  <template class="GameActionBarPlaceHolder" parent="GtkRevealer">
-    <property name="visible">True</property>
+  <requires lib="gtk+" version="3.96"/>
+  <template class="GameActionBarPlaceHolder" parent="GtkWidget">
     <child>
-      <object class="GtkDrawingArea" id="placeholder_child">
-        <property name="visible">True</property>
+      <object class="GtkRevealer" id="revealer">
+        <child>
+          <object class="GtkDrawingArea" id="placeholder_child"/>
+        </child>
       </object>
     </child>
   </template>
diff --git a/data/ui/game-actionbar.ui b/data/ui/game-actionbar.ui
index e5b640b..822f8db 100644
--- a/data/ui/game-actionbar.ui
+++ b/data/ui/game-actionbar.ui
@@ -18,19 +18,19 @@
    with this application.  If not, see <https://www.gnu.org/licenses/>.
 -->
 <interface>
-  <requires lib="gtk+" version="3.12"/>
-  <template class="GameActionBar" parent="GtkRevealer">
-    <property name="visible">True</property>
-    <property name="reveal-child">True</property>
+  <requires lib="gtk+" version="3.96"/>
+  <template class="GameActionBar" parent="GtkWidget">
     <child>
-      <object class="GtkActionBar" id="action_bar">
-        <property name="visible">True</property>
+      <object class="GtkRevealer" id="revealer">
         <child>
-          <object class="GtkLabel" id="game_label">
-            <property name="visible">True</property>
-            <style>
-              <class name="game-name-label"/>
-            </style>
+          <object class="GtkActionBar" id="action_bar">
+            <child>
+              <object class="GtkLabel" id="game_label">
+                <style>
+                  <class name="game-name-label"/>
+                </style>
+              </object>
+            </child>
           </object>
         </child>
       </object>
diff --git a/src/game-actionbar.vala b/src/game-actionbar.vala
index 7937db4..3f15e4b 100644
--- a/src/game-actionbar.vala
+++ b/src/game-actionbar.vala
@@ -21,18 +21,22 @@
 using Gtk;
 
 [GtkTemplate (ui = "/org/gnome/Four-in-a-row/ui/game-actionbar.ui")]
-private class GameActionBar : Revealer, AdaptativeWidget
+private class GameActionBar : Widget, AdaptativeWidget
 {
     [CCode (notify = false)] public bool show_actionbar  { private get; protected construct set; default = 
false; }
     [CCode (notify = false)] public bool window_has_name { private get; protected construct set; default = 
false; }
     [CCode (notify = false)] public string  window_name  { private get; protected construct set; default = 
""   ; }
     [CCode (notify = false)] public Widget? game_widget  { private get; protected construct    ; default = 
null ; }
 
+    [GtkChild] private Revealer revealer;
     [GtkChild] private ActionBar action_bar;
     [GtkChild] private Label game_label;
 
     construct
     {
+        BinLayout layout = new BinLayout ();
+        set_layout_manager (layout);
+
         if (game_widget != null)
             action_bar.pack_end ((!) game_widget);
 
@@ -69,7 +73,7 @@ private class GameActionBar : Revealer, AdaptativeWidget
 
     private void update_visibility ()
     {
-        set_reveal_child (is_extra_thin && show_actionbar);
+        revealer.set_reveal_child (is_extra_thin && show_actionbar);
     }
 
     /*\
@@ -91,23 +95,33 @@ private class GameActionBar : Revealer, AdaptativeWidget
 }
 
 [GtkTemplate (ui = "/org/gnome/Four-in-a-row/ui/game-actionbar-placeholder.ui")]
-private class GameActionBarPlaceHolder : Revealer, AdaptativeWidget
+private class GameActionBarPlaceHolder : Widget, AdaptativeWidget
 {
+    [GtkChild] private Revealer revealer;
     [GtkChild] private Widget placeholder_child;
     private GameActionBar actionbar;
 
+    construct
+    {
+        BinLayout layout = new BinLayout ();
+        set_layout_manager (layout);
+    }
+
     internal GameActionBarPlaceHolder (GameActionBar _actionbar)
     {
         actionbar = _actionbar;
         actionbar.size_allocate.connect (set_height);
         set_height ();
-        set_reveal_child (true);    // seems like setting it in the UI file does not work, while it is OK 
for GameActionBar...
+        revealer.set_reveal_child (true);    // seems like setting it in the UI file does not work, while it 
is OK for GameActionBar...
     }
 
     private void set_height ()
     {
         Requisition natural_size;
-        Widget? widget = actionbar.get_child ();
+        Widget? widget = actionbar.get_first_child ();
+        if (widget == null || !(widget is Revealer))
+            assert_not_reached ();
+        widget = ((Revealer) (!) widget).get_child ();
         if (widget == null)
             return;
         ((!) widget).get_preferred_size (/* minimum size */ null, out natural_size);
@@ -125,6 +139,6 @@ private class GameActionBarPlaceHolder : Revealer, AdaptativeWidget
         if (_is_extra_thin == is_extra_thin)
             return;
         is_extra_thin = _is_extra_thin;
-        set_reveal_child (is_extra_thin);
+        revealer.set_reveal_child (is_extra_thin);
     }
 }


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