Skip to content

Commit ad25353

Browse files
committed
actions: Add new conversion token for a file's parent uri (with
selection_count > 0) and location uri (selection_count == 0).
1 parent 997f405 commit ad25353

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

libnemo-private/nemo-action.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,10 +1143,14 @@ find_token_type (const gchar *str, TokenType *token_type)
11431143
*token_type = TOKEN_URI_LIST;
11441144
return ptr;
11451145
}
1146-
if (g_str_has_prefix (ptr, TOKEN_EXEC_PARENT)) {
1146+
if (g_str_has_prefix (ptr, TOKEN_EXEC_LOCATION_PATH)) {
11471147
*token_type = TOKEN_PARENT_PATH;
11481148
return ptr;
11491149
}
1150+
if (g_str_has_prefix (ptr, TOKEN_EXEC_LOCATION_URI)) {
1151+
*token_type = TOKEN_PARENT_URI;
1152+
return ptr;
1153+
}
11501154
if (g_str_has_prefix (ptr, TOKEN_EXEC_FILE_NAME)) {
11511155
*token_type = TOKEN_FILE_DISPLAY_NAME;
11521156
return ptr;
@@ -1322,7 +1326,7 @@ get_insertion_string (NemoAction *action,
13221326
first = FALSE;
13231327
}
13241328
} else {
1325-
goto default_parent_path;
1329+
goto default_parent_uri;
13261330
}
13271331
break;
13281332
case TOKEN_PARENT_PATH:
@@ -1343,6 +1347,33 @@ get_insertion_string (NemoAction *action,
13431347
str = insert_quote (action, str);
13441348
g_free (path);
13451349
break;
1350+
case TOKEN_PARENT_URI:
1351+
;
1352+
default_parent_uri:
1353+
;
1354+
gchar *uri;
1355+
gchar *name = nemo_file_get_display_name (parent);
1356+
if (g_strcmp0 (name, "x-nemo-desktop") == 0) {
1357+
gchar *real_desktop_path = nemo_get_desktop_directory ();
1358+
if (real_desktop_path) {
1359+
GFile *file;
1360+
file = g_file_new_for_path (real_desktop_path);
1361+
uri = g_file_get_uri (file);
1362+
g_object_unref (file);
1363+
g_free (real_desktop_path);
1364+
} else {
1365+
uri = NULL;
1366+
}
1367+
} else {
1368+
uri = nemo_file_get_uri (parent);
1369+
}
1370+
1371+
str = insert_quote (action, str);
1372+
str = score_append (action, str, uri);
1373+
str = insert_quote (action, str);
1374+
g_free (name);
1375+
g_free (uri);
1376+
break;
13461377
case TOKEN_FILE_DISPLAY_NAME:
13471378
if (g_list_length (selection) > 0) {
13481379
gchar *file_display_name = nemo_file_get_display_name (NEMO_FILE (selection->data));

libnemo-private/nemo-action.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545

4646
#define TOKEN_EXEC_URI_LIST "%U"
4747
#define TOKEN_EXEC_FILE_LIST "%F"
48-
#define TOKEN_EXEC_PARENT "%P"
48+
#define TOKEN_EXEC_LOCATION_PATH "%P" // also parent path
49+
#define TOKEN_EXEC_LOCATION_URI "%R" // and uri
4950
#define TOKEN_EXEC_FILE_NAME "%f"
5051
#define TOKEN_EXEC_PARENT_NAME "%p"
5152
#define TOKEN_EXEC_DEVICE "%D"
@@ -100,6 +101,7 @@ typedef enum {
100101
TOKEN_FILE_DISPLAY_NAME,
101102
TOKEN_PARENT_DISPLAY_NAME,
102103
TOKEN_PARENT_PATH,
104+
TOKEN_PARENT_URI,
103105
TOKEN_DEVICE,
104106
TOKEN_FILE_DISPLAY_NAME_NO_EXT,
105107
TOKEN_LITERAL_PERCENT,

0 commit comments

Comments
 (0)