[epiphany/wip/exalm/gtk4-cleanups-3: 9/23] fullscreen-box: Add 'content' property




commit 3eb165cdfb173621a48ae34b68170b6dcba20655
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Wed Dec 1 14:15:25 2021 +0500

    fullscreen-box: Add 'content' property
    
    Stop relying on GtkContainer for this, it will go away in GTK4.
    
    Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1038>

 src/ephy-fullscreen-box.c | 41 ++++++++++++++++++++++++++++++++++++++++-
 src/ephy-fullscreen-box.h | 10 +++++++---
 src/ephy-window.c         |  2 +-
 3 files changed, 48 insertions(+), 5 deletions(-)
---
diff --git a/src/ephy-fullscreen-box.c b/src/ephy-fullscreen-box.c
index 397067ad7..422198a4e 100644
--- a/src/ephy-fullscreen-box.c
+++ b/src/ephy-fullscreen-box.c
@@ -54,6 +54,7 @@ enum {
   PROP_FULLSCREEN,
   PROP_AUTOHIDE,
   PROP_TITLEBAR,
+  PROP_CONTENT,
   PROP_REVEALED,
   LAST_PROP
 };
@@ -305,6 +306,10 @@ ephy_fullscreen_box_get_property (GObject    *object,
       g_value_set_object (value, ephy_fullscreen_box_get_titlebar (self));
       break;
 
+    case PROP_CONTENT:
+      g_value_set_object (value, ephy_fullscreen_box_get_content (self));
+      break;
+
     case PROP_REVEALED:
       g_value_set_boolean (value, hdy_flap_get_reveal_flap (self->flap));
       break;
@@ -335,6 +340,10 @@ ephy_fullscreen_box_set_property (GObject      *object,
       ephy_fullscreen_box_set_titlebar (self, g_value_get_object (value));
       break;
 
+    case PROP_CONTENT:
+      ephy_fullscreen_box_set_content (self, g_value_get_object (value));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
   }
@@ -389,6 +398,13 @@ ephy_fullscreen_box_class_init (EphyFullscreenBoxClass *klass)
                          GTK_TYPE_WIDGET,
                          G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
 
+  props[PROP_CONTENT] =
+    g_param_spec_object ("content",
+                         "Content",
+                         "Content",
+                         GTK_TYPE_WIDGET,
+                         G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+
   props[PROP_REVEALED] =
     g_param_spec_boolean ("revealed",
                           "Revealed",
@@ -458,7 +474,7 @@ ephy_fullscreen_box_buildable_add_child (GtkBuildable *buildable,
   if (!g_strcmp0 (type, "titlebar"))
     ephy_fullscreen_box_set_titlebar (self, GTK_WIDGET (child));
   else
-    gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (child));
+    ephy_fullscreen_box_set_content (self, GTK_WIDGET (child));
 }
 
 static void
@@ -562,3 +578,26 @@ ephy_fullscreen_box_set_titlebar (EphyFullscreenBox *self,
 
   g_object_notify_by_pspec (G_OBJECT (self), props[PROP_TITLEBAR]);
 }
+
+GtkWidget *
+ephy_fullscreen_box_get_content (EphyFullscreenBox *self)
+{
+  g_return_val_if_fail (EPHY_IS_FULLSCREEN_BOX (self), NULL);
+
+  return hdy_flap_get_content (self->flap);
+}
+
+void
+ephy_fullscreen_box_set_content (EphyFullscreenBox *self,
+                                 GtkWidget         *content)
+{
+  g_return_if_fail (EPHY_IS_FULLSCREEN_BOX (self));
+  g_return_if_fail (GTK_IS_WIDGET (content) || content == NULL);
+
+  if (hdy_flap_get_content (self->flap) == content)
+    return;
+
+  hdy_flap_set_content (self->flap, content);
+
+  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CONTENT]);
+}
diff --git a/src/ephy-fullscreen-box.h b/src/ephy-fullscreen-box.h
index 55a1ad93b..ce85c8e42 100644
--- a/src/ephy-fullscreen-box.h
+++ b/src/ephy-fullscreen-box.h
@@ -32,14 +32,18 @@ EphyFullscreenBox *ephy_fullscreen_box_new            (void);
 
 gboolean           ephy_fullscreen_box_get_fullscreen (EphyFullscreenBox *self);
 void               ephy_fullscreen_box_set_fullscreen (EphyFullscreenBox *self,
-                                                       gboolean          fullscreen);
+                                                       gboolean           fullscreen);
 
 gboolean           ephy_fullscreen_box_get_autohide   (EphyFullscreenBox *self);
 void               ephy_fullscreen_box_set_autohide   (EphyFullscreenBox *self,
-                                                       gboolean          autohide);
+                                                       gboolean           autohide);
 
 GtkWidget         *ephy_fullscreen_box_get_titlebar   (EphyFullscreenBox *self);
 void               ephy_fullscreen_box_set_titlebar   (EphyFullscreenBox *self,
-                                                       GtkWidget        *titlebar);
+                                                       GtkWidget         *titlebar);
+
+GtkWidget         *ephy_fullscreen_box_get_content    (EphyFullscreenBox *self);
+void               ephy_fullscreen_box_set_content    (EphyFullscreenBox *self,
+                                                       GtkWidget         *content);
 
 G_END_DECLS
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 563f769b5..2866b76e5 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -3754,7 +3754,7 @@ ephy_window_constructed (GObject *object)
   gtk_box_pack_start (window->titlebar_box, GTK_WIDGET (window->tab_bar_revealer), FALSE, TRUE, 0);
   gtk_box_pack_start (box, GTK_WIDGET (window->tab_view), FALSE, TRUE, 0);
   gtk_box_pack_start (box, GTK_WIDGET (window->action_bar), FALSE, TRUE, 0);
-  gtk_container_add (GTK_CONTAINER (window->fullscreen_box), GTK_WIDGET (box));
+  ephy_fullscreen_box_set_content (window->fullscreen_box, GTK_WIDGET (box));
   ephy_fullscreen_box_set_titlebar (window->fullscreen_box, GTK_WIDGET (window->titlebar_box));
 
   gtk_container_add (GTK_CONTAINER (window->main_deck), GTK_WIDGET (window->fullscreen_box));


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