[libadwaita/wip/exalm/tab-bg] tab-box: Remove bg from a single expanded tab
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/tab-bg] tab-box: Remove bg from a single expanded tab
- Date: Tue, 26 Jul 2022 19:13:38 +0000 (UTC)
commit 96eb23068e648632e06b7dd26187befd517c9793
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Jul 26 23:12:50 2022 +0400
tab-box: Remove bg from a single expanded tab
This is mainly for Builder, to avoid a super prominent tab when there's
only one.
src/adw-tab-box.c | 27 +++++++++++++++++++++++++++
src/stylesheet/widgets/_tab-view.scss | 10 ++++++++++
2 files changed, 37 insertions(+)
---
diff --git a/src/adw-tab-box.c b/src/adw-tab-box.c
index 4dfc5b0d..7d5e9c74 100644
--- a/src/adw-tab-box.c
+++ b/src/adw-tab-box.c
@@ -495,6 +495,24 @@ update_separators (AdwTabBox *self)
}
}
+/* Single tab style */
+
+static void
+update_single_tab_style (AdwTabBox *self)
+{
+ if (self->pinned)
+ return;
+
+ if (self->view &&
+ adw_tab_view_get_n_pages (self->view) <= 1 &&
+ adw_tab_view_get_n_pinned_pages (self->view) == 0 &&
+ self->expand_tabs &&
+ self->tab_resize_mode == TAB_RESIZE_NORMAL)
+ gtk_widget_add_css_class (GTK_WIDGET (self), "single-tab");
+ else
+ gtk_widget_remove_css_class (GTK_WIDGET (self), "single-tab");
+}
+
/* Tab resize delay */
static void
@@ -567,6 +585,8 @@ set_tab_resize_mode (AdwTabBox *self,
self->tab_resize_mode = mode;
+ update_single_tab_style (self);
+
if (notify)
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_RESIZE_FROZEN]);
}
@@ -3793,6 +3813,11 @@ adw_tab_box_set_view (AdwTabBox *self,
g_signal_connect_object (self->view, "page-reordered", G_CALLBACK (page_reordered_cb), self,
G_CONNECT_SWAPPED);
if (!self->pinned) {
+ g_signal_connect_object (self->view, "notify::n-pages", G_CALLBACK (update_single_tab_style), self,
G_CONNECT_SWAPPED);
+ g_signal_connect_object (self->view, "notify::n-pinned-pages", G_CALLBACK (update_single_tab_style),
self, G_CONNECT_SWAPPED);
+
+ update_single_tab_style (self);
+
self->view_drop_target = GTK_EVENT_CONTROLLER (gtk_drop_target_new (ADW_TYPE_TAB_PAGE,
GDK_ACTION_MOVE));
g_signal_connect_object (self->view_drop_target, "drop", G_CALLBACK (view_drag_drop_cb), self,
G_CONNECT_SWAPPED);
@@ -3937,6 +3962,8 @@ adw_tab_box_set_expand_tabs (AdwTabBox *self,
self->expand_tabs = expand_tabs;
+ update_single_tab_style (self);
+
gtk_widget_queue_resize (GTK_WIDGET (self));
}
diff --git a/src/stylesheet/widgets/_tab-view.scss b/src/stylesheet/widgets/_tab-view.scss
index 4b608780..b18dabf4 100644
--- a/src/stylesheet/widgets/_tab-view.scss
+++ b/src/stylesheet/widgets/_tab-view.scss
@@ -51,6 +51,16 @@ tabbar {
&:active { background-color: $view_active_color; }
}
+ tabbox.single-tab tab {
+ &, &:hover, &:active {
+ background: none;
+
+ @if $contrast == 'high' {
+ box-shadow: none;
+ }
+ }
+ }
+
.start-action,
.end-action {
padding: 5px;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]