Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions src/nemo-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -7197,19 +7197,24 @@ cb_open_as_root_watch (GPid pid, gint status, gpointer user_data)
}

static void
open_as_admin (NemoView *view, const gchar *path) {
g_autoptr(GUri) uri_obj = g_uri_build (0, "admin", NULL, NULL, -1, path, NULL, NULL);
g_autofree gchar *uri = g_uri_to_string (uri_obj);
g_autoptr(GFile) location = g_file_new_for_uri (uri);
open_as_admin (const gchar *path) {
g_autofree gchar *uri = g_strconcat ("admin://", path, NULL);

nemo_window_slot_open_location (view->details->slot, location, 0);
gchar *argv[3];
argv[0] = "nemo";
argv[1] = uri;
argv[2] = NULL;
GPid pid;
g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
NULL, NULL, &pid, NULL);
g_child_watch_add (pid, (GChildWatchFunc) cb_open_as_root_watch, NULL);
Comment on lines +7203 to +7210
}

static void
open_as_root (NemoView *view, const gchar *path)
{
if (eel_check_is_wayland ()) {
open_as_admin (view, path);
open_as_admin (path);
return;
}

Expand Down Expand Up @@ -7277,17 +7282,27 @@ action_open_as_root_callback (GtkAction *action,
selection = nemo_view_get_selection (view);
if (selection != NULL) {
gchar *path = nemo_file_get_path (NEMO_FILE (selection->data));
open_as_root (view, path);
if (path != NULL) {
open_as_root (view, path);
g_free (path);
}
nemo_file_list_free (selection);
g_free (path);
} else {
gchar *path;
gchar *uri = nemo_view_get_uri (view);
if (uri == NULL) {
return;
}
GFile *gfile = g_file_new_for_uri (uri);
gchar *path;
if (g_file_has_uri_scheme (gfile, "x-nemo-desktop")) {
path = nemo_get_desktop_directory ();
} else {
path = g_file_get_path (gfile);
if (path == NULL) {
g_free (uri);
g_object_unref (gfile);
return;
}
}
open_as_root (view, path);
g_free (uri);
Expand Down
Loading