From db1fa96114d1a066e59b4df0af256fe7d618a672 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Thu, 28 Aug 2014 20:17:53 +0200 Subject: [PATCH] =?UTF-8?q?Add=20items=20to=20recent=20menu=20when=20?= =?UTF-8?q?=E2=80=98mate=E2=80=99=20is=20called=20without=20-w=20option?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One can force adding to the recent menu by using --recent or disable it (for files we do not wait on) using --no-recent. --- Applications/mate/src/mate.cc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Applications/mate/src/mate.cc b/Applications/mate/src/mate.cc index ab5626e3..ae14b6e0 100644 --- a/Applications/mate/src/mate.cc +++ b/Applications/mate/src/mate.cc @@ -6,7 +6,7 @@ #include #include -static double const AppVersion = 2.7; +static double const AppVersion = 2.8; static size_t const AppRevision = APP_REVISION; static char const* socket_path () @@ -146,6 +146,10 @@ static void usage (FILE* io) " -h, --help Show this information.\n" " -v, --version Print version information.\n" "\n" + "Files opened via %1$s are added to the recent menu unless\n" + "the file starts with a period, --wait or --no-recent is\n" + "specifed, or file is in the system’s temporary directory.\n" + "\n" "By default %1$s will wait for files to be closed if the command name\n" "has a \"_wait\" suffix (e.g. via a symbolic link) or when used as a\n" "filter like in this examples:\n" @@ -178,6 +182,12 @@ static void write_key_pair (int fd, std::string const& key, std::string const& v write(fd, str.data(), str.size()); } +static bool is_temporary_file (std::string path) +{ + path = path::resolve(path); + return path::is_child(path, path::resolve("/tmp")) || path::is_child(path, path::resolve(path::temp())); +} + static std::string const kUUIDPrefix = "uuid://"; namespace @@ -410,15 +420,20 @@ int main (int argc, char* argv[]) write_key_pair(fd, "display-name", i < names.size() ? names[i] : ""); write_key_pair(fd, "wait", to_s(shouldWait)); write_key_pair(fd, "re-activate", to_s(shouldWait)); + + if(addToRecent == boolean::kUnset && shouldWait != boolean::kEnable && files[i].front() != '.' && !is_temporary_file(files[i])) + write_key_pair(fd, "add-to-recents", "yes"); } + if(addToRecent != boolean::kUnset) + write_key_pair(fd, "add-to-recents", to_s(addToRecent)); + if(geteuid() == 0 && auth.obtain_right(kAuthRightName)) write_key_pair(fd, "authorization", auth); write_key_pair(fd, "selection", i < lines.size() ? lines[i] : ""); write_key_pair(fd, "file-type", i < types.size() ? types[i] : ""); write_key_pair(fd, "project-uuid", i < projects.size() ? projects[i] : defaultProject); - write_key_pair(fd, "add-to-recents", to_s(addToRecent)); write_key_pair(fd, "change-directory", to_s(changeDir)); write(fd, "\r\n", 2);