diff options
Diffstat (limited to 'src/format-window.c')
-rw-r--r-- | src/format-window.c | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/src/format-window.c b/src/format-window.c index 48ba203..17fc595 100644 --- a/src/format-window.c +++ b/src/format-window.c @@ -36,6 +36,8 @@ +/* ---------------------------------------------------------------------------------------------------- */ +static void set_new_presentable (FormatDialogPrivate *priv, GduPresentable *presentable); /* ---------------------------------------------------------------------------------------------------- */ @@ -133,9 +135,10 @@ update_ui_controls (FormatDialogPrivate *priv) gtk_widget_show_all (priv->no_media_warning); /* controls sensitivity */ - sensitive = priv->presentable != NULL && GDU_IS_PRESENTABLE (priv->presentable) && - device != NULL && (! priv->job_running) && - (! gdu_device_is_read_only (device)) && (gdu_device_is_media_available (device)); + sensitive = priv->presentable != NULL && GDU_IS_PRESENTABLE (priv->presentable) && (! priv->job_running); + if (device) + sensitive = sensitive && ! gdu_device_is_read_only (device) && gdu_device_is_media_available (device); + gtk_widget_set_sensitive (priv->controls_box, sensitive); gtk_widget_set_sensitive (priv->partition_label, sensitive); if (priv->volume_selector) @@ -495,7 +498,6 @@ update_ui (FormatDialogPrivate *priv) /* ---------------------------------------------------------------------------------------------------- */ -static void set_new_presentable (FormatDialogPrivate *priv, GduPresentable *presentable); static void nautilus_gdu_destroy (FormatDialogPrivate *priv) @@ -510,14 +512,6 @@ nautilus_gdu_destroy (FormatDialogPrivate *priv) set_new_presentable (priv, NULL); g_signal_handlers_disconnect_matched (priv->pool, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, priv); - /* destroy PolicyKit actions */ - polkit_action_unref (priv->pk_unmount_action); - g_object_unref (priv->unmount_action); - polkit_action_unref (priv->pk_format_action); - g_object_unref (priv->format_action); - polkit_action_unref (priv->pk_part_modify_action); - g_object_unref (priv->part_modify_action); - /* destroy the dialog and internal struct */ gtk_widget_destroy (GTK_WIDGET (priv->dialog)); g_object_unref (priv->pool); @@ -553,6 +547,19 @@ presentable_changed (GduPresentable *presentable, FormatDialogPrivate *priv) update_ui (priv); } +/* we do ref presentable ourselves */ +void +select_new_presentable (FormatDialogPrivate *priv, GduPresentable *presentable) +{ + if (priv->volume_selector) { + gdu_util_presentable_combo_box_rebuild (priv->volume_selector, priv->pool); + gdu_util_presentable_combo_box_select (priv->volume_selector, presentable); + } + /* force refresh when no standalone mode */ + if (presentable != priv->presentable || ! priv->volume_selector) + set_new_presentable (priv, presentable); +} + static void set_new_presentable (FormatDialogPrivate *priv, GduPresentable *presentable) { @@ -583,8 +590,11 @@ pool_presentable_changed (GduPool *pool, GduPresentable *presentable, FormatDial { g_return_if_fail (priv != NULL); g_return_if_fail (priv->volume_selector != NULL); - g_warning ("Pool presentable changed event.\n"); - gdu_util_presentable_combo_box_rebuild (priv->volume_selector, pool); + + if (! priv->job_running) { + g_warning ("Pool presentable changed event.\n"); + gdu_util_presentable_combo_box_rebuild (priv->volume_selector, pool); + } } static void @@ -615,6 +625,7 @@ cancel_operation (FormatDialogPrivate *priv) g_return_if_fail (priv != NULL); g_return_if_fail (priv->job_running == TRUE); + /* TODO: check for valid device */ g_return_if_fail (priv->presentable != NULL); g_warning ("Cancelling...\n"); @@ -932,19 +943,6 @@ nautilus_gdu_spawn_dialog (GduPresentable *presentable, gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); - /* set up PolicyKit actions */ - priv->pk_unmount_action = polkit_action_new (); - polkit_action_set_action_id (priv->pk_unmount_action, "org.freedesktop.devicekit.disks.filesystem-unmount-others"); - priv->unmount_action = polkit_gnome_action_new_default ("unmount", priv->pk_unmount_action, NULL, NULL); - priv->pk_format_action = polkit_action_new (); - polkit_action_set_action_id (priv->pk_format_action, "org.freedesktop.devicekit.disks.change"); - priv->format_action = polkit_gnome_action_new_default ("format", priv->pk_format_action, NULL, NULL); - priv->pk_part_modify_action = polkit_action_new (); - /* action_id is the same as for format, but sometimes authentication is one shot */ - polkit_action_set_action_id (priv->pk_part_modify_action, "org.freedesktop.devicekit.disks.change"); - priv->part_modify_action = polkit_gnome_action_new_default ("part_modify", priv->pk_part_modify_action, NULL, NULL); - - // gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_OK, FALSE); g_signal_connect (priv->dialog, "delete-event", |