Commit d08d4c8f authored by Carlos Soriano's avatar Carlos Soriano Committed by Carlos Soriano

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: #338
parent cb497f1c
......@@ -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 */
......@@ -1495,6 +1497,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)
{
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment