[Nautilus-list] Memleak patch



Hello,

here's a patch that fixes some of the memory leaks I came across while
using memprof to run nautilus. Most stuff is straightforward, the only
semi-complex thing I do is put the volume_mount_uri inside a struct in
nautilus-trash-directory.c so that it can be freed.

There also a change in e_paned_pack that makes the sidebar be 0 pixels
wide when collapsed (instead of 1 which is the current behavior).

Comments?

//andersca
andersca gnu org

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.4731
diff -u -r1.4731 ChangeLog
--- ChangeLog	2001/08/22 17:33:21	1.4731
+++ ChangeLog	2001/08/22 22:08:04
@@ -1,3 +1,57 @@
+2001-08-23  Anders Carlsson  <andersca gnu org>
+
+	* components/sample/Makefile.am (nautilus_sample_content_view_LDADD): 
+	add EEL_LIBS.
+
+ 	* configure.in: Remove CONTROL_CENTER_REQUIRED since nautilus
+ 	doesn't require control-center anymore.
+ 
+ 	* src/nautilus-window.c (nautilus_window_constructed): 
+ 	Set shrink to TRUE when adding the sidebar since it'll look
+ 	better when the splitter is collapsed.
+ 	(nautilus_window_destroy): Free the window title.
+ 
+ 	* src/nautilus-window-manage-views.c (begin_location_change): 
+ 	Unref the directory when we're done using it.
+ 
+ 	* src/nautilus-sidebar.c (nautilus_sidebar_destroy): Unref
+ 	the title tab if it hasn't got a parent.
+ 
+ 	* libnautilus-private/nautilus-vfs-file.c (vfs_destroy): 
+ 	Free details struct.
+ 
+ 	* libnautilus-private/nautilus-vfs-directory.c (vfs_destroy): 
+ 	Free details struct.
+ 
+ 	* libnautilus-private/nautilus-trash-directory.c: 
+ 	Add the volume mount uri to the TrashVolume struct.
+ 	(get_trash_volume): Set volume_mount_uri.
+ 	(add_volume): Set vfs_uri_as_list to the volume mount uri.
+ 	(remove_trash_volume): Unref the volume mount uri.
+ 
+ 	* libnautilus-private/nautilus-mime-actions.c 
+ 	(nautilus_mime_get_short_list_applications_for_file): 
+ 	Free uri_scheme.
+ 	(make_oaf_query_with_uri_scheme_only): Free explicit_iid_query.
+ 
+ 	* libnautilus-private/nautilus-metafile.c (destroy): 
+ 	Unref the private vfs uri, and free the directory uri.
+ 
+ 	* libnautilus-private/nautilus-file.c (nautilus_file_get_internal): 
+ 	Free the string returned by nautilus_directory_get_name_for_self_as_new_file.
+ 
+ 	* libnautilus-private/nautilus-file-changes-queue.c 
+ 	(nautilus_file_changes_consume_changes): 
+ 	Free the change struct.
+ 
+ 	* libnautilus-private/nautilus-directory-async.c 
+ 	(nautilus_directory_invalidate_count_and_mime_list): 
+ 	Unref the file after using it.
+ 
+ 	* libnautilus/nautilus-idle-queue.c (execute_queued_functions): 
+ 	Deep free the list to get rid of the allocated structs.
+ 	(nautilus_idle_queue_destroy): Likewise.
+
 2001-08-22  Ramiro Estrugo  <ramiro fateware com>
 
 	reviewed by: <delete if not using a buddy>
Index: configure.in
===================================================================
RCS file: /cvs/gnome/nautilus/configure.in,v
retrieving revision 1.360
diff -u -r1.360 configure.in
--- configure.in	2001/08/15 06:35:01	1.360
+++ configure.in	2001/08/22 22:08:05
@@ -8,7 +8,6 @@
 dnl ==========================================================================
 
 BONOBO_REQUIRED=0.37
-CONTROL_CENTER_REQUIRED=1.3
 EEL_REQUIRED=1.0
 ESOUND_REQUIRED=0.2.22
 FREETYPE_LIBRARY_REQUIRED=6.1.0
@@ -420,9 +419,6 @@
 LIBS=$GNOMEUI_LIBS
 AC_CHECK_FUNCS(gnome_canvas_set_dither)
 LIBS="$_libs"
-
-dnl control center
-NAUTILUS_VERSION_INSIST(control-center, $GNOME_CONFIG --modversion capplet | awk -F- '{print $2}', >=, CONTROL_CENTER_REQUIRED)
 
 dnl Bonobo
 NAUTILUS_VERSION_INSIST(bonobo, $GNOME_CONFIG --modversion bonobo | awk -F- '{print $2}', >=, BONOBO_REQUIRED)
Index: components/sample/Makefile.am
===================================================================
RCS file: /cvs/gnome/nautilus/components/sample/Makefile.am,v
retrieving revision 1.28
diff -u -r1.28 Makefile.am
--- components/sample/Makefile.am	2001/07/21 17:06:44	1.28
+++ components/sample/Makefile.am	2001/08/22 22:08:05
@@ -12,6 +12,7 @@
 	-DICON_DIR=\"$(datadir)/pixmaps/nautilus\" \
 	-I$(top_srcdir)				\
 	-I$(top_builddir)			\
+	$(EEL_CFLAGS)				\
 	$(GNOMEUI_CFLAGS)                       \
 	$(BONOBO_CFLAGS)			\
 	$(OAF_CFLAGS)
@@ -26,6 +27,7 @@
 
 nautilus_sample_content_view_LDADD =		\
 	$(top_builddir)/libnautilus/libnautilus.la	\
+	$(EEL_LIBS)				\
 	$(BONOBO_LIBS)				\
 	$(BONOBOX_LIBS)				\
 	$(GCONF_LIBS)				\
Index: libnautilus/nautilus-idle-queue.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus/nautilus-idle-queue.c,v
retrieving revision 1.3
diff -u -r1.3 nautilus-idle-queue.c
--- libnautilus/nautilus-idle-queue.c	2001/03/08 19:53:29	1.3
+++ libnautilus/nautilus-idle-queue.c	2001/08/22 22:08:05
@@ -26,6 +26,7 @@
 #include <config.h>
 #include "nautilus-idle-queue.h"
 
+#include <eel/eel-glib-extensions.h>
 #include <gtk/gtkmain.h>
 
 struct NautilusIdleQueue {
@@ -70,7 +71,7 @@
 			}
 		}
 
-		g_list_free (functions);
+		eel_g_list_free_deep (functions);
 	}
 	queue->in_idle = FALSE;
 
@@ -130,7 +131,7 @@
 		}
 	}
 	
-	g_list_free (queue->functions);
+	eel_g_list_free_deep (queue->functions);
 
 	if (queue->idle_id != 0) {
 		gtk_idle_remove (queue->idle_id);
Index: libnautilus-private/nautilus-directory-async.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-directory-async.c,v
retrieving revision 1.160
diff -u -r1.160 nautilus-directory-async.c
--- libnautilus-private/nautilus-directory-async.c	2001/07/23 10:12:53	1.160
+++ libnautilus-private/nautilus-directory-async.c	2001/08/22 22:08:06
@@ -1915,6 +1915,8 @@
 	if (file != NULL) {
 		nautilus_file_invalidate_count_and_mime_list (file);
 	}
+	
+	nautilus_file_unref (file);
 }
 
 static void
Index: libnautilus-private/nautilus-file-changes-queue.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-changes-queue.c,v
retrieving revision 1.19
diff -u -r1.19 nautilus-file-changes-queue.c
--- libnautilus-private/nautilus-file-changes-queue.c	2001/05/11 01:30:30	1.19
+++ libnautilus-private/nautilus-file-changes-queue.c	2001/08/22 22:08:06
@@ -547,5 +547,6 @@
 		}
 		change->from_uri = NULL;
 		change->to_uri = NULL;
+		g_free (change);
 	}	
 }
Index: libnautilus-private/nautilus-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file.c,v
retrieving revision 1.249
diff -u -r1.249 nautilus-file.c
--- libnautilus-private/nautilus-file.c	2001/07/16 21:15:06	1.249
+++ libnautilus-private/nautilus-file.c	2001/08/22 22:08:06
@@ -299,7 +299,7 @@
 static NautilusFile *
 nautilus_file_get_internal (const char *uri, gboolean create)
 {
-	char *canonical_uri, *directory_uri, *relative_uri;
+	char *canonical_uri, *directory_uri, *relative_uri, *file_name;
 	gboolean self_owned;
 	GnomeVFSURI *vfs_uri, *directory_vfs_uri;
 	NautilusDirectory *directory;
@@ -358,8 +358,9 @@
 	if (vfs_uri == NULL) {
 		g_assert (self_owned);
 		if (directory != NULL) {
-			relative_uri = gnome_vfs_escape_string
-				(nautilus_directory_get_name_for_self_as_new_file (directory));
+			file_name = nautilus_directory_get_name_for_self_as_new_file (directory);
+			relative_uri = gnome_vfs_escape_string (file_name);
+			g_free (file_name);
 		}
 	}
 
Index: libnautilus-private/nautilus-font-factory.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-font-factory.c,v
retrieving revision 1.16
diff -u -r1.16 nautilus-font-factory.c
--- libnautilus-private/nautilus-font-factory.c	2001/05/04 10:17:53	1.16
+++ libnautilus-private/nautilus-font-factory.c	2001/08/22 22:08:06
@@ -25,6 +25,7 @@
 #include <config.h>
 #include "nautilus-font-factory.h"
 
+#include <gdk/gdkprivate.h>
 #include "nautilus-global-preferences.h"
 #include <eel/eel-gtk-macros.h>
 #include <eel/eel-string.h>
Index: libnautilus-private/nautilus-icon-factory.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-factory.c,v
retrieving revision 1.224
diff -u -r1.224 nautilus-icon-factory.c
--- libnautilus-private/nautilus-icon-factory.c	2001/07/24 23:38:40	1.224
+++ libnautilus-private/nautilus-icon-factory.c	2001/08/22 22:08:07
@@ -1015,6 +1015,7 @@
 		
 			/* Return the path if the file exists. */
 			if (path != NULL) {
+				g_free (partial_path);
 				break;
 			}
 			
@@ -1512,6 +1513,7 @@
 			g_free (file_path);
 		}
 		g_free (directory);
+		g_free (directory_uri);
 		g_free (desktop_directory);
 	}
 	
Index: libnautilus-private/nautilus-metafile.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-metafile.c,v
retrieving revision 1.15
diff -u -r1.15 nautilus-metafile.c
--- libnautilus-private/nautilus-metafile.c	2001/07/07 09:19:14	1.15
+++ libnautilus-private/nautilus-metafile.c	2001/08/22 22:08:08
@@ -240,13 +240,18 @@
 	if (metafile->details->private_vfs_uri != NULL) {
 		gnome_vfs_uri_unref (metafile->details->private_vfs_uri);
 	}
-	
+	if (metafile->details->directory_vfs_uri != NULL) {
+		gnome_vfs_uri_unref (metafile->details->directory_vfs_uri);
+	}
+
 	g_hash_table_remove (metafiles, metafile->details->directory_uri);
 	
 	metafile_free_metadata (metafile);
 	g_hash_table_destroy (metafile->details->node_hash);
 
 	g_assert (metafile->details->write_idle_id == 0);
+
+	g_free (metafile->details->directory_uri);
 
 	g_free (metafile->details);
 
Index: libnautilus-private/nautilus-mime-actions.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-mime-actions.c,v
retrieving revision 1.88
diff -u -r1.88 nautilus-mime-actions.c
--- libnautilus-private/nautilus-mime-actions.c	2001/06/01 16:27:19	1.88
+++ libnautilus-private/nautilus-mime-actions.c	2001/08/22 22:08:08
@@ -486,7 +486,8 @@
 	result = eel_g_list_partition (result, application_supports_uri_scheme,
 					    uri_scheme, &removed);
 	gnome_vfs_mime_application_list_free (removed);
-
+	g_free (uri_scheme);
+	
 	metadata_application_add_ids = nautilus_file_get_metadata_list 
 		(file,
 		 NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_ADD,
@@ -1444,6 +1445,8 @@
                   , explicit_iid_query,
 		  extra_requirements != NULL ? extra_requirements : "true");
 
+	g_free (explicit_iid_query);
+	
         return result;
 }
 
Index: libnautilus-private/nautilus-trash-directory.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-trash-directory.c,v
retrieving revision 1.25
diff -u -r1.25 nautilus-trash-directory.c
--- libnautilus-private/nautilus-trash-directory.c	2001/08/15 21:03:59	1.25
+++ libnautilus-private/nautilus-trash-directory.c	2001/08/22 22:08:09
@@ -48,6 +48,8 @@
 
 	GnomeVFSAsyncHandle *handle;
 	NautilusDirectory *real_directory;
+
+	GnomeVFSURI *volume_mount_uri;
 } TrashVolume;
 
 static void     nautilus_trash_directory_initialize       (gpointer                object,
@@ -137,8 +139,7 @@
 static gboolean
 get_trash_volume (NautilusTrashDirectory *trash,
 		  NautilusVolume *volume,
-		  TrashVolume **trash_volume,
-		  GnomeVFSURI **volume_mount_uri)
+		  TrashVolume **trash_volume)
 {
 	char *uri_str;
 
@@ -154,15 +155,16 @@
 		return FALSE;
 	}
 
-	uri_str = gnome_vfs_get_uri_from_local_path (nautilus_volume_get_mount_path (volume));
-	*volume_mount_uri = gnome_vfs_uri_new (uri_str);
-	g_free (uri_str);
-
 	if (*trash_volume == NULL) {
 		/* Make the structure used to track the trash for this volume. */
 		*trash_volume = g_new0 (TrashVolume, 1);
 		(*trash_volume)->trash = trash;
 		(*trash_volume)->volume = volume;
+
+		uri_str = gnome_vfs_get_uri_from_local_path (nautilus_volume_get_mount_path (volume));
+		(*trash_volume)->volume_mount_uri = gnome_vfs_uri_new (uri_str);
+		g_free (uri_str);
+		
 		g_hash_table_insert (trash->details->volumes, volume, *trash_volume);
 	}
 	
@@ -174,15 +176,14 @@
 	    NautilusVolume *volume)
 {
 	TrashVolume *trash_volume;
-	GnomeVFSURI *volume_mount_uri;
 	GList vfs_uri_as_list;
 
-	if (!get_trash_volume (trash, volume, &trash_volume, &volume_mount_uri)) {
+	if (!get_trash_volume (trash, volume, &trash_volume)) {
 		return;
 	}
 
 	/* Find the real trash directory for this one. */
-	vfs_uri_as_list.data = volume_mount_uri;
+	vfs_uri_as_list.data = trash_volume->volume_mount_uri;
 	vfs_uri_as_list.next = NULL;
 	vfs_uri_as_list.prev = NULL;
 
@@ -200,21 +201,19 @@
 {
 	GnomeVFSResult result;
 	TrashVolume *trash_volume;
-	GnomeVFSURI *volume_mount_uri;
 	GnomeVFSURI *trash_uri;
 	char *uri;
 
-	if (!get_trash_volume (trash, volume, &trash_volume, &volume_mount_uri)) {
+	if (!get_trash_volume (trash, volume, &trash_volume)) {
 		return;
 	}
 
 	/* Do a synch trash lookup -- if the trash directory was just created, it's location will
 	 * be known and returned immediately without any blocking.
 	 */
-	result = gnome_vfs_find_directory (volume_mount_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
+	result = gnome_vfs_find_directory (trash_volume->volume_mount_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
 		&trash_uri, FALSE, FALSE, 077);
 	
-	gnome_vfs_uri_unref (volume_mount_uri);
 	if (result != GNOME_VFS_OK) {
 		return;
 	}
@@ -250,6 +249,11 @@
 			 trash_volume->real_directory);
 		nautilus_directory_unref (trash_volume->real_directory);
 	}
+
+	if (trash_volume->volume_mount_uri != NULL) {
+		gnome_vfs_uri_unref (trash_volume->volume_mount_uri);
+	}
+	
 	g_free (trash_volume);
 }
 
Index: libnautilus-private/nautilus-vfs-directory.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-vfs-directory.c,v
retrieving revision 1.15
diff -u -r1.15 nautilus-vfs-directory.c
--- libnautilus-private/nautilus-vfs-directory.c	2001/07/05 23:16:53	1.15
+++ libnautilus-private/nautilus-vfs-directory.c	2001/08/22 22:08:09
@@ -55,6 +55,12 @@
 static void
 vfs_destroy (GtkObject *object)
 {
+	NautilusVFSDirectory *directory;
+
+	directory = NAUTILUS_VFS_DIRECTORY (object);
+
+	g_free (directory->details);
+
 	EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
 }
 
Index: libnautilus-private/nautilus-vfs-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-vfs-file.c,v
retrieving revision 1.10
diff -u -r1.10 nautilus-vfs-file.c
--- libnautilus-private/nautilus-vfs-file.c	2001/07/05 23:16:53	1.10
+++ libnautilus-private/nautilus-vfs-file.c	2001/08/22 22:08:09
@@ -245,6 +245,12 @@
 static void
 vfs_destroy (GtkObject *object)
 {
+	NautilusVFSFile *file;
+
+	file = NAUTILUS_VFS_FILE (object);
+
+	g_free (file->details);
+	
 	EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
 }
 
Index: libnautilus-private/nautilus-view-identifier.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-view-identifier.c,v
retrieving revision 1.15
diff -u -r1.15 nautilus-view-identifier.c
--- libnautilus-private/nautilus-view-identifier.c	2001/04/04 00:06:03	1.15
+++ libnautilus-private/nautilus-view-identifier.c	2001/08/22 22:08:09
@@ -184,6 +184,13 @@
 }
 
 NautilusViewIdentifier *
+nautilus_view_identifier_new_from_property_page (OAF_ServerInfo *server)
+{
+	return nautilus_view_identifier_new_from_oaf_server_info
+		(server, "nautilus:property_page_name");
+}
+
+NautilusViewIdentifier *
 nautilus_view_identifier_new_from_sidebar_panel (OAF_ServerInfo *server)
 {
 	return nautilus_view_identifier_new_from_oaf_server_info
Index: libnautilus-private/nautilus-view-identifier.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-view-identifier.h,v
retrieving revision 1.9
diff -u -r1.9 nautilus-view-identifier.h
--- libnautilus-private/nautilus-view-identifier.h	2001/02/25 10:02:13	1.9
+++ libnautilus-private/nautilus-view-identifier.h	2001/08/22 22:08:09
@@ -38,6 +38,7 @@
 									   char                         *name_attribute);
 NautilusViewIdentifier *nautilus_view_identifier_new_from_content_view    (OAF_ServerInfo               *server);
 NautilusViewIdentifier *nautilus_view_identifier_new_from_sidebar_panel   (OAF_ServerInfo               *server);
+NautilusViewIdentifier *nautilus_view_identifier_new_from_property_page   (OAF_ServerInfo               *server);
 NautilusViewIdentifier *nautilus_view_identifier_copy                     (const NautilusViewIdentifier *identifier);
 void                    nautilus_view_identifier_free                     (NautilusViewIdentifier       *identifier);
 int                     nautilus_view_identifier_compare                  (const NautilusViewIdentifier *a,
Index: src/nautilus-sidebar-title.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-sidebar-title.c,v
retrieving revision 1.107
diff -u -r1.107 nautilus-sidebar-title.c
--- src/nautilus-sidebar-title.c	2001/07/15 08:54:11	1.107
+++ src/nautilus-sidebar-title.c	2001/08/22 22:08:09
@@ -573,10 +573,10 @@
 	if (largest_fitting_font == NULL) {
 		largest_fitting_font = eel_gdk_font_get_fixed ();
 	}
-	
+
 	eel_gtk_widget_set_font (sidebar_title->details->title_label,
 				      largest_fitting_font);
-	
+
 	gdk_font_unref (largest_fitting_font);
 	gdk_font_unref (bold_template_font);
 	gdk_font_unref (template_font);
Index: src/nautilus-sidebar.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-sidebar.c,v
retrieving revision 1.185
diff -u -r1.185 nautilus-sidebar.c
--- src/nautilus-sidebar.c	2001/07/20 17:36:34	1.185
+++ src/nautilus-sidebar.c	2001/08/22 22:08:09
@@ -315,6 +315,11 @@
 		nautilus_file_unref (sidebar->details->file);
 	}
 
+	/* If the title tab hasn't got a parent we have to free it explicitly */
+	if (GTK_WIDGET (sidebar->details->title_tab)->parent == NULL) {
+		gtk_object_unref (GTK_OBJECT (sidebar->details->title_tab));
+	}
+	
 	g_free (sidebar->details->uri);
 	g_free (sidebar->details->default_background_color);
 	g_free (sidebar->details->default_background_image);
Index: src/nautilus-window-manage-views.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window-manage-views.c,v
retrieving revision 1.267
diff -u -r1.267 nautilus-window-manage-views.c
--- src/nautilus-window-manage-views.c	2001/06/26 23:51:52	1.267
+++ src/nautilus-window-manage-views.c	2001/08/22 22:08:10
@@ -1398,6 +1398,7 @@
 	} else {
 		force_reload = !nautilus_directory_is_local (directory);
 	}
+
 	if (force_reload) {
 		nautilus_directory_force_reload (directory);
 		file = nautilus_directory_get_corresponding_file (directory);
@@ -1405,6 +1406,8 @@
 		nautilus_file_unref (file);
 	}
 
+        nautilus_directory_unref (directory);
+        
         window->details->determine_view_handle = nautilus_determine_initial_view
                 (location,
                  determined_initial_view_callback,
Index: src/nautilus-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window.c,v
retrieving revision 1.336
diff -u -r1.336 nautilus-window.c
--- src/nautilus-window.c	2001/08/22 17:24:16	1.336
+++ src/nautilus-window.c	2001/08/22 22:08:10
@@ -760,7 +760,7 @@
 				    go_to_callback, window);
 		e_paned_pack1 (E_PANED (window->content_hbox),
 			       GTK_WIDGET (window->sidebar),
-			       FALSE, FALSE);
+			       FALSE, TRUE);
 #if 0
 		bonobo_ui_engine_add_sync (bonobo_window_get_ui_engine (BONOBO_WINDOW (window)),
 					   sidebar_sync);
@@ -992,6 +992,8 @@
 		gtk_idle_remove (window->details->location_change_at_idle_id);
 	}
 
+	g_free (window->details->title);
+	
 	g_free (window->details);
 
 	EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.464
diff -u -r1.464 fm-directory-view.c
--- src/file-manager/fm-directory-view.c	2001/07/23 11:25:34	1.464
+++ src/file-manager/fm-directory-view.c	2001/08/22 22:08:12
@@ -75,6 +75,7 @@
 #include <libnautilus-private/nautilus-trash-monitor.h>
 #include <libnautilus-private/nautilus-view-identifier.h>
 #include <libnautilus/nautilus-bonobo-ui.h>
+
 #include <math.h>
 
 /* The list view receives files from the directory model
Index: src/file-manager/fm-properties-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-properties-window.c,v
retrieving revision 1.121
diff -u -r1.121 fm-properties-window.c
--- src/file-manager/fm-properties-window.c	2001/05/11 01:30:33	1.121
+++ src/file-manager/fm-properties-window.c	2001/08/22 22:08:12
@@ -66,7 +66,11 @@
 #include <libnautilus-private/nautilus-link.h>
 #include <libnautilus-private/nautilus-metadata.h>
 #include <libnautilus-private/nautilus-undo-signal-handlers.h>
+#include <libnautilus-private/nautilus-view-identifier.h>
+
 #include <libnautilus/nautilus-undo.h>
+#include <liboaf/liboaf.h>
+
 #include <string.h>
 
 static GHashTable *windows;
@@ -2109,6 +2113,66 @@
 	g_free (data);
 }
 
+
+static GList *
+get_property_tab_view_identifiers_for_file (NautilusFile *file)
+{
+	CORBA_Environment ev;
+	gchar *query;
+	OAF_ServerInfoList *oaf_result;
+	guint i;
+	NautilusViewIdentifier *id;
+	GList *view_identifiers;
+	
+	CORBA_exception_init (&ev);
+	query = "nautilus:property_page_name.defined() AND repo_ids.has ('IDL:Nautilus/View:1.0')";
+
+	oaf_result = oaf_query (query, NULL, &ev);
+//	g_free (query);
+	
+	view_identifiers = NULL;
+
+	if (ev._major == CORBA_NO_EXCEPTION && oaf_result != NULL) {
+		for (i = 0; i < oaf_result->_length; i++) {
+			id = nautilus_view_identifier_new_from_property_page
+				(&oaf_result->_buffer[i]);
+			view_identifiers = g_list_prepend (view_identifiers, id);
+		}
+	}
+
+	if (oaf_result != NULL) {
+		CORBA_free (oaf_result);
+	}
+
+	CORBA_exception_free (&ev);
+
+	return view_identifiers;
+}
+
+static void
+create_extra_property_tabs (FMPropertiesWindow *window)
+{
+	GtkWidget *button;
+	GList *view_identifiers;
+	GList *node;
+	NautilusViewIdentifier *identifier;
+	
+	view_identifiers = get_property_tab_view_identifiers_for_file (window->details->target_file);
+
+	g_print ("Length is: %d\n", g_list_length (view_identifiers));
+
+	for (node = view_identifiers; node; node = node->next) {
+		identifier = (NautilusViewIdentifier *) node->data;
+
+		button = gtk_button_new_with_label ("whee");
+		gtk_widget_show (button);
+		gtk_notebook_append_page (window->details->notebook, button, gtk_label_new (identifier->name));
+	}
+	
+		
+	
+}
+
 static FMPropertiesWindow *
 create_properties_window (StartupData *startup_data)
 {
@@ -2169,6 +2233,8 @@
 		create_permissions_page (window);
 	}
 
+	/* Finally, create the extra property tabs */
+	create_extra_property_tabs (window);
 	return window;
 }
 
Index: src/file-manager/fm-properties-window.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-properties-window.h,v
retrieving revision 1.6
diff -u -r1.6 fm-properties-window.h
--- src/file-manager/fm-properties-window.h	2001/05/04 03:14:42	1.6
+++ src/file-manager/fm-properties-window.h	2001/08/22 22:08:12
@@ -30,6 +30,7 @@
 
 #include <gtk/gtkwindow.h>
 #include <libnautilus-private/nautilus-file.h>
+#include <libnautilus-private/nautilus-undo-manager.h>
 
 typedef struct FMPropertiesWindow FMPropertiesWindow;
 
@@ -60,7 +61,7 @@
 
 
 GtkType fm_properties_window_get_type   (void);
-void 	fm_properties_window_present 	(NautilusFile    *file, 
-					 FMDirectoryView *directory_view);
+void 	fm_properties_window_present 	(NautilusFile        *file, 
+					 FMDirectoryView     *directory_view);
 
 #endif /* FM_PROPERTIES_WINDOW_H */


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