nautilus r15009 - in trunk: . libnautilus-private src



Author: alexl
Date: Tue Feb 24 15:51:54 2009
New Revision: 15009
URL: http://svn.gnome.org/viewvc/nautilus?rev=15009&view=rev

Log:
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.




Modified:
   trunk/ChangeLog
   trunk/libnautilus-private/nautilus-file-operations.c
   trunk/libnautilus-private/nautilus-file-operations.h
   trunk/libnautilus-private/nautilus-mime-actions.c
   trunk/src/nautilus-application.c

Modified: trunk/libnautilus-private/nautilus-file-operations.c
==============================================================================
--- trunk/libnautilus-private/nautilus-file-operations.c	(original)
+++ trunk/libnautilus-private/nautilus-file-operations.c	Tue Feb 24 15:51:54 2009
@@ -134,6 +134,7 @@
 typedef struct {
 	CommonJob common;
 	GFile *file;
+	gboolean interactive;
 	NautilusOpCallback done_callback;
 	gpointer done_callback_data;
 } MarkTrustedJob;
@@ -6004,13 +6005,18 @@
 				  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 @@
 			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 @@
 				  &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 @@
 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 @@
 	
 	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;
 	

Modified: trunk/libnautilus-private/nautilus-file-operations.h
==============================================================================
--- trunk/libnautilus-private/nautilus-file-operations.h	(original)
+++ trunk/libnautilus-private/nautilus-file-operations.h	Tue Feb 24 15:51:54 2009
@@ -126,6 +126,7 @@
 					 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);
 

Modified: trunk/libnautilus-private/nautilus-mime-actions.c
==============================================================================
--- trunk/libnautilus-private/nautilus-mime-actions.c	(original)
+++ trunk/libnautilus-private/nautilus-mime-actions.c	Tue Feb 24 15:51:54 2009
@@ -1308,6 +1308,7 @@
 		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;

Modified: trunk/src/nautilus-application.c
==============================================================================
--- trunk/src/nautilus-application.c	(original)
+++ trunk/src/nautilus-application.c	Tue Feb 24 15:51:54 2009
@@ -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 @@
 }
 
 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 @@
 			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 @@
 		}
 
 		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);			
 		}
 		



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]