Commit 47a2fa6e authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Merge some stuff from the redhat-outstanding-patches branch

2001-09-04  Alex Larsson  <alexl@redhat.com>

	Merge some stuff from the redhat-outstanding-patches branch

	* libnautilus-private/nautilus-file-utilities.[ch]
	(nautilus_user_main_directory_exists, nautilus_get_user_main_directory):
	Get rid of these. No more ~/Nautilus

	* libnautilus-private/nautilus-global-preferences.c:
	(default_home_location_callback): Always use your normal homedir
	as the home dir.

	* src/nautilus-application.c (check_required_directories): Don't
	create ~/Nautilus.
	(create_starthere_link_callback, nautilus_application_startup):
	Create a start here icon on the desktop.
	Turn of first time druid (by setting first time flag).
	(nautilus_application_startup, check_for_kdesktop, look_for_kdesktop_recursive,
	has_wm_state, get_self_typed_prop)
	Don't manage the desktop if kdesktop is running.

	* src/nautilus-first-time-druid.[ch]:
	Remove ~/Nautilus handling.
	s/druid_set_first_time_file_flag/nautilus_set_first_time_file_flag/

	* src/nautilus-shell-ui.xml:
	* src/nautilus-window-menus.c:
	Add start here to the go menu. Remove leftovers of the "support" menuimem.

	* src/file-manager/fm-directory-view.c:
	Move scripts to ~/.gnome/nautilus-scripts

	* Makefile.am:
	Add starthere icons

	* data/Makefile.am:
	* data/*.desktop.in:
	* data/*.directory.in:
	Add starthere desktop files.
parent a4cea258
2001-09-04 Alex Larsson <alexl@redhat.com>
Merge some stuff from the redhat-outstanding-patches branch
* libnautilus-private/nautilus-file-utilities.[ch]
(nautilus_user_main_directory_exists, nautilus_get_user_main_directory):
Get rid of these. No more ~/Nautilus
* libnautilus-private/nautilus-global-preferences.c:
(default_home_location_callback): Always use your normal homedir
as the home dir.
* src/nautilus-application.c (check_required_directories): Don't
create ~/Nautilus.
(create_starthere_link_callback, nautilus_application_startup):
Create a start here icon on the desktop.
Turn of first time druid (by setting first time flag).
(nautilus_application_startup, check_for_kdesktop, look_for_kdesktop_recursive,
has_wm_state, get_self_typed_prop)
Don't manage the desktop if kdesktop is running.
* src/nautilus-first-time-druid.[ch]:
Remove ~/Nautilus handling.
s/druid_set_first_time_file_flag/nautilus_set_first_time_file_flag/
* src/nautilus-shell-ui.xml:
* src/nautilus-window-menus.c:
Add start here to the go menu. Remove leftovers of the "support" menuimem.
* src/file-manager/fm-directory-view.c:
Move scripts to ~/.gnome/nautilus-scripts
* Makefile.am:
Add starthere icons
* data/Makefile.am:
* data/*.desktop.in:
* data/*.directory.in:
Add starthere desktop files.
2001-09-04 Alex Larsson <alexl@redhat.com>
Merge some stuff from the redhat-outstanding-patches branch
......
......@@ -42,6 +42,8 @@ EXTRA_DIST= \
nautilus-help.desktop \
nautilus-help.desktop.in \
nautilus-launch-icon.png \
gnome-starthere-96.png \
gnome-starthere.png \
nautilusConf.sh.in \
nautilus-config.in \
ChangeLog-20000414 \
......@@ -57,7 +59,9 @@ EXTRA_DIST= \
$(NULL)
appicondir = $(datadir)/pixmaps
appicon_DATA = nautilus-launch-icon.png
appicon_DATA = nautilus-launch-icon.png \
gnome-starthere-96.png \
gnome-starthere.png
Applicationsdir = $(datadir)/gnome/apps/Applications
Applications_DATA = $(DESKTOP_FILES)
......
NULL=
@XML_I18N_MERGE_DESKTOP_RULE@
@XML_I18N_MERGE_DIRECTORY_RULE@
DESKTOP_IN_FILES= favorites.desktop.in \
programs.desktop.in \
starthere.desktop.in \
sysconfig.desktop.in \
preferences.desktop.in \
serverconfig.desktop.in \
starthere-link.desktop.in \
$(NULL)
DIRECTORY_IN_FILES= serverconfig.directory.in \
starthere.directory.in \
sysconfig.directory.in \
$(NULL)
DESKTOP_FILES=$(DESKTOP_IN_FILES:.desktop.in=.desktop)
DIRECTORY_FILES=$(DIRECTORY_IN_FILES:.directory.in=.directory)
startheredir= $(sysconfdir)/X11/starthere
starthere_DATA= favorites.desktop \
programs.desktop \
sysconfig.desktop \
preferences.desktop \
serverconfig.desktop \
$(NULL)
DESKTOP_FILES=$(DESKTOP_IN_FILES:.in=)
nautilusdatadir = $(datadir)/nautilus
nautilusdata_DATA = \
browser.xml \
static_bookmarks.xml \
nautilus-extras.placeholder \
nautilus-suggested.placeholder \
browser.xml \
static_bookmarks.xml \
nautilus-extras.placeholder \
nautilus-suggested.placeholder \
starthere.desktop \
starthere-link.desktop \
$(NULL)
EXTRA_DIST = $(nautilusdata_DATA)
EXTRA_DIST = $(nautilusdata_DATA) \
$(DESKTOP_IN_FILES) \
$(DESKTOP_FILES) \
$(DIRECTORY_IN_FILES) \
$(DIRECTORY_FILES) \
$(NULL)
SUBDIRS = \
emblems \
linksets \
patterns \
$(NULL)
install-data-local: $(DIRECTORY_FILES)
$(mkinstalldirs) $(sysconfdir)/X11/starthere
$(mkinstalldirs) $(sysconfdir)/X11/starthere/sysconfig
$(mkinstalldirs) $(sysconfdir)/X11/starthere/serverconfig
$(INSTALL_DATA) starthere.directory $(sysconfdir)/X11/starthere/.directory
$(INSTALL_DATA) sysconfig.directory $(sysconfdir)/X11/starthere/sysconfig/.directory
$(INSTALL_DATA) serverconfig.directory $(sysconfdir)/X11/starthere/serverconfig/.directory
[Desktop Entry]
Type=Link
_Name=Favorites
_Comment=Favorite applications
URL=favorites:
Icon=gnome-favorites.png
Terminal=0
[Desktop Entry]
Type=Link
_Name=Preferences
_Comment=Adjust your user environment
URL=preferences:
Icon=apple-red.png
Terminal=0
[Desktop Entry]
_Name=Programs
_Comment=Browse available software
URL=programs:
Icon=gnome-default-dlg.png
Terminal=0
Type=Link
[Desktop Entry]
Type=Link
_Name=Server Configuration
_Comment=Configure network services (web server, DNS server, etc.)
URL=server-settings:
Icon=gnome-globe.png
Terminal=0
[Desktop Entry]
_Name=Server Configuration
_Comment=Configure network services
Icon=gnome-globe.png
Type=Directory
[Desktop Entry]
Type=Link
_Name=Start Here
_Comment=Start Here
URL=start-here:
Icon=gnome-starthere.png
X-Nautilus-Icon=gnome-starthere
Terminal=0
[Desktop Entry]
_Name=Start Here
_Comment=Start Here
Exec=nautilus start-here:
Icon=gnome-starthere.png
X-Nautilus-Icon=gnome-starthere
Terminal=0
Type=Application
[Desktop Entry]
_Name=Start Here
_Comment=Start Here
Icon=gnome-starthere.png
X-Nautilus-Icon=gnome-starthere
Type=Directory
[Desktop Entry]
Type=Link
_Name=System Settings
_Comment=Change systemwide settings (affects all users)
URL=system-settings:
Icon=gnome-settings.png
Terminal=0
[Desktop Entry]
_Name=System Settings
_Comment=Change systemwide settings (affects all users)
Icon=gnome-settings.png
Type=Directory
......@@ -43,8 +43,6 @@
#define DESKTOP_DIRECTORY_NAME ".gnome-desktop"
#define DEFAULT_DESKTOP_DIRECTORY_MODE (0755)
#define NAUTILUS_USER_MAIN_DIRECTORY_NAME "Nautilus"
gboolean
nautilus_file_name_matches_hidden_pattern (const char *name_or_relative_uri)
{
......@@ -171,83 +169,6 @@ nautilus_get_gmc_desktop_directory (void)
return nautilus_make_path (g_get_home_dir (), DESKTOP_DIRECTORY_NAME);
}
/**
* nautilus_user_main_directory_exists:
*
* returns true if the user directory exists. This must be called
* before nautilus_get_user_main_directory, which creates it if necessary
*
**/
gboolean
nautilus_user_main_directory_exists(void)
{
gboolean directory_exists;
char *main_directory;
main_directory = g_strdup_printf ("%s/%s",
g_get_home_dir(),
NAUTILUS_USER_MAIN_DIRECTORY_NAME);
directory_exists = g_file_exists(main_directory);
g_free(main_directory);
return directory_exists;
}
/**
* nautilus_get_user_main_directory:
*
* Get the path for the user's main Nautilus directory.
* Usually ~/Nautilus
*
* Return value: the directory path.
**/
char *
nautilus_get_user_main_directory (void)
{
char *user_main_directory = NULL;
GnomeVFSResult result;
char *destination_directory_uri_text;
GnomeVFSURI *destination_directory_uri;
GnomeVFSURI *destination_uri;
user_main_directory = g_strdup_printf ("%s/%s",
g_get_home_dir(),
NAUTILUS_USER_MAIN_DIRECTORY_NAME);
if (!g_file_exists (user_main_directory)) {
destination_directory_uri_text = gnome_vfs_get_uri_from_local_path (g_get_home_dir());
destination_directory_uri = gnome_vfs_uri_new (destination_directory_uri_text);
g_free (destination_directory_uri_text);
destination_uri = gnome_vfs_uri_append_file_name (destination_directory_uri,
NAUTILUS_USER_MAIN_DIRECTORY_NAME);
gnome_vfs_uri_unref (destination_directory_uri);
result = gnome_vfs_make_directory_for_uri (destination_uri,
GNOME_VFS_PERM_USER_ALL
| GNOME_VFS_PERM_GROUP_ALL
| GNOME_VFS_PERM_OTHER_READ);
/* FIXME bugzilla.eazel.com 1286:
* How should we handle error codes returned from gnome_vfs_xfer_uri?
* Note that nautilus_application_startup will refuse to launch if this
* directory doesn't get created, so that case is OK. But the directory
* could be deleted after Nautilus was launched, and perhaps
* there is some bad side-effect of not handling that case.
*/
gnome_vfs_uri_unref (destination_uri);
/* If this fails to create the directory, nautilus_application_startup will
* notice and refuse to launch.
*/
/* install the default link sets */
nautilus_link_set_install (user_main_directory, "apps");
nautilus_link_set_install (user_main_directory, "home");
}
return user_main_directory;
}
/**
* nautilus_get_pixmap_directory
*
......
......@@ -42,16 +42,10 @@ char * nautilus_make_path (const char *path,
* freed with g_free, is not NULL, and is guaranteed to exist.
*/
char * nautilus_get_user_directory (void);
char * nautilus_get_user_main_directory (void);
char * nautilus_get_desktop_directory (void);
char * nautilus_get_gmc_desktop_directory (void);
char * nautilus_get_pixmap_directory (void);
/* See if the user_main_directory exists. This should be called before
* nautilus_get_user_main_directory, which creates the directory.
*/
gboolean nautilus_user_main_directory_exists (void);
/* A version of gnome's gnome_pixmap_file that works for the nautilus prefix.
* Otherwise similar to gnome_pixmap_file in that it checks to see if the file
* exists and returns NULL if it doesn't.
......
......@@ -902,23 +902,8 @@ default_default_folder_viewer_callback (int user_level)
static gpointer
default_home_location_callback (int user_level)
{
char *default_home_location;
char *user_main_directory;
g_return_val_if_fail (eel_preferences_user_level_is_valid (user_level), NULL);
if (user_level == EEL_USER_LEVEL_NOVICE) {
user_main_directory = nautilus_get_user_main_directory ();
default_home_location = gnome_vfs_get_uri_from_local_path (user_main_directory);
g_free (user_main_directory);
return default_home_location;
}
if (user_level == EEL_USER_LEVEL_INTERMEDIATE) {
return gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
}
return NULL;
return gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
}
/*
......
......@@ -1076,27 +1076,15 @@ static float fm_directory_view_preferred_zoom_levels[] = {
static void
set_up_scripts_directory_global (void)
{
char *main_directory_path, *scripts_directory_path;
char *scripts_directory_path;
if (scripts_directory_uri != NULL) {
return;
}
main_directory_path = nautilus_get_user_main_directory ();
/* FIXME: We've discussed that we don't want names of
* directories to be localized, and we also don't think that
* this should be in ~/Nautilus, since we want to get rid of
* the novice home directory, so this should be changed.
*/
/* Localizers: This is the name of a directory that's created
* in ~/Nautilus, and stores the scripts that appear in the
* Scripts submenu.
*/
scripts_directory_path = nautilus_make_path (main_directory_path, _("scripts"));
g_free (main_directory_path);
scripts_directory_path = nautilus_make_path (g_get_home_dir (),
".gnome/nautilus-scripts");
scripts_directory_uri = gnome_vfs_get_uri_from_local_path (scripts_directory_path);
scripts_directory_uri_length = strlen (scripts_directory_uri);
......
......@@ -66,6 +66,10 @@
#include <libnautilus-private/nautilus-authn-manager.h>
#include <liboaf/liboaf.h>
/* Needed for the is_kdesktop_present check */
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
#define FACTORY_IID "OAFIID:nautilus_factory:bd1e1862-92d7-4391-963e-37583f0daef3"
#define SEARCH_LIST_VIEW_IID "OAFIID:nautilus_file_manager_search_list_view:b186e381-198e-43cf-9c46-60b6bb35db0b"
#define SHELL_IID "OAFIID:nautilus_shell:cd5183b2-3913-4b74-9b8e-10528b0de08d"
......@@ -98,6 +102,7 @@ static void volume_unmounted_callback (NautilusVolumeMonito
NautilusApplication *application);
static void update_session (gpointer callback_data);
static void init_session (void);
static gboolean is_kdesktop_present (void);
EEL_DEFINE_CLASS_BOILERPLATE (NautilusApplication, nautilus_application, BONOBO_OBJECT_TYPE)
......@@ -239,7 +244,6 @@ static gboolean
check_required_directories (NautilusApplication *application)
{
char *user_directory;
char *user_main_directory;
char *desktop_directory;
EelStringList *directories;
char *directories_as_string;
......@@ -251,7 +255,6 @@ check_required_directories (NautilusApplication *application)
g_assert (NAUTILUS_IS_APPLICATION (application));
user_directory = nautilus_get_user_directory ();
user_main_directory = nautilus_get_user_main_directory ();
desktop_directory = nautilus_get_desktop_directory ();
directories = eel_string_list_new (TRUE);
......@@ -259,12 +262,7 @@ check_required_directories (NautilusApplication *application)
if (!g_file_test (user_directory, G_FILE_TEST_ISDIR)) {
eel_string_list_insert (directories, user_directory);
}
g_free (user_directory);
if (!g_file_test (user_main_directory, G_FILE_TEST_ISDIR)) {
eel_string_list_insert (directories, user_main_directory);
}
g_free (user_main_directory);
g_free (user_directory);
if (!g_file_test (desktop_directory, G_FILE_TEST_ISDIR)) {
eel_string_list_insert (directories, desktop_directory);
......@@ -416,6 +414,35 @@ migrate_old_nautilus_files (void)
g_free (old_desktop_dir);
}
static gint
create_starthere_link_callback (gpointer data)
{
char *desktop_path;
char *desktop_link_file;
char *cmd;
/* Create default services icon on the desktop */
desktop_path = nautilus_get_desktop_directory ();
desktop_link_file = nautilus_make_path (desktop_path,
"starthere.desktop");
cmd = g_strconcat ("/bin/cp ",
NAUTILUS_DATADIR,
"/starthere-link.desktop ",
desktop_link_file,
NULL);
if (system (cmd) != 0) {
g_warning ("Failed to execute command '%s'\n", cmd);
}
g_free (desktop_path);
g_free (desktop_link_file);
g_free (cmd);
return FALSE;
}
static void
finish_startup (NautilusApplication *application)
{
......@@ -467,8 +494,12 @@ nautilus_application_startup (NautilusApplication *application,
/* Run the first time startup druid if needed. */
if (do_first_time_druid_check && need_to_show_first_time_druid ()) {
nautilus_first_time_druid_show (application, urls);
return;
/* Do this at idle time, once nautilus has initialized
* itself. Otherwise we may spawn a second nautilus
* process when looking for a metadata factory..
*/
g_idle_add (create_starthere_link_callback, NULL);
nautilus_set_first_time_file_flag ();
}
CORBA_exception_init (&ev);
......@@ -583,6 +614,10 @@ nautilus_application_startup (NautilusApplication *application,
} else if (restart_shell) {
Nautilus_Shell_restart (shell, &ev);
} else {
/* If KDE desktop is running, then force no_desktop */
if (is_kdesktop_present ())
no_desktop = TRUE;
if (!no_desktop && eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_DESKTOP)) {
Nautilus_Shell_start_desktop (shell, &ev);
}
......@@ -975,3 +1010,128 @@ init_session (void)
update_session (client);
}
static gboolean
get_self_typed_prop (Window xwindow,
Atom atom,
gulong *val)
{
Atom type;
int format;
gulong nitems;
gulong bytes_after;
gulong *num;
int err;
gdk_error_trap_push ();
type = None;
XGetWindowProperty (gdk_display,
xwindow,
atom,
0, G_MAXLONG,
False, atom, &type, &format, &nitems,
&bytes_after, (guchar **)&num);
err = gdk_error_trap_pop ();
if (err != Success) {
return FALSE;
}
if (type != atom) {
return FALSE;
}
if (val)
*val = *num;
XFree (num);
return TRUE;
}
static gboolean
has_wm_state (Window xwindow)
{
return get_self_typed_prop (xwindow,
XInternAtom (gdk_display, "WM_STATE", False),
NULL);
}
static gboolean
look_for_kdesktop_recursive (Window xwindow)
{
Window ignored1, ignored2;
Window *children;
unsigned int n_children;
unsigned int i;
gboolean retval;
/* If WM_STATE is set, this is a managed client, so look
* for the class hint and end recursion. Otherwise,
* this is probably just a WM frame, so keep recursing.
*/
if (has_wm_state (xwindow)) {
XClassHint ch;
gdk_error_trap_push ();
ch.res_name = NULL;
ch.res_class = NULL;
XGetClassHint (gdk_display, xwindow, &ch);
gdk_error_trap_pop ();
if (ch.res_name)
XFree (ch.res_name);
if (ch.res_class) {
if (strcmp (ch.res_class, "kdesktop") == 0) {
XFree (ch.res_class);
return TRUE;
}
else
XFree (ch.res_class);
}
return FALSE;
}
retval = FALSE;
gdk_error_trap_push ();
XQueryTree (gdk_display,
xwindow,
&ignored1, &ignored2, &children, &n_children);
if (gdk_error_trap_pop ()) {
return FALSE;
}
i = 0;
while (i < n_children) {
if (look_for_kdesktop_recursive (children[i])) {
retval = TRUE;
break;
}
++i;
}
if (children)
XFree (children);
return retval;
}
static gboolean
is_kdesktop_present (void)
{
/* FIXME this is a pretty lame hack, should be replaced
* eventually with e.g. a requirement that desktop managers
* support a manager selection, ICCCM sec 2.8
*/
return look_for_kdesktop_recursive (GDK_ROOT_WINDOW ());
}