Skip to content

Commit 31089c1

Browse files
diathmtwebster
authored andcommitted
Add %e action token
The new modifier will return the file name with the extension stripped.
1 parent 6212a19 commit 31089c1

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

files/usr/share/nemo/actions/sample.nemo_action

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Active=false
2222
# %f or %N (deprecated) - insert display name of first selected file
2323
# %p - insert display name of parent directory
2424
# %D - insert device path of file (i.e. /dev/sdb1)
25-
25+
# %e - insert display name of first selected file with the extension stripped
2626

2727
# The name to show in the menu, locale supported with standard desktop spec.
2828
# **** REQUIRED ****

libnemo-private/nemo-action.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "nemo-action.h"
2121
#include <eel/eel-string.h>
22+
#include <eel/eel-vfs-extensions.h>
2223
#include <glib/gi18n.h>
2324
#include <gdk/gdk.h>
2425
#include "nemo-file-utilities.h"
@@ -1158,6 +1159,10 @@ find_token_type (const gchar *str, TokenType *token_type)
11581159
*token_type = TOKEN_DEVICE;
11591160
return ptr;
11601161
}
1162+
if (g_str_has_prefix (ptr, TOKEN_EXEC_FILE_NO_EXT)) {
1163+
*token_type = TOKEN_FILE_DISPLAY_NAME_NO_EXT;
1164+
return ptr;
1165+
}
11611166
}
11621167

11631168
return NULL;
@@ -1353,6 +1358,15 @@ get_insertion_string (NemoAction *action, TokenType token_type, GList *selection
13531358
goto default_parent_path;
13541359
}
13551360
break;
1361+
case TOKEN_FILE_DISPLAY_NAME_NO_EXT:
1362+
if (g_list_length (selection) > 0) {
1363+
gchar *file_display_name = nemo_file_get_display_name (NEMO_FILE (selection->data));
1364+
str = score_append (action, str, eel_filename_strip_extension (file_display_name));
1365+
g_free (file_display_name);
1366+
} else {
1367+
goto default_parent_path;
1368+
}
1369+
break;
13561370
case TOKEN_NONE:
13571371
default:
13581372
break;

libnemo-private/nemo-action.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#define TOKEN_EXEC_FILE_NAME "%f"
5050
#define TOKEN_EXEC_PARENT_NAME "%p"
5151
#define TOKEN_EXEC_DEVICE "%D"
52+
#define TOKEN_EXEC_FILE_NO_EXT "%e"
5253

5354
#define TOKEN_LABEL_FILE_NAME "%N" // Leave in for compatibility, same as TOKEN_EXEC_FILE_NAME
5455

@@ -97,7 +98,8 @@ typedef enum {
9798
TOKEN_FILE_DISPLAY_NAME,
9899
TOKEN_PARENT_DISPLAY_NAME,
99100
TOKEN_PARENT_PATH,
100-
TOKEN_DEVICE
101+
TOKEN_DEVICE,
102+
TOKEN_FILE_DISPLAY_NAME_NO_EXT
101103
} TokenType;
102104

103105
struct _NemoAction {

0 commit comments

Comments
 (0)