diff options
author | Carlos Soriano <csoriano@gnome.org> | 2018-03-27 16:25:19 +0200 |
---|---|---|
committer | Carlos Soriano <csoriano1618@gmail.com> | 2018-03-27 19:09:30 +0000 |
commit | d08d4c8fe1282085d9a86f372cdeafbd632c35f7 (patch) | |
tree | 071694079e7714bebf7715945f47e02f03f38ea5 /src | |
parent | cb497f1cc8d764f42a758c47601d05078111fcb7 (diff) | |
download | nautilus-d08d4c8fe1282085d9a86f372cdeafbd632c35f7.tar.gz |
window: Hide starred items in the sidebar if not items present
We were always showing the starred item in the sidebar, with an empty
state in the resulting view if no starred file was present.
This is usually what we want for regular items. However, in 3.28 the
feature is not working as good as we expected for those not using
the tracker directories as heavily as other users.
In order to prevent being too annoying, we can hide the sidebar item if
no starred files are present, while still providing the context menu
to be able to use the feature.
This can be reverted once we are able to star any file, once tracker has
the required API to star a file and have a sync callback for its result.
Closes: https://gitlab.gnome.org/GNOME/nautilus/issues/338
Diffstat (limited to 'src')
-rw-r--r-- | src/nautilus-window.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 05fb98572..b2205002f 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -38,6 +38,7 @@ #include "nautilus-window-slot.h" #include "nautilus-list-view.h" #include "nautilus-other-locations-window-slot.h" +#include "nautilus-tag-manager.h" #include <eel/eel-debug.h> #include <eel/eel-gtk-extensions.h> @@ -109,6 +110,7 @@ typedef struct int side_pane_width; GtkWidget *sidebar; /* container for the GtkPlacesSidebar */ GtkWidget *places_sidebar; /* the actual GtkPlacesSidebar */ + NautilusTagManager *starred_manager; /* For the starred sidbear item */ GVolume *selected_volume; /* the selected volume in the sidebar popup callback */ GFile *selected_file; /* the selected file in the sidebar popup callback */ @@ -1496,6 +1498,19 @@ places_sidebar_populate_popup_cb (GtkPlacesSidebar *sidebar, } static void +on_starred_changed (NautilusWindow *self) +{ + g_autoptr (GList) starred_files = NULL; + NautilusWindowPrivate *priv; + + priv = nautilus_window_get_instance_private (self); + + starred_files = nautilus_tag_manager_get_starred_files (priv->starred_manager); + gtk_places_sidebar_set_show_starred_location (GTK_PLACES_SIDEBAR (priv->places_sidebar), + starred_files != NULL); +} + +static void nautilus_window_set_up_sidebar (NautilusWindow *window) { NautilusWindowPrivate *priv; @@ -1527,6 +1542,12 @@ nautilus_window_set_up_sidebar (NautilusWindow *window) G_CALLBACK (places_sidebar_populate_popup_cb), window); g_signal_connect (priv->places_sidebar, "unmount", G_CALLBACK (places_sidebar_unmount_operation_cb), window); + + + priv->starred_manager = nautilus_tag_manager_get (); + g_signal_connect_swapped (priv->starred_manager, "starred-changed", + G_CALLBACK (on_starred_changed), window); + on_starred_changed (window); } void @@ -2556,6 +2577,9 @@ nautilus_window_finalize (GObject *object) /* nautilus_window_close() should have run */ g_assert (priv->slots == NULL); + g_signal_handlers_disconnect_by_data (priv->starred_manager, window); + g_clear_object (&priv->starred_manager); + G_OBJECT_CLASS (nautilus_window_parent_class)->finalize (object); } |