Commit 72457639 authored by Seth Nickell's avatar Seth Nickell Committed by Seth Nickell

reviewed by: Darin Adler <darin@eazel.com>

2001-04-19  Seth Nickell  <snickell@stanford.edu>

	reviewed by: Darin Adler <darin@eazel.com>

	* libnautilus-extensions/nautilus-global-preferences.c:
	* libnautilus-extensions/nautilus-global-preferences.h:
	Add a preference for having the desktop directory point at the
	Unix homedir rather than the default Nautilus desktop directory.

	* libnautilus-extensions/nautilus-file-utilities.c:
	(nautilus_get_desktop_directory):
	Check the preference and return the appropriate directory.

	* src/nautilus-application.c: (nautilus_application_startup),
	(confirm_ok_to_run_as_root), (desktop_location_changed_callback):
	Add a callback for updating the desktop when the preference
	changes.

	* src/nautilus-desktop-window.h:
	* src/nautilus-desktop-window.c:
	(nautilus_desktop_window_update_directory),
	(nautilus_desktop_window_new):
	Add boolean variable affect_desktop_on_next_location_change to
	allow reloading of the desktop dir (rather than loading on open
	in to a new/toplevel window). Add a function for telling the
	desktop window to point to the updated destkop location.

	* src/nautilus-window-manage-views.c: (open_location):
	Check whether this open should be done in the desktop itself or
	if we should open a new window (/ recycle an existing window).
parent 03814a9e
2001-04-19 Seth Nickell <snickell@stanford.edu>
reviewed by: Darin Adler <darin@eazel.com>
* libnautilus-extensions/nautilus-global-preferences.c:
* libnautilus-extensions/nautilus-global-preferences.h:
Add a preference for having the desktop directory point at the
Unix homedir rather than the default Nautilus desktop directory.
* libnautilus-extensions/nautilus-file-utilities.c:
(nautilus_get_desktop_directory):
Check the preference and return the appropriate directory.
* src/nautilus-application.c: (nautilus_application_startup),
(confirm_ok_to_run_as_root), (desktop_location_changed_callback):
Add a callback for updating the desktop when the preference
changes.
* src/nautilus-desktop-window.h:
* src/nautilus-desktop-window.c:
(nautilus_desktop_window_update_directory),
(nautilus_desktop_window_new):
Add boolean variable affect_desktop_on_next_location_change to
allow reloading of the desktop dir (rather than loading on open
in to a new/toplevel window). Add a function for telling the
desktop window to point to the updated destkop location.
* src/nautilus-window-manage-views.c: (open_location):
Check whether this open should be done in the desktop itself or
if we should open a new window (/ recycle an existing window).
2001-04-19 Darin Adler <darin@eazel.com>
Fix bug 8082 (Dragging a file to a treeview destination causes
......
......@@ -25,6 +25,7 @@
#include <config.h>
#include "nautilus-file-utilities.h"
#include "nautilus-global-preferences.h"
#include "nautilus-lib-self-check-functions.h"
#include "nautilus-link-set.h"
#include "nautilus-metadata.h"
......@@ -138,9 +139,13 @@ nautilus_get_desktop_directory (void)
{
char *desktop_directory, *user_directory;
user_directory = nautilus_get_user_directory ();
desktop_directory = nautilus_make_path (user_directory, DESKTOP_DIRECTORY_NAME);
g_free (user_directory);
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR)) {
desktop_directory = strdup (g_get_home_dir());
} else {
user_directory = nautilus_get_user_directory ();
desktop_directory = nautilus_make_path (user_directory, DESKTOP_DIRECTORY_NAME);
g_free (user_directory);
}
if (!g_file_exists (desktop_directory)) {
mkdir (desktop_directory, DEFAULT_DESKTOP_DIRECTORY_MODE);
......
......@@ -433,6 +433,12 @@ static const PreferenceDefault preference_defaults[] = {
{ NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) },
{ USER_LEVEL_NONE }
},
{ NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
PREFERENCE_BOOLEAN,
NAUTILUS_USER_LEVEL_ADVANCED,
{ NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) },
{ USER_LEVEL_NONE }
},
{ NAUTILUS_PREFERENCES_CAN_ADD_CONTENT,
PREFERENCE_BOOLEAN,
NAUTILUS_USER_LEVEL_NOVICE,
......@@ -929,6 +935,11 @@ static PreferenceDialogItem windows_and_desktop_items[] = {
N_("Use Nautilus to draw the desktop"),
NAUTILUS_PREFERENCE_ITEM_BOOLEAN
},
{ N_("Desktop"),
NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
N_("Use your home folder as the desktop"),
NAUTILUS_PREFERENCE_ITEM_BOOLEAN
},
{ N_("Opening New Windows"),
NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
N_("Open each file or folder in a separate window"),
......
......@@ -47,6 +47,7 @@ BEGIN_GNOME_DECLS
/* Desktop options */
#define NAUTILUS_PREFERENCES_SHOW_DESKTOP "preferences/show_desktop"
#define NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR "preferences/desktop_is_home_dir"
/* Display */
#define NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES "preferences/show_hidden_files"
......
......@@ -25,6 +25,7 @@
#include <config.h>
#include "nautilus-file-utilities.h"
#include "nautilus-global-preferences.h"
#include "nautilus-lib-self-check-functions.h"
#include "nautilus-link-set.h"
#include "nautilus-metadata.h"
......@@ -138,9 +139,13 @@ nautilus_get_desktop_directory (void)
{
char *desktop_directory, *user_directory;
user_directory = nautilus_get_user_directory ();
desktop_directory = nautilus_make_path (user_directory, DESKTOP_DIRECTORY_NAME);
g_free (user_directory);
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR)) {
desktop_directory = strdup (g_get_home_dir());
} else {
user_directory = nautilus_get_user_directory ();
desktop_directory = nautilus_make_path (user_directory, DESKTOP_DIRECTORY_NAME);
g_free (user_directory);
}
if (!g_file_exists (desktop_directory)) {
mkdir (desktop_directory, DEFAULT_DESKTOP_DIRECTORY_MODE);
......
......@@ -433,6 +433,12 @@ static const PreferenceDefault preference_defaults[] = {
{ NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) },
{ USER_LEVEL_NONE }
},
{ NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
PREFERENCE_BOOLEAN,
NAUTILUS_USER_LEVEL_ADVANCED,
{ NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) },
{ USER_LEVEL_NONE }
},
{ NAUTILUS_PREFERENCES_CAN_ADD_CONTENT,
PREFERENCE_BOOLEAN,
NAUTILUS_USER_LEVEL_NOVICE,
......@@ -929,6 +935,11 @@ static PreferenceDialogItem windows_and_desktop_items[] = {
N_("Use Nautilus to draw the desktop"),
NAUTILUS_PREFERENCE_ITEM_BOOLEAN
},
{ N_("Desktop"),
NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
N_("Use your home folder as the desktop"),
NAUTILUS_PREFERENCE_ITEM_BOOLEAN
},
{ N_("Opening New Windows"),
NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
N_("Open each file or folder in a separate window"),
......
......@@ -47,6 +47,7 @@ BEGIN_GNOME_DECLS
/* Desktop options */
#define NAUTILUS_PREFERENCES_SHOW_DESKTOP "preferences/show_desktop"
#define NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR "preferences/desktop_is_home_dir"
/* Display */
#define NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES "preferences/show_hidden_files"
......
......@@ -82,6 +82,7 @@ static void nautilus_application_destroy (GtkObject
static gboolean confirm_ok_to_run_as_root (void);
static gboolean need_to_show_first_time_druid (void);
static void desktop_changed_callback (gpointer user_data);
static void desktop_location_changed_callback (gpointer user_data);
static void volume_mounted_callback (NautilusVolumeMonitor *monitor,
NautilusVolume *volume,
NautilusApplication *application);
......@@ -531,6 +532,13 @@ nautilus_application_startup (NautilusApplication *application,
application,
GTK_OBJECT (application));
/* Monitor the preference to have the desktop */
/* point to the Unix home folder */
nautilus_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
desktop_location_changed_callback,
nautilus_application_desktop_window,
GTK_OBJECT (application));
nautilus_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_DEFAULT_FOLDER_VIEWER,
default_folder_viewer_changed_callback,
NULL,
......@@ -680,6 +688,16 @@ confirm_ok_to_run_as_root (void)
return result == 0;
}
/* callback for changing the directory the desktop points to */
static void
desktop_location_changed_callback (gpointer user_data)
{
NautilusDesktopWindow *desktop_window;
desktop_window = NAUTILUS_DESKTOP_WINDOW (user_data);
nautilus_desktop_window_update_directory (desktop_window);
}
/* callback for showing or hiding the desktop based on the user's preference */
static void
desktop_changed_callback (gpointer user_data)
......
......@@ -110,12 +110,27 @@ nautilus_desktop_window_delete_event (NautilusDesktopWindow *window)
return TRUE;
}
void
nautilus_desktop_window_update_directory (NautilusDesktopWindow *window)
{
char *desktop_directory_path;
char *desktop_directory_uri;
g_assert (NAUTILUS_IS_DESKTOP_WINDOW (window));
desktop_directory_path = nautilus_get_desktop_directory ();
desktop_directory_uri = gnome_vfs_get_uri_from_local_path (desktop_directory_path);
g_free (desktop_directory_path);
window->affect_desktop_on_next_location_change = TRUE;
nautilus_window_go_to (NAUTILUS_WINDOW (window), desktop_directory_uri);
g_free (desktop_directory_uri);
}
NautilusDesktopWindow *
nautilus_desktop_window_new (NautilusApplication *application)
{
NautilusDesktopWindow *window;
char *desktop_directory_path;
char *desktop_directory_uri;
window = NAUTILUS_DESKTOP_WINDOW
(gtk_widget_new (nautilus_desktop_window_get_type(),
......@@ -129,16 +144,11 @@ nautilus_desktop_window_new (NautilusApplication *application)
gtk_signal_connect (GTK_OBJECT (window), "realize", GTK_SIGNAL_FUNC (nautilus_desktop_window_realized), NULL);
gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (nautilus_desktop_window_delete_event), NULL);
desktop_directory_path = nautilus_get_desktop_directory ();
/* Point window at the desktop folder.
* Note that nautilus_desktop_window_initialize is too early to do this.
*/
desktop_directory_uri = gnome_vfs_get_uri_from_local_path (desktop_directory_path);
g_free (desktop_directory_path);
nautilus_window_go_to (NAUTILUS_WINDOW (window), desktop_directory_uri);
g_free (desktop_directory_uri);
nautilus_desktop_window_update_directory (window);
gtk_widget_show (GTK_WIDGET (window));
return window;
......
......@@ -42,13 +42,15 @@ typedef struct NautilusDesktopWindowDetails NautilusDesktopWindowDetails;
typedef struct {
NautilusWindow parent_spot;
NautilusDesktopWindowDetails *details;
gboolean affect_desktop_on_next_location_change;
} NautilusDesktopWindow;
typedef struct {
NautilusWindowClass parent_spot;
} NautilusDesktopWindowClass;
GtkType nautilus_desktop_window_get_type (void);
NautilusDesktopWindow *nautilus_desktop_window_new (NautilusApplication *application);
GtkType nautilus_desktop_window_get_type (void);
NautilusDesktopWindow *nautilus_desktop_window_new (NautilusApplication *application);
void nautilus_desktop_window_update_directory (NautilusDesktopWindow *window);
#endif /* NAUTILUS_DESKTOP_WINDOW_H */
......@@ -715,14 +715,16 @@ open_location (NautilusWindow *window,
* the topmost window, or create a new window if the desktop
* is the topmost (and only).
*/
if (!create_new_window
&& NAUTILUS_IS_DESKTOP_WINDOW (window)
&& window->content_view != NULL) {
target_window = get_topmost_nautilus_window ();
if (target_window == window) {
create_new_window = TRUE;
if (!create_new_window && NAUTILUS_IS_DESKTOP_WINDOW (window)) {
if (NAUTILUS_DESKTOP_WINDOW(window)->affect_desktop_on_next_location_change == FALSE) {
target_window = get_topmost_nautilus_window ();
if (target_window == window) {
create_new_window = TRUE;
} else {
eel_gtk_window_present (GTK_WINDOW (target_window));
}
} else {
eel_gtk_window_present (GTK_WINDOW (target_window));
NAUTILUS_DESKTOP_WINDOW(window)->affect_desktop_on_next_location_change = FALSE;
}
}
......
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