[nautilus/wip/cdavis/toolbar-refactor: 4/4] window, toolbar: Change toolbar visibility based on size
- From: Christopher Davis <christopherdavis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/cdavis/toolbar-refactor: 4/4] window, toolbar: Change toolbar visibility based on size
- Date: Sat, 23 Jul 2022 04:51:07 +0000 (UTC)
commit fbf2dde5d39f8e5b624ba4e85d3dd152277cc822
Author: Christopher Davis <christopherdavis gnome org>
Date: Fri Jul 22 23:41:35 2022 -0400
window, toolbar: Change toolbar visibility based on size
Show a bottom bar at small sizes, while hiding the start
and end children.
src/nautilus-toolbar.c | 18 ++++++++++++++
src/nautilus-window.c | 46 ++++++++++++++++++++++++++++++++++++
src/resources/ui/nautilus-toolbar.ui | 20 ++++++++++++----
src/resources/ui/nautilus-window.ui | 16 +++++++++++++
4 files changed, 96 insertions(+), 4 deletions(-)
---
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 79275ad3e..6a5c27b78 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -64,6 +64,8 @@ struct _NautilusToolbar
gboolean show_sidebar_button;
gboolean sidebar_button_active;
+ gboolean show_toolbar_children;
+
GtkWidget *search_button;
GtkWidget *location_entry_close_button;
@@ -81,6 +83,7 @@ enum
PROP_SEARCHING,
PROP_SHOW_SIDEBAR_BUTTON,
PROP_SIDEBAR_BUTTON_ACTIVE,
+ PROP_SHOW_TOOLBAR_CHILDREN,
NUM_PROPERTIES
};
@@ -302,6 +305,12 @@ nautilus_toolbar_get_property (GObject *object,
}
break;
+ case PROP_SHOW_TOOLBAR_CHILDREN:
+ {
+ g_value_set_boolean (value, self->show_toolbar_children);
+ }
+ break;
+
default:
{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -419,6 +428,12 @@ nautilus_toolbar_set_property (GObject *object,
}
break;
+ case PROP_SHOW_TOOLBAR_CHILDREN:
+ {
+ self->show_toolbar_children = g_value_get_boolean (value);
+ }
+ break;
+
default:
{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -510,6 +525,9 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass)
properties[PROP_SIDEBAR_BUTTON_ACTIVE] =
g_param_spec_boolean ("sidebar-button-active", NULL, NULL, FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ properties[PROP_SHOW_TOOLBAR_CHILDREN] =
+ g_param_spec_boolean ("show-toolbar-children", NULL, NULL, TRUE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 7316c76cf..47aafe3bd 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -131,6 +131,8 @@ struct _NautilusWindow
GtkWidget *tab_menu;
GQueue *tab_data_queue;
+
+ gboolean mobile;
};
enum
@@ -147,6 +149,7 @@ G_DEFINE_TYPE (NautilusWindow, nautilus_window, ADW_TYPE_APPLICATION_WINDOW);
enum {
PROP_0,
PROP_ACTIVE_SLOT,
+ PROP_MOBILE,
N_PROPS
};
@@ -1603,6 +1606,36 @@ nautilus_window_initialize_actions (NautilusWindow *window)
action, "enabled", G_BINDING_SYNC_CREATE);
}
+static gboolean
+nautilus_window_get_mobile (NautilusWindow *self)
+{
+ return self->mobile;
+}
+
+static void
+nautilus_window_set_mobile (NautilusWindow *self,
+ gboolean mobile)
+{
+ if (self->mobile == mobile)
+ {
+ return;
+ }
+
+ self->mobile = mobile;
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MOBILE]);
+}
+
+static void
+nautilus_window_size_allocate (GtkWidget *self,
+ int width,
+ int height,
+ int baseline)
+{
+ GTK_WIDGET_CLASS (nautilus_window_parent_class)->size_allocate (self, width, height, baseline);
+
+ nautilus_window_set_mobile (NAUTILUS_WINDOW (self), width < 700);
+}
static void
nautilus_window_constructed (GObject *self)
@@ -2233,6 +2266,9 @@ nautilus_window_get_property (GObject *object,
case PROP_ACTIVE_SLOT:
g_value_set_object (value, G_OBJECT (nautilus_window_get_active_slot (self)));
break;
+ case PROP_MOBILE:
+ g_value_set_boolean (value, nautilus_window_get_mobile (self));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -2251,6 +2287,9 @@ nautilus_window_set_property (GObject *object,
case PROP_ACTIVE_SLOT:
nautilus_window_set_active_slot (self, NAUTILUS_WINDOW_SLOT (g_value_get_object (value)));
break;
+ case PROP_MOBILE:
+ nautilus_window_set_mobile (self, g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -2272,6 +2311,7 @@ nautilus_window_class_init (NautilusWindowClass *class)
wclass->show = nautilus_window_show;
wclass->realize = nautilus_window_realize;
wclass->grab_focus = nautilus_window_grab_focus;
+ wclass->size_allocate = nautilus_window_size_allocate;
winclass->close_request = nautilus_window_close_request;
@@ -2281,6 +2321,12 @@ nautilus_window_class_init (NautilusWindowClass *class)
NAUTILUS_TYPE_WINDOW_SLOT,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+ properties[PROP_MOBILE] =
+ g_param_spec_boolean ("mobile",
+ NULL, NULL,
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+
g_object_class_install_properties (oclass, N_PROPS, properties);
gtk_widget_class_set_template_from_resource (wclass,
diff --git a/src/resources/ui/nautilus-toolbar.ui b/src/resources/ui/nautilus-toolbar.ui
index c324f6591..d29bc95f7 100644
--- a/src/resources/ui/nautilus-toolbar.ui
+++ b/src/resources/ui/nautilus-toolbar.ui
@@ -126,8 +126,14 @@
</object>
</child>
<child type="start">
- <object class="NautilusToolbarStart">
- <property name="window-slot" bind-source="NautilusToolbar" bind-property="window-slot"
bind-flags="sync-create"/>
+ <object class="GtkRevealer">
+ <property name="reveal-child" bind-source="NautilusToolbar"
bind-property="show-toolbar-children" bind-flags="sync-create"/>
+ <property name="transition-type">slide-right</property>
+ <property name="child">
+ <object class="NautilusToolbarStart">
+ <property name="window-slot" bind-source="NautilusToolbar" bind-property="window-slot"
bind-flags="sync-create"/>
+ </object>
+ </property>
</object>
</child>
<child type="end">
@@ -163,8 +169,14 @@
</object>
</child>
<child type="end">
- <object class="NautilusToolbarEnd">
- <property name="window-slot" bind-source="NautilusToolbar" bind-property="window-slot"
bind-flags="sync-create"/>
+ <object class="GtkRevealer">
+ <property name="reveal-child" bind-source="NautilusToolbar"
bind-property="show-toolbar-children" bind-flags="sync-create"/>
+ <property name="transition-type">slide-left</property>
+ <property name="child">
+ <object class="NautilusToolbarEnd">
+ <property name="window-slot" bind-source="NautilusToolbar" bind-property="window-slot"
bind-flags="sync-create"/>
+ </object>
+ </property>
</object>
</child>
</object>
diff --git a/src/resources/ui/nautilus-window.ui b/src/resources/ui/nautilus-window.ui
index 1b72e2e6b..eb724faa0 100644
--- a/src/resources/ui/nautilus-window.ui
+++ b/src/resources/ui/nautilus-window.ui
@@ -40,6 +40,7 @@
<object class="NautilusToolbar" id="toolbar">
<property name="show-sidebar-button" bind-source="content_flap" bind-property="folded"
bind-flags="sync-create"/>
<property name="sidebar-button-active" bind-source="content_flap"
bind-property="reveal-flap" bind-flags="bidirectional|sync-create"/>
+ <property name="show-toolbar-children" bind-source="NautilusWindow" bind-property="mobile"
bind-flags="sync-create|invert-boolean"/>
<property name="window-slot" bind-source="NautilusWindow" bind-property="active-slot"
bind-flags="sync-create"/>
</object>
</child>
@@ -68,6 +69,21 @@
</child>
</object>
</child>
+ <child>
+ <object class="GtkActionBar">
+ <property name="revealed" bind-source="NautilusWindow" bind-property="mobile"
bind-flags="sync-create"/>
+ <child type="start">
+ <object class="NautilusToolbarStart">
+ <property name="window-slot" bind-source="NautilusWindow" bind-property="active-slot"
bind-flags="sync-create"/>
+ </object>
+ </child>
+ <child type="end">
+ <object class="NautilusToolbarEnd">
+ <property name="window-slot" bind-source="NautilusWindow" bind-property="active-slot"
bind-flags="sync-create"/>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</property>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]