Commit 8fc1e99e authored by David Zeuthen's avatar David Zeuthen Committed by Alexander Larsson
Browse files

Update for API changes in gio trunk.

2007-12-14  David Zeuthen  <davidz@redhat.com>

	* libnautilus-private/nautilus-desktop-icon-file.c:
	(update_info_from_link):
	* libnautilus-private/nautilus-desktop-link-monitor.c:
	(volume_delete_dialog):
	* src/file-manager/fm-tree-view.c: (button_pressed_callback),
	(fm_tree_view_unmount_cb):
	* src/nautilus-pathbar.c: (nautilus_path_bar_class_init):
	* src/nautilus-places-sidebar.c: (check_visibility),
	(volume_mount_cb), (open_selected_bookmark), (mount_shortcut_cb),
	(drive_eject_cb), (volume_eject_cb), (mount_eject_cb),
	(eject_shortcut_cb):

	Update for API changes in gio trunk.


svn path=/trunk/; revision=13532
parent a00649cd
2007-12-14 David Zeuthen <davidz@redhat.com>
* libnautilus-private/nautilus-desktop-icon-file.c:
(update_info_from_link):
* libnautilus-private/nautilus-desktop-link-monitor.c:
(volume_delete_dialog):
* src/file-manager/fm-tree-view.c: (button_pressed_callback),
(fm_tree_view_unmount_cb):
* src/nautilus-pathbar.c: (nautilus_path_bar_class_init):
* src/nautilus-places-sidebar.c: (check_visibility),
(volume_mount_cb), (open_selected_bookmark), (mount_shortcut_cb),
(drive_eject_cb), (volume_eject_cb), (mount_eject_cb),
(eject_shortcut_cb):
Update for API changes in gio trunk.
2007-12-14 Alexander Larsson <alexl@redhat.com> 2007-12-14 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-file-operations.c: * libnautilus-private/nautilus-file-operations.c:
......
...@@ -185,17 +185,8 @@ update_info_from_link (NautilusDesktopIconFile *icon_file) ...@@ -185,17 +185,8 @@ update_info_from_link (NautilusDesktopIconFile *icon_file)
file->details->can_eject = FALSE; file->details->can_eject = FALSE;
mount = nautilus_desktop_link_get_mount (link); mount = nautilus_desktop_link_get_mount (link);
if (mount) { if (mount) {
GDrive *drive;
gboolean can_eject = FALSE;
drive = g_mount_get_drive (mount);
if (drive != NULL) {
can_eject = g_drive_can_eject (drive);
g_object_unref (drive);
}
file->details->can_unmount = g_mount_can_unmount (mount); file->details->can_unmount = g_mount_can_unmount (mount);
file->details->can_eject = can_eject; file->details->can_eject = g_mount_can_eject (mount);
g_object_unref (mount); g_object_unref (mount);
} }
......
...@@ -99,21 +99,12 @@ volume_delete_dialog (GtkWidget *parent_view, ...@@ -99,21 +99,12 @@ volume_delete_dialog (GtkWidget *parent_view,
mount = nautilus_desktop_link_get_mount (link); mount = nautilus_desktop_link_get_mount (link);
if (mount != NULL) { if (mount != NULL) {
GDrive *drive;
gboolean can_eject = FALSE;
drive = g_mount_get_drive (mount);
if (drive != NULL) {
can_eject = g_drive_can_eject (drive);
g_object_unref (drive);
}
display_name = nautilus_desktop_link_get_display_name (link); display_name = nautilus_desktop_link_get_display_name (link);
dialog_str = g_strdup_printf (_("You cannot move the volume \"%s\" to the trash."), dialog_str = g_strdup_printf (_("You cannot move the volume \"%s\" to the trash."),
display_name); display_name);
g_free (display_name); g_free (display_name);
if (can_eject) { if (g_mount_can_eject (mount)) {
eel_run_simple_dialog eel_run_simple_dialog
(parent_view, (parent_view,
FALSE, FALSE,
......
...@@ -744,18 +744,9 @@ button_pressed_callback (GtkTreeView *treeview, GdkEventButton *event, ...@@ -744,18 +744,9 @@ button_pressed_callback (GtkTreeView *treeview, GdkEventButton *event,
mount = fm_tree_model_get_mount_for_root_node_file (view->details->child_model, view->details->popup_file); mount = fm_tree_model_get_mount_for_root_node_file (view->details->child_model, view->details->popup_file);
if (mount) { if (mount) {
GDrive *drive; show_unmount = g_mount_can_unmount (mount) || g_mount_can_eject (mount);
gboolean can_eject = FALSE;
drive = g_mount_get_drive (mount);
if (drive != NULL) {
can_eject = g_drive_can_eject (drive);
g_object_unref (drive);
}
show_unmount = g_mount_can_unmount (mount) || can_eject;
/* TODO: show both unmount and eject if there are more than one volume for the drive */ /* TODO: show both unmount and eject if there are more than one volume for the drive */
unmount_is_eject = can_eject; unmount_is_eject = g_mount_can_eject (mount);
} }
gtk_label_set_text (GTK_LABEL (GTK_BIN (GTK_MENU_ITEM (view->details->popup_unmount))->child), gtk_label_set_text (GTK_LABEL (GTK_BIN (GTK_MENU_ITEM (view->details->popup_unmount))->child),
...@@ -1105,18 +1096,9 @@ fm_tree_view_unmount_cb (GtkWidget *menu_item, ...@@ -1105,18 +1096,9 @@ fm_tree_view_unmount_cb (GtkWidget *menu_item,
mount = fm_tree_model_get_mount_for_root_node_file (view->details->child_model, file); mount = fm_tree_model_get_mount_for_root_node_file (view->details->child_model, file);
if (mount != NULL) { if (mount != NULL) {
GDrive *drive;
gboolean can_eject = FALSE;
drive = g_mount_get_drive (mount);
if (drive != NULL) {
can_eject = g_drive_can_eject (drive);
g_object_unref (drive);
}
nautilus_file_operations_unmount_mount (fm_tree_view_get_containing_window (view), nautilus_file_operations_unmount_mount (fm_tree_view_get_containing_window (view),
mount, mount,
can_eject); g_mount_can_eject (mount));
} }
} }
......
...@@ -268,7 +268,7 @@ nautilus_path_bar_class_init (NautilusPathBarClass *path_bar_class) ...@@ -268,7 +268,7 @@ nautilus_path_bar_class_init (NautilusPathBarClass *path_bar_class)
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NautilusPathBarClass, path_clicked), G_STRUCT_OFFSET (NautilusPathBarClass, path_clicked),
NULL, NULL, NULL, NULL,
g_cclosure_marshal_VOID__STRING, g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
G_TYPE_FILE); G_TYPE_FILE);
} }
......
...@@ -1181,12 +1181,15 @@ check_visibility (GMount *mount, ...@@ -1181,12 +1181,15 @@ check_visibility (GMount *mount,
*show_rescan = TRUE; *show_rescan = TRUE;
} }
if (volume != NULL && mount == NULL) { if (volume != NULL) {
*show_mount = g_volume_can_mount (volume); *show_eject |= g_volume_can_eject (volume);
if (mount == NULL)
*show_mount = g_volume_can_mount (volume);
} }
if (mount != NULL) { if (mount != NULL) {
*show_unmount = g_mount_can_unmount (mount); *show_unmount = g_mount_can_unmount (mount);
*show_eject |= g_mount_can_eject (mount);
} }
#ifdef TODO_GIO #ifdef TODO_GIO
...@@ -1268,6 +1271,7 @@ volume_mount_cb (GObject *source_object, ...@@ -1268,6 +1271,7 @@ volume_mount_cb (GObject *source_object,
GAsyncResult *res, GAsyncResult *res,
gpointer user_data) gpointer user_data)
{ {
GMountOperation *mount_op = user_data;
GError *error; GError *error;
char *primary; char *primary;
char *name; char *name;
...@@ -1283,6 +1287,8 @@ volume_mount_cb (GObject *source_object, ...@@ -1283,6 +1287,8 @@ volume_mount_cb (GObject *source_object,
g_free (primary); g_free (primary);
g_error_free (error); g_error_free (error);
} }
g_object_unref (mount_op);
} }
static void static void
...@@ -1331,7 +1337,9 @@ open_selected_bookmark (NautilusPlacesSidebar *sidebar, ...@@ -1331,7 +1337,9 @@ open_selected_bookmark (NautilusPlacesSidebar *sidebar,
GVolume *volume; GVolume *volume;
gtk_tree_model_get (model, &iter, PLACES_SIDEBAR_COLUMN_VOLUME, &volume, -1); gtk_tree_model_get (model, &iter, PLACES_SIDEBAR_COLUMN_VOLUME, &volume, -1);
if (volume != NULL) { if (volume != NULL) {
g_volume_mount (volume, NULL, NULL, volume_mount_cb, NULL); GMountOperation *mount_op;
mount_op = g_mount_operation_new ();
g_volume_mount (volume, mount_op, NULL, volume_mount_cb, mount_op);
g_object_unref (volume); g_object_unref (volume);
} }
} }
...@@ -1447,10 +1455,8 @@ mount_shortcut_cb (GtkMenuItem *item, ...@@ -1447,10 +1455,8 @@ mount_shortcut_cb (GtkMenuItem *item,
if (volume != NULL) { if (volume != NULL) {
GMountOperation *mount_op; GMountOperation *mount_op;
/* TODO: do we leak this? */
mount_op = g_mount_operation_new (); mount_op = g_mount_operation_new ();
g_volume_mount (volume, mount_op, NULL, volume_mount_cb, NULL); g_volume_mount (volume, mount_op, NULL, volume_mount_cb, mount_op);
g_object_unref (volume); g_object_unref (volume);
} }
} }
...@@ -1495,10 +1501,8 @@ drive_eject_cb (GObject *source_object, ...@@ -1495,10 +1501,8 @@ drive_eject_cb (GObject *source_object,
GError *error; GError *error;
char *primary; char *primary;
char *name; char *name;
error = NULL; error = NULL;
if (!g_drive_eject_finish (G_DRIVE (source_object), if (!g_drive_eject_finish (G_DRIVE (source_object), res, &error)) {
res, &error)) {
name = g_drive_get_name (G_DRIVE (source_object)); name = g_drive_get_name (G_DRIVE (source_object));
primary = g_strdup_printf (_("Unable to eject %s"), name); primary = g_strdup_printf (_("Unable to eject %s"), name);
g_free (name); g_free (name);
...@@ -1510,6 +1514,48 @@ drive_eject_cb (GObject *source_object, ...@@ -1510,6 +1514,48 @@ drive_eject_cb (GObject *source_object,
} }
} }
static void
volume_eject_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GError *error;
char *primary;
char *name;
error = NULL;
if (!g_volume_eject_finish (G_VOLUME (source_object), res, &error)) {
name = g_volume_get_name (G_VOLUME (source_object));
primary = g_strdup_printf (_("Unable to eject %s"), name);
g_free (name);
eel_show_error_dialog (primary,
error->message,
NULL);
g_free (primary);
g_error_free (error);
}
}
static void
mount_eject_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GError *error;
char *primary;
char *name;
error = NULL;
if (!g_mount_eject_finish (G_MOUNT (source_object), res, &error)) {
name = g_mount_get_name (G_MOUNT (source_object));
primary = g_strdup_printf (_("Unable to eject %s"), name);
g_free (name);
eel_show_error_dialog (primary,
error->message,
NULL);
g_free (primary);
g_error_free (error);
}
}
static void static void
eject_shortcut_cb (GtkMenuItem *item, eject_shortcut_cb (GtkMenuItem *item,
NautilusPlacesSidebar *sidebar) NautilusPlacesSidebar *sidebar)
...@@ -1530,18 +1576,19 @@ eject_shortcut_cb (GtkMenuItem *item, ...@@ -1530,18 +1576,19 @@ eject_shortcut_cb (GtkMenuItem *item,
-1); -1);
if (mount != NULL) { if (mount != NULL) {
GtkWidget *toplevel; g_mount_eject (mount, NULL, mount_eject_cb, NULL);
} else if (volume != NULL) {
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (sidebar->tree_view)); g_volume_eject (volume, NULL, volume_eject_cb, NULL);
nautilus_file_operations_unmount_mount (GTK_WINDOW (toplevel),
mount,
TRUE);
} else if (drive != NULL) { } else if (drive != NULL) {
g_drive_eject (drive, NULL, drive_eject_cb, NULL); g_drive_eject (drive, NULL, drive_eject_cb, NULL);
} }
g_object_unref (mount);
g_object_unref (volume); if (mount != NULL)
g_object_unref (drive); g_object_unref (mount);
if (volume != NULL)
g_object_unref (volume);
if (drive != NULL)
g_object_unref (drive);
} }
static void static void
......
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