Commit f0a64222 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Add girara_xdg_open_with_working_directory

parent e263f458
...@@ -63,7 +63,7 @@ girara_fix_path(const char* path) ...@@ -63,7 +63,7 @@ girara_fix_path(const char* path)
} }
bool bool
girara_xdg_open(const char* uri) girara_xdg_open_with_working_directory(const char* uri, const char* working_directory)
{ {
if (uri == NULL || strlen(uri) == 0) { if (uri == NULL || strlen(uri) == 0) {
return false; return false;
...@@ -73,7 +73,7 @@ girara_xdg_open(const char* uri) ...@@ -73,7 +73,7 @@ girara_xdg_open(const char* uri)
char* argv[] = { g_strdup("xdg-open"), g_strdup(uri), NULL }; char* argv[] = { g_strdup("xdg-open"), g_strdup(uri), NULL };
GError* error = NULL; GError* error = NULL;
const bool res = g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, const bool res = g_spawn_async(working_directory, argv, NULL, G_SPAWN_SEARCH_PATH, NULL,
NULL, NULL, &error); NULL, NULL, &error);
if (error != NULL) { if (error != NULL) {
girara_warning("Failed to execute command: %s", error->message); girara_warning("Failed to execute command: %s", error->message);
...@@ -86,6 +86,12 @@ girara_xdg_open(const char* uri) ...@@ -86,6 +86,12 @@ girara_xdg_open(const char* uri)
return res; return res;
} }
bool
girara_xdg_open(const char* uri)
{
return girara_xdg_open_with_working_directory(uri, NULL);
}
char* char*
girara_get_home_directory(const char* user) girara_get_home_directory(const char* user)
{ {
......
...@@ -47,6 +47,15 @@ char* girara_get_xdg_path(girara_xdg_path_t path) GIRARA_VISIBLE; ...@@ -47,6 +47,15 @@ char* girara_get_xdg_path(girara_xdg_path_t path) GIRARA_VISIBLE;
*/ */
bool girara_xdg_open(const char* uri) GIRARA_VISIBLE; bool girara_xdg_open(const char* uri) GIRARA_VISIBLE;
/**
* Opens a URI with xdg-open in a different working directory.
*
* @param uri the URI to be opened.
* @param working_directory working directory
* @return true on success, false otherwise
*/
bool girara_xdg_open_with_working_directory(const char* uri, const char* working_directory) GIRARA_VISIBLE;
/** /**
* Splits paths separated by : (as in $PATH) into a list. * Splits paths separated by : (as in $PATH) into a list.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment