[libadwaita/wip/exalm/view-switcher-simple: 7/7] view-switcher-button: Remove non-bold labels
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/view-switcher-simple: 7/7] view-switcher-button: Remove non-bold labels
- Date: Sat, 27 Nov 2021 14:55:59 +0000 (UTC)
commit 91e67752cb511380cf66014995d8f32267f709dc
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Nov 26 23:22:23 2021 +0500
view-switcher-button: Remove non-bold labels
Just make them unconditionally bold.
src/adw-view-switcher-button.c | 63 +++++-------------------------
src/adw-view-switcher-button.ui | 42 ++++----------------
src/stylesheet/widgets/_view-switcher.scss | 7 +---
3 files changed, 18 insertions(+), 94 deletions(-)
---
diff --git a/src/adw-view-switcher-button.c b/src/adw-view-switcher-button.c
index a229baa0..434d8787 100644
--- a/src/adw-view-switcher-button.c
+++ b/src/adw-view-switcher-button.c
@@ -35,15 +35,11 @@ struct _AdwViewSwitcherButton
GtkBox *horizontal_box;
GtkImage *horizontal_image;
- GtkLabel *horizontal_label_active;
- GtkLabel *horizontal_label_inactive;
- GtkStack *horizontal_label_stack;
+ GtkLabel *horizontal_label;
GtkStack *stack;
GtkBox *vertical_box;
GtkImage *vertical_image;
- GtkLabel *vertical_label_active;
- GtkLabel *vertical_label_inactive;
- GtkStack *vertical_label_stack;
+ GtkLabel *vertical_label;
char *icon_name;
char *label;
@@ -72,46 +68,14 @@ adw_view_switcher_button_switch_timeout (AdwViewSwitcherButton *self)
static void
update_mnemonic (AdwViewSwitcherButton *self)
{
- GtkLabel *label;
-
g_assert (ADW_IS_VIEW_SWITCHER_BUTTON (self));
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self))) {
- if (self->orientation == GTK_ORIENTATION_VERTICAL)
- label = self->vertical_label_active;
- else
- label = self->horizontal_label_active;
- } else {
- if (self->orientation == GTK_ORIENTATION_VERTICAL)
- label = self->vertical_label_inactive;
- else
- label = self->horizontal_label_inactive;
- }
-
- gtk_label_set_mnemonic_widget (self->horizontal_label_active,
- (label == self->horizontal_label_active) ? GTK_WIDGET (self) : NULL);
- gtk_label_set_mnemonic_widget (self->horizontal_label_inactive,
- (label == self->horizontal_label_inactive) ? GTK_WIDGET (self) : NULL);
- gtk_label_set_mnemonic_widget (self->vertical_label_active,
- (label == self->vertical_label_active) ? GTK_WIDGET (self) : NULL);
- gtk_label_set_mnemonic_widget (self->vertical_label_inactive,
- (label == self->vertical_label_inactive) ? GTK_WIDGET (self) : NULL);
-}
-
-static void
-active_changed_cb (AdwViewSwitcherButton *self)
-{
- g_assert (ADW_IS_VIEW_SWITCHER_BUTTON (self));
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self))) {
- gtk_stack_set_visible_child (self->horizontal_label_stack, GTK_WIDGET (self->horizontal_label_active));
- gtk_stack_set_visible_child (self->vertical_label_stack, GTK_WIDGET (self->vertical_label_active));
- } else {
- gtk_stack_set_visible_child (self->horizontal_label_stack, GTK_WIDGET (self->horizontal_label_inactive));
- gtk_stack_set_visible_child (self->vertical_label_stack, GTK_WIDGET (self->vertical_label_inactive));
- }
-
- update_mnemonic (self);
+ gtk_label_set_mnemonic_widget (self->horizontal_label,
+ (self->orientation == GTK_ORIENTATION_HORIZONTAL)
+ ? GTK_WIDGET (self) : NULL);
+ gtk_label_set_mnemonic_widget (self->vertical_label,
+ (self->orientation == GTK_ORIENTATION_VERTICAL)
+ ? GTK_WIDGET (self) : NULL);
}
static void
@@ -370,16 +334,11 @@ adw_view_switcher_button_class_init (AdwViewSwitcherButtonClass *klass)
"/org/gnome/Adwaita/ui/adw-view-switcher-button.ui");
gtk_widget_class_bind_template_child (widget_class, AdwViewSwitcherButton, horizontal_box);
gtk_widget_class_bind_template_child (widget_class, AdwViewSwitcherButton, horizontal_image);
- gtk_widget_class_bind_template_child (widget_class, AdwViewSwitcherButton, horizontal_label_active);
- gtk_widget_class_bind_template_child (widget_class, AdwViewSwitcherButton, horizontal_label_inactive);
- gtk_widget_class_bind_template_child (widget_class, AdwViewSwitcherButton, horizontal_label_stack);
+ gtk_widget_class_bind_template_child (widget_class, AdwViewSwitcherButton, horizontal_label);
gtk_widget_class_bind_template_child (widget_class, AdwViewSwitcherButton, stack);
gtk_widget_class_bind_template_child (widget_class, AdwViewSwitcherButton, vertical_box);
gtk_widget_class_bind_template_child (widget_class, AdwViewSwitcherButton, vertical_image);
- gtk_widget_class_bind_template_child (widget_class, AdwViewSwitcherButton, vertical_label_active);
- gtk_widget_class_bind_template_child (widget_class, AdwViewSwitcherButton, vertical_label_inactive);
- gtk_widget_class_bind_template_child (widget_class, AdwViewSwitcherButton, vertical_label_stack);
- gtk_widget_class_bind_template_callback (widget_class, active_changed_cb);
+ gtk_widget_class_bind_template_child (widget_class, AdwViewSwitcherButton, vertical_label);
gtk_widget_class_bind_template_callback (widget_class, drag_enter_cb);
gtk_widget_class_bind_template_callback (widget_class, drag_leave_cb);
gtk_widget_class_bind_template_callback (widget_class, get_badge_text);
@@ -401,8 +360,6 @@ adw_view_switcher_button_init (AdwViewSwitcherButton *self)
gtk_stack_set_visible_child (GTK_STACK (self->stack), GTK_WIDGET (self->horizontal_box));
gtk_widget_set_focus_on_click (GTK_WIDGET (self), FALSE);
-
- active_changed_cb (self);
}
/**
diff --git a/src/adw-view-switcher-button.ui b/src/adw-view-switcher-button.ui
index ceeafaf0..707cda89 100644
--- a/src/adw-view-switcher-button.ui
+++ b/src/adw-view-switcher-button.ui
@@ -2,7 +2,6 @@
<interface domain="libadwaita">
<requires lib="gtk" version="4.0"/>
<template class="AdwViewSwitcherButton" parent="GtkToggleButton">
- <signal name="notify::active" handler="active_changed_cb" after="yes"/>
<style>
<class name="flat"/>
</style>
@@ -37,22 +36,9 @@
</object>
</child>
<child>
- <object class="GtkStack" id="horizontal_label_stack">
- <child>
- <object class="GtkLabel" id="horizontal_label_inactive">
- <property name="label" bind-source="AdwViewSwitcherButton" bind-property="label"
bind-flags="sync-create|bidirectional" />
- <property name="use-underline" bind-source="AdwViewSwitcherButton"
bind-property="use-underline" bind-flags="sync-create|bidirectional" />
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="horizontal_label_active">
- <property name="label" bind-source="AdwViewSwitcherButton" bind-property="label"
bind-flags="sync-create|bidirectional" />
- <property name="use-underline" bind-source="AdwViewSwitcherButton"
bind-property="use-underline" bind-flags="sync-create|bidirectional" />
- <style>
- <class name="active"/>
- </style>
- </object>
- </child>
+ <object class="GtkLabel" id="horizontal_label">
+ <property name="label" bind-source="AdwViewSwitcherButton" bind-property="label"
bind-flags="sync-create|bidirectional" />
+ <property name="use-underline" bind-source="AdwViewSwitcherButton"
bind-property="use-underline" bind-flags="sync-create|bidirectional" />
</object>
</child>
</object>
@@ -85,24 +71,10 @@
</object>
</child>
<child>
- <object class="GtkStack" id="vertical_label_stack">
- <child>
- <object class="GtkLabel" id="vertical_label_inactive">
- <property name="label" bind-source="AdwViewSwitcherButton" bind-property="label"
bind-flags="sync-create|bidirectional" />
- <property name="use-underline" bind-source="AdwViewSwitcherButton"
bind-property="use-underline" bind-flags="sync-create|bidirectional" />
- <property name="ellipsize">end</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="vertical_label_active">
- <property name="label" bind-source="AdwViewSwitcherButton" bind-property="label"
bind-flags="sync-create|bidirectional" />
- <property name="use-underline" bind-source="AdwViewSwitcherButton"
bind-property="use-underline" bind-flags="sync-create|bidirectional" />
- <property name="ellipsize">end</property>
- <style>
- <class name="active"/>
- </style>
- </object>
- </child>
+ <object class="GtkLabel" id="vertical_label">
+ <property name="label" bind-source="AdwViewSwitcherButton" bind-property="label"
bind-flags="sync-create|bidirectional" />
+ <property name="use-underline" bind-source="AdwViewSwitcherButton"
bind-property="use-underline" bind-flags="sync-create|bidirectional" />
+ <property name="ellipsize">end</property>
</object>
</child>
</object>
diff --git a/src/stylesheet/widgets/_view-switcher.scss b/src/stylesheet/widgets/_view-switcher.scss
index b722be38..d499407b 100644
--- a/src/stylesheet/widgets/_view-switcher.scss
+++ b/src/stylesheet/widgets/_view-switcher.scss
@@ -21,8 +21,7 @@ viewswitcher {
}
button.toggle {
- font-size: 1rem;
- font-weight: inherit;
+ font-weight: bold;
padding: 0;
> stack > box {
@@ -42,10 +41,6 @@ viewswitcher {
padding: 2px 12px;
border-spacing: 6px;
}
-
- label.active {
- font-weight: bold;
- }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]