-
Notifications
You must be signed in to change notification settings - Fork 305
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?
Conversation
So it is implicit that files will be sorted by basename within suffix?
------- Original Message -------
…On Friday, September 30th, 2022 at 13:47, VitanovG ***@***.***> wrote:
This pull request integrates the File extension column into nemo. You can use the column in list view, and you can sort the files in any views according to file extensions. This is useful in case someone works with Latex and has 10+ .tex files, 10+ .sty files and 10+ .aux files in a directory, and would like to sort them such that:
1.aux
2.aux
3.aux
a.sty
b.sty
1.tex
2.tex
3.tex
will be the sort behavior. This is not possible with the current "Type", "Detailed type" and "MIME type" methods. This feature was already requested in the issues, and dolphin recently added the same "Extension" column.
---------------------------------------------------------------
You can view, comment on, or merge this pull request online at:
#3086
Commit Summary
- [a6b86dd](a6b86dd) added column "extension", partly works
- [03501ed](03501ed) updated couple files that were left out
- [0c8adac](0c8adac) repositioned the extension col
- [e2e1b80](e2e1b80) reordered "extension" menus and fixed NULL bug
- [35d818d](35d818d) install instructions
- [d5d034e](d5d034e) Update README.md
File Changes
([12 files](https://github.com/linuxmint/nemo/pull/3086/files))
- M [gresources/nemo-desktop-overlay.glade](https://github.com/linuxmint/nemo/pull/3086/files#diff-01cf74c1fecc9a50e852067ef6e9c17cc9ec2992dec322f1bff6726c7ffb96d3) (7)
- M [gresources/nemo-file-management-properties.glade](https://github.com/linuxmint/nemo/pull/3086/files#diff-3c0bc6d536443c67502ce849dd6e6185406550affd9de92a289b324c14a425e4) (5)
- M [gresources/nemo-icon-view-ui.xml](https://github.com/linuxmint/nemo/pull/3086/files#diff-973fa95316203f6208e6da0a0b91a3e3272c28216e0ca21ab7ff4bc8158acb04) (2)
- M [libnemo-private/nemo-column-utilities.c](https://github.com/linuxmint/nemo/pull/3086/files#diff-77063be76e4a92e803992b603971e6826a7d18a273904f52d1df96c5d2d7ba77) (8)
- M [libnemo-private/nemo-file.c](https://github.com/linuxmint/nemo/pull/3086/files#diff-8e3ad51d2de96d7ec879e93940c4e69d2827e629baae869ba0fc0026320bad5f) (61)
- M [libnemo-private/nemo-file.h](https://github.com/linuxmint/nemo/pull/3086/files#diff-264adaba2bc8f5745dc91282369f11ba34c611f0489d11404f49ced7384e53ae) (22)
- M [libnemo-private/org.nemo.gschema.xml](https://github.com/linuxmint/nemo/pull/3086/files#diff-9cc08478e0781016e7f97c58a83fde4e3ba22228ef17a22cd302b44c9669cff5) (11)
- M [src/nemo-desktop-icon-grid-view.c](https://github.com/linuxmint/nemo/pull/3086/files#diff-d49a77b5912ce55473bafe9f495659651d4303e7caab78bbd754b9251781742f) (9)
- M [src/nemo-desktop-overlay.c](https://github.com/linuxmint/nemo/pull/3086/files#diff-cca5aaa6b1f10cbb30ce9189bbef1fdfa02e5809b668b13e6f6f57c3960771ba) (3)
- M [src/nemo-file-management-properties.c](https://github.com/linuxmint/nemo/pull/3086/files#diff-dd45cca6978fa7d09d66f7e23a154632d088124d54edafc54ae2c6841d232653) (1)
- M [src/nemo-icon-view.c](https://github.com/linuxmint/nemo/pull/3086/files#diff-436565a38495447046b62a59794222335cff2a2e2929a5f7527cf6afd05a5a92) (11)
- M [src/nemo-list-view.c](https://github.com/linuxmint/nemo/pull/3086/files#diff-8e6d697bbf6a5247c3d134536d7dafe44c97d7b5f7b41e65f752f87ddf9c9fbc) (1)
Patch Links:
- https://github.com/linuxmint/nemo/pull/3086.patch
- https://github.com/linuxmint/nemo/pull/3086.diff
—
Reply to this email directly, [view it on GitHub](#3086), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AMRGFH7T3DLEPYDXD4SUTWTWA3OPZANCNFSM6AAAAAAQZX25F4).
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
<row> | ||
<row> | ||
<col id="0" translatable="yes">By Extension</col> | ||
<row> |
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>
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; | ||
} |
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.
There are a few problems here:
Remember you're not returning a new string (const char*
), since you're 'peeking' at the value:
- link broken string should just be a static string (no g_strdup).
- The remaining code either returns a new string, or a static empty one, and leaks memory (you never free
token
while running thestrsep
loop, and if there are multiple separators the intermediate ones leak).
I would suggest using g_strrstr
as it works from the end of the string and returns a pointer or NULL
, and no new strings need to be created:
const char *str, *ptr;
str = eel_ref_str_peek (file->details->name);
if ((ptr = g_strrstr (str, "."))) {
return ptr + 1;
}
return "";
We usually try to stick with glib functions, as they're generally more convenient (and often safer).
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Here you're returning a new string (char *
return), so you would need to g_strdup the peeked extension name.
Merged in nemo master 6.4.2 to my fork
This pull request integrates the File extension column into nemo. You can use the column in list view, and you can sort the files in any views according to file extensions. This is useful in case someone works with Latex and has 10+ .tex files, 10+ .sty files and 10+ .aux files in a directory, and would like to sort them such that:
1.aux
2.aux
3.aux
a.sty
b.sty
1.tex
2.tex
3.tex
will be the sort behavior. This is not possible with the current "Type", "Detailed type" and "MIME type" methods. This feature was already requested in the issues, and dolphin recently added the same "Extension" column.