Logging user actions, updated



Hi,

I've forward-ported my patch with the logging code to Nautilus 2.16.
This version has some more logging for async notifications as well.

[The Unix signal code runs pretty well, btw :) ]

  Federico
2006-10-23  Federico Mena Quintero  <federico novell com>

	* libnautilus-private/nautilus-debug-log.h
	(NAUTILUS_DEBUG_LOG_DOMAIN_GLOG): New domain for GLog messages.
	We'll spit the messages that come from GLog as milestone events.

	* src/nautilus-main.c (setup_debug_log): New function; set up
	everything here.
	(setup_debug_log_glog): New function.  Override the default
	handler for GLog so that its messages will also appear as
	milestone events in our own debug log.

2006-10-16  Federico Mena Quintero  <federico novell com>

	* src/file-manager/fm-directory-view.c (files_added_callback): Log
	when files are added to the view.
	(files_changed_callback): Log when files get changed in the view.
	(fm_directory_view_notify_selection_changed): Log when the
	selection changes.

	* src/nautilus-main.c (setup_debug_log_domains): Add
	NAUTILUS_DEBUG_LOG_DOMAIN_ASYNC to the list of enabled log domains.

	* libnautilus-private/nautilus-debug-log.h: New prototype for
	nautilus_debug_log_with_file_list().

	* libnautilus-private/nautilus-debug-log.c
	(nautilus_debug_log_with_file_list): New function; takes a GList
	of NautilusFile.

2006-10-03  Federico Mena Quintero  <federico novell com>

	* libnautilus-private/nautilus-debug-log.c (nautilus_debug_logv):
	Deal with URI lists optionally.
	(nautilus_debug_log_with_uri_list): New function.

	* libnautilus-private/nautilus-icon-dnd.c
	(receive_dropped_color): Log when a color is dropped.
	(receive_dropped_tile_image): Log when a tile image is dropped.

	* libnautilus-private/nautilus-icon-container.c
	(motion_notify_event): Log when a drag begins.
	(button_release_event): Log when a drag ends.

	* libnautilus-private/nautilus-file-operations.c
	(nautilus_file_operations_copy_move): Log move/copy/link actions.
	(nautilus_file_operations_new_folder): Log when a folder is created.
	(nautilus_file_operations_new_file_from_template): Log when a file
	is created from a template.
	(nautilus_file_operations_new_file): Log when a file is created.
	(nautilus_file_operations_delete): Log when files are deleted.
	(do_empty_trash): Log when the trash is emptied.

2006-09-22  Federico Mena Quintero  <federico novell com>

	* libnautilus-private/nautilus-debug-log.[ch]: New files with a
	simple logging infrastructure based on a ring buffer.

	* libnautilus-private/Makefile.am
	(libnautilus_private_la_SOURCES): Added nautilus-debug-log.[ch].

	* src/nautilus-main.c (main): Make SIGUSR1 dump the debug log to
	~/nautilus-debug-log.txt.

	* src/file-manager/fm-directory-view.c
	(fm_directory_view_activate_files): Log the action of activating a
	file.
	(open_location): Likewise.
	(fm_directory_view_launch_application): Likewise, for launching an
	application.
	(action_new_launcher_callback): Likewise, for creating a launcher.
	(activate_callback): Log the various actions that can happen here.

	* src/file-manager/fm-tree-view.c (got_activation_uri_callback):
	Log the various activations/launches that can happen.

	* src/nautilus-places-sidebar.c (row_activated_callback): Log the
	action of the user activating something in the Places sidebar.

	* src/nautilus-window-manage-views.c
	(nautilus_window_open_location_full): Log the action of changing
	the location in a window.
	(nautilus_window_set_content_view): Log the action of thanging the
	view of a window.
	(end_location_change): Log when the window finishes loading.

	* src/file-manager/fm-list-view.c (row_expanded_callback): Log the
	action of expanding a row to load a subdirectory.
	(row_collapsed_callback): Likewise, for collapsing a row.

	* src/file-manager/fm-error-reporting.c (fm_rename_file): Log the
	action of renaming a file.

	* src/nautilus-application.c
	(nautilus_application_present_spatial_window_with_selection): Log
	when new or existing spatial windows get presented.
	(nautilus_application_create_navigation_window): Log when a
	navigation window gets created.

--- /dev/null	2006-10-03 05:17:45.000000000 -0500
+++ libnautilus-private/nautilus-debug-log.h	2006-10-23 18:51:36.000000000 -0500
@@ -0,0 +1,56 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+   nautilus-debug-log.h: Ring buffer for logging debug messages
+ 
+   Copyright (C) 2006 Novell, Inc.
+  
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+  
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+  
+   You should have received a copy of the GNU General Public
+   License along with this program; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+  
+   Author: Federico Mena-Quintero <federico novell com>
+*/
+
+#ifndef NAUTILUS_DEBUG_LOG_H
+#define NAUTILUS_DEBUG_LOG_H
+
+#include <glib.h>
+
+#define NAUTILUS_DEBUG_LOG_DOMAIN_USER		"USER"	/* always enabled */
+#define NAUTILUS_DEBUG_LOG_DOMAIN_ASYNC		"async"	/* when asynchronous notifications come in */
+#define NAUTILUS_DEBUG_LOG_DOMAIN_GLOG          "GLog"	/* used for GLog messages; don't use it yourself */
+
+void nautilus_debug_log (gboolean is_milestone, const char *domain, const char *format, ...);
+
+void nautilus_debug_log_with_uri_list (gboolean is_milestone, const char *domain, const GList *uris,
+				       const char *format, ...);
+void nautilus_debug_log_with_file_list (gboolean is_milestone, const char *domain, GList *files,
+					const char *format, ...);
+
+void nautilus_debug_logv (gboolean is_milestone, const char *domain, const GList *uris, const char *format, va_list args);
+
+void nautilus_debug_log_enable_domains (const char **domains, int n_domains);
+void nautilus_debug_log_disable_domains (const char **domains, int n_domains);
+
+gboolean nautilus_debug_log_is_domain_enabled (const char *domain);
+
+gboolean nautilus_debug_log_dump (const char *filename, GError **error);
+
+void nautilus_debug_log_set_max_lines (int num_lines);
+int nautilus_debug_log_get_max_lines (void);
+
+/* For testing only */
+void nautilus_debug_log_clear (void);
+
+#endif /* NAUTILUS_DEBUG_LOG_H */
--- /dev/null	2006-10-03 05:17:45.000000000 -0500
+++ libnautilus-private/nautilus-debug-log.c	2006-10-23 14:49:59.000000000 -0500
@@ -0,0 +1,482 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+   nautilus-debug-log.c: Ring buffer for logging debug messages
+ 
+   Copyright (C) 2006 Novell, Inc.
+  
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+  
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+  
+   You should have received a copy of the GNU General Public
+   License along with this program; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+  
+   Author: Federico Mena-Quintero <federico novell com>
+*/
+#include <config.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <sys/time.h>
+#include <eel/eel-glib-extensions.h>
+#include "nautilus-debug-log.h"
+#include "nautilus-file.h"
+
+#define DEFAULT_RING_BUFFER_NUM_LINES 3000
+
+static GStaticMutex log_mutex = G_STATIC_MUTEX_INIT;
+
+static GHashTable *domains_hash;
+static char **ring_buffer;
+static int ring_buffer_next_index;
+static int ring_buffer_num_lines;
+static int ring_buffer_max_lines = DEFAULT_RING_BUFFER_NUM_LINES;
+
+static void
+lock (void)
+{
+	g_static_mutex_lock (&log_mutex);
+}
+
+static void
+unlock (void)
+{
+	g_static_mutex_unlock (&log_mutex);
+}
+
+void
+nautilus_debug_log (gboolean is_milestone, const char *domain, const char *format, ...)
+{
+	va_list args;
+
+	va_start (args, format);
+	nautilus_debug_logv (is_milestone, domain, NULL, format, args);
+	va_end (args);
+}
+
+static gboolean
+is_domain_enabled (const char *domain)
+{
+	/* User actions are always logged */
+	if (strcmp (domain, NAUTILUS_DEBUG_LOG_DOMAIN_USER) == 0)
+		return TRUE;
+
+	if (!domains_hash)
+		return FALSE;
+
+	return (g_hash_table_lookup (domains_hash, domain) != NULL);
+}
+
+static void
+ensure_ring (void)
+{
+	if (ring_buffer)
+		return;
+
+	ring_buffer = g_new0 (char *, ring_buffer_max_lines);
+	ring_buffer_next_index = 0;
+	ring_buffer_num_lines = 0;
+}
+
+static void
+add_to_ring (char *str)
+{
+	ensure_ring ();
+
+	g_assert (str != NULL);
+
+	if (ring_buffer_num_lines == ring_buffer_max_lines) {
+		/* We have an overlap, and the ring_buffer_next_index points to
+		 * the "first" item.  Free it to make room for the new item.
+		 */
+
+		g_assert (ring_buffer[ring_buffer_next_index] != NULL);
+		g_free (ring_buffer[ring_buffer_next_index]);
+	} else
+		ring_buffer_num_lines++;
+
+	g_assert (ring_buffer_num_lines <= ring_buffer_max_lines);
+
+	ring_buffer[ring_buffer_next_index] = str;
+
+	ring_buffer_next_index++;
+	if (ring_buffer_next_index == ring_buffer_max_lines) {
+		ring_buffer_next_index = 0;
+		g_assert (ring_buffer_num_lines == ring_buffer_max_lines);
+	}
+}
+
+void
+nautilus_debug_logv (gboolean is_milestone, const char *domain, const GList *uris, const char *format, va_list args)
+{
+	char *str;
+	char *debug_str;
+	struct timeval tv;
+	struct tm tm;
+
+	lock ();
+
+	if (!(is_milestone || is_domain_enabled (domain)))
+		goto out;
+
+	str = g_strdup_vprintf (format, args);
+	gettimeofday (&tv, NULL);
+
+	tm = *localtime (&tv.tv_sec);
+
+	debug_str = g_strdup_printf ("%p %04d/%02d/%02d %02d:%02d:%02d.%04d (%s): %s",
+				     g_thread_self (),
+				     tm.tm_year + 1900,
+				     tm.tm_mon + 1,
+				     tm.tm_mday,
+				     tm.tm_hour,
+				     tm.tm_min,
+				     tm.tm_sec,
+				     (int) (tv.tv_usec / 100),
+				     domain,
+				     str);
+	g_free (str);
+
+	if (uris) {
+		int debug_str_len;
+		int uris_len;
+		const GList *l;
+		char *new_str;
+		char *p;
+
+		uris_len = 0;
+
+		for (l = uris; l; l = l->next) {
+			const char *uri;
+
+			uri = l->data;
+			uris_len += strlen (uri) + 2; /* plus 2 for a tab and the newline */
+		}
+
+		debug_str_len = strlen (debug_str);
+		new_str = g_new (char, debug_str_len + 1 + uris_len); /* plus 1 for newline */
+
+		p = g_stpcpy (new_str, debug_str);
+		*p++ = '\n';
+
+		for (l = uris; l; l = l->next) {
+			const char *uri;
+
+			uri = l->data;
+
+			*p++ = '\t';
+
+			p = g_stpcpy (p, uri);
+
+			if (l->next)
+				*p++ = '\n';
+		}
+
+		g_free (debug_str);
+		debug_str = new_str;
+	}
+
+	add_to_ring (debug_str);
+
+	/* FIXME: deal with milestones */
+
+ out:
+	unlock ();
+}
+
+void
+nautilus_debug_log_with_uri_list (gboolean is_milestone, const char *domain, const GList *uris,
+				  const char *format, ...)
+{
+	va_list args;
+
+	va_start (args, format);
+	nautilus_debug_logv (is_milestone, domain, uris, format, args);
+	va_end (args);
+}
+
+void
+nautilus_debug_log_with_file_list (gboolean is_milestone, const char *domain, GList *files,
+				   const char *format, ...)
+{
+	va_list args;
+	GList *uris;
+	GList *l;
+
+	uris = NULL;
+
+	for (l = files; l; l = l->next) {
+		NautilusFile *file;
+		char *uri;
+
+		file = NAUTILUS_FILE (l->data);
+		uri = nautilus_file_get_uri (file);
+
+		if (nautilus_file_is_gone (file)) {
+			char *new_uri;
+
+			/* Hack: this will create an invalid URI, but it's for
+			 * display purposes only.
+			 */
+			new_uri = g_strconcat (uri ? uri : "", " (gone)", NULL);
+			g_free (uri);
+			uri = new_uri;
+		}
+		uris = g_list_prepend (uris, uri);
+	}
+
+	uris = g_list_reverse (uris);
+
+	va_start (args, format);
+	nautilus_debug_logv (is_milestone, domain, uris, format, args);
+	va_end (args);
+
+	eel_g_list_free_deep (uris);
+}
+
+void
+nautilus_debug_log_enable_domains (const char **domains, int n_domains)
+{
+	int i;
+
+	g_assert (domains != NULL);
+	g_assert (n_domains >= 0);
+
+	lock ();
+
+	if (!domains_hash)
+		domains_hash = g_hash_table_new (g_str_hash, g_str_equal);
+
+	for (i = 0; i < n_domains; i++) {
+		g_assert (domains[i] != NULL);
+
+		if (strcmp (domains[i], NAUTILUS_DEBUG_LOG_DOMAIN_USER) == 0)
+			continue; /* user actions are always enabled */
+
+		if (g_hash_table_lookup (domains_hash, domains[i]) == NULL) {
+			char *domain;
+
+			domain = g_strdup (domains[i]);
+			g_hash_table_insert (domains_hash, domain, domain);
+		}
+	}
+
+	unlock ();
+}
+
+void
+nautilus_debug_log_disable_domains (const char **domains, int n_domains)
+{
+	int i;
+
+	g_assert (domains != NULL);
+	g_assert (n_domains >= 0);
+
+	lock ();
+
+	if (domains_hash) {
+		for (i = 0; i < n_domains; i++) {
+			char *domain;
+
+			g_assert (domains[i] != NULL);
+
+			if (strcmp (domains[i], NAUTILUS_DEBUG_LOG_DOMAIN_USER) == 0)
+				continue; /* user actions are always enabled */
+
+			domain = g_hash_table_lookup (domains_hash, domains[i]);
+			if (domain) {
+				g_hash_table_remove (domains_hash, domain);
+				g_free (domain);
+			}
+		}
+	} /* else, there is nothing to disable */
+
+	unlock ();
+}
+
+gboolean
+nautilus_debug_log_is_domain_enabled (const char *domain)
+{
+	gboolean retval;
+
+	g_assert (domain != NULL);
+
+	lock ();
+	retval = is_domain_enabled (domain);
+	unlock ();
+
+	return retval;
+}
+
+gboolean
+nautilus_debug_log_dump (const char *filename, GError **error)
+{
+	FILE *file;
+	gboolean success;
+	int start_index;
+	int i;
+
+	g_assert (error == NULL || *error == NULL);
+
+	lock ();
+
+	success = TRUE;
+
+	file = fopen (filename, "w");
+	if (!file) {
+		int saved_errno;
+
+		saved_errno = errno;
+		g_set_error (error,
+			     G_FILE_ERROR,
+			     g_file_error_from_errno (saved_errno),
+			     "could not open log file %s", filename);
+		success = FALSE;
+		goto out;
+	}
+
+	if (ring_buffer_num_lines == ring_buffer_max_lines)
+		start_index = ring_buffer_next_index;
+	else
+		start_index = 0;
+
+	for (i = 0; i < ring_buffer_num_lines; i++) {
+		int idx;
+
+		idx = (start_index + i) % ring_buffer_max_lines;
+
+		if (fputs (ring_buffer[idx], file) == EOF
+		    || fputc ('\n', file) == EOF) {
+			int saved_errno;
+
+			saved_errno = errno;
+			g_set_error (error,
+				     G_FILE_ERROR,
+				     g_file_error_from_errno (saved_errno),
+				     "error when writing to log file %s", filename);
+
+			success = FALSE;
+			goto do_close;
+		}
+	}
+
+ do_close:
+
+	if (fclose (file) != 0) {
+		int saved_errno;
+
+		saved_errno = errno;
+
+		if (error && *error) {
+			g_error_free (*error);
+			*error = NULL;
+		}
+
+		g_set_error (error,
+			     G_FILE_ERROR,
+			     g_file_error_from_errno (saved_errno),
+			     "error when closing log file %s", filename);
+		success = FALSE;
+	}
+
+ out:
+
+	unlock ();
+	return success;
+}
+
+void
+nautilus_debug_log_set_max_lines (int num_lines)
+{
+	char **new_buffer;
+	int lines_to_copy;
+
+	g_assert (num_lines > 0);
+
+	lock ();
+
+	if (num_lines == ring_buffer_max_lines)
+		goto out;
+
+	new_buffer = g_new0 (char *, num_lines);
+
+	lines_to_copy = MIN (num_lines, ring_buffer_num_lines);
+
+	if (ring_buffer) {
+		int start_index;
+		int i;
+
+		if (ring_buffer_num_lines == ring_buffer_max_lines)
+			start_index = (ring_buffer_next_index + ring_buffer_max_lines - lines_to_copy) % ring_buffer_max_lines;
+		else
+			start_index = ring_buffer_num_lines - lines_to_copy;
+
+		g_assert (start_index >= 0 && start_index < ring_buffer_max_lines);
+
+		for (i = 0; i < lines_to_copy; i++) {
+			int idx;
+
+			idx = (start_index + i) % ring_buffer_max_lines;
+
+			new_buffer[i] = ring_buffer[idx];
+			ring_buffer[idx] = NULL;
+		}
+
+		for (i = 0; i < ring_buffer_max_lines; i++)
+			g_free (ring_buffer[i]);
+
+		g_free (ring_buffer);
+	}
+
+	ring_buffer = new_buffer;
+	ring_buffer_next_index = lines_to_copy;
+	ring_buffer_num_lines = lines_to_copy;
+	ring_buffer_max_lines = num_lines;
+
+ out:
+
+	unlock ();
+}
+
+int
+nautilus_debug_log_get_max_lines (void)
+{
+	int retval;
+
+	lock ();
+	retval = ring_buffer_max_lines;
+	unlock ();
+
+	return retval;
+}
+
+void
+nautilus_debug_log_clear (void)
+{
+	int i;
+
+	lock ();
+
+	if (!ring_buffer)
+		goto out;
+
+	for (i = 0; i < ring_buffer_max_lines; i++) {
+		g_free (ring_buffer[i]);
+		ring_buffer[i] = NULL;
+	}
+
+	ring_buffer_next_index = 0;
+	ring_buffer_num_lines = 0;
+
+ out:
+	unlock ();
+}
Index: libnautilus-private/Makefile.am
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/Makefile.am,v
retrieving revision 1.254
diff -u -r1.254 Makefile.am
--- libnautilus-private/Makefile.am	25 Jul 2006 14:18:03 -0000	1.254
+++ libnautilus-private/Makefile.am	23 Oct 2006 20:30:47 -0000
@@ -67,6 +67,8 @@
 	nautilus-column-utilities.h \
 	nautilus-customization-data.c \
 	nautilus-customization-data.h \
+	nautilus-debug-log.c \
+	nautilus-debug-log.h \
 	nautilus-default-file-icon.c \
 	nautilus-default-file-icon.h \
 	nautilus-desktop-directory-file.c \
Index: libnautilus-private/nautilus-file-operations.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-operations.c,v
retrieving revision 1.214
diff -u -r1.214 nautilus-file-operations.c
--- libnautilus-private/nautilus-file-operations.c	23 Aug 2006 09:07:15 -0000	1.214
+++ libnautilus-private/nautilus-file-operations.c	23 Oct 2006 20:30:47 -0000
@@ -30,6 +30,7 @@
 #include <locale.h>
 #include "nautilus-file-operations.h"
 
+#include "nautilus-debug-log.h"
 #include "nautilus-file-operations-progress.h"
 #include "nautilus-lib-self-check-functions.h"
 
@@ -1907,6 +1908,33 @@
 
 	g_assert (item_uris != NULL);
 
+	{
+		const char *action_str;
+
+		switch (copy_action) {
+		case GDK_ACTION_COPY:
+			action_str = "copy";
+			break;
+
+		case GDK_ACTION_MOVE:
+			action_str = "move";
+			break;
+
+		case GDK_ACTION_LINK:
+			action_str = "link";
+			break;
+
+		default:
+			action_str = "[unknown action]";
+			break;
+		}
+
+		nautilus_debug_log_with_uri_list (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER, item_uris,
+						  "%s the following URIs to \"%s\":",
+						  action_str,
+						  target_dir ? target_dir : "[empty location]");
+	}
+
 	target_dir_uri = NULL;
 	trash_dir_uri = NULL;
 	result = GNOME_VFS_OK;
@@ -2376,6 +2404,9 @@
 
 	g_assert (parent_dir != NULL);
 
+	nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+			    "create an untitled folder in \"%s\"", parent_dir);
+
 	/* pass in the target directory and the new folder name as a destination URI */
 	if (eel_uri_is_desktop (parent_dir)) {
 		char *desktop_dir_uri;
@@ -2574,6 +2605,10 @@
 	g_assert (parent_dir != NULL);
 	g_assert (template_uri != NULL);
 
+	nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+			    "create new file \"%s\" from template \"%s\" in \"%s\"",
+			    target_filename ? target_filename : "(none)", template_uri, parent_dir);
+
 	/* pass in the target directory and the new folder name as a destination URI */
 	if (eel_uri_is_desktop (parent_dir)) {
 		tmp = nautilus_get_desktop_directory_uri ();
@@ -2677,6 +2712,10 @@
 	char *target_filename;
 	int fd;
 
+	nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+			    "create new file in \"%s\"",
+			    parent_dir);
+
 	fd = mkstemp (source_file_str);
 	if (fd == -1) {
 		(*done_callback) (NULL, data);
@@ -2723,6 +2762,9 @@
 	NautilusFile *file;
 	TransferInfo *transfer_info;
 
+	nautilus_debug_log_with_uri_list (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER, item_uris,
+					  "delete files:");
+
 	uri_list = NULL;
 	for (p = item_uris; p != NULL; p = p->next) {
 		item_uri = (const char *) p->data;
@@ -2786,6 +2828,9 @@
 {
 	TransferInfo *transfer_info;
 	GList *trash_dir_list;
+
+	nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+			    "empty trash");
 
 	trash_dir_list = nautilus_trash_monitor_get_trash_directories ();
 	if (trash_dir_list != NULL) {
Index: libnautilus-private/nautilus-icon-container.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.c,v
retrieving revision 1.419
diff -u -r1.419 nautilus-icon-container.c
--- libnautilus-private/nautilus-icon-container.c	18 Oct 2006 12:28:35 -0000	1.419
+++ libnautilus-private/nautilus-icon-container.c	23 Oct 2006 20:30:47 -0000
@@ -29,6 +29,7 @@
 #include <math.h>
 #include "nautilus-icon-container.h"
 
+#include "nautilus-debug-log.h"
 #include "nautilus-global-preferences.h"
 #include "nautilus-icon-private.h"
 #include "nautilus-lib-self-check-functions.h"
@@ -3596,6 +3597,8 @@
 				nautilus_icon_container_did_not_drag (container, event);
 			} else {
 				nautilus_icon_dnd_end_drag (container);
+				nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+						    "end drag from icon container");
 			}
 			break;
 		case DRAG_STATE_STRETCH:
@@ -3667,6 +3670,8 @@
 							      event, 
 							      canvas_x,
 							      canvas_y);
+				nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+						    "begin drag from icon container");
 			}
 			break;
 		case DRAG_STATE_STRETCH:
Index: libnautilus-private/nautilus-icon-dnd.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-dnd.c,v
retrieving revision 1.156
diff -u -r1.156 nautilus-icon-dnd.c
--- libnautilus-private/nautilus-icon-dnd.c	27 Jul 2006 21:58:41 -0000	1.156
+++ libnautilus-private/nautilus-icon-dnd.c	23 Oct 2006 20:30:47 -0000
@@ -31,6 +31,7 @@
 #include <math.h>
 #include "nautilus-icon-dnd.h"
 
+#include "nautilus-debug-log.h"
 #include "nautilus-file-dnd.h"
 #include "nautilus-icon-private.h"
 #include "nautilus-link.h"
@@ -559,8 +560,15 @@
 		       GtkSelectionData *data)
 {
 	action = get_background_drag_action (container, action);
-	
+
 	if (action > 0) {
+		char *uri;
+
+		uri = get_container_uri (container);
+		nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+				    "dropped color on icon container displaying %s", uri);
+		g_free (uri);
+
 		eel_background_receive_dropped_color
 			(eel_get_widget_background (GTK_WIDGET (container)),
 			 GTK_WIDGET (container), 
@@ -577,6 +585,13 @@
 	action = get_background_drag_action (container, action);
 
 	if (action > 0) {
+		char *uri;
+
+		uri = get_container_uri (container);
+		nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+				    "dropped tile image on icon container displaying %s", uri);
+		g_free (uri);
+
 		eel_background_receive_dropped_background_image
 			(eel_get_widget_background (GTK_WIDGET (container)), 
 			 action, 
@@ -611,6 +626,11 @@
 	 * so we don't have to worry about async. issues here.
 	 */
 	uri = nautilus_icon_container_get_icon_uri (container, drop_target_icon);
+
+	nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+			    "dropped emblem '%s' on icon container URI: %s",
+			    keyword, uri);
+
 	file = nautilus_file_get (uri);
 	g_free (uri);
 	
Index: src/nautilus-application.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-application.c,v
retrieving revision 1.243
diff -u -r1.243 nautilus-application.c
--- src/nautilus-application.c	21 Jun 2006 16:26:16 -0000	1.243
+++ src/nautilus-application.c	23 Oct 2006 20:30:48 -0000
@@ -76,6 +76,7 @@
 #include <libgnomevfs/gnome-vfs-ops.h>
 #include <libgnomevfs/gnome-vfs-utils.h>
 #include <libgnomevfs/gnome-vfs-volume-monitor.h>
+#include <libnautilus-private/nautilus-debug-log.h>
 #include <libnautilus-private/nautilus-file-utilities.h>
 #include <libnautilus-private/nautilus-global-preferences.h>
 #include <libnautilus-private/nautilus-icon-factory.h>
@@ -1133,6 +1134,10 @@
 			if (new_selection) {
 				nautilus_view_set_selection (existing_window->content_view, new_selection);
 			}
+
+			nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+					    "present EXISTING spatial window=%p: %s",
+					    existing_window, location);
 			return existing_window;
 		}
 	}
@@ -1170,6 +1175,10 @@
 			   spatial_window_destroyed_callback, NULL);
 	
 	nautilus_window_go_to_with_selection (window, location, new_selection);
+
+	nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+			    "present NEW spatial window=%p: %s",
+			    window, location);
 	
 	return window;
 }
@@ -1231,6 +1240,10 @@
 			 another_navigation_window_already_showing (window));
 	}
 	g_free (geometry_string);
+
+	nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+			    "create new navigation window=%p",
+			    window);
 
 	return window;
 }
Index: src/nautilus-main.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-main.c,v
retrieving revision 1.160
diff -u -p -r1.160 nautilus-main.c
--- src/nautilus-main.c	19 Oct 2006 14:24:28 -0000	1.160
+++ src/nautilus-main.c	24 Oct 2006 00:04:54 -0000
@@ -37,6 +37,7 @@
 #include <bonobo-activation/bonobo-activation.h>
 #include <bonobo/bonobo-main.h>
 #include <dlfcn.h>
+#include <signal.h>
 #include <eel/eel-debug.h>
 #include <eel/eel-glib-extensions.h>
 #include <eel/eel-self-checks.h>
@@ -49,6 +50,7 @@
 #include <libgnome/gnome-init.h>
 #include <libgnomeui/gnome-ui-init.h>
 #include <libgnomevfs/gnome-vfs-init.h>
+#include <libnautilus-private/nautilus-debug-log.h>
 #include <libnautilus-private/nautilus-directory-metafile.h>
 #include <libnautilus-private/nautilus-global-preferences.h>
 #include <libnautilus-private/nautilus-lib-self-check-functions.h>
@@ -183,6 +185,140 @@ slowly_and_stupidly_obtain_timestamp (Di
 	return event.xproperty.time;
 }
 
+static void
+dump_debug_log (void)
+{
+	char *filename;
+
+	filename = g_build_filename (g_get_home_dir (), "nautilus-debug-log.txt", NULL);
+	nautilus_debug_log_dump (filename, NULL); /* NULL GError */
+	g_free (filename);
+}
+
+static gboolean
+dump_debug_log_idle_cb (gpointer data)
+{
+	nautilus_debug_log (TRUE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+			    "user requested dump of debug log");
+
+	dump_debug_log ();
+	return FALSE;
+}
+
+/* sigaction structures for the old handlers of these signals */
+static struct sigaction old_segv_sa;
+static struct sigaction old_abrt_sa;
+static struct sigaction old_trap_sa;
+static struct sigaction old_fpe_sa;
+static struct sigaction old_bus_sa;
+
+static void
+sigusr1_handler (int sig)
+{
+	g_idle_add (dump_debug_log_idle_cb, NULL);
+}
+
+static void
+sigfatal_handler (int sig)
+{
+	void (* func) (int);
+
+	/* FIXME: is this totally busted?  We do malloc() inside these functions,
+	 * and yet we are inside a signal handler...
+	 */
+	nautilus_debug_log (TRUE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+			    "debug log dumped due to signal %d", sig);
+	dump_debug_log ();
+
+	switch (sig) {
+	case SIGSEGV:
+		func = old_segv_sa.sa_handler;
+		break;
+
+	case SIGABRT:
+		func = old_abrt_sa.sa_handler;
+		break;
+
+	case SIGTRAP:
+		func = old_trap_sa.sa_handler;
+		break;
+
+	case SIGFPE:
+		func = old_fpe_sa.sa_handler;
+		break;
+
+	case SIGBUS:
+		func = old_bus_sa.sa_handler;
+		break;
+
+	default:
+		func = NULL;
+		break;
+	}
+
+	/* this scares me */
+	if (func != NULL && func != SIG_IGN && func != SIG_DFL)
+		(* func) (sig);
+}
+
+static void
+setup_debug_log_signals (void)
+{
+	struct sigaction sa;
+
+	sa.sa_handler = sigusr1_handler;
+	sigemptyset (&sa.sa_mask);
+	sa.sa_flags = 0;
+	sigaction (SIGUSR1, &sa, NULL);
+
+	sa.sa_handler = sigfatal_handler;
+	sigemptyset (&sa.sa_mask);
+	sa.sa_flags = 0;
+
+	sigaction(SIGSEGV, &sa, &old_segv_sa);
+	sigaction(SIGABRT, &sa, &old_abrt_sa);
+	sigaction(SIGTRAP, &sa, &old_trap_sa);
+	sigaction(SIGFPE,  &sa, &old_fpe_sa);
+	sigaction(SIGBUS,  &sa, &old_bus_sa);
+}
+
+static void
+setup_debug_log_domains (void)
+{
+	const char *domains[] = {
+		NAUTILUS_DEBUG_LOG_DOMAIN_ASYNC
+	};
+
+	nautilus_debug_log_enable_domains (domains, G_N_ELEMENTS (domains));
+}
+
+static GLogFunc default_log_handler;
+
+static void
+log_override_cb (const gchar   *log_domain,
+		 GLogLevelFlags log_level,
+		 const gchar   *message,
+		 gpointer       user_data)
+{
+	nautilus_debug_log (TRUE, NAUTILUS_DEBUG_LOG_DOMAIN_GLOG, "%s", message);
+
+	(* default_log_handler) (log_domain, log_level, message, user_data);
+}
+
+static void
+setup_debug_log_glog (void)
+{
+	default_log_handler = g_log_set_default_handler (log_override_cb, NULL);
+}
+
+static void
+setup_debug_log (void)
+{
+	setup_debug_log_domains ();
+	setup_debug_log_signals ();
+	setup_debug_log_glog ();
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -271,6 +407,12 @@ main (int argc, char *argv[])
 				      GNOME_PARAM_GOPTION_CONTEXT, context,
 				      GNOME_PARAM_HUMAN_READABLE_NAME, _("Nautilus"),
 				      NULL);
+
+	/* We do this after gnome_program_init(), since that function sets up
+	 * its own handler for SIGSEGV and others --- we want to chain to those
+	 * handlers.
+	 */
+	setup_debug_log ();
 
 	if (session_to_load != NULL) {
 		no_default_window = TRUE;
Index: src/nautilus-places-sidebar.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-places-sidebar.c,v
retrieving revision 1.25
diff -u -r1.25 nautilus-places-sidebar.c
--- src/nautilus-places-sidebar.c	13 Sep 2006 20:09:19 -0000	1.25
+++ src/nautilus-places-sidebar.c	23 Oct 2006 20:30:48 -0000
@@ -45,6 +45,7 @@
 #include <libgnome/gnome-macros.h>
 #include <glib/gi18n.h>
 #include <libgnomeui/gnome-popup-menu.h>
+#include <libnautilus-private/nautilus-debug-log.h>
 #include <libnautilus-private/nautilus-dnd.h>
 #include <libnautilus-private/nautilus-bookmark.h>
 #include <libnautilus-private/nautilus-global-preferences.h>
@@ -474,6 +475,9 @@
 		(model, &iter, PLACES_SIDEBAR_COLUMN_URI, &uri, -1);
 	
 	if (uri != NULL) {
+		nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+				    "activate from places sidebar window=%p: %s",
+				    sidebar->window, uri);
 		/* Navigate to the clicked location. */
 		nautilus_window_info_open_location
 			(sidebar->window, 
@@ -484,6 +488,14 @@
 		gtk_tree_model_get 
 			(model, &iter, PLACES_SIDEBAR_COLUMN_DRIVE, &drive, -1);
 		if (drive != NULL) {
+			char *path;
+
+			path = gnome_vfs_drive_get_device_path (drive);
+			nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+					    "activate drive from places sidebar window=%p: %s",
+					    sidebar->window, path);
+			g_free (path);
+
 			gnome_vfs_drive_mount (drive, volume_op_callback, sidebar);
 			gnome_vfs_drive_unref (drive);
 		}
Index: src/nautilus-window-manage-views.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window-manage-views.c,v
retrieving revision 1.368
diff -u -r1.368 nautilus-window-manage-views.c
--- src/nautilus-window-manage-views.c	8 Jul 2006 08:38:17 -0000	1.368
+++ src/nautilus-window-manage-views.c	23 Oct 2006 20:30:48 -0000
@@ -54,6 +54,7 @@
 #include <libgnomevfs/gnome-vfs-uri.h>
 #include <libgnomevfs/gnome-vfs-utils.h>
 #include <libnautilus-extension/nautilus-location-widget-provider.h>
+#include <libnautilus-private/nautilus-debug-log.h>
 #include <libnautilus-private/nautilus-file-attributes.h>
 #include <libnautilus-private/nautilus-file-utilities.h>
 #include <libnautilus-private/nautilus-file.h>
@@ -473,9 +474,18 @@
 {
         NautilusWindow *target_window;
         gboolean do_load_location = TRUE;
+	char *old_location;
         
         target_window = NULL;
 
+	old_location = nautilus_window_get_location (window);
+	nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+			    "window %p open location: old=\"%s\", new=\"%s\"",
+			    window,
+			    old_location ? old_location : "(none)",
+			    location);
+	g_free (old_location);
+
 	switch (mode) {
         case NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE :
 		if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
@@ -1275,6 +1285,15 @@
 static void
 end_location_change (NautilusWindow *window)
 {
+	char *location;
+
+	location = nautilus_window_get_location (window);
+	if (location) {
+		nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+				    "finished loading window %p: %s", window, location);
+		g_free (location);
+	}
+
         nautilus_window_allow_stop (window, FALSE);
 
         /* Now we can free pending_scroll_to, since the load_complete
@@ -1532,10 +1551,17 @@
                                   const char *id)
 {
 	NautilusFile *file;
+	char *location;
 	
 	g_return_if_fail (NAUTILUS_IS_WINDOW (window));
         g_return_if_fail (window->details->location != NULL);
 	g_return_if_fail (id != NULL);
+
+	location = nautilus_window_get_location (window);
+	nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+			    "change view of window %p: \"%s\" to \"%s\"",
+			    window, location, id);
+	g_free (location);
 
         if (nautilus_window_content_view_matches_iid (window, id)) {
         	return;
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.752
diff -u -p -r1.752 fm-directory-view.c
--- src/file-manager/fm-directory-view.c	19 Oct 2006 14:28:47 -0000	1.752
+++ src/file-manager/fm-directory-view.c	23 Oct 2006 23:57:23 -0000
@@ -80,6 +80,7 @@
 #include <libnautilus-private/nautilus-recent.h>
 #include <libnautilus-extension/nautilus-menu-provider.h>
 #include <libnautilus-private/nautilus-clipboard-monitor.h>
+#include <libnautilus-private/nautilus-debug-log.h>
 #include <libnautilus-private/nautilus-desktop-icon-file.h>
 #include <libnautilus-private/nautilus-desktop-directory.h>
 #include <libnautilus-private/nautilus-search-directory.h>
@@ -770,14 +771,18 @@ fm_directory_view_launch_application (Gn
 {
 	NautilusFile *file;
 	GList *l;
+	GtkWindow *window;
 
 	g_assert (application != NULL);
 	g_assert (NAUTILUS_IS_FILE (files->data));
 	g_assert (FM_IS_DIRECTORY_VIEW (directory_view));
 
-	nautilus_launch_application
-			(application, files, 
-			 fm_directory_view_get_containing_window (directory_view));
+	window = fm_directory_view_get_containing_window (directory_view);
+
+	nautilus_debug_log_with_file_list (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER, files,
+					   "fm_directory_view_launch_application window=%p", window);
+
+	nautilus_launch_application (application, files, window);
 
 	for (l = files; l != NULL; l = l->next) {
 		file = NAUTILUS_FILE (l->data);
@@ -816,6 +821,7 @@ open_location (FMDirectoryView *director
 	       NautilusWindowOpenFlags flags)
 {
 	NautilusFile *file;
+	GtkWindow *window;
 
 	g_assert (FM_IS_DIRECTORY_VIEW (directory_view));
 	g_assert (new_uri != NULL);
@@ -830,7 +836,10 @@ open_location (FMDirectoryView *director
 		monitor_file_for_open_with (directory_view, NULL);
 	}
 	nautilus_file_unref (file);
-	
+
+	window = fm_directory_view_get_containing_window (directory_view);
+	nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+			    "directory view open_location window=%p: %s", window, new_uri);
 	nautilus_window_info_open_location (directory_view->details->window,
 					    new_uri, mode, flags, NULL);
 }
@@ -1412,6 +1421,7 @@ action_new_launcher_callback (GtkAction 
 {
 	char *parent_uri;
 	FMDirectoryView *view;
+	GtkWindow *window;
 
 	g_assert (FM_IS_DIRECTORY_VIEW (callback_data));
 
@@ -1419,6 +1429,9 @@ action_new_launcher_callback (GtkAction 
 
 	parent_uri = fm_directory_view_get_backing_uri (view);
 
+	window = fm_directory_view_get_containing_window (view);
+	nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+			    "directory view create new launcher in window=%p: %s", window, parent_uri);
 	nautilus_launch_application_from_command (gtk_widget_get_screen (GTK_WIDGET (view)),
 						  "gnome-desktop-item-edit", 
 						  "gnome-desktop-item-edit --create-new",
@@ -3097,9 +3110,19 @@ files_added_callback (NautilusDirectory 
 		      gpointer callback_data)
 {
 	FMDirectoryView *view;
+	GtkWindow *window;
+	char *uri;
 
 	view = FM_DIRECTORY_VIEW (callback_data);
 
+	window = fm_directory_view_get_containing_window (view);
+	uri = fm_directory_view_get_uri (view);
+	nautilus_debug_log_with_file_list (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_ASYNC, files,
+					   "files added in window %p: %s",
+					   window,
+					   uri ? uri : "(no directory)");
+	g_free (uri);
+
 	schedule_changes (view);
 
 	queue_pending_files (view, directory, files, &view->details->new_added_files);
@@ -3114,9 +3137,19 @@ files_changed_callback (NautilusDirector
 			gpointer callback_data)
 {
 	FMDirectoryView *view;
+	GtkWindow *window;
+	char *uri;
 	
 	view = FM_DIRECTORY_VIEW (callback_data);
 
+	window = fm_directory_view_get_containing_window (view);
+	uri = fm_directory_view_get_uri (view);
+	nautilus_debug_log_with_file_list (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_ASYNC, files,
+					   "files changed in window %p: %s",
+					   window,
+					   uri ? uri : "(no directory)");
+	g_free (uri);
+
 	schedule_changes (view);
 
 	queue_pending_files (view, directory, files, &view->details->new_changed_files);
@@ -5297,6 +5330,7 @@ run_script_callback (GtkAction *action, 
 	char *quoted_path;
 	char *old_working_dir;
 	char *parameters, *command, *name;
+	GtkWindow *window;
 	
 	launch_parameters = (ScriptLaunchParameters *) callback_data;
 
@@ -5333,6 +5367,10 @@ run_script_callback (GtkAction *action, 
 
 	name = nautilus_file_get_name (launch_parameters->file);
 	/* FIXME: handle errors with dialog? Or leave up to each script? */
+	window = fm_directory_view_get_containing_window (launch_parameters->directory_view);
+	nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+			    "directory view run_script_callback, window=%p, name=\"%s\", command=\"%s\"",
+			    window, name, command);
 	nautilus_launch_application_from_command (screen, name, command, NULL, FALSE);
 	g_free (name);
 	g_free (command);
@@ -7999,9 +8037,17 @@ fm_directory_view_notify_selection_chang
 {
 	NautilusFile *file;
 	GList *selection;
+	GtkWindow *window;
 	
 	g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
 
+	selection = fm_directory_view_get_selection (view);
+
+	window = fm_directory_view_get_containing_window (view);
+	nautilus_debug_log_with_file_list (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER, selection,
+					   "selection changed in window %p",
+					   window);
+
 	view->details->selection_was_removed = FALSE;
 
 	if (!view->details->selection_change_is_due_to_shell) {
@@ -8030,7 +8076,6 @@ fm_directory_view_notify_selection_chang
 		/* If there's exactly one item selected we sniff the slower attributes needed
 		 * to activate a file ahead of time to improve interactive response.
 		 */
-		selection = fm_directory_view_get_selection (view);
 
 		if (eel_g_list_exactly_one_item (selection)) {
 			file = NAUTILUS_FILE (selection->data);
@@ -8049,9 +8094,9 @@ fm_directory_view_notify_selection_chang
 				 NULL, 
 				 NULL);
 		}
-
-		nautilus_file_list_free (selection);
 	}
+
+	nautilus_file_list_free (selection);
 }
 
 static gboolean
@@ -8293,6 +8338,7 @@ activate_callback (GList *files, gpointe
 	char *old_working_dir;
 	ActivationAction action;
 	GdkScreen *screen;
+	GtkWindow *window;
 
 	parameters = callback_data;
 
@@ -8353,12 +8399,18 @@ activate_callback (GList *files, gpointe
 		}
 	}
 
+	window = fm_directory_view_get_containing_window (parameters->view);
 
 	launch_desktop_files = g_list_reverse (launch_desktop_files);
 	for (l = launch_desktop_files; l != NULL; l = l->next) {
 		file = NAUTILUS_FILE (l->data);
 
 		uri = nautilus_file_get_uri (file);
+
+		nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+				    "directory view activate_callback launch_desktop_file window=%p: %s",
+				    window, uri);
+
 		nautilus_launch_desktop_file (
 				screen, uri, NULL,
 				fm_directory_view_get_containing_window (view));
@@ -8370,6 +8422,11 @@ activate_callback (GList *files, gpointe
 		file = NAUTILUS_FILE (l->data);
 
 		uri = nautilus_file_get_activation_uri (file);
+
+		nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+				    "directory view activate_callback launch_application_from_command window=%p: %s",
+				    window, uri);
+
 		nautilus_launch_application_from_command (
 				screen, NULL, uri + strlen (NAUTILUS_COMMAND_SPECIFIER),
 				NULL, FALSE);
@@ -8389,6 +8446,11 @@ activate_callback (GList *files, gpointe
 		executable_path = gnome_vfs_get_local_path_from_uri (uri);
 		quoted_path = g_shell_quote (executable_path);
 		name = nautilus_file_get_name (file);
+
+		nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+				    "directory view activate_callback launch_file window=%p: %s",
+				    window, quoted_path);
+
 		nautilus_launch_application_from_command (screen, name, quoted_path, NULL, FALSE);
 		g_free (name);
 		g_free (quoted_path);
@@ -8405,6 +8467,11 @@ activate_callback (GList *files, gpointe
 		executable_path = gnome_vfs_get_local_path_from_uri (uri);
 		quoted_path = g_shell_quote (executable_path);
 		name = nautilus_file_get_name (file);
+
+		nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+				    "directory view activate_callback launch_in_terminal window=%p: %s",
+				    window, quoted_path);
+
 		nautilus_launch_application_from_command (screen, name, quoted_path, NULL, TRUE);
 		g_free (name);
 		g_free (quoted_path);
@@ -8685,12 +8752,18 @@ fm_directory_view_activate_files (FMDire
 	char *file_name;
 	char *timed_wait_prompt;
 	int file_count;
+	GtkWindow *window;
 
 	g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
 
 	if (files == NULL) {
 		return;
 	}
+
+	window = fm_directory_view_get_containing_window (view);
+	nautilus_debug_log_with_file_list (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER, files,
+					   "fm_directory_view_activate_files window=%p",
+					    window);
 
 	file_count = g_list_length (files);
 
Index: src/file-manager/fm-error-reporting.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-error-reporting.c,v
retrieving revision 1.43
diff -u -r1.43 fm-error-reporting.c
--- src/file-manager/fm-error-reporting.c	18 Mar 2006 07:27:37 -0000	1.43
+++ src/file-manager/fm-error-reporting.c	23 Oct 2006 20:30:50 -0000
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <glib/gi18n.h>
 #include <libgnomevfs/gnome-vfs-result.h>
+#include <libnautilus-private/nautilus-debug-log.h>
 #include <libnautilus-private/nautilus-file.h>
 #include <eel/eel-string.h>
 #include <eel/eel-stock-dialogs.h>
@@ -319,6 +320,7 @@
 {
 	char *old_name, *wait_message;
 	FMRenameData *data;
+	char *uri;
 
 	g_return_if_fail (NAUTILUS_IS_FILE (file));
 	g_return_if_fail (new_name != NULL);
@@ -345,6 +347,12 @@
 	eel_timed_wait_start (cancel_rename_callback, file, wait_message, 
 			      NULL); /* FIXME bugzilla.gnome.org 42395: Parent this? */
 	g_free (wait_message);
+
+	uri = nautilus_file_get_uri (file);
+	nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+			    "rename file old=\"%s\", new=\"%s\"",
+			    uri, new_name);
+	g_free (uri);
 
 	/* Start the rename. */
 	nautilus_file_rename (file, new_name,
Index: src/file-manager/fm-list-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-view.c,v
retrieving revision 1.274
diff -u -r1.274 fm-list-view.c
--- src/file-manager/fm-list-view.c	18 Oct 2006 13:20:44 -0000	1.274
+++ src/file-manager/fm-list-view.c	23 Oct 2006 20:30:51 -0000
@@ -54,6 +54,7 @@
 #include <libnautilus-extension/nautilus-column-provider.h>
 #include <libnautilus-private/nautilus-column-chooser.h>
 #include <libnautilus-private/nautilus-column-utilities.h>
+#include <libnautilus-private/nautilus-debug-log.h>
 #include <libnautilus-private/nautilus-directory-background.h>
 #include <libnautilus-private/nautilus-dnd.h>
 #include <libnautilus-private/nautilus-file-dnd.h>
@@ -785,6 +786,15 @@
 	view = FM_LIST_VIEW (callback_data);
 
 	if (fm_list_model_load_subdirectory (view->details->model, path, &directory)) {
+		char *uri;
+
+		uri = nautilus_directory_get_uri (directory);
+		nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+				    "list view row expanded window=%p: %s",
+				    fm_directory_view_get_containing_window (FM_DIRECTORY_VIEW (view)),
+				    uri);
+		g_free (uri);
+
 		fm_directory_view_add_subdirectory (FM_DIRECTORY_VIEW (view), directory);
 		
 		if (nautilus_directory_are_all_files_seen (directory)) {
@@ -848,6 +858,7 @@
 	GtkTreeIter parent;
 	struct UnloadDelayData *unload_data;
 	GtkTreeModel *model;
+	char *uri;
 	
 	view = FM_LIST_VIEW (callback_data);
 	model = GTK_TREE_MODEL (view->details->model);
@@ -863,6 +874,14 @@
 				    -1);
 	}
 	
+
+	uri = nautilus_file_get_uri (file);
+	nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+			    "list view row collapsed window=%p: %s",
+			    fm_directory_view_get_containing_window (FM_DIRECTORY_VIEW (view)),
+			    uri);
+	g_free (uri);
+
 	unload_data = g_new (struct UnloadDelayData, 1);
 	unload_data->view = view;
 	unload_data->file = file;
Index: src/file-manager/fm-tree-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-tree-view.c,v
retrieving revision 1.28
diff -u -r1.28 fm-tree-view.c
--- src/file-manager/fm-tree-view.c	24 Jul 2006 23:40:48 -0000	1.28
+++ src/file-manager/fm-tree-view.c	23 Oct 2006 20:30:51 -0000
@@ -61,6 +61,7 @@
 #include <libgnomevfs/gnome-vfs-utils.h>
 #include <libgnomevfs/gnome-vfs-volume-monitor.h>
 #include <libnautilus-private/nautilus-clipboard-monitor.h>
+#include <libnautilus-private/nautilus-debug-log.h>
 #include <libnautilus-private/nautilus-file-attributes.h>
 #include <libnautilus-private/nautilus-file-operations.h>
 #include <libnautilus-private/nautilus-global-preferences.h>
@@ -344,12 +345,18 @@
 	    && eel_str_has_prefix (uri, NAUTILUS_COMMAND_SPECIFIER)) {
 
 		uri += strlen (NAUTILUS_COMMAND_SPECIFIER);
+		nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+				    "tree view launch_application_from_command window=%p: %s",
+				    view->details->window, uri);
 		nautilus_launch_application_from_command (screen, NULL, uri, NULL, FALSE);
 
 	} else if (uri != NULL
 	    	   && eel_str_has_prefix (uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
 		   
 		file_uri = nautilus_file_get_uri (file);
+		nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+				    "tree view launch_desktop_file window=%p: %s",
+				    view->details->window, file_uri);
 		nautilus_launch_desktop_file (screen, file_uri, NULL, NULL);
 		g_free (file_uri);
 		
@@ -362,6 +369,9 @@
 
 		/* Non-local executables don't get launched. They act like non-executables. */
 		if (file_uri == NULL) {
+			nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+					    "tree view window_info_open_location window=%p: %s",
+					    view->details->window, uri);
 			nautilus_window_info_open_location
 				(view->details->window, 
 				 uri, 
@@ -369,6 +379,9 @@
 				 0,
 				 NULL);
 		} else {
+			nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+					    "tree view launch_application_from_command window=%p: %s",
+					    view->details->window, file_uri);
 			nautilus_launch_application_from_command (screen, NULL, file_uri, NULL, FALSE);
 			g_free (file_uri);
 		}
@@ -380,6 +393,9 @@
 				g_free (view->details->selection_location);
 			}
 			view->details->selection_location = g_strdup (uri);
+			nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+					    "tree view window_info_open_location window=%p: %s",
+					    view->details->window, uri);
 			nautilus_window_info_open_location
 				(view->details->window, 
 				 uri,


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