[nautilus/starred-items: 2/3] window: Hide starred items in the sidebar if not items present
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/starred-items: 2/3] window: Hide starred items in the sidebar if not items present
- Date: Tue, 27 Mar 2018 19:10:32 +0000 (UTC)
commit d08d4c8fe1282085d9a86f372cdeafbd632c35f7
Author: Carlos Soriano <csoriano gnome org>
Date: Tue Mar 27 16:25:19 2018 +0200
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
src/nautilus-window.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
---
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 */
@@ -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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]