Blob Blame History Raw
--- gnome-vfs-2.5.5/libgnomevfs/Makefile.am.vfolder-hacks	2004-01-08 03:31:06.000000000 -0500
+++ gnome-vfs-2.5.5/libgnomevfs/Makefile.am	2004-01-29 18:44:53.000000000 -0500
@@ -19,6 +19,7 @@
 	-DGNOMEVFS_LOCALEDIR=\"$(prefix)/@DATADIRNAME@/locale\" \
 	-DSYSCONFDIR=\"$(sysconfdir)\"		\
 	-DG_LOG_DOMAIN=\"libgnomevfs\"		\
+	-I/usr/kerberos/include \
 	$(NULL)
 
 libgnomevfs_headers_to_scan_for_enums = 			\
--- gnome-vfs-2.5.5/modules/vfolder/vfolder-common.c.vfolder-hacks	2003-04-24 11:46:24.000000000 -0400
+++ gnome-vfs-2.5.5/modules/vfolder/vfolder-common.c	2004-01-29 18:44:53.000000000 -0500
@@ -61,7 +61,8 @@
 	entry->weight = weight;
 
 	entry->dirty = TRUE;
-
+	entry->not_shown = FALSE;
+	
 	/* 
 	 * Lame-O special case .directory handling, as we don't want them
 	 * showing up for all-applications:///.
@@ -201,7 +202,7 @@
 entry_reload_if_needed (Entry *entry)
 {
 	gboolean changed = FALSE;
-	gchar *keywords, *deprecates;
+	gchar *keywords, *deprecates, *onlyshowin;
 	int i;
 
 	if (!entry->dirty)
@@ -211,8 +212,17 @@
 			       "Categories",
 			       &keywords,
 			       "Deprecates",
-			       &deprecates);
-
+			       &deprecates,
+			       "OnlyShowIn",
+			       &onlyshowin);
+
+#if 0
+	g_printerr ("Read cats=%s onlyshowin=%s from entry %s\n",
+		    keywords ? keywords : "none",
+		    onlyshowin ? onlyshowin : "none",
+		    entry->filename);
+#endif
+	
 	/* 
 	 * Clear keywords from file, leaving only ones added from 
 	 * the directory.
@@ -269,8 +279,28 @@
 		g_strfreev (parsed);
 	}
 
+	if (onlyshowin) {
+		char **parsed = g_strsplit (onlyshowin, ";", -1);
+
+		/* If OnlyShowIn exists, then the default is
+		 * that we don't show the entry, unless the
+		 * value includes "GNOME"
+		 */
+		entry->not_shown = TRUE;
+		
+		for (i = 0; parsed[i] != NULL; i++) {
+			if (strcmp (parsed[i], "GNOME") == 0)
+				entry->not_shown = FALSE;
+		}
+
+		/* FIXME do we need to emit some kind of notification here? */
+		
+		g_strfreev (parsed);
+	}
+	
 	g_free (keywords);
 	g_free (deprecates);
+	g_free (onlyshowin);
 
 	entry->dirty = FALSE;
 }
@@ -380,7 +410,9 @@
 		       const gchar  *key1,
 		       gchar       **result1,
 		       const gchar  *key2,
-		       gchar       **result2)
+		       gchar       **result2,
+		       const gchar  *key3,
+		       gchar       **result3)
 {
 	GnomeVFSHandle *handle;
 	GnomeVFSFileSize readlen;
@@ -389,7 +421,9 @@
 
 	*result1 = NULL;
 	if (key2)
-	  *result2 = NULL;
+		*result2 = NULL;
+	if (key3)
+		*result3 = NULL;
 
 	if (gnome_vfs_open (&handle, 
 			    entry_get_filename (entry), 
@@ -416,6 +450,9 @@
 	if (key2)
 		entry_key_val_from_string (fullbuf->str, key2, result2);
 
+	if (key3)
+		entry_key_val_from_string (fullbuf->str, key3, result3);
+	
 	g_string_free (fullbuf, TRUE);
 }
 
@@ -458,7 +495,7 @@
 	folder->refcnt       = 1;
 
 	folder->dirty = TRUE;
-
+	
 	return folder;
 }
 
@@ -832,6 +869,10 @@
 {
 	Query *query = folder_get_query (folder);
 
+#if 0
+	g_printerr ("reading one extended entry %s\n", file_uri ? file_uri : "null");
+#endif
+	
 	if (is_excluded (folder, file_uri, file_info->name))
 		return FALSE;
 
@@ -897,6 +938,13 @@
 	result = gnome_vfs_directory_open (&handle,
 					   extend_uri,
 					   GNOME_VFS_FILE_INFO_DEFAULT);
+
+#if 0
+	g_printerr ("reading extended entries from %s result = %s\n"<
+		    extend_uri ? extend_uri : "null",
+		    result == GNOME_VFS_OK ? "ok" : "failed");
+#endif
+	
 	if (result != GNOME_VFS_OK)
 		return FALSE;
 
@@ -1038,6 +1086,11 @@
 {
 	gboolean changed = FALSE;
 
+#if 0
+	g_printerr ("folder maybe reload dirty = %d loading = %d\n",
+		    folder->dirty, folder->loading);
+#endif
+	
 	if (!folder->dirty || folder->loading)
 		return;
 
@@ -1066,6 +1119,11 @@
 					folder_get_extend_uri (folder),
 					folder_extend_monitor_cb,
 					folder);
+	} else {
+#if 0
+		g_printerr ("folder %s has no extend uri, not reading\n",
+			    folder->name);
+#endif
 	}
 
 	if (folder_get_query (folder))
@@ -1123,6 +1181,12 @@
 void
 folder_set_extend_uri (Folder *folder, const gchar *uri)
 {
+#if 0
+	g_printerr ("setting extend URI of %s to %s\n",
+		    folder->name,
+		    uri ? uri : "null");
+#endif
+	
 	g_free (folder->extend_uri);
 	folder->extend_uri = g_strdup (uri);
 
@@ -1262,6 +1326,9 @@
 			if (query && !query_try_match (query, folder, entry))
 				continue;
 
+			if (entry->not_shown)
+				continue;
+			
 			g_hash_table_insert (
 				name_hash, 
 				(gchar *) entry_get_displayname (entry),
@@ -1276,6 +1343,8 @@
 				       "SortOrder",
 				       &sortorder,
 				       NULL, 
+				       NULL,
+				       NULL,
 				       NULL);
 		if (sortorder) {
 			list = child_list_prepend_sorted (sortorder,
@@ -1527,6 +1596,9 @@
 			if (entry_is_allocated (entry))
 				continue;
 
+			if (entry->not_shown)
+				continue;
+			
 			if (query && !query_try_match (query, folder, entry))
 				continue;
 
@@ -1601,9 +1673,12 @@
 {
 	GSList *li;
 
+	if (efile->not_shown)
+		return FALSE;
+	
 	if (query == NULL)
 		return TRUE;
-
+	
 	switch (query->type) {
 	case QUERY_OR:
 		for (li = query->val.queries; li != NULL; li = li->next) {
--- gnome-vfs-2.5.5/modules/vfolder/vfolder-common.h.vfolder-hacks	2002-10-25 01:54:43.000000000 -0400
+++ gnome-vfs-2.5.5/modules/vfolder/vfolder-common.h	2004-01-29 18:44:53.000000000 -0500
@@ -82,6 +82,7 @@
 
 	guint           dirty : 1;
 	guint           user_private : 1;
+	guint           not_shown : 1; /* OnlyShowIn=SomeOtherDesktop */
 } Entry;
 
 Entry        *entry_new                  (VFolderInfo *info,
@@ -120,7 +121,9 @@
 					  const gchar  *key1,
 					  gchar       **value1,
 					  const gchar  *key2,
-					  gchar       **value2);
+					  gchar       **value2,
+					  const gchar  *key3,
+					  gchar       **value3);
 
 void          entry_dump                 (Entry *entry, int indent);
 
--- gnome-vfs-2.5.5/modules/vfolder/vfolder-info.c.vfolder-hacks	2003-10-31 06:17:59.000000000 -0500
+++ gnome-vfs-2.5.5/modules/vfolder/vfolder-info.c	2004-01-29 18:52:06.000000000 -0500
@@ -193,12 +193,15 @@
 		     folder_get_name (folder) /* content */);
 
 	extend_uri = folder_get_extend_uri (folder);
+#if 0
+	/* this would confuse KDE, just use hardcoded value. */
 	if (extend_uri) {
 		xmlNewChild (folder_node /* parent */,
 			     NULL /* ns */,
 			     folder->is_link ? "ParentLink" : "Parent",
 			     extend_uri /* content */);
 	}
+#endif
 
 	if (folder->user_private) {
 		const gchar *desktop_file;
@@ -274,12 +277,17 @@
 				 NULL /* content */);
 	doc->xmlRootNode = topnode;
 
+#if 0
+	/* Never write the WriteDir field, it will
+	 * break KDE menus. Just use the hardcoded one.
+	 */
 	if (info->write_dir != NULL) {
 		xmlNewChild (topnode /* parent */,
 			     NULL /* ns */,
 			     "WriteDir" /* name */,
 			     info->write_dir /* content */);
 	}
+#endif
 
 	/* Deprecated */
 	if (info->desktop_dir != NULL) {
@@ -539,8 +547,10 @@
 				gchar *esc_parent;
 
 				esc_parent = vfolder_escape_home (parent);
-				folder_set_extend_uri (folder, esc_parent);
-				folder->is_link = FALSE;
+				if (*esc_parent != '\0') {
+					folder_set_extend_uri (folder, esc_parent);
+					folder->is_link = FALSE;
+				}
 
 				xmlFree (parent);
 				g_free (esc_parent);
@@ -553,8 +563,10 @@
 				gchar *esc_parent;
 
 				esc_parent = vfolder_escape_home (parent);
-				folder_set_extend_uri (folder, esc_parent);
-				folder->is_link = TRUE;
+				if (*esc_parent != '\0') {
+					folder_set_extend_uri (folder, esc_parent);
+					folder->is_link = TRUE;
+				}
 				
 				xmlFree (parent);
 				g_free (esc_parent);
@@ -734,6 +746,53 @@
 	g_free (itemdir);
 }
 
+static void
+set_hardcoded_extend_uri_recursive (Folder     *parent,
+				    const char *parent_uri)
+{
+	GSList *subfolders;
+	GSList *tmp;
+	
+	/* we set the extend URI unconditionally,
+	 * ignoring anything in the file
+	 */
+	folder_set_extend_uri (parent, parent_uri);
+	
+	subfolders = (GSList*) folder_list_subfolders (parent);
+	tmp = subfolders;
+	while (tmp != NULL) {
+		Folder *sub = tmp->data;
+		char *child_uri;
+
+		child_uri = g_strconcat (parent_uri, folder_get_name (sub),
+					 "/", NULL);
+
+		set_hardcoded_extend_uri_recursive (sub, child_uri);
+
+		g_free (child_uri);
+		
+		tmp = tmp->next;
+	}
+}
+
+static void
+set_hardcoded_extend_uri (VFolderInfo *info)
+{
+	gchar *all_user_scheme;
+
+	/* 
+	 * Set the extend uri for the root folder to the -all-users version of
+	 * the scheme, in case the user doesn't have a private .vfolder-info
+	 * file yet.  
+	 */
+	if (!g_str_has_suffix (info->scheme,
+			       "-all-users")) {
+		all_user_scheme = g_strconcat (info->scheme, "-all-users:///", NULL);
+		set_hardcoded_extend_uri_recursive (info->root, all_user_scheme);
+		g_free (all_user_scheme);
+	}
+}
+
 static gboolean
 read_vfolder_from_file (VFolderInfo     *info,
 			const gchar     *filename,
@@ -829,6 +888,7 @@
 					folder_unref (info->root);
 
 				info->root = folder;
+				set_hardcoded_extend_uri (info);
 			}
 		} 
 		else if (g_ascii_strcasecmp (node->name, "ReadOnly") == 0) {
@@ -1723,23 +1783,45 @@
 	GnomeVFSURI *file_uri;
 	gboolean exists;
 
-	/* 
-	 * FIXME: load from gconf 
+	/* Here we're finding the primary XML file
+	 * that this URI will write changes to.
+	 * It's the .menu file for -all-users,
+	 * and the ~/.gnome2/vfolders/scheme.vfolder-info
+	 * file otherwise.
 	 */
+	
+	if (g_str_has_suffix (info->scheme,
+			      "-all-users")) {
+		/* The all-users scheme uses the
+		 * .menu files
+		 */
+		const char *suffix;
+		char *single_scheme;
+		
+		suffix = g_strrstr (info->scheme, "-all-users");
+		g_assert (suffix != NULL);
+		single_scheme = g_strndup (info->scheme,
+					   suffix - info->scheme);
+
+		info->filename = g_strconcat (SYSCONFDIR,
+					      "/X11/desktop-menus/",
+					      single_scheme,
+					      ".menu",
+					      NULL);
+		g_free (single_scheme);
 
-	/* 
-	 * 1st: Try mandatory system-global file located at
-	 * /etc/gnome-vfs-2.0/vfolders/scheme.vfolder-info.  Writability will
-	 * depend on permissions of this file.
-	 */
-	info->filename = g_strconcat (SYSCONFDIR,
-				      "/gnome-vfs-2.0/vfolders/",
-				      scheme, ".vfolder-info",
-				      NULL);
-	file_uri = gnome_vfs_uri_new (info->filename);
+		file_uri = gnome_vfs_uri_new (info->filename);
+		
+		exists = gnome_vfs_uri_exists (file_uri);
+		gnome_vfs_uri_unref (file_uri);
 
-	exists = gnome_vfs_uri_exists (file_uri);
-	gnome_vfs_uri_unref (file_uri);
+#if 0
+		g_printerr ("all-users filename %s exists = %d\n",
+			    info->filename, exists);
+#endif
+	} else {
+		exists = FALSE;
+	}
 
 	if (!exists) {
 		/* 
@@ -1751,37 +1833,6 @@
 					      scheme, ".vfolder-info",
 					      NULL);
 	}
-
-	/* 
-	 * Special case for applications-all-users where we want to add any
-	 * paths specified in $GNOME2_PATH, for people installing in strange
-	 * places.
-	 */
-	if (!strcmp (scheme, "applications-all-users")) {
-		int i;
-		const char *path;
-		char *dir, **ppath;
-		ItemDir *id;
-		int weight = 800;
-
-		path = g_getenv ("GNOME2_PATH");
-		if (path) {
-			ppath = g_strsplit (path, ":", -1);
-
-			for (i = 0; ppath[i] != NULL; i++) {
-				dir = g_build_filename (ppath[i], 
-							"/share/applications/",
-							NULL);
-				id = itemdir_new (info, 
-						  dir, 
-						  ITEM_DIR,
-						  weight--);
-				g_free (dir);
-			}
-
-			g_strfreev (ppath);
-		}
-	}
 }
 
 static gboolean
@@ -1811,25 +1862,16 @@
 static gboolean
 vfolder_info_init (VFolderInfo *info)
 {
-	gchar *all_user_scheme;
-
 	info->loading = TRUE;
 	info->entries_ht = g_hash_table_new (g_str_case_hash, g_str_case_equal);
 	info->root = folder_new (info, "Root", TRUE);
 
+	set_hardcoded_extend_uri (info);
+	
 	/* 
-	 * Set the extend uri for the root folder to the -all-users version of
-	 * the scheme, in case the user doesn't have a private .vfolder-info
-	 * file yet.  
-	 */
-	all_user_scheme = g_strconcat (info->scheme, "-all-users:///", NULL);
-	folder_set_extend_uri (info->root, all_user_scheme);
-	g_free (all_user_scheme);
-
-	/* 
-	 * Set the default writedir, in case there is no .vfolder-info for this
-	 * scheme yet.  Otherwise this will be overwritten when we read our
-	 * source.
+	 * Set the default writedir, in case there is no .vfolder-info
+	 * for this scheme yet.  Otherwise this will be overwritten
+	 * when we read our source.
 	 */
 	info->write_dir = g_strconcat (g_get_home_dir (),
 				       "/" DOT_GNOME "/vfolders/",
@@ -1839,29 +1881,6 @@
 	/* Figure out which .vfolder-info to read */
 	vfolder_info_find_filenames (info);
 
-	if (g_getenv ("GNOME_VFS_VFOLDER_INFODIR")) {
-		gchar *filename = g_strconcat (info->scheme, 
-					       ".vfolder-info", 
-					       NULL);
-
-		g_free (info->filename);
-		info->filename = 
-			vfolder_build_uri (
-				g_getenv ("GNOME_VFS_VFOLDER_INFODIR"),
-				filename,
-				NULL);
-		g_free (filename);
-	}
-
-	if (g_getenv ("GNOME_VFS_VFOLDER_WRITEDIR")) {
-		g_free (info->write_dir);
-		info->write_dir = 
-			vfolder_build_uri (
-				g_getenv ("GNOME_VFS_VFOLDER_WRITEDIR"),
-				info->scheme,
-				NULL);
-	}
-
 	info->filename_monitor = 
 		vfolder_monitor_file_new (info->filename,
 					  filename_monitor_cb,
--- gnome-vfs-2.5.5/modules/vfolder/vfolder-util.c.vfolder-hacks	2002-10-10 00:46:29.000000000 -0400
+++ gnome-vfs-2.5.5/modules/vfolder/vfolder-util.c	2004-01-29 18:44:53.000000000 -0500
@@ -207,6 +207,7 @@
 {
 	GnomeVFSResult result;
 	VFolderMonitor *monitor;
+#if 0
 	GnomeVFSFileInfo *info;
 
 	/* Check the file exists so we don't get a bogus DELETED event */
@@ -218,7 +219,8 @@
 
 	if (result != GNOME_VFS_OK)
 		return NULL;
-
+#endif
+	
 	monitor = g_new0 (VFolderMonitor, 1);
 	monitor->callback = callback;
 	monitor->user_data = user_data;