Commit c3a49b83 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Don't set theme if model is NULL.

2003-08-29  Alexander Larsson  <alexl@redhat.com>

	* components/tree/nautilus-tree-view.c (theme_changed_callback):
	Don't set theme if model is NULL.

2003-08-27  Alexander Larsson  <alexl@redhat.com>

	* libnautilus-private/nautilus-directory-async.c:
	* libnautilus-private/nautilus-directory-private.h:
	New function nautilus_set_kde_trash_name.
	Auto hide KDE trash dir in desktop dir

	* libnautilus-private/nautilus-directory.[ch]:
	New function nautilus_directory_is_desktop_directory()

	* libnautilus-private/nautilus-file-utilities.[ch]:
	* libnautilus-private/nautilus-file.c:
	Tweak the is_desktop_directory a bit so it works for
	both Files and Directories.

	* src/nautilus-application.c:
	On initialization, read the kde config to figure out the kde
	trash directory name.
parent f0e68a2a
2003-08-27 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-directory-async.c:
* libnautilus-private/nautilus-directory-private.h:
New function nautilus_set_kde_trash_name.
Auto hide KDE trash dir in desktop dir
* libnautilus-private/nautilus-directory.[ch]:
New function nautilus_directory_is_desktop_directory()
* libnautilus-private/nautilus-file-utilities.[ch]:
* libnautilus-private/nautilus-file.c:
Tweak the is_desktop_directory a bit so it works for
both Files and Directories.
* src/nautilus-application.c:
On initialization, read the kde config to figure out the kde
trash directory name.
=== nautilus 2.3.9 ===
2003-08-25 Alexander Larsson <alexl@redhat.com>
......
......@@ -432,8 +432,10 @@ theme_changed_callback (GObject *icon_factory, gpointer callback_data)
{
NautilusTreeView *view;
view = NAUTILUS_TREE_VIEW (callback_data);
nautilus_tree_model_set_theme (NAUTILUS_TREE_MODEL (view->details->child_model));
view = NAUTILUS_TREE_VIEW (callback_data);
if (view->details->child_model != NULL) {
nautilus_tree_model_set_theme (NAUTILUS_TREE_MODEL (view->details->child_model));
}
}
static void
......
......@@ -103,6 +103,9 @@ static GHashTable *waiting_directories;
static GHashTable *async_jobs;
#endif
/* Hide kde trashcan directory */
static char *kde_trash_dir_name = NULL;
/* Forward declarations for functions that need them. */
static void deep_count_load (NautilusDirectory *directory,
const char *uri);
......@@ -125,6 +128,12 @@ static void move_file_to_low_priority_queue (NautilusDirectory *directory
NautilusFile *file);
void
nautilus_set_kde_trash_name (const char *trash_dir)
{
g_free (kde_trash_dir_name);
kde_trash_dir_name = g_strdup (trash_dir);
}
/* Some helpers for case-insensitive strings.
* Move to nautilus-glib-extensions?
......@@ -2045,6 +2054,15 @@ start_monitoring_file_list (NautilusDirectory *directory)
read_dot_hidden_file (directory);
/* Hack to work around kde trash dir */
if (kde_trash_dir_name != NULL && nautilus_directory_is_desktop_directory (directory)) {
char *escaped;
escaped = gnome_vfs_escape_string (kde_trash_dir_name);
g_hash_table_insert (directory->details->hidden_file_hash,
escaped, escaped);
}
#ifdef DEBUG_LOAD_DIRECTORY
g_message ("load_directory called to monitor file list of %s", directory->details->uri);
#endif
......
......@@ -219,5 +219,9 @@ void nautilus_directory_add_file_to_work_queue (NautilusD
void nautilus_directory_remove_file_from_work_queue (NautilusDirectory *directory,
NautilusFile *file);
/* KDE compatibility hacks */
void nautilus_set_kde_trash_name (const char *trash_dir);
/* debugging functions */
int nautilus_directory_number_outstanding (void);
......@@ -1704,6 +1704,21 @@ nautilus_directory_list_sort_by_uri (GList *list)
return g_list_sort (list, compare_by_uri_cover);
}
gboolean
nautilus_directory_is_desktop_directory (NautilusDirectory *directory)
{
GnomeVFSURI *dir_vfs_uri;
dir_vfs_uri = directory->details->vfs_uri;
if (dir_vfs_uri == NULL ||
strcmp (dir_vfs_uri->method_string, "file") != 0) {
return FALSE;
}
return nautilus_is_desktop_directory_escaped (dir_vfs_uri->text);
}
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
#include <eel/eel-debug.h>
......
......@@ -212,4 +212,8 @@ void nautilus_directory_list_free (GList
GList * nautilus_directory_list_copy (GList *directory_list);
GList * nautilus_directory_list_sort_by_uri (GList *directory_list);
/* Fast way to check if a directory is the desktop directory */
gboolean nautilus_directory_is_desktop_directory (NautilusDirectory *directory);
#endif /* NAUTILUS_DIRECTORY_H */
......@@ -169,25 +169,64 @@ nautilus_get_desktop_directory_uri_no_create (void)
/* These need to be reset to NULL when desktop_is_home_dir changes */
static char *escaped_desktop_dir = NULL;
static char *escaped_desktop_file = NULL;
static char *escaped_desktop_dir_dirname = NULL;
static char *escaped_desktop_dir_filename = NULL;
static gboolean desktop_dir_changed_callback_installed = FALSE;
static void
desktop_dir_changed_callback (gpointer callback_data)
{
g_free (escaped_desktop_dir);
g_free (escaped_desktop_file);
g_free (escaped_desktop_dir_filename);
g_free (escaped_desktop_dir_dirname);
escaped_desktop_dir = NULL;
escaped_desktop_file = NULL;
escaped_desktop_dir_dirname = NULL;
escaped_desktop_dir_filename = NULL;
}
gboolean
nautilus_is_desktop_directory_escaped (char *escaped_dir,
char *escaped_file)
static void
update_desktop_dir (void)
{
char *uri, *path;
GnomeVFSURI *vfs_uri;
path = get_desktop_path ();
uri = gnome_vfs_get_uri_from_local_path (path);
vfs_uri = gnome_vfs_uri_new (uri);
g_free (path);
g_free (uri);
escaped_desktop_dir = g_strdup (vfs_uri->text);
escaped_desktop_dir_filename = gnome_vfs_uri_extract_short_path_name (vfs_uri);
escaped_desktop_dir_dirname = gnome_vfs_uri_extract_dirname (vfs_uri);
gnome_vfs_uri_unref (vfs_uri);
}
gboolean
nautilus_is_desktop_directory_file_escaped (char *escaped_dirname,
char *escaped_file)
{
if (!desktop_dir_changed_callback_installed) {
eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
desktop_dir_changed_callback,
NULL);
desktop_dir_changed_callback_installed = TRUE;
}
if (escaped_desktop_dir == NULL) {
update_desktop_dir ();
}
return (strcmp (escaped_dirname, escaped_desktop_dir_dirname) == 0 &&
strcmp (escaped_file, escaped_desktop_dir_filename) == 0);
}
gboolean
nautilus_is_desktop_directory_escaped (char *escaped_dir)
{
if (!desktop_dir_changed_callback_installed) {
eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
desktop_dir_changed_callback,
......@@ -196,18 +235,10 @@ nautilus_is_desktop_directory_escaped (char *escaped_dir,
}
if (escaped_desktop_dir == NULL) {
path = get_desktop_path ();
uri = gnome_vfs_get_uri_from_local_path (path);
vfs_uri = gnome_vfs_uri_new (uri);
g_free (path);
g_free (uri);
escaped_desktop_file = gnome_vfs_uri_extract_short_path_name (vfs_uri);
escaped_desktop_dir = gnome_vfs_uri_extract_dirname (vfs_uri);
gnome_vfs_uri_unref (vfs_uri);
update_desktop_dir ();
}
return (strcmp (escaped_dir, escaped_desktop_dir) == 0 &&
strcmp (escaped_file, escaped_desktop_file) == 0);
return strcmp (escaped_dir, escaped_desktop_dir) == 0;
}
......
......@@ -37,8 +37,9 @@ gboolean nautilus_file_name_matches_backup_pattern (const char *name_or_relati
char * nautilus_get_user_directory (void);
char * nautilus_get_desktop_directory (void);
char * nautilus_get_desktop_directory_uri (void);
gboolean nautilus_is_desktop_directory_escaped (char *escaped_dir,
gboolean nautilus_is_desktop_directory_file_escaped (char *escaped_dirname,
char *escaped_filename);
gboolean nautilus_is_desktop_directory_escaped (char *escaped_dir);
char * nautilus_get_gmc_desktop_directory (void);
char * nautilus_get_pixmap_directory (void);
......
......@@ -1724,8 +1724,8 @@ file_is_desktop (NautilusFile *file)
return FALSE;
}
return nautilus_is_desktop_directory_escaped (dir_vfs_uri->text,
file->details->relative_uri);
return nautilus_is_desktop_directory_file_escaped (dir_vfs_uri->text,
file->details->relative_uri);
}
static int
......
......@@ -71,6 +71,7 @@
#include <libnautilus-private/nautilus-undo-manager.h>
#include <libnautilus-private/nautilus-volume-monitor.h>
#include <libnautilus-private/nautilus-desktop-link-monitor.h>
#include <libnautilus-private/nautilus-directory-private.h>
#include <bonobo-activation/bonobo-activation.h>
/* Needed for the is_kdesktop_present check */
......@@ -366,6 +367,53 @@ finish_startup (NautilusApplication *application)
nautilus_desktop_link_monitor_get ();
}
static void
initialize_kde_trash_hack (void)
{
char *trash_dir;
char *desktop_dir, *desktop_uri, *kde_trash_dir;
char *dir, *basename;
char *kde_conf_file;
char *key;
gboolean def;
trash_dir = NULL;
desktop_uri = nautilus_get_desktop_directory_uri_no_create ();
desktop_dir = gnome_vfs_get_local_path_from_uri (desktop_uri);
g_free (desktop_uri);
if (g_file_test (desktop_dir, G_FILE_TEST_EXISTS)) {
/* Look for trash directory */
kde_conf_file = g_build_filename (g_get_home_dir(), ".kde/share/config/kdeglobals", NULL);
key = g_strconcat ("=", kde_conf_file, "=/Paths/Trash", NULL);
kde_trash_dir = gnome_config_get_string_with_default (key, &def);
gnome_config_drop_file (kde_conf_file);
g_free (kde_conf_file);
g_free (key);
if (kde_trash_dir != NULL) {
basename = g_path_get_basename (kde_trash_dir);
g_free (kde_trash_dir);
dir = g_build_filename (desktop_dir, basename, NULL);
if (g_file_test (dir, G_FILE_TEST_IS_DIR)) {
trash_dir = g_strdup (basename);
}
g_free (basename);
g_free (dir);
}
if (trash_dir != NULL) {
nautilus_set_kde_trash_name (trash_dir);
}
g_free (trash_dir);
}
g_free (desktop_dir);
}
void
nautilus_application_startup (NautilusApplication *application,
gboolean kill_shell,
......@@ -404,6 +452,8 @@ nautilus_application_startup (NautilusApplication *application,
nautilus_set_first_time_file_flag ();
}
initialize_kde_trash_hack ();
CORBA_exception_init (&ev);
/* Start up the factory. */
......
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