diff --git a/gresources/nemo-desktop-overlay.glade b/gresources/nemo-desktop-overlay.glade index feb020262..c4e3e959f 100644 --- a/gresources/nemo-desktop-overlay.glade +++ b/gresources/nemo-desktop-overlay.glade @@ -122,10 +122,15 @@ Desktop Sort by Size - 4 + 3 Type Desktop Sort by Type + + 4 + Extension + Desktop Sort by Extension + 5 Date diff --git a/gresources/nemo-file-management-properties.glade b/gresources/nemo-file-management-properties.glade index 709a70f02..ac8f11cf5 100644 --- a/gresources/nemo-file-management-properties.glade +++ b/gresources/nemo-file-management-properties.glade @@ -185,7 +185,10 @@ along with . If not, see . By Type - + + + By Extension + By Detailed Type diff --git a/gresources/nemo-icon-view-ui.xml b/gresources/nemo-icon-view-ui.xml index bfe9baf60..579dc222a 100644 --- a/gresources/nemo-icon-view-ui.xml +++ b/gresources/nemo-icon-view-ui.xml @@ -8,6 +8,7 @@ + @@ -30,6 +31,7 @@ + diff --git a/libnemo-private/nemo-column-utilities.c b/libnemo-private/nemo-column-utilities.c index e7e97d8f3..4d6a9a5bd 100644 --- a/libnemo-private/nemo-column-utilities.c +++ b/libnemo-private/nemo-column-utilities.c @@ -58,6 +58,13 @@ get_builtin_columns (void) "label", _("Type"), "description", _("The general type of the file."), NULL)); + columns = g_list_append (columns, + g_object_new (NEMO_TYPE_COLUMN, + "name", "extension", + "attribute", "extension", + "label", _("Extension"), + "description", _("The extension of the file."), + NULL)); columns = g_list_append (columns, g_object_new (NEMO_TYPE_COLUMN, "name", "detailed_type", @@ -72,6 +79,7 @@ get_builtin_columns (void) "label", _("Date Modified"), "description", _("The date the file was modified."), NULL)); + columns = g_list_append (columns, g_object_new (NEMO_TYPE_COLUMN, "name", "date_modified_with_time", diff --git a/libnemo-private/nemo-file.c b/libnemo-private/nemo-file.c index ab55743e4..b6f5600d1 100644 --- a/libnemo-private/nemo-file.c +++ b/libnemo-private/nemo-file.c @@ -129,6 +129,7 @@ static GHashTable *symbolic_links; static GQuark attribute_name_q, attribute_size_q, attribute_type_q, + attribute_ext_q, attribute_detailed_type_q, attribute_modification_date_q, attribute_date_modified_q, @@ -172,6 +173,7 @@ static void nemo_file_info_iface_init (NemoFileInfoInterface static gboolean update_info_and_name (NemoFile *file, GFileInfo *info); static const char * nemo_file_peek_display_name (NemoFile *file); +const char * nemo_file_peek_extension_name (NemoFile *file); static const char * nemo_file_peek_display_name_collation_key (NemoFile *file); static void file_mount_unmounted (GMount *mount, gpointer data); static void metadata_hash_free (GHashTable *hash); @@ -3102,6 +3104,20 @@ compare_by_display_name (NemoFile *file_1, NemoFile *file_2) return compare; } +static int +compare_by_extension_name (NemoFile *file_1, NemoFile *file_2) +{ + const char *key_1, *key_2; + int compare=0; + + key_1 = nemo_file_peek_extension_name (file_1); + key_2 = nemo_file_peek_extension_name (file_2); + + compare = g_strcmp0 (key_1, key_2); + + return compare; +} + static int compare_by_directory_name (NemoFile *file_1, NemoFile *file_2) { @@ -3385,6 +3401,12 @@ nemo_file_compare_for_sort (NemoFile *file_1, result = compare_by_directory_name (file_1, file_2); } break; + case NEMO_FILE_SORT_BY_EXTENSION_NAME: + result = compare_by_extension_name (file_1, file_2); + if (result == 0) { + result = compare_by_display_name (file_1, file_2); + } + break; case NEMO_FILE_SORT_BY_SIZE: /* Compare directory sizes ourselves, then if necessary * use GnomeVFS to compare file sizes. @@ -3474,6 +3496,13 @@ nemo_file_compare_for_sort_by_attribute_q (NemoFile *file_1, favorites_first, reversed, search_dir); + } else if (attribute == attribute_ext_q) { + return nemo_file_compare_for_sort (file_1, file_2, + NEMO_FILE_SORT_BY_EXTENSION_NAME, + directories_first, + favorites_first, + reversed, + search_dir); } else if (attribute == attribute_size_q) { return nemo_file_compare_for_sort (file_1, file_2, NEMO_FILE_SORT_BY_SIZE, @@ -4063,6 +4092,28 @@ nemo_file_peek_display_name_collation_key (NemoFile *file) return res; } +const char * +nemo_file_peek_extension_name (NemoFile *file) +{ + if (file == NULL) { + return NULL; + } + + if (nemo_file_is_broken_symbolic_link (file)) { + return g_strdup (_("link (broken)")); + } + + char *str, *token, *result; + str = g_strdup (eel_ref_str_peek(file->details->name));//strdup() + + while ((token = strsep(&str, "."))) {result = g_strdup(token);} + if (result == NULL) {result = "";} + g_free(str); + g_free(token); + + return result; +} + static const char * nemo_file_peek_display_name (NemoFile *file) { @@ -4104,6 +4155,12 @@ nemo_file_get_display_name (NemoFile *file) return g_strdup (nemo_file_peek_display_name (file)); } +char * +nemo_file_get_extension_name (NemoFile *file) +{ + return nemo_file_peek_extension_name (file); +} + char * nemo_file_get_edit_name (NemoFile *file) { @@ -6714,6 +6771,9 @@ nemo_file_get_string_attribute_q (NemoFile *file, GQuark attribute_q) if (attribute_q == attribute_name_q) { return nemo_file_get_display_name (file); } + if (attribute_q == attribute_ext_q) { + return nemo_file_get_extension_name (file); + } if (attribute_q == attribute_type_q) { return nemo_file_get_type_as_string (file); } @@ -8914,6 +8974,7 @@ nemo_file_class_init (NemoFileClass *class) attribute_name_q = g_quark_from_static_string ("name"); attribute_size_q = g_quark_from_static_string ("size"); attribute_type_q = g_quark_from_static_string ("type"); + attribute_ext_q = g_quark_from_static_string ("extension"); attribute_detailed_type_q = g_quark_from_static_string ("detailed_type"); attribute_modification_date_q = g_quark_from_static_string ("modification_date"); attribute_date_modified_q = g_quark_from_static_string ("date_modified"); diff --git a/libnemo-private/nemo-file.h b/libnemo-private/nemo-file.h index 8b0f76975..e3f3115a9 100644 --- a/libnemo-private/nemo-file.h +++ b/libnemo-private/nemo-file.h @@ -60,6 +60,7 @@ typedef enum { NEMO_FILE_SORT_BY_DISPLAY_NAME, NEMO_FILE_SORT_BY_SIZE, NEMO_FILE_SORT_BY_TYPE, + NEMO_FILE_SORT_BY_EXTENSION_NAME, NEMO_FILE_SORT_BY_DETAILED_TYPE, NEMO_FILE_SORT_BY_MTIME, NEMO_FILE_SORT_BY_ATIME, @@ -156,7 +157,7 @@ NemoFile * nemo_file_get_existing_by_uri (const char * 1) Using these is type safe. * 2) You are allowed to call these with NULL, */ -NemoFile * nemo_file_ref (NemoFile *file); +NemoFile * nemo_file_ref (NemoFile *file); void nemo_file_unref (NemoFile *file); /* Monitor the file. */ @@ -190,16 +191,19 @@ gboolean nemo_file_contains_text (NemoFile char * nemo_file_get_display_name (NemoFile *file); char * nemo_file_get_edit_name (NemoFile *file); char * nemo_file_get_name (NemoFile *file); +char * nemo_file_get_extension_name (NemoFile *file); + const char * nemo_file_peek_name (NemoFile *file); +const char * nemo_file_peek_extension_name (NemoFile *file); GFile * nemo_file_get_location (NemoFile *file); -char * nemo_file_get_description (NemoFile *file); +char * nemo_file_get_description (NemoFile *file); char * nemo_file_get_uri (NemoFile *file); char * nemo_file_get_local_uri (NemoFile *file); char * nemo_file_get_path (NemoFile *file); char * nemo_file_get_uri_scheme (NemoFile *file); gboolean nemo_file_has_uri_scheme (NemoFile *file, const gchar *scheme); -NemoFile * nemo_file_get_parent (NemoFile *file); +NemoFile * nemo_file_get_parent (NemoFile *file); GFile * nemo_file_get_parent_location (NemoFile *file); char * nemo_file_get_parent_uri (NemoFile *file); char * nemo_file_get_parent_uri_for_display (NemoFile *file); @@ -210,7 +214,7 @@ time_t nemo_file_get_ctime (NemoFile GFileType nemo_file_get_file_type (NemoFile *file); char * nemo_file_get_mime_type (NemoFile *file); gboolean nemo_file_is_mime_type (NemoFile *file, - const char *mime_type); + const char *mime_type); gboolean nemo_file_is_launchable (NemoFile *file); gboolean nemo_file_is_symbolic_link (NemoFile *file); gboolean nemo_file_is_mountpoint (NemoFile *file); @@ -222,12 +226,12 @@ char * nemo_file_get_volume_name (NemoFile char * nemo_file_get_symbolic_link_target_path (NemoFile *file); char * nemo_file_get_symbolic_link_target_uri (NemoFile *file); gboolean nemo_file_is_broken_symbolic_link (NemoFile *file); -gboolean nemo_file_is_nemo_link (NemoFile *file); +gboolean nemo_file_is_nemo_link (NemoFile *file); gboolean nemo_file_is_executable (NemoFile *file); gboolean nemo_file_is_directory (NemoFile *file); gboolean nemo_file_is_user_special_directory (NemoFile *file, GUserDirectory special_directory); -gboolean nemo_file_is_archive (NemoFile *file); +gboolean nemo_file_is_archive (NemoFile *file); gboolean nemo_file_is_in_trash (NemoFile *file); gboolean nemo_file_is_in_recent (NemoFile *file); gboolean nemo_file_is_in_favorites (NemoFile *file); @@ -235,14 +239,14 @@ gboolean nemo_file_is_in_search (NemoFile gboolean nemo_file_is_unavailable_favorite (NemoFile *file); gboolean nemo_file_is_in_admin (NemoFile *file); gboolean nemo_file_is_in_desktop (NemoFile *file); -gboolean nemo_file_is_home (NemoFile *file); +gboolean nemo_file_is_home (NemoFile *file); gboolean nemo_file_is_desktop_directory (NemoFile *file); GError * nemo_file_get_file_info_error (NemoFile *file); gboolean nemo_file_get_directory_item_count (NemoFile *file, guint *count, gboolean *count_unreadable); void nemo_file_recompute_deep_counts (NemoFile *file); -NemoRequestStatus nemo_file_get_deep_counts (NemoFile *file, +NemoRequestStatus nemo_file_get_deep_counts (NemoFile *file, guint *directory_count, guint *file_count, guint *unreadable_directory_count, @@ -268,7 +272,7 @@ GFilesystemPreviewType nemo_file_get_filesystem_use_preview (NemoFile *f char * nemo_file_get_filesystem_id (NemoFile *file); -NemoFile * nemo_file_get_trash_original_file (NemoFile *file); +NemoFile * nemo_file_get_trash_original_file (NemoFile *file); /* Permissions. */ gboolean nemo_file_can_get_permissions (NemoFile *file); diff --git a/libnemo-private/org.nemo.gschema.xml b/libnemo-private/org.nemo.gschema.xml index 3577a610b..a715df844 100644 --- a/libnemo-private/org.nemo.gschema.xml +++ b/libnemo-private/org.nemo.gschema.xml @@ -39,10 +39,11 @@ - - - - + + + + + @@ -447,7 +448,7 @@ A list of captions below an icon in the icon view and the desktop. The actual number of captions shown depends on the zoom level. Some possible values are: - "size", "type", "date_modified", "date_changed", "date_accessed", "owner", + "size", "type", "date_modified", "extension", "date_changed", "date_accessed", "owner", "group", "permissions", "octal_permissions" and "mime_type". diff --git a/src/nemo-desktop-icon-grid-view.c b/src/nemo-desktop-icon-grid-view.c index 4ef00601c..d5746bcc7 100644 --- a/src/nemo-desktop-icon-grid-view.c +++ b/src/nemo-desktop-icon-grid-view.c @@ -104,6 +104,11 @@ static const DesktopSortCriterion sort_criteria[] = { "Desktop Sort by Type", "detailed_type", NEMO_FILE_SORT_BY_DETAILED_TYPE + }, + { + "Desktop Sort by Extension", + "extension", + NEMO_FILE_SORT_BY_EXTENSION_NAME }, { "Desktop Sort by Date", @@ -1074,6 +1079,10 @@ static const GtkRadioActionEntry desktop_sort_radio_entries[] = { N_("Name"), NULL, NULL, NEMO_FILE_SORT_BY_DISPLAY_NAME }, + { "Desktop Sort by Extension", NULL, + N_("Extension"), NULL, + NULL, + NEMO_FILE_SORT_BY_EXTENSION_NAME }, { "Desktop Sort by Size", NULL, N_("Size"), NULL, NULL, diff --git a/src/nemo-desktop-overlay.c b/src/nemo-desktop-overlay.c index 9deb6b298..c1cbdfe26 100644 --- a/src/nemo-desktop-overlay.c +++ b/src/nemo-desktop-overlay.c @@ -204,6 +204,9 @@ sync_controls (NemoDesktopOverlay *overlay, case NEMO_FILE_SORT_BY_DETAILED_TYPE: combo_id = "Desktop Sort by Type"; break; + case NEMO_FILE_SORT_BY_EXTENSION_NAME: + combo_id = "Desktop Sort by Extension"; + break; case NEMO_FILE_SORT_BY_MTIME: combo_id = "Desktop Sort by Date"; break; diff --git a/src/nemo-file-management-properties.c b/src/nemo-file-management-properties.c index 6e86fceb4..c1704661f 100644 --- a/src/nemo-file-management-properties.c +++ b/src/nemo-file-management-properties.c @@ -145,6 +145,7 @@ static const char * const sort_order_values[] = { "name", "size", "type", + "extension", "detailed_type", "mtime", "atime", diff --git a/src/nemo-icon-view.c b/src/nemo-icon-view.c index b24e1271d..f584baf57 100644 --- a/src/nemo-icon-view.c +++ b/src/nemo-icon-view.c @@ -151,6 +151,13 @@ static const SortCriterion sort_criteria[] = { N_("by _Type"), N_("Keep icons sorted by type in rows") }, + { + NEMO_FILE_SORT_BY_EXTENSION_NAME, + "extension", + "Sort by Extension", + N_("by _Extension"), + N_("Keep icons sorted by Extension in rows") + }, { NEMO_FILE_SORT_BY_DETAILED_TYPE, "detailed_type", @@ -1428,6 +1435,10 @@ static const GtkRadioActionEntry arrange_radio_entries[] = { N_("By _Name"), NULL, N_("Keep icons sorted by name in rows"), NEMO_FILE_SORT_BY_DISPLAY_NAME }, + { "Sort by Extension", NULL, + N_("By _Extension"), NULL, + N_("Keep icons sorted by extension in rows"), + NEMO_FILE_SORT_BY_EXTENSION_NAME }, { "Sort by Size", NULL, N_("By _Size"), NULL, N_("Keep icons sorted by size in rows"), diff --git a/src/nemo-list-view.c b/src/nemo-list-view.c index c2ffa6a0d..a0f735924 100644 --- a/src/nemo-list-view.c +++ b/src/nemo-list-view.c @@ -249,6 +249,7 @@ get_default_sort_order (NemoFile *file, gboolean *reversed) "name", "size", "type", + "extension", "detailed_type", "date_modified", "date_accessed",