[nautilus/wip/cdavis/adaptive-flap: 169/178] general: Use libhandy and HdyFlap
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/cdavis/adaptive-flap: 169/178] general: Use libhandy and HdyFlap
- Date: Mon, 22 Feb 2021 10:43:58 +0000 (UTC)
commit e4e8dec38306659ebb5f69fd7c610fd8ea3612bf
Author: Christopher Davis <brainblasted disroot org>
Date: Tue Nov 17 12:51:04 2020 -0800
general: Use libhandy and HdyFlap
Use libhandy + HdyFlap for an initial adaptive sidebar.
build-aux/flatpak/org.gnome.Nautilus.json | 1 +
src/nautilus-window.c | 66 +------------------------------
src/resources/ui/nautilus-window.ui | 14 +++----
3 files changed, 8 insertions(+), 73 deletions(-)
---
diff --git a/build-aux/flatpak/org.gnome.Nautilus.json b/build-aux/flatpak/org.gnome.Nautilus.json
index ac9b215e0..ae68cbbf5 100644
--- a/build-aux/flatpak/org.gnome.Nautilus.json
+++ b/build-aux/flatpak/org.gnome.Nautilus.json
@@ -22,6 +22,7 @@
"--filesystem=~/.config/dconf:ro",
"--talk-name=ca.desrt.dconf",
"--env=DCONF_USER_CONFIG_DIR=.config/dconf",
+ "--env=GTK_DEBUG=interactive",
"--add-policy=Tracker3.dbus:org.freedesktop.Tracker3.Miner.Files=tracker:FileSystem;tracker:Documents"
],
"modules": [
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 73fe741b7..49d0314dc 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -108,10 +108,9 @@ struct _NautilusWindow
GList *slots;
NautilusWindowSlot *active_slot;
- GtkWidget *content_paned;
+ GtkWidget *content_flap;
/* Side Pane */
- int side_pane_width;
GtkWidget *sidebar; /* container for the GtkPlacesSidebar */
GtkWidget *places_sidebar; /* the actual GtkPlacesSidebar */
GVolume *selected_volume; /* the selected volume in the sidebar popup callback */
@@ -882,60 +881,6 @@ nautilus_window_get_notebook (NautilusWindow *window)
return window->notebook;
}
-static gboolean
-save_sidebar_width_cb (gpointer user_data)
-{
- NautilusWindow *window = user_data;
-
-
- window->sidebar_width_handler_id = 0;
-
- DEBUG ("Saving sidebar width: %d", window->side_pane_width);
-
- g_settings_set_int (nautilus_window_state,
- NAUTILUS_WINDOW_STATE_SIDEBAR_WIDTH,
- window->side_pane_width);
-
- return FALSE;
-}
-
-/* side pane helpers */
-static void
-side_pane_size_allocate_callback (GtkWidget *widget,
- GtkAllocation *allocation,
- gpointer user_data)
-{
- NautilusWindow *window = user_data;
-
-
- if (window->sidebar_width_handler_id != 0)
- {
- g_source_remove (window->sidebar_width_handler_id);
- window->sidebar_width_handler_id = 0;
- }
-
- if (allocation->width != window->side_pane_width &&
- allocation->width > 1)
- {
- window->side_pane_width = allocation->width;
-
- window->sidebar_width_handler_id =
- g_idle_add (save_sidebar_width_cb, window);
- }
-}
-
-static void
-setup_side_pane_width (NautilusWindow *window)
-{
- g_return_if_fail (window->sidebar != NULL);
-
- window->side_pane_width =
- g_settings_get_int (nautilus_window_state,
- NAUTILUS_WINDOW_STATE_SIDEBAR_WIDTH);
-
- gtk_paned_set_position (GTK_PANED (window->content_paned),
- window->side_pane_width);
-}
/* Callback used when the places sidebar changes location; we need to change the displayed folder */
static void
@@ -1379,12 +1324,6 @@ places_sidebar_populate_popup_cb (GtkPlacesSidebar *sidebar,
static void
nautilus_window_set_up_sidebar (NautilusWindow *window)
{
- setup_side_pane_width (window);
- g_signal_connect (window->sidebar,
- "size-allocate",
- G_CALLBACK (side_pane_size_allocate_callback),
- window);
-
gtk_places_sidebar_set_open_flags (GTK_PLACES_SIDEBAR (window->places_sidebar),
(GTK_PLACES_OPEN_NORMAL
| GTK_PLACES_OPEN_NEW_TAB
@@ -1424,7 +1363,6 @@ nautilus_window_show_sidebar (NautilusWindow *window)
g_return_if_fail (NAUTILUS_IS_WINDOW (window));
gtk_widget_show (window->sidebar);
- setup_side_pane_width (window);
}
void
@@ -2823,7 +2761,7 @@ nautilus_window_class_init (NautilusWindowClass *class)
gtk_widget_class_set_template_from_resource (wclass,
"/org/gnome/nautilus/ui/nautilus-window.ui");
gtk_widget_class_bind_template_child (wclass, NautilusWindow, toolbar);
- gtk_widget_class_bind_template_child (wclass, NautilusWindow, content_paned);
+ gtk_widget_class_bind_template_child (wclass, NautilusWindow, content_flap);
gtk_widget_class_bind_template_child (wclass, NautilusWindow, sidebar);
gtk_widget_class_bind_template_child (wclass, NautilusWindow, places_sidebar);
gtk_widget_class_bind_template_child (wclass, NautilusWindow, main_view);
diff --git a/src/resources/ui/nautilus-window.ui b/src/resources/ui/nautilus-window.ui
index e554696ca..d9350fcdc 100644
--- a/src/resources/ui/nautilus-window.ui
+++ b/src/resources/ui/nautilus-window.ui
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
+ <!-- TODO: Use child type="flap" when added to libhandy -->
<template class="NautilusWindow" parent="HdyApplicationWindow">
<property name="show-menubar">False</property>
<property name="title" translatable="yes">_Files</property>
@@ -11,15 +12,16 @@
<object class="NautilusToolbar" id="toolbar"/>
</child>
<child>
- <object class="GtkPaned" id="content_paned">
+ <object class="HdyFlap" id="content_flap">
<property name="visible">True</property>
<property name="vexpand">True</property>
<property name="hexpand">True</property>
- <child>
+ <child type="flap">
<object class="GtkBox" id="sidebar">
<property name="visible">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
+ <property name="width_request">204</property>
<child>
<object class="GtkPlacesSidebar" id="places_sidebar">
<property name="visible">True</property>
@@ -36,14 +38,11 @@
</packing>
</child>
</object>
- <packing>
- <property name="resize">False</property>
- <property name="shrink">False</property>
- </packing>
</child>
<child>
<object class="GtkOverlay" id="main_view">
<property name="visible">True</property>
+ <property name="width_request">360</property>
<child>
<object class="NautilusNotebook" id="notebook">
<property name="visible">True</property>
@@ -189,9 +188,6 @@
</object>
</child>
</object>
- <packing>
- <property name="shrink">False</property>
- </packing>
</child>
</object>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]