Re: [PATCH] Information & Notes side panes follow selection



Ehm... in fact I don't remember why I put this option in the preferences
window :P. 
By the way, here's a simplified version without the preference key.

A.


Il giorno dom, 23/03/2008 alle 12.39 +0100, Cosimo Cecchi ha scritto:

> Also, why do you think we need a preference key to control this
> behavior?
> 
> Cheers (and happy Easter!)
thank you (a little too late :) )
> 
> Cosimo

-- 
Amos Brocco | Ph.D Student | Computer Science Department - DIUF |
University of Fribourg | A406 Pérolles 21 | Bd. Pérolles 90 |
CH-1700 Fribourg | http://diuf.unifr.ch/pai/people/broccoa

diff -rupN nautilus-2.22.0-orig/src/nautilus-information-panel.c nautilus-2.22.0/src/nautilus-information-panel.c
--- nautilus-2.22.0-orig/src/nautilus-information-panel.c	2008-03-07 16:28:03.000000000 +0100
+++ nautilus-2.22.0/src/nautilus-information-panel.c	2008-03-24 02:20:41.000000000 +0100
@@ -51,6 +51,8 @@
 #include <libnautilus-private/nautilus-program-choosing.h>
 #include <libnautilus-private/nautilus-sidebar-provider.h>
 #include <libnautilus-private/nautilus-module.h>
+#include <gio/gio.h>
+
 
 struct NautilusInformationPanelDetails {
 	GtkVBox *container;
@@ -1094,6 +1096,32 @@ nautilus_information_panel_style_set (Gt
 }
 
 static void
+selection_changed_callback (NautilusWindowInfo *window,
+		      NautilusInformationPanel *panel)
+{	
+	int selection_count = nautilus_window_info_get_selection_count (window);
+
+	if (selection_count == 1) {
+		/* One selected, show detailed info */
+		GList* selection = nautilus_window_info_get_selection (window);
+		GFile* selected = selection->data;
+		
+		nautilus_information_panel_set_uri (panel, 
+				    g_file_get_uri (selected), g_file_get_basename (selected));
+				    
+		g_object_unref (selected);
+		g_list_free (selection);		 
+	} else {
+		/* Nothing or more than one selected, show directory info */
+		char* uri = nautilus_window_info_get_current_location (window);
+		char* title = nautilus_window_info_get_title (window);
+		nautilus_information_panel_set_uri (panel, uri, title);
+		g_free (title);		
+		g_free (uri);
+	}
+}
+
+static void
 loading_uri_callback (NautilusWindowInfo *window,
 		      char               *uri,
 		      NautilusInformationPanel *panel)
@@ -1119,6 +1147,8 @@ nautilus_information_panel_set_parent_wi
 				 G_CALLBACK (loading_uri_callback), panel, 0);
 	g_signal_connect_object (window, "title_changed",
 				 G_CALLBACK (title_changed_callback), panel, 0);
+    g_signal_connect_object (window, "selection_changed",
+    			 G_CALLBACK (selection_changed_callback), panel, 0);
 	
 	title = nautilus_window_info_get_title (window);
 	location = nautilus_window_info_get_current_location (window);
diff -rupN nautilus-2.22.0-orig/src/nautilus-notes-viewer.c nautilus-2.22.0/src/nautilus-notes-viewer.c
--- nautilus-2.22.0-orig/src/nautilus-notes-viewer.c	2008-03-07 16:28:03.000000000 +0100
+++ nautilus-2.22.0/src/nautilus-notes-viewer.c	2008-03-24 02:20:21.000000000 +0100
@@ -279,6 +279,39 @@ notes_load_metainfo (NautilusNotesViewer
 }
 
 static void
+selection_changed_callback (NautilusWindowInfo *window,
+		      NautilusNotesViewer *notes)
+{	
+	int selection_count = nautilus_window_info_get_selection_count (window);
+
+	if (selection_count == 1) {
+		/* One selected, show notes of selected file */
+		GList* selection = nautilus_window_info_get_selection (window);
+		GFile* selected = selection->data;
+		char* location = g_file_get_uri (selected);
+		if (strcmp (notes->details->uri, location) != 0) {
+                notes_save_metainfo (notes);
+                g_free (notes->details->uri);
+                notes->details->uri = g_strdup (location);
+                notes_load_metainfo (notes);
+        }
+        g_free (location);				    
+		g_object_unref (selected);
+		g_list_free (selection);		 
+	} else {
+		/* Nothing or more than one selected, show directory notes */
+		char* location = nautilus_window_info_get_current_location (window);
+		if (strcmp (notes->details->uri, location) != 0) {
+                notes_save_metainfo (notes);
+                g_free (notes->details->uri);
+                notes->details->uri = g_strdup (location);
+                notes_load_metainfo (notes);
+        }
+        g_free (location);
+	}
+}
+
+static void
 loading_uri_callback (NautilusSidebar *sidebar,
                       const char *location,
                       NautilusNotesViewer *notes)
@@ -432,6 +465,9 @@ nautilus_notes_viewer_set_parent_window 
 {
 	g_signal_connect_object (window, "loading_uri",
 				 G_CALLBACK (loading_uri_callback), sidebar, 0);
+				 
+    g_signal_connect_object (window, "selection_changed",
+    			 G_CALLBACK (selection_changed_callback), sidebar, 0);				 
         
         g_free (sidebar->details->uri);
         sidebar->details->uri = nautilus_window_info_get_current_location (window);

Attachment: signature.asc
Description: Questa =?ISO-8859-1?Q?=E8?= una parte del messaggio firmata digitalmente



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