summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2009-02-17 12:32:56 +0100
committerTomas Bzatek <tbzatek@redhat.com>2009-02-17 12:32:56 +0100
commit3e1706c1f7736e10ba3d0a3ab3af7daf618add8c (patch)
tree98cb37a7d2f3ca34c99cef3383f91a3828e325ea
parentfb55089673387a6bbe0071cd5e40dd5d2eae2143 (diff)
downloadnautilus-gdu-3e1706c1f7736e10ba3d0a3ab3af7daf618add8c.tar.gz
nautilus-gdu-3e1706c1f7736e10ba3d0a3ab3af7daf618add8c.tar.xz
nautilus-gdu-3e1706c1f7736e10ba3d0a3ab3af7daf618add8c.zip
Show read only infobox
Clear combo box on unknown filesystem
-rw-r--r--.gitignore1
-rw-r--r--README4
-rw-r--r--TODO1
-rw-r--r--src/nautilus-gdu-window.c100
4 files changed, 71 insertions, 35 deletions
diff --git a/.gitignore b/.gitignore
index e3f2d7f..2acf39e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,3 +34,4 @@ src/gnome-disk-utility-format
.cproject
.project
Debug/
+.settings/
diff --git a/README b/README
index 24447c2..5a5d4ed 100644
--- a/README
+++ b/README
@@ -2,3 +2,7 @@ Nautilus-gdu is a simple extension for formatting disks, usb sticks and other me
available from Nautilus context menu. This extension is built on top.
of the gnome-disk-utility library with DeviceKit-disks as a backend.
Access to physical devices is controlled by PolicyKit.
+
+
+What it can do:
+ - format _removable_ media, such as USB disks, memory cards, DVD-RAM media etc.
diff --git a/TODO b/TODO
index c207336..d237eba 100644
--- a/TODO
+++ b/TODO
@@ -34,6 +34,7 @@ DONE, NEEDS_TESTING - monitor device/presentable events like eject, umount etc.
- test multihead (need to ref screen of the source nautilus window)
- nautilus integration: be able to spawn the dialog from sidebar
DONE - make standalone mode optional (configure --enable-standalone)
+- duplicate /dev/sr0 device in the list when media is present
Ideas:
diff --git a/src/nautilus-gdu-window.c b/src/nautilus-gdu-window.c
index 8fe5120..500b1c5 100644
--- a/src/nautilus-gdu-window.c
+++ b/src/nautilus-gdu-window.c
@@ -51,6 +51,7 @@ typedef struct {
GtkWidget *details2_label;
GtkWidget *details3_label;
GtkWidget *mount_warning;
+ GtkWidget *readonly_warning;
GtkWidget *label_entry;
GtkWidget *part_type_combo_box;
GtkWidget *part_flag_boot_check_button;
@@ -197,25 +198,6 @@ type_combo_box_changed (GtkWidget *combo_box, FormatDialogPrivate *priv)
}
-static void
-update_ui_mounted (FormatDialogPrivate *priv)
-{
- GduDevice *device = NULL;
-
- g_return_if_fail (priv != NULL);
-
- if (priv->presentable && GDU_IS_PRESENTABLE (priv->presentable))
- device = gdu_presentable_get_device (priv->presentable);
-
- if (device && gdu_device_is_mounted (device))
- gtk_widget_show_all (priv->mount_warning);
- else
- gtk_widget_hide_all (priv->mount_warning);
-
- if (device != NULL)
- g_object_unref (device);
-}
-
static gboolean
job_progress_pulse_timeout_handler (gpointer user_data)
{
@@ -281,6 +263,45 @@ presentable_job_changed (GduPresentable *presentable, gpointer user_data)
}
}
+
+static void
+update_ui_controls (FormatDialogPrivate *priv)
+{
+ GduDevice *device = NULL;
+ gboolean sensitive;
+
+ g_return_if_fail (priv != NULL);
+
+ if (priv->presentable && GDU_IS_PRESENTABLE (priv->presentable))
+ device = gdu_presentable_get_device (priv->presentable);
+
+ /* mount warning box */
+ if (device && gdu_device_is_mounted (device))
+ gtk_widget_show_all (priv->mount_warning);
+ else
+ gtk_widget_hide_all (priv->mount_warning);
+
+ /* read only info box */
+ if (device && gdu_device_is_read_only (device))
+ gtk_widget_show_all (priv->readonly_warning);
+ else
+ gtk_widget_hide_all (priv->readonly_warning);
+
+ /* controls sensitivity */
+ sensitive = priv->presentable != NULL && GDU_IS_PRESENTABLE (priv->presentable) &&
+ device != NULL && (! priv->job_running) && (! gdu_device_is_read_only (device));
+ gtk_widget_set_sensitive (priv->controls_box, sensitive);
+ gtk_widget_set_sensitive (priv->partition_label, sensitive);
+ if (priv->volume_selector)
+ gtk_widget_set_sensitive (priv->volume_selector, ! priv->job_running);
+ gtk_dialog_set_response_sensitive (priv->dialog, GTK_RESPONSE_OK, sensitive);
+/* gtk_dialog_set_response_sensitive (priv->dialog, GTK_RESPONSE_REJECT, sensitive); */
+// gtk_dialog_set_response_sensitive (priv->dialog, GTK_RESPONSE_CLOSE, sensitive);
+
+ if (device != NULL)
+ g_object_unref (device);
+}
+
static void unmount_auth_end_callback (PolKitGnomeAction *action, gboolean gained_privilege, gpointer user_data);
static void unmount_action_callback (GtkAction *action, gpointer user_data);
static void format_auth_end_callback (PolKitGnomeAction *action, gboolean gained_privilege, gpointer user_data);
@@ -339,13 +360,7 @@ update_ui_progress (FormatDialogPrivate *priv,
gtk_widget_hide_all (priv->progress_bar_box);
gtk_button_set_label (GTK_BUTTON (priv->close_button), GTK_STOCK_CLOSE);
}
- gtk_widget_set_sensitive (priv->controls_box, ! working && priv->presentable);
- gtk_widget_set_sensitive (priv->partition_label, ! working && priv->presentable);
- if (priv->volume_selector)
- gtk_widget_set_sensitive (priv->volume_selector, ! working);
- gtk_dialog_set_response_sensitive (priv->dialog, GTK_RESPONSE_OK, ! working && priv->presentable);
-/* gtk_dialog_set_response_sensitive (priv->dialog, GTK_RESPONSE_REJECT, ! working && priv->presentable); */
-// gtk_dialog_set_response_sensitive (priv->dialog, GTK_RESPONSE_CLOSE, ! working && priv->presentable);
+ update_ui_controls (priv);
}
@@ -370,6 +385,7 @@ update_ui (FormatDialogPrivate *priv)
gboolean show_flag_boot;
gboolean show_flag_required;
// gboolean can_edit_part_label;
+ gboolean known_fs;
const char *scheme;
char **flags;
@@ -408,9 +424,6 @@ update_ui (FormatDialogPrivate *priv)
gtk_label_set_markup (GTK_LABEL (priv->name_label), s);
g_free (s);
- /* Is device mounted? */
- update_ui_mounted (priv);
-
usage = NULL;
type = NULL;
@@ -602,12 +615,13 @@ update_ui (FormatDialogPrivate *priv)
/* partition type combo */
if (! priv->job_running) {
+ known_fs = priv->presentable != NULL && type != NULL && strlen (type) > 0;
if (priv->presentable) {
gdu_util_fstype_combo_box_rebuild (priv->part_type_combo_box, priv->pool, NULL);
- gdu_util_fstype_combo_box_select (priv->part_type_combo_box, (type && strlen (type) > 0) ? type : "empty");
- } else {
- gtk_combo_box_set_active (GTK_COMBO_BOX (priv->part_type_combo_box), -1);
+ known_fs = known_fs && gdu_util_fstype_combo_box_select (priv->part_type_combo_box, type);
}
+ if (! known_fs)
+ gtk_combo_box_set_active (GTK_COMBO_BOX (priv->part_type_combo_box), -1);
}
/* encryption check button */
@@ -680,6 +694,9 @@ update_ui (FormatDialogPrivate *priv)
gtk_widget_hide (priv->icon_image);
}
+ /* Is device mounted? */
+ update_ui_controls (priv);
+
if (device != NULL)
g_object_unref (device);
@@ -949,7 +966,7 @@ unmount_action_completed (GduDevice *device,
g_return_if_fail (data != NULL);
g_print ("unmount_action_completed\n");
- update_ui_mounted (data->priv);
+ update_ui_controls (data->priv);
if (error != NULL) {
if (g_error_matches (error, GDU_ERROR, GDU_ERROR_BUSY)) {
@@ -1537,10 +1554,8 @@ nautilus_gdu_spawn_dialog (GduPresentable *presentable,
gtk_container_add (GTK_CONTAINER (align), hbox);
gtk_box_pack_start (GTK_BOX (content_area), align, FALSE, TRUE, 0);
priv->mount_warning = align;
-
image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_LARGE_TOOLBAR);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
-
label = gtk_label_new (_("The volume is currently mounted. Please make sure to close all open files before formatting."));
// gtk_label_set_width_chars (GTK_LABEL (label), 50);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
@@ -1548,6 +1563,21 @@ nautilus_gdu_spawn_dialog (GduPresentable *presentable,
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
+ /* readonly info box */
+ hbox = gtk_hbox_new (FALSE, 7);
+ align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (align), 10, 10, 20, 0);
+ gtk_container_add (GTK_CONTAINER (align), hbox);
+ gtk_box_pack_start (GTK_BOX (content_area), align, FALSE, TRUE, 0);
+ priv->readonly_warning = align;
+ image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_LARGE_TOOLBAR);
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
+ label = gtk_label_new (_("Device is read only"));
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ 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");