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

Add GMount attribute to NautilusFile. (not implemented yet)

2008-01-17  Alexander Larsson  <alexl@redhat.com>

        * libnautilus-private/nautilus-file.[ch]:
        * libnautilus-private/nautilus-file-attributes.h:
        * libnautilus-private/nautilus-file-private.h:
	Add GMount attribute to NautilusFile.
	(not implemented yet)
	
        * Makefile.am:
        * configure.in:
        * data/nautilus.xml.in:
        * libnautilus-private/apps_nautilus_preferences.schemas.in:
        * libnautilus-private/nautilus-autorun.[ch]:
        * libnautilus-private/nautilus-global-preferences.c:
        * libnautilus-private/nautilus-global-preferences.h:
        * libnautilus-private/nautilus-program-choosing.c:
        * src/Makefile.am:
        * src/file-manager/fm-directory-view.c:
        * src/nautilus-application.c:
        * src/nautilus-autorun-software.c: Added.
        * src/nautilus-file-management-properties.c:
        * src/nautilus-file-management-properties.glade:
        * src/nautilus-window-manage-views.c:
        * src/nautilus-x-content-bar.[ch]: Added.
	More work on autorun and x-content types from David Zeuthen


svn path=/trunk/; revision=13616
parent 74a104f8
2008-01-17 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-file.[ch]:
* libnautilus-private/nautilus-file-attributes.h:
* libnautilus-private/nautilus-file-private.h:
Add GMount attribute to NautilusFile.
(not implemented yet)
* Makefile.am:
* configure.in:
* data/nautilus.xml.in:
* libnautilus-private/apps_nautilus_preferences.schemas.in:
* libnautilus-private/nautilus-autorun.[ch]:
* libnautilus-private/nautilus-global-preferences.c:
* libnautilus-private/nautilus-global-preferences.h:
* libnautilus-private/nautilus-program-choosing.c:
* src/Makefile.am:
* src/file-manager/fm-directory-view.c:
* src/nautilus-application.c:
* src/nautilus-autorun-software.c: Added.
* src/nautilus-file-management-properties.c:
* src/nautilus-file-management-properties.glade:
* src/nautilus-window-manage-views.c:
* src/nautilus-x-content-bar.[ch]: Added.
More work on autorun and x-content types from David Zeuthen
2008-01-16 Alexander Larsson <alexl@redhat.com>
* src/nautilus-application.c:
......
......@@ -9,7 +9,8 @@ desktop_in_files = \
nautilus-home.desktop.in \
nautilus-computer.desktop.in \
nautilus-folder-handler.desktop.in \
nautilus-file-management-properties.desktop.in
nautilus-file-management-properties.desktop.in \
nautilus-autorun-software.desktop.in
SUBDIRS = \
libnautilus-extension \
......
......@@ -484,6 +484,7 @@ nautilus-file-management-properties.desktop.in
nautilus-home.desktop.in
nautilus.desktop.in
nautilus-folder-handler.desktop.in
nautilus-autorun-software.desktop.in
po/Makefile.in
src/Makefile
src/file-manager/Makefile
......
......@@ -13,11 +13,11 @@
<mime-type type="x-content/video-vcd">
<!-- http://en.wikipedia.org/wiki/Video_CD -->
<_comment>VCD Video</_comment>
<_comment>Video CD</_comment>
</mime-type>
<mime-type type="x-content/video-svcd">
<!-- http://en.wikipedia.org/wiki/Super_Video_CD -->
<_comment>SVCD Video</_comment>
<_comment>Super Video CD</_comment>
</mime-type>
<mime-type type="x-content/video-dvd">
<!-- http://en.wikipedia.org/wiki/DVD-Video -->
......@@ -34,26 +34,57 @@
<_comment>Compact Disc Audio</_comment>
</mime-type>
<mime-type type="x-content/blank-media">
<mime-type type="x-content/blank-cd">
<!-- http://en.wikipedia.org/wiki/Compact_Disc -->
<_comment>Blank CD Disc</_comment>
</mime-type>
<mime-type type="x-content/blank-dvd">
<!-- http://en.wikipedia.org/wiki/DVD -->
<_comment>Blank Media</_comment>
<_comment>Blank DVD Disc</_comment>
</mime-type>
<mime-type type="x-content/software-autostart">
<!-- http://www.freedesktop.org/wiki/Specifications/autostart-spec -->
<_comment>Software</_comment>
<mime-type type="x-content/blank-bd">
<!-- http://en.wikipedia.org/wiki/Blu-ray_Disc -->
<_comment>Blank Blu-Ray Disc</_comment>
</mime-type>
<!-- TODO:
<mime-type type="x-content/blank-hddvd">
<!-- http://en.wikipedia.org/wiki/HD_DVD -->
<_comment>Blank HD DVD Disc</_comment>
</mime-type>
<mime-type type="x-content/audio-dvd">
<!-- http://en.wikipedia.org/wiki/DVD-Audio -->
<_comment>DVD Audio</_comment>
</mime-type>
<mime-type type="x-content/video-bluray">
<!-- http://en.wikipedia.org/wiki/Blu-ray_Disc -->
<_comment>Blu-Ray Video</_comment>
</mime-type>
- Blu-Ray video : http://en.wikipedia.org/wiki/Blu-ray_Disc
- HD-DVD video : http://en.wikipedia.org/wiki/HD_DVD
- DVD-Audio : http://en.wikipedia.org/wiki/DVD-Audio
<mime-type type="x-content/video-hddvd">
<!-- http://en.wikipedia.org/wiki/HD_DVD -->
<_comment>HD DVD Video</_comment>
</mime-type>
- Photo CD : http://en.wikipedia.org/wiki/Photo_CD
- Picture CD : http://en.wikipedia.org/wiki/Picture_CD
<mime-type type="x-content/image-picturecd">
<!-- http://en.wikipedia.org/wiki/Picture_CD -->
<_comment>Picture CD</_comment>
</mime-type>
<mime-type type="x-content/audio-player">
<!-- see fd.o hal spec -->
<_comment>Portable Audio Player</_comment>
</mime-type>
<mime-type type="x-content/software">
<!-- http://standards.freedesktop.org/autostart-spec/autostart-spec-latest.html -->
<_comment>Software</_comment>
</mime-type>
<!-- TODO:
- SACD : http://en.wikipedia.org/wiki/Super_Audio_CD
- This might be dead and appear to be totally unsupported anyway
......@@ -62,8 +93,6 @@
- Enhanced DVD Movie (see link 1. below)
- ??
- music player (x-content/music-player)
- picture files
- audio files
- video files
......
......@@ -101,6 +101,21 @@
</locale>
</schema>
<schema>
<key>/schemas/apps/nautilus/preferences/media_autorun_never_</key>
<applyto>/apps/nautilus/preferences/media_autorun_never</applyto>
<owner>nautilus</owner>
<type>bool</type>
<default>false</default>
<locale name="C">
<short>Never prompt or autorun/autostart programs when media is inserted</short>
<long>
If set to true, then Nautilus will never prompt nor autorun/autostart
programs when media is inserted.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/nautilus/preferences/media_autorun_x_content_ask</key>
<applyto>/apps/nautilus/preferences/media_autorun_x_content_ask</applyto>
......@@ -109,9 +124,9 @@
<list_type>string</list_type>
<default>[]</default>
<locale name="C">
<short>list of x-content/* types to ask the user what to do on insertion</short>
<short>List of x-content/* types to ask the user what to do on insertion</short>
<long>
list of x-content/* types to ask the user what to do on insertion
List of x-content/* types to ask the user what to do on insertion.
</long>
</locale>
</schema>
......@@ -124,9 +139,25 @@
<list_type>string</list_type>
<default>[]</default>
<locale name="C">
<short>list of x-content/* types to ignore on insertion</short>
<short>List of x-content/* where to prompt the user on insertion</short>
<long>
List of x-content/* types to ask the user what to do on insertion.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/nautilus/preferences/media_autorun_x_content_open_folder</key>
<applyto>/apps/nautilus/preferences/media_autorun_x_content_open_folder</applyto>
<owner>nautilus</owner>
<type>list</type>
<list_type>string</list_type>
<default>[]</default>
<locale name="C">
<short>List of x-content/* types where a folder window should be opened</short>
<long>
list of x-content/* types to ask the user what to do on insertion
List of x-content/* types where a folder window should be opened
on insertion.
</long>
</locale>
</schema>
......
This diff is collapsed.
......@@ -44,11 +44,29 @@
#include <eel/eel-background.h>
#include <libnautilus-private/nautilus-file.h>
void _g_mount_guess_content_type_async (GMount *mount,
gboolean force_rescan,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
char ** _g_mount_guess_content_type_finish (GMount *mount,
GAsyncResult *result,
GError **error);
char ** _g_mount_guess_content_type (GMount *mount,
gboolean force_rescan,
GError **error);
typedef void (*NautilusAutorunComboBoxChanged) (gboolean selected_ask,
gboolean selected_ignore,
gboolean selected_open_folder,
GAppInfo *selected_app,
gpointer user_data);
typedef void (*NautilusAutorunOpenWindow) (GMount *mount, gpointer user_data);
void nautilus_autorun_prepare_combo_box (GtkWidget *combo_box,
const char *x_content_type,
gboolean include_ask,
......@@ -56,10 +74,16 @@ void nautilus_autorun_prepare_combo_box (GtkWidget *combo_box,
NautilusAutorunComboBoxChanged changed_cb,
gpointer user_data);
void nautilus_autorun_set_preferences (const char *x_content_type, gboolean pref_ask, gboolean pref_ignore);
void nautilus_autorun_get_preferences (const char *x_content_type, gboolean *pref_ask, gboolean *pref_ignore);
void nautilus_autorun_set_preferences (const char *x_content_type, gboolean pref_ask, gboolean pref_ignore, gboolean pref_open_folder);
void nautilus_autorun_get_preferences (const char *x_content_type, gboolean *pref_ask, gboolean *pref_ignore, gboolean *pref_open_folder);
void nautilus_autorun (GMount *mount, NautilusAutorunOpenWindow open_window_func, gpointer user_data);
void nautilus_autorun (GMount *mount);
char **nautilus_autorun_get_x_content_types_for_file (NautilusFile *file,
GMount **out_mount,
gboolean force_rescan,
gboolean include_child_dirs);
void nautilus_autorun_launch_for_mount (GMount *mount, GAppInfo *app_info);
#endif /* NAUTILUS_AUTORUN_H */
......@@ -40,6 +40,7 @@ typedef enum {
NAUTILUS_FILE_ATTRIBUTE_LARGE_TOP_LEFT_TEXT = 1 << 7,
NAUTILUS_FILE_ATTRIBUTE_EXTENSION_INFO = 1 << 8,
NAUTILUS_FILE_ATTRIBUTE_THUMBNAIL = 1 << 9,
NAUTILUS_FILE_ATTRIBUTE_MOUNT = 1 << 10,
} NautilusFileAttributes;
#endif /* NAUTILUS_FILE_ATTRIBUTES_H */
......@@ -137,6 +137,9 @@ struct NautilusFileDetails
GHashTable *extension_attributes;
GHashTable *pending_extension_attributes;
/* Mount for mountpoint or the references GMount for a "mountable" */
GMount *mount;
/* boolean fields: bitfield to save space, since there can be
many NautilusFile objects. */
......@@ -166,6 +169,8 @@ struct NautilusFileDetails
eel_boolean_bit mime_list_failed : 1;
eel_boolean_bit mime_list_is_up_to_date : 1;
eel_boolean_bit mount_is_up_to_date : 1;
eel_boolean_bit got_top_left_text : 1;
eel_boolean_bit got_large_top_left_text : 1;
eel_boolean_bit top_left_text_is_up_to_date : 1;
......
......@@ -5606,6 +5606,14 @@ nautilus_file_is_mountpoint (NautilusFile *file)
return file->details->is_mountpoint;
}
GMount *
nautilus_file_get_mount (NautilusFile *file)
{
if (file->details->mount) {
return g_object_ref (file->details->mount);
}
return NULL;
}
/**
* nautilus_file_is_broken_symbolic_link
......
......@@ -171,6 +171,7 @@ gboolean nautilus_file_is_mime_type (Nautilu
gboolean nautilus_file_is_launchable (NautilusFile *file);
gboolean nautilus_file_is_symbolic_link (NautilusFile *file);
gboolean nautilus_file_is_mountpoint (NautilusFile *file);
GMount * nautilus_file_get_mount (NautilusFile *file);
char * nautilus_file_get_volume_free_space (NautilusFile *file);
char * nautilus_file_get_volume_name (NautilusFile *file);
char * nautilus_file_get_symbolic_link_target_path (NautilusFile *file);
......
......@@ -492,6 +492,10 @@ static const PreferenceDefault preference_defaults[] = {
PREFERENCE_BOOLEAN,
GINT_TO_POINTER (TRUE)
},
{ NAUTILUS_PREFERENCES_MEDIA_AUTORUN_NEVER,
PREFERENCE_BOOLEAN,
GINT_TO_POINTER (FALSE)
},
{ NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_ASK,
PREFERENCE_STRING_ARRAY,
"", NULL, NULL, NULL
......@@ -500,6 +504,10 @@ static const PreferenceDefault preference_defaults[] = {
PREFERENCE_STRING_ARRAY,
"", NULL, NULL, NULL
},
{ NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_OPEN_FOLDER,
PREFERENCE_STRING_ARRAY,
"", NULL, NULL, NULL
},
{ NULL }
};
......
......@@ -51,8 +51,10 @@ G_BEGIN_DECLS
#define NAUTILUS_PREFERENCES_MEDIA_AUTOMOUNT_OPEN "preferences/media_automount_open"
/* Autorun options */
#define NAUTILUS_PREFERENCES_MEDIA_AUTORUN_NEVER "preferences/media_autorun_never"
#define NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_ASK "preferences/media_autorun_x_content_ask"
#define NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_IGNORE "preferences/media_autorun_x_content_ignore"
#define NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_OPEN_FOLDER "preferences/media_autorun_x_content_open_folder"
/* Trash options */
#define NAUTILUS_PREFERENCES_CONFIRM_TRASH "preferences/confirm_trash"
......
......@@ -49,6 +49,8 @@
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include "nautilus-desktop-icon-file.h"
extern char **environ;
/* Cut and paste from gdkspawn-x11.c */
......@@ -261,10 +263,30 @@ nautilus_launch_application (GAppInfo *application,
location = NULL;
if (nautilus_file_is_nautilus_link (file)) {
uri = nautilus_file_get_activation_uri (file);
location = g_file_new_for_uri (uri);
g_free (uri);
if (g_type_is_a (G_OBJECT_TYPE (file), NAUTILUS_TYPE_DESKTOP_ICON_FILE)) {
NautilusDesktopIconFile *desktop_icon_file = NAUTILUS_DESKTOP_ICON_FILE (file);
NautilusDesktopLink *desktop_link;
desktop_link = nautilus_desktop_icon_file_get_link (desktop_icon_file);
if (desktop_link != NULL) {
if (nautilus_desktop_link_get_link_type (desktop_link) == NAUTILUS_DESKTOP_LINK_MOUNT) {
GMount *mount;
mount = nautilus_desktop_link_get_mount (desktop_link);
if (mount != NULL) {
location = g_mount_get_root (mount);
g_object_unref (mount);
}
}
g_object_unref (desktop_link);
}
}
if (location == NULL) {
if (nautilus_file_is_nautilus_link (file)) {
uri = nautilus_file_get_activation_uri (file);
location = g_file_new_for_uri (uri);
g_free (uri);
}
}
if (location == NULL) {
......
[Desktop Entry]
Encoding=UTF-8
_Name=Autorun Prompt
TryExec=nautilus-autorun-software
Exec=nautilus-autorun-software %u
Icon=application-x-executable
NoDisplay=true
Terminal=false
StartupNotify=true
Type=Application
MimeType=x-content/software;
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=nautilus
X-GNOME-Bugzilla-Component=general
X-GNOME-Bugzilla-Version=@VERSION@
......@@ -5,6 +5,7 @@ SUBDIRS=file-manager
bin_PROGRAMS= \
nautilus \
nautilus-file-management-properties \
nautilus-autorun-software \
$(NULL)
# nautilus-connect-server
......@@ -130,6 +131,8 @@ nautilus_SOURCES = \
nautilus-window-toolbars.c \
nautilus-window.c \
nautilus-window.h \
nautilus-x-content-bar.c \
nautilus-x-content-bar.h \
nautilus-zoom-control.c \
nautilus-zoom-control.h \
$(NULL)
......@@ -140,6 +143,10 @@ nautilus_file_management_properties_SOURCES= \
nautilus-file-management-properties-main.c \
$(NULL)
nautilus_autorun_software_SOURCES= \
nautilus-autorun-software.c \
$(NULL)
# Disabled for now in the gio world
#nautilus_connect_server_SOURCES= \
# nautilus-connect-server-dialog.c \
......
......@@ -95,6 +95,7 @@
#include <libnautilus-private/nautilus-trash-monitor.h>
#include <libnautilus-private/nautilus-ui-utilities.h>
#include <libnautilus-private/nautilus-signaller.h>
#include <libnautilus-private/nautilus-autorun.h>
#include <unistd.h>
/* Minimum starting update inverval */
......@@ -4158,6 +4159,27 @@ add_application_to_open_with_menu (FMDirectoryView *view,
g_free (tip);
}
static void
add_x_content_apps (NautilusFile *file, GList **applications)
{
char **x_content_types;
g_return_if_fail (applications != NULL);
x_content_types = nautilus_autorun_get_x_content_types_for_file (file, NULL, FALSE, FALSE);
if (x_content_types != NULL) {
unsigned int n;
for (n = 0; x_content_types[n] != NULL; n++) {
char *x_content_type = x_content_types[n];
GList *app_info_for_x_content_type;
app_info_for_x_content_type = g_app_info_get_all_for_type (x_content_type);
*applications = g_list_concat (*applications, app_info_for_x_content_type);
}
g_strfreev (x_content_types);
}
}
static void
reset_open_with_menu (FMDirectoryView *view, GList *selection)
......@@ -4191,6 +4213,7 @@ reset_open_with_menu (FMDirectoryView *view, GList *selection)
filter_default = (selection != NULL);
for (node = selection; node != NULL; node = node->next) {
file = NAUTILUS_FILE (node->data);
other_applications_visible &=
......@@ -4208,6 +4231,11 @@ reset_open_with_menu (FMDirectoryView *view, GList *selection)
applications = nautilus_mime_get_applications_for_files (selection);
}
if (g_list_length (selection) == 1) {
add_x_content_apps (NAUTILUS_FILE (selection->data), &applications);
}
num_applications = g_list_length (applications);
for (node = applications, index = 0; node != NULL; node = node->next, index++) {
......
......@@ -118,6 +118,11 @@ static void mount_added_callback (GVolumeMonitor *mo
static void volume_added_callback (GVolumeMonitor *monitor,
GVolume *volume,
NautilusApplication *application);
static void drive_connected_callback (GVolumeMonitor *monitor,
GDrive *drive,
NautilusApplication *application);
static void drive_listen_for_eject_button (GDrive *drive,
NautilusApplication *application);
static void update_session (gpointer callback_data);
static void init_session (void);
static gboolean is_kdesktop_present (void);
......@@ -164,6 +169,55 @@ nautilus_application_get_n_windows (void)
g_list_length (nautilus_application_desktop_windows);
}
static void
startup_volume_mount_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
if (!g_volume_mount_finish (G_VOLUME (source_object), res, NULL)) {
/* There was an error mounting the volume, so we
clear the automount part. This is otherwise done
when the mount is added to the volume monitor */
g_object_set_data (source_object, "nautilus-automounted", GINT_TO_POINTER (0));
}
}
static void
automount_all_volumes (NautilusApplication *application)
{
GList *volumes, *l;
GMount *mount;
GVolume *volume;
if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_MEDIA_AUTOMOUNT)) {
/* automount all mountable volumes at start-up */
volumes = g_volume_monitor_get_volumes (application->volume_monitor);
for (l = volumes; l != NULL; l = l->next) {
volume = l->data;
/* TODO: only do this for local volumes */
if (!g_volume_can_mount (volume)) {
continue;
}
mount = g_volume_get_mount (volume);
if (mount != NULL) {
g_object_unref (mount);
continue;
}
/* Set this so we don't autorun stuff from it */
g_object_set_data (G_OBJECT (volume), "nautilus-automounted", GINT_TO_POINTER (1));
/* pass NULL as GMountOperation to avoid user interaction */
g_volume_mount (volume, NULL, NULL, startup_volume_mount_cb, NULL);
}
eel_g_object_list_free (volumes);
}
}
static void
nautilus_application_instance_init (NautilusApplication *application)
{
......@@ -172,22 +226,6 @@ nautilus_application_instance_init (NautilusApplication *application)
application->shell = nautilus_shell_new (application);
/* Watch for mounts so we can restore open windows This used
* to be for showing new window on mount, but is not used
* anymore */
/* Watch for unmounts so we can close open windows */
/* TODO-gio: This should be using the UNMOUNTED feature of GFileMonitor instead */
application->volume_monitor = g_volume_monitor_get ();
g_signal_connect_object (application->volume_monitor, "mount_removed",
G_CALLBACK (mount_removed_callback), application, 0);
g_signal_connect_object (application->volume_monitor, "mount_pre_unmount",
G_CALLBACK (mount_removed_callback), application, 0);
g_signal_connect_object (application->volume_monitor, "mount_added",
G_CALLBACK (mount_added_callback), application, 0);
g_signal_connect_object (application->volume_monitor, "volume_added",
G_CALLBACK (volume_added_callback), application, 0);
/* register views */
fm_icon_view_register ();
fm_desktop_icon_view_register ();
......@@ -342,49 +380,6 @@ nautilus_make_uri_list_from_shell_strv (const char * const *strv)
return uri_list;
}
static void
migrate_old_nautilus_files (void)
{
char *new_desktop_dir;
char *old_desktop_dir;
char *migrated_file;
char *link_name;
char *link_path;
int fd;
old_desktop_dir = nautilus_get_gmc_desktop_directory ();
if (!g_file_test (old_desktop_dir, G_FILE_TEST_IS_DIR) ||
g_file_test (old_desktop_dir, G_FILE_TEST_IS_SYMLINK)) {
g_free (old_desktop_dir);
return;
}
migrated_file = g_build_filename (old_desktop_dir, ".migrated", NULL);
if (!g_file_test (migrated_file, G_FILE_TEST_EXISTS)) {
link_name = g_filename_from_utf8 (_("Link To Old Desktop"), -1, NULL, NULL, NULL);
new_desktop_dir = nautilus_get_desktop_directory ();
link_path = g_build_filename (new_desktop_dir, link_name, NULL);
symlink ("../.gnome-desktop", link_path);
g_free (link_name);
g_free (new_desktop_dir);
g_free (link_path);
fd = creat (migrated_file, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
if (fd >= 0) {
close (fd);
}
eel_show_info_dialog (_("A link called \"Link To Old Desktop\" has been created on the desktop."),
_("The location of the desktop directory has changed in GNOME 2.4. "
"You can open the link and move over the files you want, then delete the link."),
NULL);
}