-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] File extension column #3086
base: master
Are you sure you want to change the base?
Changes from all commits
a6b86dd
03501ed
0c8adac
e2e1b80
35d818d
d5d034e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,6 +130,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, | ||
|
@@ -173,6 +174,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); | ||
|
@@ -3074,6 +3076,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) | ||
{ | ||
|
@@ -3357,6 +3373,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. | ||
|
@@ -3446,6 +3468,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, | ||
|
@@ -4036,6 +4065,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; | ||
} | ||
Comment on lines
+4075
to
+4088
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are a few problems here: Remember you're not returning a new string (
I would suggest using
We usually try to stick with glib functions, as they're generally more convenient (and often safer). |
||
|
||
static const char * | ||
nemo_file_peek_display_name (NemoFile *file) | ||
{ | ||
|
@@ -4077,6 +4128,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); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you're returning a new string ( |
||
|
||
char * | ||
nemo_file_get_edit_name (NemoFile *file) | ||
{ | ||
|
@@ -6689,6 +6746,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); | ||
} | ||
|
@@ -8902,6 +8962,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"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tags are wrong - this causes nemo to crash.
Each column needs to open with
<row>
and close with</row>