multihead desktop



Hello nautilus dudes,

I've a patch here that changes the multihead behavior of nautilus.  Currently, nautilus (poorly) displays the same desktop icons on every screen.  This patch makes the desktop icons screen-specific.  That is, each icon will only show up on one screen.  You can drag the icons between screens, create new folders on a given screen, etc.  The patch is a bit hacky (esp. the dnd stuff), but it seems to work pretty well, and I think it's much more usable this way.  It might be a bit late to get this into 2.2, but what do y'all think of it?

Thanks,
James
Index: libnautilus-private/nautilus-directory-notify.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-directory-notify.h,v
retrieving revision 1.11
diff -u -r1.11 nautilus-directory-notify.h
--- libnautilus-private/nautilus-directory-notify.h	21 Feb 2002 19:26:46 -0000	1.11
+++ libnautilus-private/nautilus-directory-notify.h	19 Dec 2002 05:09:06 -0000
@@ -31,6 +31,7 @@
 } URIPair;
 
 typedef struct {
+	int screen;
 	char *uri;
 	gboolean set;
 	GdkPoint point;
Index: libnautilus-private/nautilus-directory.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-directory.c,v
retrieving revision 1.241
diff -u -r1.241 nautilus-directory.c
--- libnautilus-private/nautilus-directory.c	18 Oct 2002 15:47:28 -0000	1.241
+++ libnautilus-private/nautilus-directory.c	19 Dec 2002 05:09:10 -0000
@@ -1447,6 +1447,7 @@
 	const NautilusFileChangesQueuePosition *item;
 	NautilusFile *file;
 	char *position_string;
+	char *screen_string;
 
 	for (p = position_setting_list; p != NULL; p = p->next) {
 		item = (NautilusFileChangesQueuePosition *) p->data;
@@ -1465,6 +1466,14 @@
 			 NULL,
 			 position_string);
 		g_free (position_string);
+
+		screen_string = g_strdup_printf ("%d", item->screen);
+		nautilus_file_set_metadata
+			(file,
+			 NAUTILUS_METADATA_KEY_SCREEN,
+			 NULL,
+			 screen_string);
+		g_free (screen_string);
 		
 		nautilus_file_unref (file);
 	}
Index: libnautilus-private/nautilus-file-changes-queue.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-changes-queue.c,v
retrieving revision 1.20
diff -u -r1.20 nautilus-file-changes-queue.c
--- libnautilus-private/nautilus-file-changes-queue.c	23 Aug 2001 16:48:09 -0000	1.20
+++ libnautilus-private/nautilus-file-changes-queue.c	19 Dec 2002 05:09:10 -0000
@@ -52,6 +52,7 @@
 	char *from_uri;
 	char *to_uri;
 	GdkPoint point;
+	int screen;
 } NautilusFileChange;
 
 typedef struct {
@@ -242,7 +243,8 @@
 
 void
 nautilus_file_changes_queue_schedule_position_set (const char *uri, 
-						   GdkPoint point)
+						   GdkPoint point,
+						   int screen)
 {
 	NautilusFileChange *new_item;
 	NautilusFileChangesQueue *queue;
@@ -253,6 +255,7 @@
 	new_item->kind = CHANGE_POSITION_SET;
 	new_item->from_uri = g_strdup (uri);
 	new_item->point = point;
+	new_item->screen = screen;
 	nautilus_file_changes_queue_add_common (queue, new_item);
 }
 
@@ -529,6 +532,7 @@
 			position_set->uri = change->from_uri;
 			position_set->set = TRUE;
 			position_set->point = change->point;
+			position_set->screen = change->screen;
 			position_set_requests = g_list_prepend (position_set_requests,
 								position_set);
 			break;
Index: libnautilus-private/nautilus-file-changes-queue.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-changes-queue.h,v
retrieving revision 1.7
diff -u -r1.7 nautilus-file-changes-queue.h
--- libnautilus-private/nautilus-file-changes-queue.h	16 Apr 2001 22:07:01 -0000	1.7
+++ libnautilus-private/nautilus-file-changes-queue.h	19 Dec 2002 05:09:10 -0000
@@ -36,7 +36,8 @@
 							   const char *to_uri);
 void nautilus_file_changes_queue_schedule_metadata_remove (const char *uri);
 void nautilus_file_changes_queue_schedule_position_set    (const char *uri,
-							   GdkPoint    point);
+							   GdkPoint    point,
+							   int screen);
 void nautilus_file_changes_queue_schedule_position_remove (const char *uri);
 
 void nautilus_file_changes_consume_changes                (gboolean    consume_all);
Index: libnautilus-private/nautilus-file-operations.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-operations.c,v
retrieving revision 1.159
diff -u -r1.159 nautilus-file-operations.c
--- libnautilus-private/nautilus-file-operations.c	18 Dec 2002 12:39:34 -0000	1.159
+++ libnautilus-private/nautilus-file-operations.c	19 Dec 2002 05:09:15 -0000
@@ -117,10 +117,12 @@
 	int last_icon_position_index;
 	GList *uris;
 	const GList *last_uri;
+	int screen;
 } IconPositionIterator;
 
 static IconPositionIterator *
-icon_position_iterator_new (GArray *icon_positions, const GList *uris)
+icon_position_iterator_new (GArray *icon_positions, const GList *uris,
+			    int screen)
 {
 	IconPositionIterator *result;
 	guint index;
@@ -137,6 +139,7 @@
 
 	result->uris = eel_g_str_list_copy ((GList *)uris);
 	result->last_uri = result->uris;
+	result->screen = screen;
 
 	return result;
 }
@@ -1525,7 +1528,7 @@
 	GdkPoint point;
 
 	if (icon_position_iterator_get_next (position_iterator, source_name, &point)) {
-		nautilus_file_changes_queue_schedule_position_set (target_name, point);
+		nautilus_file_changes_queue_schedule_position_set (target_name, point, position_iterator->screen);
 	} else {
 		nautilus_file_changes_queue_schedule_position_remove (target_name);
 	}
@@ -1715,6 +1718,9 @@
 	
 	IconPositionIterator *icon_position_iterator;
 
+	GdkScreen *screen;
+	int screen_num;
+
 	g_assert (item_uris != NULL);
 
 	target_dir_uri = NULL;
@@ -1834,11 +1840,13 @@
 	/* set up the copy/move parameters */
 	transfer_info = transfer_info_new (parent_view);
 	if (relative_item_points != NULL && relative_item_points->len > 0) {
+		screen = gtk_widget_get_screen (GTK_WIDGET (parent_view));
+		screen_num = gdk_screen_get_number (screen);
 		/* FIXME: we probably don't need an icon_position_iterator
 		 * here at all.
 		 */
 		icon_position_iterator = icon_position_iterator_new
-			(relative_item_points, item_uris);
+			(relative_item_points, item_uris, screen_num);
 	} else {
 		icon_position_iterator = NULL;
 	}
Index: libnautilus-private/nautilus-icon-dnd.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-dnd.c,v
retrieving revision 1.123
diff -u -r1.123 nautilus-icon-dnd.c
--- libnautilus-private/nautilus-icon-dnd.c	31 Oct 2002 22:38:46 -0000	1.123
+++ libnautilus-private/nautilus-icon-dnd.c	19 Dec 2002 05:09:26 -0000
@@ -33,6 +33,7 @@
 #include "nautilus-file-dnd.h"
 #include "nautilus-icon-private.h"
 #include "nautilus-link.h"
+#include "nautilus-metadata.h"
 #include <eel/eel-background.h>
 #include <eel/eel-gdk-pixbuf-extensions.h>
 #include <eel/eel-glib-extensions.h>
@@ -758,6 +759,9 @@
 	GList *moved_icons, *p;
 	NautilusDragSelectionItem *item;
 	NautilusIcon *icon;
+	NautilusFile *file;
+	char *screen_string;
+	GdkScreen *screen;
 
 	if (container->details->auto_layout) {
 		if (!confirm_switch_to_manual_layout (container)) {
@@ -766,6 +770,7 @@
 		nautilus_icon_container_freeze_icon_positions (container);
 	}
 
+
 	/* Move and select the icons. */
 	moved_icons = NULL;
 	for (p = container->details->dnd_info->drag_info.selection_list; p != NULL; p = p->next) {
@@ -774,6 +779,29 @@
 		icon = nautilus_icon_container_get_icon_by_uri
 			(container, item->uri);
 
+		if (icon == NULL) {
+			/* probably dragged from another screen.  Add it to
+			 * this screen
+			 */
+
+			file = nautilus_file_get (item->uri);
+
+			screen = gtk_widget_get_screen (GTK_WIDGET (container));
+			screen_string = g_strdup_printf ("%d",
+						gdk_screen_get_number (screen));
+			nautilus_file_set_metadata (file,
+					NAUTILUS_METADATA_KEY_SCREEN,
+					NULL, screen_string);
+
+			g_free (screen_string);
+
+			nautilus_icon_container_add (container,
+					NAUTILUS_ICON_CONTAINER_ICON_DATA (file));
+			
+			icon = nautilus_icon_container_get_icon_by_uri
+				(container, item->uri);
+		}
+
 		if (item->got_icon_position) {
 			nautilus_icon_container_move_icon
 				(container, icon,
@@ -804,7 +832,7 @@
 	if (container->details->dnd_info->drag_info.selection_list == NULL) {
 		return;
 	}
-	
+
 	source_uris = NULL;
 	for (p = container->details->dnd_info->drag_info.selection_list; p != NULL; p = p->next) {
 		/* do a shallow copy of all the uri strings of the copied files */
Index: libnautilus-private/nautilus-metadata.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-metadata.h,v
retrieving revision 1.24
diff -u -r1.24 nautilus-metadata.h
--- libnautilus-private/nautilus-metadata.h	31 Jan 2001 00:26:57 -0000	1.24
+++ libnautilus-private/nautilus-metadata.h	19 Dec 2002 05:09:26 -0000
@@ -71,6 +71,7 @@
 #define NAUTILUS_METADATA_KEY_ICON_POSITION              	"icon_position"
 #define NAUTILUS_METADATA_KEY_ICON_SCALE                 	"icon_scale"
 #define NAUTILUS_METADATA_KEY_CUSTOM_ICON                	"custom_icon"
+#define NAUTILUS_METADATA_KEY_SCREEN				"screen"
 
 /* per link file */
 
Index: src/file-manager/fm-desktop-icon-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-desktop-icon-view.c,v
retrieving revision 1.197
diff -u -r1.197 fm-desktop-icon-view.c
--- src/file-manager/fm-desktop-icon-view.c	6 Nov 2002 11:25:45 -0000	1.197
+++ src/file-manager/fm-desktop-icon-view.c	19 Dec 2002 05:09:29 -0000
@@ -665,8 +665,8 @@
 		desktop_directory_changed_callback (NULL);
 	}
 
+	fm_icon_view_filter_by_screen (FM_ICON_VIEW (desktop_icon_view), TRUE);
 	icon_container = get_icon_container (desktop_icon_view);
-
 	nautilus_icon_container_set_use_drop_shadows (icon_container, TRUE);
 	fm_icon_container_set_sort_desktop (FM_ICON_CONTAINER (icon_container), TRUE);
 
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.558
diff -u -r1.558 fm-directory-view.c
--- src/file-manager/fm-directory-view.c	7 Nov 2002 19:20:40 -0000	1.558
+++ src/file-manager/fm-directory-view.c	19 Dec 2002 05:09:57 -0000
@@ -3200,10 +3200,23 @@
 new_folder_done (const char *new_folder_uri, gpointer data)
 {
 	FMDirectoryView *directory_view;
+	NautilusFile *file;
+	char *screen_string;
+	GdkScreen *screen;
 
 	directory_view = (FMDirectoryView *) data;
 	g_assert (FM_IS_DIRECTORY_VIEW (directory_view));
 
+	screen = gtk_widget_get_screen (GTK_WIDGET (directory_view));
+	screen_string = g_strdup_printf ("%d", gdk_screen_get_number (screen));
+
+	file = nautilus_file_get (new_folder_uri);
+	nautilus_file_set_metadata
+		(file, NAUTILUS_METADATA_KEY_SCREEN,
+		 NULL,
+		 screen_string);
+	g_free (screen_string);
+
 	/* We need to run after the default handler adds the folder we want to
 	 * operate on. The ADD_FILE signal is registered as G_SIGNAL_RUN_LAST, so we
 	 * must use connect_after.
@@ -5244,7 +5257,7 @@
 file_changed_callback (NautilusFile *file, gpointer callback_data)
 {
 	FMDirectoryView *view = FM_DIRECTORY_VIEW (callback_data);
-	
+
 	schedule_update_menus (view);
 
 	/* We might have different capabilities, so we need to update
Index: src/file-manager/fm-icon-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-icon-view.c,v
retrieving revision 1.269
diff -u -r1.269 fm-icon-view.c
--- src/file-manager/fm-icon-view.c	18 Oct 2002 15:47:29 -0000	1.269
+++ src/file-manager/fm-icon-view.c	19 Dec 2002 05:09:58 -0000
@@ -28,6 +28,7 @@
 #include "fm-icon-container.h"
 #include "fm-desktop-icon-view.h"
 #include "fm-error-reporting.h"
+#include <stdlib.h>
 #include <bonobo/bonobo-ui-util.h>
 #include <eel/eel-background.h>
 #include <eel/eel-glib-extensions.h>
@@ -132,6 +133,9 @@
 	NautilusAudioPlayerData *audio_player_data;
 	int audio_preview_timeout;
 	NautilusFile *audio_preview_file;
+
+	gboolean filter_by_screen;
+	int num_screens;
 };
 
 
@@ -463,14 +467,54 @@
 	nautilus_icon_container_clear (icon_container);
 }
 
+
+static gboolean
+should_show_file (FMDirectoryView *view, NautilusFile *file)
+{
+	char *screen_string;
+	int screen_num;
+	FMIconView *icon_view;
+	GdkScreen *screen;
+
+	icon_view = FM_ICON_VIEW (view);
+
+	/* Get the screen for this icon from the metadata. */
+	screen_string = nautilus_file_get_metadata
+		(file, NAUTILUS_METADATA_KEY_SCREEN, "0");
+	screen_num = atoi (screen_string);
+	g_free (screen_string);
+	screen = gtk_widget_get_screen (GTK_WIDGET (view));
+
+	if (screen_num != gdk_screen_get_number (screen) &&
+	    screen_num < icon_view->details->num_screens) {
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static void
+fm_icon_view_remove_file (FMDirectoryView *view, NautilusFile *file)
+{
+	if (nautilus_icon_container_remove (get_icon_container (FM_ICON_VIEW (view)),
+					    NAUTILUS_ICON_CONTAINER_ICON_DATA (file))) {
+		nautilus_file_unref (file);
+	}
+}
+
 static void
 fm_icon_view_add_file (FMDirectoryView *view, NautilusFile *file)
 {
 	FMIconView *icon_view;
 	NautilusIconContainer *icon_container;
-
+	
 	icon_view = FM_ICON_VIEW (view);
 	icon_container = get_icon_container (icon_view);
+
+	if (icon_view->details->filter_by_screen &&
+	    !should_show_file (view, file)) {
+			return;
+	}
 	
 	/* Reset scroll region for the first icon added when loading a directory. */
 	if (icon_view->details->loading && nautilus_icon_container_is_empty (icon_container)) {
@@ -482,21 +526,30 @@
 	}
 }
 
-static void
-fm_icon_view_remove_file (FMDirectoryView *view, NautilusFile *file)
-{
-	if (nautilus_icon_container_remove (get_icon_container (FM_ICON_VIEW (view)),
-					    NAUTILUS_ICON_CONTAINER_ICON_DATA (file))) {
-		nautilus_file_unref (file);
-	}
-}
 
 static void
 fm_icon_view_file_changed (FMDirectoryView *view, NautilusFile *file)
 {
-	nautilus_icon_container_request_update
-		(get_icon_container (FM_ICON_VIEW (view)),
-		 NAUTILUS_ICON_CONTAINER_ICON_DATA (file));
+	FMIconView *icon_view;
+
+	g_return_if_fail (view != NULL);
+	icon_view = FM_ICON_VIEW (view);
+
+	if (!icon_view->details->filter_by_screen) {
+		nautilus_icon_container_request_update
+			(get_icon_container (icon_view),
+			 NAUTILUS_ICON_CONTAINER_ICON_DATA (file));
+		return;
+	}
+	
+	if (!should_show_file (view, file)) {
+		fm_icon_view_remove_file (view, file);
+	} else {
+
+		nautilus_icon_container_request_update
+			(get_icon_container (icon_view),
+			 NAUTILUS_ICON_CONTAINER_ICON_DATA (file));
+	}
 }
 
 static gboolean
@@ -1756,6 +1809,14 @@
 		 icon_view->details->sort_reversed);
 }
 
+void
+fm_icon_view_filter_by_screen (FMIconView *icon_view,
+			       gboolean filter)
+{
+	icon_view->details->filter_by_screen = filter;
+	icon_view->details->num_screens = gdk_display_get_n_screens (gtk_widget_get_display (GTK_WIDGET (icon_view)));
+}
+
 static int
 compare_files_cover (gconstpointer a, gconstpointer b, gpointer callback_data)
 {
@@ -2416,6 +2477,7 @@
 
 	icon_view->details = g_new0 (FMIconViewDetails, 1);
 	icon_view->details->sort = &sort_criteria[0];
+	icon_view->details->filter_by_screen = FALSE;
 
 	create_icon_container (icon_view);
 
Index: src/file-manager/fm-icon-view.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-icon-view.h,v
retrieving revision 1.10
diff -u -r1.10 fm-icon-view.h
--- src/file-manager/fm-icon-view.h	9 Apr 2002 13:51:12 -0000	1.10
+++ src/file-manager/fm-icon-view.h	19 Dec 2002 05:09:58 -0000
@@ -91,5 +91,6 @@
 int     fm_icon_view_compare_files (FMIconView   *icon_view,
 				    NautilusFile *a,
 				    NautilusFile *b);
+void    fm_icon_view_filter_by_screen (FMIconView *icon_view, gboolean filter);
 
 #endif /* FM_ICON_VIEW_H */


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