Skip to content

Commit eb489a1

Browse files
committed
nemo-list-view.c: Don't allow the 'Location' column for normal
directories. The Location column is only useful in special views where files being shown aren't necessarily all in the same location - Recents, Favorites and search results. In normal folders, the Location is identical for all files (their parent folder's path).
1 parent 3f1d9bb commit eb489a1

2 files changed

Lines changed: 67 additions & 65 deletions

File tree

libnemo-private/nemo-column-utilities.c

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include <string.h>
2929
#include <eel/eel-glib-extensions.h>
30+
#include <eel/eel-vfs-extensions.h>
3031
#include <glib/gi18n.h>
3132
#include <libnemo-extension/nemo-column-provider.h>
3233
#include <libnemo-private/nemo-module.h>
@@ -152,16 +153,6 @@ get_builtin_columns (void)
152153
"description", _("The SELinux security context of the file."),
153154
NULL));
154155
#endif
155-
columns = g_list_append (columns,
156-
g_object_new (NEMO_TYPE_COLUMN,
157-
"name", "where",
158-
"attribute", "where",
159-
"label", _("Location"),
160-
"description", _("The location of the file."),
161-
"width-chars", 60,
162-
"ellipsize", PANGO_ELLIPSIZE_END,
163-
NULL));
164-
165156
return columns;
166157
}
167158

@@ -221,13 +212,6 @@ get_search_columns (void)
221212
static GList *columns = NULL;
222213

223214
if (columns == NULL) {
224-
// columns = g_list_append (columns,
225-
// g_object_new (NEMO_TYPE_COLUMN,
226-
// "name", "search-result-snippet",
227-
// "attribute", "search_result_snippet",
228-
// "label", _("Result"),
229-
// "description", _("A portion of the contents where the string was found"),
230-
// NULL));
231215
columns = g_list_append (columns,
232216
g_object_new (NEMO_TYPE_COLUMN,
233217
"name", "search_result_count",
@@ -240,6 +224,25 @@ get_search_columns (void)
240224
return nemo_column_list_copy (columns);
241225
}
242226

227+
static GList *
228+
get_mixed_file_list_columns (void)
229+
{
230+
static GList *columns = NULL;
231+
232+
if (columns == NULL) {
233+
columns = g_list_append (columns,
234+
g_object_new (NEMO_TYPE_COLUMN,
235+
"name", "where",
236+
"attribute", "where",
237+
"label", _("Location"),
238+
"description", _("The location of the file."),
239+
"width-chars", 60,
240+
"ellipsize", PANGO_ELLIPSIZE_END,
241+
NULL));
242+
}
243+
244+
return nemo_column_list_copy (columns);
245+
}
243246

244247
GList *
245248
nemo_get_common_columns (void)
@@ -258,33 +261,48 @@ GList *
258261
nemo_get_all_columns (void)
259262
{
260263
GList *columns = NULL;
261-
GList *with_search_columns = NULL;
262264

263265
columns = g_list_concat (nemo_get_common_columns (),
264266
get_trash_columns ());
267+
columns = g_list_concat (columns, get_search_columns ());
268+
columns = g_list_concat (columns, get_mixed_file_list_columns ());
265269

266-
with_search_columns = g_list_concat (columns, get_search_columns ());
267-
268-
return with_search_columns;
270+
return columns;
269271
}
270272

271273
GList *
272274
nemo_get_columns_for_file (NemoFile *file)
273275
{
274-
GList *columns;
276+
GList *columns;
277+
gchar *uri;
278+
279+
columns = nemo_get_common_columns ();
280+
281+
if (file == NULL) {
282+
return columns;
283+
}
275284

276-
columns = nemo_get_common_columns ();
285+
uri = nemo_file_get_uri (file);
277286

278-
if (file != NULL && nemo_file_is_in_trash (file)) {
279-
columns = g_list_concat (columns,
280-
get_trash_columns ());
281-
} else
282-
if (file != NULL && nemo_file_is_in_search (file)) {
287+
if (eel_uri_is_trash (uri)) {
288+
columns = g_list_concat (columns,
289+
get_trash_columns ());
290+
} else if (eel_uri_is_search (uri)) {
283291
columns = g_list_concat (columns,
284292
get_search_columns ());
293+
columns = g_list_concat (columns,
294+
get_mixed_file_list_columns ());
295+
} else if (eel_uri_is_favorite (uri)) {
296+
columns = g_list_concat (columns,
297+
get_mixed_file_list_columns ());
298+
} else if (eel_uri_is_recent (uri)) {
299+
columns = g_list_concat (columns,
300+
get_mixed_file_list_columns ());
285301
}
286302

287-
return columns;
303+
g_free (uri);
304+
305+
return columns;
288306
}
289307

290308
GList *

src/nemo-list-view.c

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,60 +2023,43 @@ column_header_clicked (GtkWidget *column_button,
20232023
GdkEventButton *event,
20242024
NemoListView *list_view)
20252025
{
2026-
GList *current_view_columns, *l;
2026+
GList *valid_columns, *l;
2027+
gchar **visible_columns;
20272028
NemoFile *file;
20282029
GtkWidget *menu;
20292030
GtkWidget *menu_item;
20302031

2031-
if (event->button != GDK_BUTTON_SECONDARY) {
2032-
return FALSE;
2033-
}
2032+
if (event->button != GDK_BUTTON_SECONDARY) {
2033+
return FALSE;
2034+
}
20342035

20352036
file = nemo_view_get_directory_as_file (NEMO_VIEW (list_view));
20362037

20372038
menu = gtk_menu_new ();
20382039

2039-
current_view_columns = gtk_tree_view_get_columns (list_view->details->tree_view);
2040-
2041-
for (l = current_view_columns; l != NULL; l = l->next) {
2042-
const char *name;
2043-
char *label;
2044-
char *lowercase;
2045-
gboolean visible;
2046-
2047-
GtkTreeViewColumn *c = GTK_TREE_VIEW_COLUMN (l->data);
2040+
visible_columns = get_visible_columns (list_view);
2041+
valid_columns = nemo_get_columns_for_file (file);
20482042

2049-
name = g_object_get_data (G_OBJECT (c), "column-id");
2043+
for (l = valid_columns; l != NULL; l = l->next) {
2044+
gchar *name;
2045+
gchar *label;
20502046

2051-
if (!nemo_file_is_in_trash (file)) {
2052-
if (g_strcmp0 (name, "trashed_on") == 0 ||
2053-
g_strcmp0 (name, "trash_orig_path") == 0)
2054-
continue;
2055-
}
2056-
2057-
if (!nemo_file_is_in_search (file)) {
2058-
if (g_strcmp0 (name, "search_result_count") == 0 ||
2059-
g_strcmp0 (name, "search_result_snippet") == 0)
2060-
continue;
2061-
}
2062-
2063-
g_object_get (G_OBJECT (c),
2064-
"title", &label,
2065-
"visible", &visible,
2047+
g_object_get (G_OBJECT (l->data),
2048+
"name", &name,
2049+
"label", &label,
20662050
NULL);
20672051

2068-
lowercase = g_ascii_strdown (name, -1);
2069-
20702052
menu_item = gtk_check_menu_item_new_with_label (label);
20712053
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
20722054

20732055
g_object_set_data_full (G_OBJECT (menu_item),
20742056
"column-name", g_strdup (name), g_free);
20752057

2076-
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), visible);
2058+
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
2059+
g_strv_contains ((const gchar * const *) visible_columns, name));
20772060

20782061
/* Don't allow hiding the filename */
2079-
if (g_strcmp0 (lowercase, "name") == 0) {
2062+
if (g_strcmp0 (name, "name") == 0) {
20802063
gtk_widget_set_sensitive (GTK_WIDGET (menu_item), FALSE);
20812064
}
20822065

@@ -2085,11 +2068,12 @@ column_header_clicked (GtkWidget *column_button,
20852068
G_CALLBACK (column_header_menu_toggled),
20862069
list_view);
20872070

2088-
g_clear_pointer (&lowercase, g_free);
2089-
g_clear_pointer (&label, g_free);
2071+
g_free (name);
2072+
g_free (label);
20902073
}
20912074

2092-
g_list_free (current_view_columns);
2075+
g_strfreev (visible_columns);
2076+
nemo_column_list_free (valid_columns);
20932077

20942078
menu_item = gtk_separator_menu_item_new ();
20952079
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);

0 commit comments

Comments
 (0)