[libadwaita/wip/exalm/tab-overview: 4/15] tab-list-base: Drop depending on AdwTabBar




commit cadd5f6864a50dca66e8a9f191670710ac6575ae
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri Aug 20 23:04:20 2021 +0500

    tab-list-base: Drop depending on AdwTabBar

 src/adw-tab-bar.c               |  3 +++
 src/adw-tab-bar.ui              |  2 --
 src/adw-tab-box-private.h       |  6 +++++-
 src/adw-tab-box.c               | 20 ++++++++++++++++++++
 src/adw-tab-list-base-private.h |  2 ++
 src/adw-tab-list-base.c         | 24 +++---------------------
 6 files changed, 33 insertions(+), 24 deletions(-)
---
diff --git a/src/adw-tab-bar.c b/src/adw-tab-bar.c
index 6a67c2f4..be95045a 100644
--- a/src/adw-tab-bar.c
+++ b/src/adw-tab-bar.c
@@ -625,6 +625,9 @@ adw_tab_bar_init (AdwTabBar *self)
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
+  adw_tab_box_set_tab_bar (ADW_TAB_BOX (self->box), self);
+  adw_tab_box_set_tab_bar (ADW_TAB_BOX (self->pinned_box), self);
+
   adj = gtk_scrolled_window_get_hadjustment (self->scrolled_window);
   g_signal_connect_object (adj, "changed", G_CALLBACK (update_is_overflowing),
                            self, G_CONNECT_SWAPPED);
diff --git a/src/adw-tab-bar.ui b/src/adw-tab-bar.ui
index c6f68e0c..123c132e 100644
--- a/src/adw-tab-bar.ui
+++ b/src/adw-tab-bar.ui
@@ -32,7 +32,6 @@
                 <child>
                   <object class="AdwTabBox" id="pinned_box">
                     <property name="pinned">True</property>
-                    <property name="tab-bar">AdwTabBar</property>
                     <signal name="notify::needs-attention-left" handler="notify_needs_attention_pinned_cb" 
swapped="true"/>
                     <signal name="notify::needs-attention-right" handler="notify_needs_attention_pinned_cb" 
swapped="true"/>
                     <signal name="notify::resize-frozen" handler="notify_resize_frozen_cb" swapped="true"/>
@@ -51,7 +50,6 @@
                 <property name="min-content-width">100</property>
                 <child>
                   <object class="AdwTabBox" id="box">
-                    <property name="tab-bar">AdwTabBar</property>
                     <signal name="notify::needs-attention-left" handler="notify_needs_attention_cb" 
swapped="true"/>
                     <signal name="notify::needs-attention-right" handler="notify_needs_attention_cb" 
swapped="true"/>
                     <signal name="notify::resize-frozen" handler="notify_resize_frozen_cb" swapped="true"/>
diff --git a/src/adw-tab-box-private.h b/src/adw-tab-box-private.h
index 8c852e44..4a7057ea 100644
--- a/src/adw-tab-box-private.h
+++ b/src/adw-tab-box-private.h
@@ -12,13 +12,17 @@
 #error "Only <adwaita.h> can be included directly."
 #endif
 
-#include <gtk/gtk.h>
 #include "adw-tab-list-base-private.h"
 
+#include "adw-tab-bar-private.h"
+
 G_BEGIN_DECLS
 
 #define ADW_TYPE_TAB_BOX (adw_tab_box_get_type())
 
 G_DECLARE_FINAL_TYPE (AdwTabBox, adw_tab_box, ADW, TAB_BOX, AdwTabListBase)
 
+void adw_tab_box_set_tab_bar (AdwTabBox *self,
+                              AdwTabBar *tab_bar);
+
 G_END_DECLS
diff --git a/src/adw-tab-box.c b/src/adw-tab-box.c
index 32a86f42..729a4c84 100644
--- a/src/adw-tab-box.c
+++ b/src/adw-tab-box.c
@@ -12,14 +12,27 @@
 struct _AdwTabBox
 {
   AdwTabListBase parent_instance;
+
+  AdwTabBar *tab_bar;
 };
 
 G_DEFINE_TYPE (AdwTabBox, adw_tab_box, ADW_TYPE_TAB_LIST_BASE)
 
+static gboolean
+adw_tab_box_tabs_have_visible_focus (AdwTabListBase *base)
+{
+  AdwTabBox *self = ADW_TAB_BOX (base);
+
+  return adw_tab_bar_tabs_have_visible_focus (self->tab_bar);
+}
+
 static void
 adw_tab_box_class_init (AdwTabBoxClass *klass)
 {
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+  AdwTabListBaseClass *base_class = ADW_TAB_LIST_BASE_CLASS (klass);
+
+  base_class->tabs_have_visible_focus = adw_tab_box_tabs_have_visible_focus;
 
   gtk_widget_class_set_css_name (widget_class, "tabbox");
 }
@@ -28,3 +41,10 @@ static void
 adw_tab_box_init (AdwTabBox *self)
 {
 }
+
+void
+adw_tab_box_set_tab_bar (AdwTabBox *self,
+                         AdwTabBar *tab_bar)
+{
+  self->tab_bar = tab_bar;
+}
diff --git a/src/adw-tab-list-base-private.h b/src/adw-tab-list-base-private.h
index 84ea6999..e196bd29 100644
--- a/src/adw-tab-list-base-private.h
+++ b/src/adw-tab-list-base-private.h
@@ -24,6 +24,8 @@ G_DECLARE_DERIVABLE_TYPE (AdwTabListBase, adw_tab_list_base, ADW, TAB_LIST_BASE,
 struct _AdwTabListBaseClass
 {
   GtkWidgetClass parent_class;
+
+  gboolean (*tabs_have_visible_focus) (AdwTabListBase *self);
 };
 
 void adw_tab_list_base_set_view (AdwTabListBase *self,
diff --git a/src/adw-tab-list-base.c b/src/adw-tab-list-base.c
index 92c324f5..ddf453f5 100644
--- a/src/adw-tab-list-base.c
+++ b/src/adw-tab-list-base.c
@@ -14,7 +14,6 @@
 #include "adw-animation-private.h"
 #include "adw-gizmo-private.h"
 #include "adw-tab-private.h"
-#include "adw-tab-bar-private.h"
 #include "adw-tab-view-private.h"
 #include <math.h>
 
@@ -77,7 +76,6 @@ typedef struct {
 
 typedef struct {
   gboolean pinned;
-  AdwTabBar *tab_bar;
   AdwTabView *view;
   GtkAdjustment *adjustment;
   gboolean needs_attention_left;
@@ -164,7 +162,6 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (AdwTabListBase, adw_tab_list_base, GTK_TYPE_WI
 enum {
   PROP_0,
   PROP_PINNED,
-  PROP_TAB_BAR,
   PROP_VIEW,
   PROP_NEEDS_ATTENTION_LEFT,
   PROP_NEEDS_ATTENTION_RIGHT,
@@ -1660,7 +1657,7 @@ select_page (AdwTabListBase *self,
     return;
   }
 
-  if (adw_tab_bar_tabs_have_visible_focus (priv->tab_bar))
+  if (ADW_TAB_LIST_BASE_GET_CLASS (self)->tabs_have_visible_focus (self))
     gtk_widget_grab_focus (GTK_WIDGET (priv->selected_tab->tab));
 
   gtk_widget_set_focus_child (GTK_WIDGET (self),
@@ -2843,7 +2840,8 @@ handle_click (AdwTabListBase *self,
     }
   }
 
-  can_grab_focus = adw_tab_bar_tabs_have_visible_focus (priv->tab_bar);
+  can_grab_focus = ADW_TAB_LIST_BASE_GET_CLASS (self)->tabs_have_visible_focus (self);
+
 
   if (info == priv->selected_tab)
     can_grab_focus = TRUE;
@@ -3329,7 +3327,6 @@ adw_tab_list_base_dispose (GObject *object)
   g_clear_pointer (&priv->background, gtk_widget_unparent);
 
   priv->drag_gesture = NULL;
-  priv->tab_bar = NULL;
   adw_tab_list_base_set_view (self, NULL);
   set_hadjustment (self, NULL);
 
@@ -3361,10 +3358,6 @@ adw_tab_list_base_get_property (GObject    *object,
     g_value_set_boolean (value, priv->pinned);
     break;
 
-  case PROP_TAB_BAR:
-    g_value_set_object (value, priv->tab_bar);
-    break;
-
   case PROP_VIEW:
     g_value_set_object (value, priv->view);
     break;
@@ -3409,10 +3402,6 @@ adw_tab_list_base_set_property (GObject      *object,
     priv->pinned = g_value_get_boolean (value);
     break;
 
-  case PROP_TAB_BAR:
-    priv->tab_bar = g_value_get_object (value);
-    break;
-
   case PROP_VIEW:
     adw_tab_list_base_set_view (self, g_value_get_object (value));
     break;
@@ -3457,13 +3446,6 @@ adw_tab_list_base_class_init (AdwTabListBaseClass *klass)
                           FALSE,
                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
 
-  props[PROP_TAB_BAR] =
-    g_param_spec_object ("tab-bar",
-                         "Tab Bar",
-                         "Tab Bar",
-                         ADW_TYPE_TAB_BAR,
-                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
-
   props[PROP_VIEW] =
     g_param_spec_object ("view",
                          "View",


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