[gnome-disk-utility/udisks2-port] Support floppy drives
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/udisks2-port] Support floppy drives
- Date: Mon, 10 Oct 2011 20:27:39 +0000 (UTC)
commit 249c1c3820df7ce8fd6a8f8a83003ea9a3defe99
Author: David Zeuthen <davidz redhat com>
Date: Mon Oct 10 16:27:25 2011 -0400
Support floppy drives
Signed-off-by: David Zeuthen <davidz redhat com>
src/palimpsest/gduvolumegrid.c | 85 +++++++++++++++++++++++++++-------------
src/palimpsest/gduwindow.c | 83 ++++++++++++++++++++------------------
2 files changed, 101 insertions(+), 67 deletions(-)
---
diff --git a/src/palimpsest/gduvolumegrid.c b/src/palimpsest/gduvolumegrid.c
index 4456a95..7ca4a80 100644
--- a/src/palimpsest/gduvolumegrid.c
+++ b/src/palimpsest/gduvolumegrid.c
@@ -1780,18 +1780,36 @@ recompute_grid (GduVolumeGrid *grid)
/* No partitions and whole-disk has no partition table signature... */
if (top_size == 0)
{
- element = g_new0 (GridElement, 1);
- element->type = GDU_VOLUME_GRID_ELEMENT_TYPE_NO_MEDIA;
- element->size_ratio = 1.0;
- element->offset = 0;
- element->size = top_size;
- if (grid->elements != NULL)
+ UDisksDrive *drive;
+ drive = udisks_client_get_drive_for_block (grid->client, top_block);
+ if (drive != NULL && !udisks_drive_get_media_change_detected (drive))
{
- ((GridElement *) grid->elements->data)->next = element;
- element->prev = ((GridElement *) grid->elements->data);
+ /* If we can't detect media change, just always assume media */
+ element = g_new0 (GridElement, 1);
+ element->type = GDU_VOLUME_GRID_ELEMENT_TYPE_DEVICE;
+ element->size_ratio = 1.0;
+ element->offset = 0;
+ element->size = 0;
+ element->object = g_object_ref (grid->block_object);
+ grid->elements = g_list_append (grid->elements, element);
+ grid_element_set_details (grid, element);
}
- grid->elements = g_list_append (grid->elements, element);
- grid_element_set_details (grid, element);
+ else
+ {
+ element = g_new0 (GridElement, 1);
+ element->type = GDU_VOLUME_GRID_ELEMENT_TYPE_NO_MEDIA;
+ element->size_ratio = 1.0;
+ element->offset = 0;
+ element->size = top_size;
+ if (grid->elements != NULL)
+ {
+ ((GridElement *) grid->elements->data)->next = element;
+ element->prev = ((GridElement *) grid->elements->data);
+ }
+ grid->elements = g_list_append (grid->elements, element);
+ grid_element_set_details (grid, element);
+ }
+ g_clear_object (&drive);
}
else
{
@@ -1934,9 +1952,11 @@ grid_element_set_details (GduVolumeGrid *grid,
const gchar *version;
gint partition_type;
gchar *type_for_display;
+ UDisksFilesystem *filesystem;
size_str = udisks_util_get_size_for_display (element->size, FALSE, FALSE);
block = udisks_object_peek_block (element->object);
+ filesystem = udisks_object_peek_filesystem (element->object);
usage = udisks_block_get_id_usage (block);
type = udisks_block_get_id_type (block);
@@ -1947,33 +1967,42 @@ grid_element_set_details (GduVolumeGrid *grid,
element->show_configured = TRUE;
if (udisks_block_get_part_entry (block) &&
- g_strcmp0 (udisks_block_get_part_entry_scheme (block), "mbr") == 0 &&
- (partition_type == 0x05 || partition_type == 0x0f || partition_type == 0x85))
+ g_strcmp0 (udisks_block_get_part_entry_scheme (block), "mbr") == 0 &&
+ (partition_type == 0x05 || partition_type == 0x0f || partition_type == 0x85))
{
s = g_strdup_printf ("%s\n%s",
C_("volume-grid", "Extended Partition"),
size_str);
}
- else if (g_strcmp0 (usage, "filesystem") == 0)
+ else if (filesystem != NULL)
{
- const gchar *label;
- UDisksFilesystem *filesystem;
-
- label = udisks_block_get_id_label (block);
- type_for_display = udisks_util_get_id_for_display (usage, type, version, FALSE);
- if (strlen (label) == 0)
- label = C_("volume-grid", "Filesystem");
- s = g_strdup_printf ("%s\n%s %s", label, size_str, type_for_display);
- g_free (type_for_display);
+ const gchar *const *mount_points;
+ UDisksDrive *drive;
- filesystem = udisks_object_peek_filesystem (element->object);
- if (filesystem != NULL)
+ drive = udisks_client_get_drive_for_block (grid->client, block);
+ if (drive != NULL && !udisks_drive_get_media_change_detected (drive))
{
- const gchar *const *mount_points;
- mount_points = udisks_filesystem_get_mount_points (filesystem);
- if (g_strv_length ((gchar **) mount_points) > 0)
- element->show_mounted = TRUE;
+ /* This is for e.g. /dev/fd0 - e.g. if we can't track media
+ * changes then we don't know the size nor usage/type ... so
+ * just print the device name
+ */
+ s = udisks_block_dup_preferred_device (block);
}
+ else
+ {
+ const gchar *label;
+ label = udisks_block_get_id_label (block);
+ type_for_display = udisks_util_get_id_for_display (usage, type, version, FALSE);
+ if (strlen (label) == 0)
+ label = C_("volume-grid", "Filesystem");
+ s = g_strdup_printf ("%s\n%s %s", label, size_str, type_for_display);
+ g_free (type_for_display);
+ }
+ g_clear_object (&drive);
+
+ mount_points = udisks_filesystem_get_mount_points (filesystem);
+ if (g_strv_length ((gchar **) mount_points) > 0)
+ element->show_mounted = TRUE;
}
else if (g_strcmp0 (usage, "other") == 0 && g_strcmp0 (type, "swap") == 0)
{
diff --git a/src/palimpsest/gduwindow.c b/src/palimpsest/gduwindow.c
index 56024a5..55e6998 100644
--- a/src/palimpsest/gduwindow.c
+++ b/src/palimpsest/gduwindow.c
@@ -1476,10 +1476,6 @@ update_device_page_for_drive (GduWindow *window,
"devtab-drive-size-value-label",
s, SET_MARKUP_FLAGS_HYPHEN_IF_EMPTY);
g_free (s);
- set_markup (window,
- "devtab-media-label",
- "devtab-media-value-label",
- media_description, SET_MARKUP_FLAGS_NONE);
}
else
{
@@ -1488,6 +1484,17 @@ update_device_page_for_drive (GduWindow *window,
"devtab-drive-size-value-label",
"",
SET_MARKUP_FLAGS_HYPHEN_IF_EMPTY);
+ }
+
+ if (udisks_drive_get_media_available (drive))
+ {
+ set_markup (window,
+ "devtab-media-label",
+ "devtab-media-value-label",
+ media_description, SET_MARKUP_FLAGS_NONE);
+ }
+ else
+ {
set_markup (window,
"devtab-media-label",
"devtab-media-value-label",
@@ -1495,6 +1502,7 @@ update_device_page_for_drive (GduWindow *window,
SET_MARKUP_FLAGS_HYPHEN_IF_EMPTY);
}
+
if (udisks_drive_get_media_removable (drive))
{
*show_flags |= SHOW_FLAGS_EJECT_BUTTON;
@@ -1717,6 +1725,9 @@ update_device_page_for_block (GduWindow *window,
gint partition_type;
gchar *type_for_display;
gchar *configuration_for_display;
+ UDisksFilesystem *filesystem;
+
+ filesystem = udisks_object_peek_filesystem (object);
/* Since /etc/fstab, /etc/crypttab and so on can reference
* any device regardless of its content ... we want to show
@@ -1810,50 +1821,44 @@ update_device_page_for_block (GduWindow *window,
}
}
- if (g_strcmp0 (udisks_block_get_id_usage (block), "filesystem") == 0)
+ if (filesystem != NULL)
{
- UDisksFilesystem *filesystem;
+ const gchar *const *mount_points;
+ gchar *mount_point;
- filesystem = udisks_object_peek_filesystem (object);
- if (filesystem != NULL)
+ mount_points = udisks_filesystem_get_mount_points (filesystem);
+ if (g_strv_length ((gchar **) mount_points) > 0)
{
- const gchar *const *mount_points;
- gchar *mount_point;
-
- mount_points = udisks_filesystem_get_mount_points (filesystem);
- if (g_strv_length ((gchar **) mount_points) > 0)
+ /* TODO: right now we only display the first mount point */
+ if (g_strcmp0 (mount_points[0], "/") == 0)
{
- /* TODO: right now we only display the first mount point */
- if (g_strcmp0 (mount_points[0], "/") == 0)
- {
- /* Translators: This is shown for a device mounted at the filesystem root / - we show
- * this text instead of '/', because '/' is too small to hit as a hyperlink
- */
- mount_point = g_strdup_printf ("<a href=\"file:///\">%s</a>", _("Root Filesystem (/)"));
- }
- else
- {
- mount_point = g_strdup_printf ("<a href=\"file://%s\">%s</a>",
- mount_points[0], mount_points[0]);
- }
+ /* Translators: This is shown for a device mounted at the filesystem root / - we show
+ * this text instead of '/', because '/' is too small to hit as a hyperlink
+ */
+ mount_point = g_strdup_printf ("<a href=\"file:///\">%s</a>", _("Root Filesystem (/)"));
}
else
{
- /* Translators: Shown when the device is not mounted next to the "Mounted" label */
- mount_point = g_strdup (_("No"));
+ mount_point = g_strdup_printf ("<a href=\"file://%s\">%s</a>",
+ mount_points[0], mount_points[0]);
}
- set_markup (window,
- "devtab-volume-filesystem-mounted-label",
- "devtab-volume-filesystem-mounted-value-label",
- mount_point,
- SET_MARKUP_FLAGS_NONE);
- g_free (mount_point);
-
- if (g_strv_length ((gchar **) mount_points) > 0)
- *show_flags |= SHOW_FLAGS_UNMOUNT_BUTTON;
- else
- *show_flags |= SHOW_FLAGS_MOUNT_BUTTON;
}
+ else
+ {
+ /* Translators: Shown when the device is not mounted next to the "Mounted" label */
+ mount_point = g_strdup (_("No"));
+ }
+ set_markup (window,
+ "devtab-volume-filesystem-mounted-label",
+ "devtab-volume-filesystem-mounted-value-label",
+ mount_point,
+ SET_MARKUP_FLAGS_NONE);
+ g_free (mount_point);
+
+ if (g_strv_length ((gchar **) mount_points) > 0)
+ *show_flags |= SHOW_FLAGS_UNMOUNT_BUTTON;
+ else
+ *show_flags |= SHOW_FLAGS_MOUNT_BUTTON;
*show_flags |= SHOW_FLAGS_POPUP_MENU_EDIT_LABEL;
*show_flags |= SHOW_FLAGS_POPUP_MENU_CONFIGURE_FSTAB;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]