Add "interactive" argument to nautilus_file_mark_desktop_file_trusted.

2009-02-24  Alexander Larsson  <alexl@redhat.com>

        * libnautilus-private/nautilus-file-operations.c:
        * libnautilus-private/nautilus-file-operations.h:
        * libnautilus-private/nautilus-mime-actions.c:
        Add "interactive" argument to
	nautilus_file_mark_desktop_file_trusted.

        * src/nautilus-application.c:
	Mark all desktopfiles on the desktop trusted on first
	run.



svn path=/trunk/; revision=15009
This commit is contained in:
Alexander Larsson 2009-02-24 15:51:54 +00:00 committed by Alexander Larsson
parent 7f175fec75
commit 1e1c916f55
5 changed files with 128 additions and 25 deletions

View file

@ -1,3 +1,15 @@
2009-02-24 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-file-operations.c:
* libnautilus-private/nautilus-file-operations.h:
* libnautilus-private/nautilus-mime-actions.c:
Add "interactive" argument to
nautilus_file_mark_desktop_file_trusted.
* src/nautilus-application.c:
Mark all desktopfiles on the desktop trusted on first
run.
2009-02-24 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-file-operations.c:

View file

@ -134,6 +134,7 @@ typedef struct {
typedef struct {
CommonJob common;
GFile *file;
gboolean interactive;
NautilusOpCallback done_callback;
gpointer done_callback_data;
} MarkTrustedJob;
@ -6004,13 +6005,18 @@ mark_trusted_job (GIOSchedulerJob *io_job,
cancellable,
&contents, &length,
NULL, &error)) {
response = run_error (common,
g_strdup (_("Unable to mark launcher trusted (executable)")),
error->message,
NULL,
FALSE,
GTK_STOCK_CANCEL, RETRY,
NULL);
if (job->interactive) {
response = run_error (common,
g_strdup (_("Unable to mark launcher trusted (executable)")),
error->message,
NULL,
FALSE,
GTK_STOCK_CANCEL, RETRY,
NULL);
} else {
response = 0;
}
if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
abort_job (common);
@ -6040,14 +6046,18 @@ mark_trusted_job (GIOSchedulerJob *io_job,
g_free (contents);
g_free (new_contents);
response = run_error (common,
g_strdup (_("Unable to mark launcher trusted (executable)")),
error->message,
NULL,
FALSE,
GTK_STOCK_CANCEL, RETRY,
NULL);
if (job->interactive) {
response = run_error (common,
g_strdup (_("Unable to mark launcher trusted (executable)")),
error->message,
NULL,
FALSE,
GTK_STOCK_CANCEL, RETRY,
NULL);
} else {
response = 0;
}
if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
abort_job (common);
} else if (response == 1) {
@ -6071,13 +6081,17 @@ mark_trusted_job (GIOSchedulerJob *io_job,
&error);
if (info == NULL) {
response = run_error (common,
g_strdup (_("Unable to mark launcher trusted (executable)")),
error->message,
NULL,
FALSE,
GTK_STOCK_CANCEL, RETRY,
NULL);
if (job->interactive) {
response = run_error (common,
g_strdup (_("Unable to mark launcher trusted (executable)")),
error->message,
NULL,
FALSE,
GTK_STOCK_CANCEL, RETRY,
NULL);
} else {
response = 0;
}
if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
abort_job (common);
@ -6135,6 +6149,7 @@ out:
void
nautilus_file_mark_desktop_file_trusted (GFile *file,
GtkWindow *parent_window,
gboolean interactive,
NautilusOpCallback done_callback,
gpointer done_callback_data)
{
@ -6142,6 +6157,7 @@ nautilus_file_mark_desktop_file_trusted (GFile *file,
job = op_job_new (MarkTrustedJob, parent_window);
job->file = g_object_ref (file);
job->interactive = interactive;
job->done_callback = done_callback;
job->done_callback_data = done_callback_data;

View file

@ -126,6 +126,7 @@ void nautilus_file_operations_link (GList *files,
gpointer done_callback_data);
void nautilus_file_mark_desktop_file_trusted (GFile *file,
GtkWindow *parent_window,
gboolean interactive,
NautilusOpCallback done_callback,
gpointer done_callback_data);

View file

@ -1308,6 +1308,7 @@ untrusted_launcher_response_callback (GtkDialog *dialog,
file = nautilus_file_get_location (parameters->file);
nautilus_file_mark_desktop_file_trusted (file,
parameters->parent_window,
TRUE,
NULL, NULL);
g_object_unref (file);
break;

View file

@ -55,6 +55,7 @@
#include "libnautilus-private/nautilus-file-operations.h"
#include "nautilus-window-private.h"
#include "nautilus-window-manage-views.h"
#include <unistd.h>
#include <libxml/xmlsave.h>
#include <glib/gstdio.h>
#include <glib/gi18n.h>
@ -458,10 +459,77 @@ automount_all_volumes_idle_cb (gpointer data)
}
static void
finish_startup (NautilusApplication *application)
mark_desktop_files_trusted (void)
{
char *user_dir, *do_once_file;
GFile *f, *c;
GFileEnumerator *e;
GFileInfo *info;
const char *name;
int fd;
user_dir = nautilus_get_user_directory ();
do_once_file = g_build_filename (user_dir, "converted-launchers", NULL);
g_free (user_dir);
if (g_file_test (do_once_file, G_FILE_TEST_EXISTS)) {
goto out;
}
f = nautilus_get_desktop_location ();
e = g_file_enumerate_children (f,
G_FILE_ATTRIBUTE_STANDARD_TYPE ","
G_FILE_ATTRIBUTE_STANDARD_NAME ","
G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE
,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
NULL, NULL);
if (e == NULL) {
goto out2;
}
while ((info = g_file_enumerator_next_file (e, NULL, NULL)) != NULL) {
name = g_file_info_get_name (info);
if (g_str_has_suffix (name, ".desktop") &&
!g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE)) {
c = g_file_get_child (f, name);
nautilus_file_mark_desktop_file_trusted (c,
NULL, FALSE,
NULL, NULL);
g_object_unref (c);
}
g_object_unref (info);
}
g_object_unref (e);
out2:
fd = g_creat (do_once_file, 0666);
close (fd);
g_object_unref (f);
out:
g_free (do_once_file);
}
static void
do_upgrades_once (NautilusApplication *application,
gboolean no_desktop)
{
if (!no_desktop) {
mark_desktop_files_trusted ();
}
}
static void
finish_startup (NautilusApplication *application,
gboolean no_desktop)
{
GList *drives;
do_upgrades_once (application, no_desktop);
/* initialize nautilus modules */
nautilus_module_setup ();
@ -645,7 +713,12 @@ nautilus_application_startup (NautilusApplication *application,
no_desktop = TRUE;
}
if (!no_desktop && eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_DESKTOP)) {
if (!no_desktop &&
!eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_DESKTOP)) {
no_desktop = TRUE;
}
if (!no_desktop) {
if (unique_app_is_running (application->unique_app)) {
unique_app_send_message (application->unique_app,
COMMAND_START_DESKTOP, NULL);
@ -655,7 +728,7 @@ nautilus_application_startup (NautilusApplication *application,
}
if (!unique_app_is_running (application->unique_app)) {
finish_startup (application);
finish_startup (application, no_desktop);
g_signal_connect (application->unique_app, "message-received", G_CALLBACK (message_received_cb), application);
}