mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-09-13 04:51:15 +00:00
Make changes to "desktop_is_home_dir" GConf key instant apply. Fixes
2005-09-26 Christian Neumair <chris@gnome-de.org> * libnautilus-private/nautilus-desktop-directory.c: (desktop_directory_changed_callback), (desktop_finalize), (update_desktop_directory): Make changes to "desktop_is_home_dir" GConf key instant apply. Fixes #116217. * libnautilus-private/nautilus-icon-canvas-item.c: (nautilus_icon_canvas_item_get_image): Add emblems to drag icon. Partially fixes #159643. * src/file-manager/fm-directory-view.c: (action_mount_volume_callback), (action_unmount_volume_callback), (action_eject_volume_callback), (file_should_show_foreach), (real_update_menus_volumes): Allow to mount/unmount/eject multiple volumes at once. Fixes #156169.
This commit is contained in:
parent
5a5a202ab0
commit
e64d43ee5f
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
|||
2005-09-26 Christian Neumair <chris@gnome-de.org>
|
||||
|
||||
* libnautilus-private/nautilus-desktop-directory.c:
|
||||
(desktop_directory_changed_callback), (desktop_finalize),
|
||||
(update_desktop_directory): Make changes to "desktop_is_home_dir"
|
||||
GConf key instant apply. Fixes #116217.
|
||||
|
||||
* libnautilus-private/nautilus-icon-canvas-item.c:
|
||||
(nautilus_icon_canvas_item_get_image): Add emblems to drag icon.
|
||||
Partially fixes #159643.
|
||||
|
||||
* src/file-manager/fm-directory-view.c:
|
||||
(action_mount_volume_callback), (action_unmount_volume_callback),
|
||||
(action_eject_volume_callback), (file_should_show_foreach),
|
||||
(real_update_menus_volumes): Allow to mount/unmount/eject multiple
|
||||
volumes at once. Fixes #156169.
|
||||
|
||||
2005-09-20 christian neumair <chris@gnome-de.org>
|
||||
|
||||
* src/nautilus-connect-server-dialog.c: (connect_to_server):
|
||||
|
|
|
@ -31,8 +31,10 @@
|
|||
#include "nautilus-file.h"
|
||||
#include "nautilus-file-private.h"
|
||||
#include "nautilus-file-utilities.h"
|
||||
#include "nautilus-global-preferences.h"
|
||||
#include <eel/eel-glib-extensions.h>
|
||||
#include <libgnomevfs/gnome-vfs-utils.h>
|
||||
#include <gtk/gtkmain.h>
|
||||
#include <gtk/gtksignal.h>
|
||||
#include <libgnome/gnome-macros.h>
|
||||
|
||||
|
@ -63,6 +65,7 @@ typedef struct {
|
|||
NautilusFileAttributes monitor_attributes;
|
||||
} MergedMonitor;
|
||||
|
||||
static void desktop_directory_changed_callback (gpointer data);
|
||||
|
||||
GNOME_CLASS_BOILERPLATE (NautilusDesktopDirectory, nautilus_desktop_directory,
|
||||
NautilusDirectory, NAUTILUS_TYPE_DIRECTORY)
|
||||
|
@ -424,6 +427,10 @@ desktop_finalize (GObject *object)
|
|||
g_hash_table_destroy (desktop->details->callbacks);
|
||||
g_hash_table_destroy (desktop->details->monitors);
|
||||
g_free (desktop->details);
|
||||
|
||||
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
|
||||
desktop_directory_changed_callback,
|
||||
desktop);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -452,38 +459,64 @@ forward_files_changed_cover (NautilusDirectory *real_directory,
|
|||
nautilus_directory_emit_files_changed (NAUTILUS_DIRECTORY (callback_data), files);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
nautilus_desktop_directory_instance_init (NautilusDesktopDirectory *desktop)
|
||||
update_desktop_directory (NautilusDesktopDirectory *desktop)
|
||||
{
|
||||
char *desktop_path;
|
||||
char *desktop_uri;
|
||||
NautilusDirectory *real_directory;
|
||||
|
||||
desktop->details = g_new0 (NautilusDesktopDirectoryDetails, 1);
|
||||
|
||||
real_directory = desktop->details->real_directory;
|
||||
if (real_directory != NULL) {
|
||||
g_hash_table_foreach_remove (desktop->details->callbacks, (GHRFunc) gtk_true, NULL);
|
||||
g_hash_table_foreach_remove (desktop->details->monitors, (GHRFunc) gtk_true, NULL);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (real_directory, done_loading_callback, desktop);
|
||||
g_signal_handlers_disconnect_by_func (real_directory, forward_files_added_cover, desktop);
|
||||
g_signal_handlers_disconnect_by_func (real_directory, forward_files_changed_cover, desktop);
|
||||
|
||||
nautilus_directory_unref (real_directory);
|
||||
}
|
||||
|
||||
desktop_path = nautilus_get_desktop_directory ();
|
||||
desktop_uri = gnome_vfs_get_uri_from_local_path (desktop_path);
|
||||
desktop->details->real_directory = nautilus_directory_get (desktop_uri);
|
||||
real_directory = nautilus_directory_get (desktop_uri);
|
||||
g_free (desktop_uri);
|
||||
g_free (desktop_path);
|
||||
|
||||
g_signal_connect_object (real_directory, "done_loading",
|
||||
G_CALLBACK (done_loading_callback), desktop, 0);
|
||||
g_signal_connect_object (real_directory, "files_added",
|
||||
G_CALLBACK (forward_files_added_cover), desktop, 0);
|
||||
g_signal_connect_object (real_directory, "files_changed",
|
||||
G_CALLBACK (forward_files_changed_cover), desktop, 0);
|
||||
|
||||
desktop->details->real_directory = real_directory;
|
||||
}
|
||||
|
||||
static void
|
||||
desktop_directory_changed_callback (gpointer data)
|
||||
{
|
||||
update_desktop_directory (NAUTILUS_DESKTOP_DIRECTORY (data));
|
||||
nautilus_directory_force_reload (NAUTILUS_DIRECTORY (data));
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_desktop_directory_instance_init (NautilusDesktopDirectory *desktop)
|
||||
{
|
||||
desktop->details = g_new0 (NautilusDesktopDirectoryDetails, 1);
|
||||
|
||||
desktop->details->callbacks = g_hash_table_new_full
|
||||
(merged_callback_hash, merged_callback_equal,
|
||||
NULL, (GDestroyNotify)merged_callback_destroy);
|
||||
desktop->details->monitors = g_hash_table_new_full (NULL, NULL,
|
||||
NULL, (GDestroyNotify)merged_monitor_destroy);
|
||||
|
||||
real_directory = desktop->details->real_directory;
|
||||
|
||||
g_signal_connect_object (real_directory, "done_loading",
|
||||
G_CALLBACK (done_loading_callback), desktop, 0);
|
||||
|
||||
g_signal_connect_object (real_directory, "files_added",
|
||||
G_CALLBACK (forward_files_added_cover), desktop, 0);
|
||||
g_signal_connect_object (real_directory, "files_changed",
|
||||
G_CALLBACK (forward_files_changed_cover), desktop, 0);
|
||||
update_desktop_directory (NAUTILUS_DESKTOP_DIRECTORY (desktop));
|
||||
|
||||
eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
|
||||
desktop_directory_changed_callback,
|
||||
desktop);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -467,7 +467,10 @@ nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item,
|
|||
int width, height;
|
||||
int item_offset_x, item_offset_y;
|
||||
ArtIRect icon_rect;
|
||||
ArtIRect emblem_rect;
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkPixbuf *emblem_pixbuf;
|
||||
EmblemLayout emblem_layout;
|
||||
double item_x, item_y;
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), NULL);
|
||||
|
@ -496,14 +499,42 @@ nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item,
|
|||
gdk_colormap_get_visual (colormap)->depth);
|
||||
gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), colormap);
|
||||
|
||||
pixbuf = item->details->pixbuf;
|
||||
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
|
||||
TRUE,
|
||||
gdk_pixbuf_get_bits_per_sample (item->details->pixbuf),
|
||||
width, height);
|
||||
gdk_pixbuf_fill (pixbuf, 0x00000000);
|
||||
|
||||
gdk_pixbuf_composite (item->details->pixbuf, pixbuf,
|
||||
item_offset_x, item_offset_y,
|
||||
gdk_pixbuf_get_width (item->details->pixbuf),
|
||||
gdk_pixbuf_get_height (item->details->pixbuf),
|
||||
item_offset_x, item_offset_y, 1.0, 1.0,
|
||||
GDK_INTERP_BILINEAR, 255);
|
||||
|
||||
icon_rect.x0 = item_offset_x;
|
||||
icon_rect.y0 = item_offset_y;
|
||||
icon_rect.x1 = item_offset_x + gdk_pixbuf_get_width (item->details->pixbuf);
|
||||
icon_rect.y1 = item_offset_y + gdk_pixbuf_get_height (item->details->pixbuf);
|
||||
|
||||
emblem_layout_reset (&emblem_layout, item, icon_rect);
|
||||
while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect)) {
|
||||
gdk_pixbuf_composite (emblem_pixbuf, pixbuf,
|
||||
emblem_rect.x0, emblem_rect.y0,
|
||||
gdk_pixbuf_get_width (emblem_pixbuf),
|
||||
gdk_pixbuf_get_height (emblem_pixbuf),
|
||||
emblem_rect.x0, emblem_rect.y0,
|
||||
1.0, 1.0,
|
||||
GDK_INTERP_BILINEAR, 255);
|
||||
}
|
||||
|
||||
gc = gdk_gc_new (pixmap);
|
||||
gdk_draw_rectangle (pixmap, GTK_WIDGET (canvas)->style->white_gc,
|
||||
TRUE,
|
||||
0, 0,
|
||||
width, height);
|
||||
gdk_draw_pixbuf (pixmap, gc, pixbuf,
|
||||
0, 0, item_offset_x, item_offset_y,
|
||||
0, 0, 0, 0,
|
||||
gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf),
|
||||
GDK_RGB_DITHER_NORMAL,
|
||||
0, 0);
|
||||
|
@ -520,20 +551,18 @@ nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item,
|
|||
g_object_unref (gc);
|
||||
|
||||
gdk_pixbuf_render_threshold_alpha (pixbuf, *mask,
|
||||
0, 0, item_offset_x, item_offset_y,
|
||||
0, 0, 0, 0,
|
||||
gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf),
|
||||
128);
|
||||
|
||||
draw_embedded_text (item, GDK_DRAWABLE (pixmap),
|
||||
item_offset_x, item_offset_y);
|
||||
|
||||
icon_rect.x0 = item_offset_x;
|
||||
icon_rect.y0 = item_offset_y;
|
||||
icon_rect.x1 = item_offset_x + gdk_pixbuf_get_width (pixbuf);
|
||||
icon_rect.y1 = item_offset_y + gdk_pixbuf_get_height (pixbuf);
|
||||
draw_label_text (item, GDK_DRAWABLE (pixmap), FALSE, icon_rect);
|
||||
draw_label_text (item, GDK_DRAWABLE (*mask), TRUE, icon_rect);
|
||||
|
||||
|
||||
gdk_pixbuf_unref (pixbuf);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
|
|
|
@ -5696,28 +5696,23 @@ action_mount_volume_callback (GtkAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
NautilusFile *file;
|
||||
GList *selection;
|
||||
GList *selection, *l;
|
||||
GnomeVFSDrive *drive;
|
||||
FMDirectoryView *view;
|
||||
|
||||
view = FM_DIRECTORY_VIEW (data);
|
||||
|
||||
selection = fm_directory_view_get_selection (view);
|
||||
for (l = selection; l != NULL; l = l->next) {
|
||||
file = NAUTILUS_FILE (l->data);
|
||||
|
||||
if (!eel_g_list_exactly_one_item (selection)) {
|
||||
nautilus_file_list_free (selection);
|
||||
return;
|
||||
}
|
||||
|
||||
file = NAUTILUS_FILE (selection->data);
|
||||
|
||||
if (nautilus_file_has_drive (file)) {
|
||||
drive = nautilus_file_get_drive (file);
|
||||
if (drive != NULL) {
|
||||
gnome_vfs_drive_mount (drive, drive_mounted_callback, NULL);
|
||||
if (nautilus_file_has_drive (file)) {
|
||||
drive = nautilus_file_get_drive (file);
|
||||
if (drive != NULL) {
|
||||
gnome_vfs_drive_mount (drive, drive_mounted_callback, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nautilus_file_list_free (selection);
|
||||
}
|
||||
|
||||
|
@ -5766,7 +5761,7 @@ action_unmount_volume_callback (GtkAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
NautilusFile *file;
|
||||
GList *selection;
|
||||
GList *selection, *l;
|
||||
GnomeVFSDrive *drive;
|
||||
GnomeVFSVolume *volume;
|
||||
FMDirectoryView *view;
|
||||
|
@ -5775,34 +5770,29 @@ action_unmount_volume_callback (GtkAction *action,
|
|||
|
||||
selection = fm_directory_view_get_selection (view);
|
||||
|
||||
if (!eel_g_list_exactly_one_item (selection)) {
|
||||
nautilus_file_list_free (selection);
|
||||
return;
|
||||
}
|
||||
|
||||
file = NAUTILUS_FILE (selection->data);
|
||||
|
||||
if (nautilus_file_has_volume (file)) {
|
||||
volume = nautilus_file_get_volume (file);
|
||||
if (volume != NULL) {
|
||||
gnome_vfs_volume_unmount (volume, volume_or_drive_unmounted_callback, NULL);
|
||||
}
|
||||
} else if (nautilus_file_has_drive (file)) {
|
||||
drive = nautilus_file_get_drive (file);
|
||||
if (drive != NULL) {
|
||||
gnome_vfs_drive_unmount (drive, volume_or_drive_unmounted_callback, NULL);
|
||||
for (l = selection; l != NULL; l = l->next) {
|
||||
file = NAUTILUS_FILE (l->data);
|
||||
if (nautilus_file_has_volume (file)) {
|
||||
volume = nautilus_file_get_volume (file);
|
||||
if (volume != NULL) {
|
||||
gnome_vfs_volume_unmount (volume, volume_or_drive_unmounted_callback, NULL);
|
||||
}
|
||||
} else if (nautilus_file_has_drive (file)) {
|
||||
drive = nautilus_file_get_drive (file);
|
||||
if (drive != NULL) {
|
||||
gnome_vfs_drive_unmount (drive, volume_or_drive_unmounted_callback, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nautilus_file_list_free (selection);
|
||||
}
|
||||
|
||||
static void
|
||||
action_eject_volume_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
gpointer data)
|
||||
{
|
||||
NautilusFile *file;
|
||||
GList *selection;
|
||||
GList *selection, *l;
|
||||
GnomeVFSDrive *drive;
|
||||
GnomeVFSVolume *volume;
|
||||
FMDirectoryView *view;
|
||||
|
@ -5810,26 +5800,21 @@ action_eject_volume_callback (GtkAction *action,
|
|||
view = FM_DIRECTORY_VIEW (data);
|
||||
|
||||
selection = fm_directory_view_get_selection (view);
|
||||
|
||||
if (!eel_g_list_exactly_one_item (selection)) {
|
||||
nautilus_file_list_free (selection);
|
||||
return;
|
||||
}
|
||||
|
||||
file = NAUTILUS_FILE (selection->data);
|
||||
|
||||
if (nautilus_file_has_volume (file)) {
|
||||
volume = nautilus_file_get_volume (file);
|
||||
if (volume != NULL) {
|
||||
gnome_vfs_volume_eject (volume, volume_or_drive_ejected_callback, NULL);
|
||||
for (l = selection; l != NULL; l = l->next) {
|
||||
file = NAUTILUS_FILE (l->data);
|
||||
|
||||
if (nautilus_file_has_volume (file)) {
|
||||
volume = nautilus_file_get_volume (file);
|
||||
if (volume != NULL) {
|
||||
gnome_vfs_volume_eject (volume, volume_or_drive_ejected_callback, NULL);
|
||||
}
|
||||
} else if (nautilus_file_has_drive (file)) {
|
||||
drive = nautilus_file_get_drive (file);
|
||||
if (drive != NULL) {
|
||||
gnome_vfs_drive_eject (drive, volume_or_drive_ejected_callback, NULL);
|
||||
}
|
||||
}
|
||||
} else if (nautilus_file_has_drive (file)) {
|
||||
drive = nautilus_file_get_drive (file);
|
||||
if (drive != NULL) {
|
||||
gnome_vfs_drive_eject (drive, volume_or_drive_ejected_callback, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
nautilus_file_list_free (selection);
|
||||
}
|
||||
|
||||
|
@ -6458,56 +6443,87 @@ file_list_all_are_folders (GList *file_list)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
file_should_show_foreach (NautilusFile *file,
|
||||
gboolean *show_mount,
|
||||
gboolean *show_unmount,
|
||||
gboolean *show_eject,
|
||||
gboolean *show_connect)
|
||||
{
|
||||
GnomeVFSVolume *volume;
|
||||
GnomeVFSDrive *drive;
|
||||
char *uri;
|
||||
|
||||
*show_mount = FALSE;
|
||||
*show_unmount = FALSE;
|
||||
*show_eject = FALSE;
|
||||
*show_connect = FALSE;
|
||||
|
||||
if (nautilus_file_has_volume (file)) {
|
||||
*show_unmount = TRUE;
|
||||
|
||||
volume = nautilus_file_get_volume (file);
|
||||
*show_eject = eject_for_type (gnome_vfs_volume_get_device_type (volume));
|
||||
} else if (nautilus_file_has_drive (file)) {
|
||||
drive = nautilus_file_get_drive (file);
|
||||
*show_eject = eject_for_type (gnome_vfs_drive_get_device_type (drive));
|
||||
if (gnome_vfs_drive_is_mounted (drive)) {
|
||||
*show_unmount = TRUE;
|
||||
} else {
|
||||
*show_mount = TRUE;
|
||||
}
|
||||
} else if (nautilus_file_is_nautilus_link (file)) {
|
||||
uri = nautilus_file_get_activation_uri (file);
|
||||
if (uri != NULL &&
|
||||
(eel_istr_has_prefix (uri, "ftp:") ||
|
||||
eel_istr_has_prefix (uri, "dav:") ||
|
||||
eel_istr_has_prefix (uri, "davs:"))) {
|
||||
*show_connect = TRUE;
|
||||
}
|
||||
g_free (uri);
|
||||
} else if (nautilus_file_is_mime_type (file,
|
||||
"x-directory/smb-share")) {
|
||||
*show_connect = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
real_update_menus_volumes (FMDirectoryView *view,
|
||||
GList *selection,
|
||||
gint selection_count)
|
||||
{
|
||||
GList *l;
|
||||
NautilusFile *file;
|
||||
gboolean show_mount;
|
||||
gboolean show_unmount;
|
||||
gboolean show_eject;
|
||||
gboolean show_connect;
|
||||
GnomeVFSVolume *volume;
|
||||
GnomeVFSDrive *drive;
|
||||
GtkAction *action;
|
||||
char *uri;
|
||||
|
||||
show_mount = FALSE;
|
||||
show_unmount = FALSE;
|
||||
show_eject = FALSE;
|
||||
show_connect = FALSE;
|
||||
show_mount = (selection != NULL);
|
||||
show_unmount = (selection != NULL);
|
||||
show_eject = (selection != NULL);
|
||||
show_connect = (selection != NULL && selection_count == 1);
|
||||
|
||||
if (selection_count == 1) {
|
||||
file = NAUTILUS_FILE (selection->data);
|
||||
for (l = selection; l != NULL && (show_mount || show_unmount
|
||||
|| show_eject || show_connect);
|
||||
l = l->next) {
|
||||
gboolean show_mount_one;
|
||||
gboolean show_unmount_one;
|
||||
gboolean show_eject_one;
|
||||
gboolean show_connect_one;
|
||||
|
||||
if (nautilus_file_has_volume (file)) {
|
||||
show_unmount = TRUE;
|
||||
file = NAUTILUS_FILE (l->data);
|
||||
file_should_show_foreach (file,
|
||||
&show_mount_one,
|
||||
&show_unmount_one,
|
||||
&show_eject_one,
|
||||
&show_connect_one);
|
||||
|
||||
volume = nautilus_file_get_volume (file);
|
||||
show_eject = eject_for_type (gnome_vfs_volume_get_device_type (volume));
|
||||
} else if (nautilus_file_has_drive (file)) {
|
||||
drive = nautilus_file_get_drive (file);
|
||||
show_eject = eject_for_type (gnome_vfs_drive_get_device_type (drive));
|
||||
if (gnome_vfs_drive_is_mounted (drive)) {
|
||||
show_unmount = TRUE;
|
||||
} else {
|
||||
show_mount = TRUE;
|
||||
}
|
||||
} else if (nautilus_file_is_nautilus_link (file)) {
|
||||
uri = nautilus_file_get_activation_uri (file);
|
||||
if (uri != NULL &&
|
||||
(eel_istr_has_prefix (uri, "ftp:") ||
|
||||
eel_istr_has_prefix (uri, "dav:") ||
|
||||
eel_istr_has_prefix (uri, "davs:"))) {
|
||||
show_connect = TRUE;
|
||||
}
|
||||
g_free (uri);
|
||||
} else if (nautilus_file_is_mime_type (file,
|
||||
"x-directory/smb-share")) {
|
||||
show_connect = TRUE;
|
||||
}
|
||||
|
||||
show_mount &= show_mount_one;
|
||||
show_unmount &= show_unmount_one;
|
||||
show_eject &= show_eject_one;
|
||||
show_connect &= show_connect_one;
|
||||
}
|
||||
|
||||
/* We don't want both eject and unmount, since eject
|
||||
|
|
Loading…
Reference in a new issue