Commit d31bf8d6 authored by Darin Adler's avatar Darin Adler

Added support for nested directories inside the scripts directory,

	starting with a patch by David Emory Watson <dwatson@cs.ucr.edu>.

	* src/file-manager/fm-directory-view.c: (get_scripts_directory):
	Keep the scripts directory URI and string length in a global
	variable.
	(add_scripts_directory): New function, replaces
	connect_script_handlers. Refs the directory, puts it on the
	scripts directory list, and monitors more attributes than before.
	(fm_directory_view_initialize): Use add_scripts_directory instead
	of connect_script_handlers.
	(fm_directory_view_destroy): Use remove_scripts_directory on the
	entire list instead of disconnect_script_handlers.
	(add_submenu): New function.
	(add_script_to_script_menus): Change name, pass in path.
	(add_submenu_to_script_menus): New function.
	(directory_belongs_in_scripts_menu): New function.
	(add_directory_to_scripts_directory_list): New function, high
	level call used to turn a NautilusFile into a NautilusDirectory
	and call add_scripts_directory.
	(update_directory_in_scripts_menu): New function.
	(update_scripts_menu): New function, replaces reset_scripts_menu
	and uses new nautilus_directory_get_files_list rather than
	nautilus_directory_call_when_ready.
	(open_scripts_folder_callback): Use new global variable instead
	of calling get_scripts_directory.
	(real_update_menus): Call update_scripts_menu instead of
	schedule_reset_scripts_menu.
	(remove_scripts_directory): New function, replaces
	disconnect_script_handlers. Removes the directory from the scripts
	directory list and unrefs it after disconnecting handlers.

	* libnautilus-private/nautilus-directory.h:
	* libnautilus-private/nautilus-directory.c: (is_tentative): Moved
	from nautilus-directory-async.c.
	(nautilus_directory_get_file_list): New, made from formerly-
	private get_non_tentative_file_list in nautilus-directory-async.c.
	(nautilus_directory_list_ref): New.
	(nautilus_directory_list_unref): New.
	(nautilus_directory_list_free): New.
	(nautilus_directory_list_copy): New.
	(compare_by_uri), (compare_by_uri_cover),
	(nautilus_directory_list_sort_by_uri): New. Sorrts directories by
	URI, parents before children, and children sorted as if by
	nautilus_file_list_sort_by_name.
	* libnautilus-private/nautilus-directory-async.c:
	(nautilus_directory_monitor_add_internal), (ready_callback_call):
	Use nautilus_directory_get_file_list instead of
	get_non_tentative_file_list.
parent e2341ed5
2001-08-24 Darin Adler <darin@bentspoon.com>
Added support for nested directories inside the scripts directory,
starting with a patch by David Emory Watson <dwatson@cs.ucr.edu>.
* src/file-manager/fm-directory-view.c: (get_scripts_directory):
Keep the scripts directory URI and string length in a global
variable.
(add_scripts_directory): New function, replaces
connect_script_handlers. Refs the directory, puts it on the
scripts directory list, and monitors more attributes than before.
(fm_directory_view_initialize): Use add_scripts_directory instead
of connect_script_handlers.
(fm_directory_view_destroy): Use remove_scripts_directory on the
entire list instead of disconnect_script_handlers.
(add_submenu): New function.
(add_script_to_script_menus): Change name, pass in path.
(add_submenu_to_script_menus): New function.
(directory_belongs_in_scripts_menu): New function.
(add_directory_to_scripts_directory_list): New function, high
level call used to turn a NautilusFile into a NautilusDirectory
and call add_scripts_directory.
(update_directory_in_scripts_menu): New function.
(update_scripts_menu): New function, replaces reset_scripts_menu
and uses new nautilus_directory_get_files_list rather than
nautilus_directory_call_when_ready.
(open_scripts_folder_callback): Use new global variable instead
of calling get_scripts_directory.
(real_update_menus): Call update_scripts_menu instead of
schedule_reset_scripts_menu.
(remove_scripts_directory): New function, replaces
disconnect_script_handlers. Removes the directory from the scripts
directory list and unrefs it after disconnecting handlers.
* libnautilus-private/nautilus-directory.h:
* libnautilus-private/nautilus-directory.c: (is_tentative): Moved
from nautilus-directory-async.c.
(nautilus_directory_get_file_list): New, made from formerly-
private get_non_tentative_file_list in nautilus-directory-async.c.
(nautilus_directory_list_ref): New.
(nautilus_directory_list_unref): New.
(nautilus_directory_list_free): New.
(nautilus_directory_list_copy): New.
(compare_by_uri), (compare_by_uri_cover),
(nautilus_directory_list_sort_by_uri): New. Sorrts directories by
URI, parents before children, and children sorted as if by
nautilus_file_list_sort_by_name.
* libnautilus-private/nautilus-directory-async.c:
(nautilus_directory_monitor_add_internal), (ready_callback_call):
Use nautilus_directory_get_file_list instead of
get_non_tentative_file_list.
2001-08-23 Anders Carlsson <andersca@gnu.org>
* nautilus.spec.in: Remove CONTROL_CENTER_REQUIRED since nautilus
......
......@@ -10,6 +10,7 @@ Christopher Blizzard <blizzard@redhat.com> - mozilla component fixes
Christopher James Lahey <clahey@ximian.com> - bug fixes
Cody Russell <bratsche@gnome.org> - bug fixes
Dan Mueth <d-mueth@uchicago.edu> - documentation, help system design
David Emory Watson <dwatson@cs.ucr.edu> - hierarchical scripts menu
Don Melton <don@eazel.com> - Management, moral support, design help
Eric Fischer <eric@eazel.com> - bug fixes
Fatih Demir <kabalak@kabalak.net> - bug fixes
......
......@@ -561,31 +561,6 @@ nautilus_directory_set_up_request (Request *request,
eel_strcmp_compare_func) != NULL;
}
static gboolean
is_tentative (gpointer data, gpointer callback_data)
{
NautilusFile *file;
g_assert (callback_data == NULL);
file = NAUTILUS_FILE (data);
return file->details->info == NULL;
}
static GList *
get_non_tentative_file_list (NautilusDirectory *directory)
{
GList *tentative_files, *non_tentative_files;
tentative_files = eel_g_list_partition
(g_list_copy (directory->details->file_list),
is_tentative, NULL, &non_tentative_files);
g_list_free (tentative_files);
nautilus_file_list_ref (non_tentative_files);
return non_tentative_files;
}
void
nautilus_directory_monitor_add_internal (NautilusDirectory *directory,
NautilusFile *file,
......@@ -618,7 +593,7 @@ nautilus_directory_monitor_add_internal (NautilusDirectory *directory,
g_list_prepend (directory->details->monitor_list, monitor);
if (callback != NULL) {
file_list = get_non_tentative_file_list (directory);
file_list = nautilus_directory_get_file_list (directory);
(* callback) (directory, file_list, callback_data);
nautilus_file_list_free (file_list);
}
......@@ -1183,7 +1158,7 @@ ready_callback_call (NautilusDirectory *directory,
if (directory == NULL || !callback->request.file_list) {
file_list = NULL;
} else {
file_list = get_non_tentative_file_list (directory);
file_list = nautilus_directory_get_file_list (directory);
}
/* Pass back the file list if the user was waiting for it. */
......
......@@ -1507,6 +1507,105 @@ nautilus_directory_is_not_empty (NautilusDirectory *directory)
is_not_empty, (directory));
}
static gboolean
is_tentative (gpointer data, gpointer callback_data)
{
NautilusFile *file;
g_assert (callback_data == NULL);
file = NAUTILUS_FILE (data);
return file->details->info == NULL;
}
GList *
nautilus_directory_get_file_list (NautilusDirectory *directory)
{
GList *tentative_files, *non_tentative_files;
tentative_files = eel_g_list_partition
(g_list_copy (directory->details->file_list),
is_tentative, NULL, &non_tentative_files);
g_list_free (tentative_files);
nautilus_file_list_ref (non_tentative_files);
return non_tentative_files;
}
/**
* nautilus_directory_list_ref
*
* Ref all the directories in a list.
* @list: GList of directories.
**/
GList *
nautilus_directory_list_ref (GList *list)
{
g_list_foreach (list, (GFunc) nautilus_directory_ref, NULL);
return list;
}
/**
* nautilus_directory_list_unref
*
* Unref all the directories in a list.
* @list: GList of directories.
**/
void
nautilus_directory_list_unref (GList *list)
{
eel_g_list_safe_for_each (list, (GFunc) nautilus_directory_unref, NULL);
}
/**
* nautilus_directory_list_free
*
* Free a list of directories after unrefing them.
* @list: GList of directories.
**/
void
nautilus_directory_list_free (GList *list)
{
nautilus_directory_list_unref (list);
g_list_free (list);
}
/**
* nautilus_directory_list_copy
*
* Copy the list of directories, making a new ref of each,
* @list: GList of directories.
**/
GList *
nautilus_directory_list_copy (GList *list)
{
return g_list_copy (nautilus_directory_list_ref (list));
}
static int
compare_by_uri (NautilusDirectory *a, NautilusDirectory *b)
{
return strcmp (a->details->uri, b->details->uri);
}
static int
compare_by_uri_cover (gconstpointer a, gconstpointer b)
{
return compare_by_uri (NAUTILUS_DIRECTORY (a), NAUTILUS_DIRECTORY (b));
}
/**
* nautilus_directory_list_sort_by_uri
*
* Sort the list of directories by directory uri.
* @list: GList of directories.
**/
GList *
nautilus_directory_list_sort_by_uri (GList *list)
{
return g_list_sort (list, compare_by_uri_cover);
}
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
#include <eel/eel-debug.h>
......
......@@ -160,8 +160,8 @@ gboolean nautilus_directory_contains_file (NautilusDirector
NautilusFile *file);
/* Get the uri of the file in the directory, NULL if not found */
char * nautilus_directory_get_file_uri (NautilusDirectory *directory,
const char *file_name);
char * nautilus_directory_get_file_uri (NautilusDirectory *directory,
const char *file_name);
/* Get (and ref) a NautilusFile object for this directory. */
NautilusFile * nautilus_directory_get_corresponding_file (NautilusDirectory *directory);
......@@ -191,6 +191,9 @@ void nautilus_directory_file_monitor_remove (NautilusDirector
gconstpointer client);
void nautilus_directory_force_reload (NautilusDirectory *directory);
/* Get a list of all files currently known in the directory. */
GList * nautilus_directory_get_file_list (NautilusDirectory *directory);
/* Return true if the directory has information about all the files.
* This will be false until the directory has been read at least once.
*/
......@@ -204,7 +207,15 @@ gboolean nautilus_directory_is_local (NautilusDirector
*/
gboolean nautilus_directory_is_not_empty (NautilusDirectory *directory);
gboolean nautilus_directory_file_list_length_reached (NautilusDirectory *directory);
char * nautilus_directory_make_uri_canonical (const char *uri);
char * nautilus_directory_make_uri_canonical (const char *uri);
/* Convenience functions for dealing with a list of NautilusDirectory objects that each have a ref.
* These are just convenient names for functions that work on lists of GtkObject *.
*/
GList * nautilus_directory_list_ref (GList *directory_list);
void nautilus_directory_list_unref (GList *directory_list);
void nautilus_directory_list_free (GList *directory_list);
GList * nautilus_directory_list_copy (GList *directory_list);
GList * nautilus_directory_list_sort_by_uri (GList *directory_list);
#endif /* NAUTILUS_DIRECTORY_H */
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment