[nautilus/wip/antoniof/new-list-view-without-expanders: 6/12] list-view: Make Star column non-configurable
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/new-list-view-without-expanders: 6/12] list-view: Make Star column non-configurable
- Date: Fri, 10 Jun 2022 19:03:46 +0000 (UTC)
commit b87935dc34970243aea896cc29e6347fc1ea91b9
Author: António Fernandes <antoniof gnome org>
Date: Wed Apr 6 16:23:03 2022 +0100
list-view: Make Star column non-configurable
We don't want it to be enabled in locations where it's not
supported.
data/org.gnome.nautilus.gschema.xml | 2 +-
src/nautilus-column-chooser.c | 6 ++++++
src/nautilus-list-view.c | 39 +++++++++++++------------------------
3 files changed, 20 insertions(+), 27 deletions(-)
---
diff --git a/data/org.gnome.nautilus.gschema.xml b/data/org.gnome.nautilus.gschema.xml
index 90f63c488..39a8ed753 100644
--- a/data/org.gnome.nautilus.gschema.xml
+++ b/data/org.gnome.nautilus.gschema.xml
@@ -226,7 +226,7 @@
<summary>Default list view zoom level</summary>
</key>
<key type="as" name="default-visible-columns">
- <default>[ 'name', 'size', 'date_modified', 'starred' ]</default>
+ <default>[ 'name', 'size', 'date_modified' ]</default>
<summary>Columns visible in list view</summary>
</key>
<key type="as" name="default-column-order">
diff --git a/src/nautilus-column-chooser.c b/src/nautilus-column-chooser.c
index 3412fb1bd..23aa5af5c 100644
--- a/src/nautilus-column-chooser.c
+++ b/src/nautilus-column-chooser.c
@@ -298,6 +298,12 @@ populate_tree (NautilusColumnChooser *chooser)
visible = TRUE;
sensitive = FALSE;
}
+ if (strcmp (name, "starred") == 0)
+ {
+ g_free (name);
+ g_free (label);
+ continue;
+ }
gtk_list_store_append (chooser->store, &iter);
gtk_list_store_set (chooser->store, &iter,
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 9bd0adb3a..fd38ae65d 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -1432,7 +1432,7 @@ popup_column_header_menu (NautilusListView *list_view,
"column-name", name, g_free);
/* name is always visible */
- if (strcmp (lowercase, "name") == 0)
+ if (strcmp (lowercase, "name") == 0 || strcmp (lowercase, "starred") == 0)
{
gtk_widget_set_sensitive (menu_item, FALSE);
}
@@ -1478,11 +1478,13 @@ apply_columns_settings (NautilusListView *list_view,
NautilusFile *file;
GList *old_view_columns, *view_columns;
GHashTable *visible_columns_hash;
+ g_autoptr (GFile) location = NULL;
GtkTreeViewColumn *prev_view_column;
GList *l;
int i;
file = nautilus_files_view_get_directory_as_file (NAUTILUS_FILES_VIEW (list_view));
+ location = nautilus_file_get_location (file);
/* prepare ordered list of view columns using column_order and visible_columns */
view_columns = NULL;
@@ -1497,6 +1499,14 @@ apply_columns_settings (NautilusListView *list_view,
(GDestroyNotify) g_free);
/* always show name column */
g_hash_table_insert (visible_columns_hash, g_strdup ("name"), g_strdup ("name"));
+
+ /* always show star column if supported */
+ if (nautilus_tag_manager_can_star_contents (nautilus_tag_manager_get (), location) ||
+ nautilus_is_starred_directory (location))
+ {
+ g_hash_table_insert (visible_columns_hash, g_strdup ("starred"), g_strdup ("starred"));
+ }
+
if (visible_columns != NULL)
{
for (i = 0; visible_columns[i] != NULL; ++i)
@@ -2347,40 +2357,17 @@ get_visible_columns (NautilusListView *list_view)
{
NautilusFile *file;
g_autofree gchar **visible_columns = NULL;
- g_autoptr (GFile) location = NULL;
- GPtrArray *res;
- g_autofree gchar *uri = NULL;
- gboolean can_star_current_directory;
- gboolean is_starred;
file = nautilus_files_view_get_directory_as_file (NAUTILUS_FILES_VIEW (list_view));
- uri = nautilus_file_get_uri (file);
-
- location = g_file_new_for_uri (uri);
- can_star_current_directory = nautilus_tag_manager_can_star_contents (nautilus_tag_manager_get (),
- location);
- is_starred = eel_uri_is_starred (uri);
visible_columns = nautilus_file_get_metadata_list (file,
NAUTILUS_METADATA_KEY_LIST_VIEW_VISIBLE_COLUMNS);
if (visible_columns == NULL)
{
- visible_columns = get_default_visible_columns (list_view);
+ return get_default_visible_columns (list_view);
}
- res = g_ptr_array_new ();
- for (gint i = 0; visible_columns[i] != NULL; i++)
- {
- if (g_strcmp0 (visible_columns[i], "starred") != 0 ||
- (g_strcmp0 (visible_columns[i], "starred") == 0 && (can_star_current_directory || is_starred)))
- {
- g_ptr_array_add (res, visible_columns[i]);
- }
- }
-
- g_ptr_array_add (res, NULL);
-
- return (char **) g_ptr_array_free (res, FALSE);
+ return g_steal_pointer (&visible_columns);
}
static char **
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]