Re: [PATCH] - Information-Sidebar should display informations about the selected object (bug 122045)



Previous patch was leaking the selection. Updated patch attached.
Cheers
Vincent

2005/7/15, Vincent Noel <vincent noel gmail com>:
> Hey all,
> here is a patch to fix bug 122045 -
> Information-Sidebar should display informations about the selected object
> http://bugzilla.gnome.org/show_bug.cgi?id=122045
> 
> With this patch, the information sidebar shows information about the
> current selected object (or the current opened folder if nothing is
> selected). If several objects are selected, the last selected object
> is displayed (this is non-optimal but can be improved later...)
> 
> I had to make one function public in nautilus-information-panel.
> 
> Please comment
> 
> Cheers
> Vincent
> 
> 
>
Index: src/nautilus-information-panel.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-information-panel.c,v
retrieving revision 1.231
diff -u -r1.231 nautilus-information-panel.c
--- src/nautilus-information-panel.c	15 Jul 2005 13:47:53 -0000	1.231
+++ src/nautilus-information-panel.c	15 Jul 2005 16:32:41 -0000
@@ -1155,7 +1155,7 @@
 
 /* here is the key routine that populates the information_panel with the appropriate information when the uri changes */
 
-static void
+void
 nautilus_information_panel_set_uri (NautilusInformationPanel *information_panel, 
 				    const char* new_uri,
 				    const char* initial_title)
Index: src/nautilus-information-panel.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-information-panel.h,v
retrieving revision 1.19
diff -u -r1.19 nautilus-information-panel.h
--- src/nautilus-information-panel.h	22 Nov 2004 15:24:37 -0000	1.19
+++ src/nautilus-information-panel.h	15 Jul 2005 16:32:42 -0000
@@ -59,5 +59,9 @@
 
 GType            nautilus_information_panel_get_type     (void);
 void             nautilus_information_panel_register     (void);
+void nautilus_information_panel_set_uri (NautilusInformationPanel *information_panel, 
+					 const char* new_uri,
+					 const char* initial_title);
+
 
 #endif /* NAUTILUS_INFORMATION_PANEL_H */
Index: src/nautilus-navigation-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-navigation-window.c,v
retrieving revision 1.436
diff -u -r1.436 nautilus-navigation-window.c
--- src/nautilus-navigation-window.c	13 Jul 2005 12:23:37 -0000	1.436
+++ src/nautilus-navigation-window.c	15 Jul 2005 16:32:42 -0000
@@ -798,11 +798,63 @@
 }
 
 static void
+selection_changed_callback (NautilusNavigationWindow *window, NautilusView *view)
+{
+	GList *selection, *p;
+	NautilusFile *file;
+	GtkWidget *panel;
+	char *selection_uri;
+	char *selection_name;
+
+	view = NAUTILUS_WINDOW (window)->content_view;
+
+	g_assert (NAUTILUS_IS_VIEW (view));
+	g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
+
+	if (!NAUTILUS_IS_SIDE_PANE (window->sidebar)) {
+		return;
+	}
+
+	panel = nautilus_side_pane_get_current_panel (window->sidebar);
+	if (!NAUTILUS_IS_INFORMATION_PANEL (panel)) {
+		return;
+	}
+
+	selection_uri = NULL;
+
+	selection = nautilus_view_get_selection  (NAUTILUS_VIEW (view));
+	if (selection == NULL) {
+		selection_uri = nautilus_window_get_location (NAUTILUS_WINDOW (window));
+	} else {
+		for (p = selection; p != NULL; p = p->next) {
+			if (p->data != NULL) {
+				selection_uri = g_strdup (p->data);
+			}
+		}
+		eel_g_list_free_deep (selection);
+	}
+	
+	if (selection_uri != NULL) {
+		file = nautilus_file_get (selection_uri);
+		selection_name = nautilus_file_get_display_name (NAUTILUS_FILE (file));
+		nautilus_information_panel_set_uri (NAUTILUS_INFORMATION_PANEL (panel),
+						    selection_uri,
+						    selection_name);
+		nautilus_file_unref (file);
+		g_free (selection_uri);
+		g_free (selection_name);
+	}
+}
+
+static void
 connect_view (NautilusNavigationWindow *window, NautilusView *view)
 {
 	g_signal_connect (view, "zoom_level_changed",
 			  G_CALLBACK (zoom_level_changed_callback),
 			  window);
+	g_signal_connect (window, "selection_changed",
+			  G_CALLBACK (selection_changed_callback),
+			  view);
 }
 
 static void


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