[gnome-disk-utility] Use UDisksObjectInfo everywhere instead of hard-coding names and icons
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility] Use UDisksObjectInfo everywhere instead of hard-coding names and icons
- Date: Wed, 5 Dec 2012 16:41:59 +0000 (UTC)
commit 6aea2797837b9782f609307f43f73d0710f0b511
Author: David Zeuthen <zeuthen gmail com>
Date: Wed Dec 5 11:41:20 2012 -0500
Use UDisksObjectInfo everywhere instead of hard-coding names and icons
Signed-off-by: David Zeuthen <zeuthen gmail com>
src/disks/gdudevicetreemodel.c | 31 ++++---------------
src/disks/gdumdraiddisksdialog.c | 6 +---
src/disks/gduwindow.c | 60 ++++++++++---------------------------
3 files changed, 24 insertions(+), 73 deletions(-)
---
diff --git a/src/disks/gdudevicetreemodel.c b/src/disks/gdudevicetreemodel.c
index 47a1327..1770fe7 100644
--- a/src/disks/gdudevicetreemodel.c
+++ b/src/disks/gdudevicetreemodel.c
@@ -1335,7 +1335,7 @@ update_block (GduDeviceTreeModel *model,
GtkTreeIter iter;
UDisksBlock *block;
UDisksLoop *loop;
- GIcon *icon = NULL;
+ UDisksObjectInfo *info = NULL;
gchar *s = NULL;
gchar *sort_key = NULL;
const gchar *preferred_device;
@@ -1360,42 +1360,25 @@ update_block (GduDeviceTreeModel *model,
size = udisks_block_get_size (block);
size_str = udisks_client_get_size_for_display (model->client, size, FALSE, FALSE);
+ info = udisks_client_get_object_info (model->client, object);
+
preferred_device = udisks_block_get_preferred_device (block);
loop_backing_file = loop != NULL ? udisks_loop_get_backing_file (loop) : NULL;
if (loop_backing_file != NULL)
{
- gchar *loop_name;
gchar *backing_file_unfused;
-
backing_file_unfused = gdu_utils_unfuse_path (loop_backing_file);
-
- /* Translators: This is for a /dev/loop device - %s is the size of the device e.g. "230 MB". */
- loop_name = g_strdup_printf (_("%s Loop Device"), size_str);
-
- /* loop devices */
- icon = g_themed_icon_new ("drive-removable-media"); /* for now */
s = g_strdup_printf ("%s\n"
"<small>%s</small>",
- loop_name,
+ udisks_object_info_get_description (info),
backing_file_unfused);
- g_free (loop_name);
g_free (backing_file_unfused);
}
else
{
- gchar *block_name;
-
- /* Translators: This is for a block device which we failed to categorize - %s is
- * the size of the device e.g. "230 MB".
- */
- block_name = g_strdup_printf (_("%s Block Device"),
- size_str);
-
- /* fallback: preferred device and drive-harddisk icon */
- icon = g_themed_icon_new ("drive-removable-media"); /* for now */
s = g_strdup_printf ("%s\n"
"<small>%s</small>",
- block_name,
+ udisks_object_info_get_description (info),
preferred_device);
}
@@ -1414,7 +1397,7 @@ update_block (GduDeviceTreeModel *model,
gtk_tree_store_set (GTK_TREE_STORE (model),
&iter,
- GDU_DEVICE_TREE_MODEL_COLUMN_ICON, icon,
+ GDU_DEVICE_TREE_MODEL_COLUMN_ICON, udisks_object_info_get_icon (info),
GDU_DEVICE_TREE_MODEL_COLUMN_NAME, s,
GDU_DEVICE_TREE_MODEL_COLUMN_SORT_KEY, sort_key,
GDU_DEVICE_TREE_MODEL_COLUMN_JOBS_RUNNING, jobs_running,
@@ -1433,7 +1416,7 @@ update_block (GduDeviceTreeModel *model,
}
out:
- g_object_unref (icon);
+ g_clear_object (&info);
g_free (sort_key);
g_free (s);
g_free (size_str);
diff --git a/src/disks/gdumdraiddisksdialog.c b/src/disks/gdumdraiddisksdialog.c
index e7b5062..a7a08a5 100644
--- a/src/disks/gdumdraiddisksdialog.c
+++ b/src/disks/gdumdraiddisksdialog.c
@@ -489,11 +489,7 @@ pixbuf_cell_func (GtkTreeViewColumn *column,
goto out;
info = udisks_client_get_object_info (data->client, object);
- if (udisks_object_info_get_icon (info) != NULL)
- icon = g_object_ref (udisks_object_info_get_icon (info));
-
- if (icon == NULL)
- icon = g_themed_icon_new ("drive-removable-media"); /* fallback - for now */
+ icon = g_object_ref (udisks_object_info_get_icon (info));
out:
g_object_set (renderer,
diff --git a/src/disks/gduwindow.c b/src/disks/gduwindow.c
index cac04bb..fa901c7 100644
--- a/src/disks/gduwindow.c
+++ b/src/disks/gduwindow.c
@@ -2827,37 +2827,22 @@ update_device_page_for_loop (GduWindow *window,
UDisksLoop *loop,
ShowFlags *show_flags)
{
- GIcon *icon = NULL;
+ UDisksObjectInfo *info = NULL;
gchar *s = NULL;
- gchar *desc = NULL;
gchar *device_desc = NULL;
- guint64 size = 0;
gdu_volume_grid_set_no_media_string (GDU_VOLUME_GRID (window->volume_grid),
_("Loop device is empty"));
- size = udisks_block_get_size (block);
-
- icon = g_themed_icon_new ("drive-removable-media"); /* for now */
-
- if (size > 0)
- {
- s = udisks_client_get_size_for_display (window->client, size, FALSE, FALSE);
- /* Translators: Used in the main window for a loop device, the first %s is the size */
- desc = g_strdup_printf (C_("loop-window", "%s Loop Device"), s);
- g_free (s);
- }
- else
- {
- /* Translators: Used in the main window for a block device where the size is not known */
- desc = g_strdup (C_("loop-window", "Loop Device"));
- }
+ info = udisks_client_get_object_info (window->client, object);
device_desc = get_device_file_for_display (block);
- gtk_image_set_from_gicon (GTK_IMAGE (window->devtab_drive_image), icon, GTK_ICON_SIZE_DIALOG);
+ gtk_image_set_from_gicon (GTK_IMAGE (window->devtab_drive_image),
+ udisks_object_info_get_icon (info),
+ GTK_ICON_SIZE_DIALOG);
gtk_widget_show (window->devtab_drive_image);
- s = g_strdup_printf ("<big><b>%s</b></big>", desc);
+ s = g_strdup_printf ("<big><b>%s</b></big>", udisks_object_info_get_description (info));
gtk_label_set_markup (GTK_LABEL (window->devtab_drive_desc_label), s);
gtk_widget_show (window->devtab_drive_desc_label);
g_free (s);
@@ -2893,7 +2878,8 @@ update_device_page_for_loop (GduWindow *window,
}
/* cleanup */
- g_clear_object (&icon);
+ g_clear_object (&info);
+ g_free (device_desc);
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -2908,37 +2894,22 @@ update_device_page_for_fake_block (GduWindow *window,
UDisksBlock *block,
ShowFlags *show_flags)
{
- GIcon *icon = NULL;
+ UDisksObjectInfo *info = NULL;
gchar *s = NULL;
- gchar *desc = NULL;
gchar *device_desc = NULL;
- guint64 size = 0;
gdu_volume_grid_set_no_media_string (GDU_VOLUME_GRID (window->volume_grid),
_("Block device is empty"));
- size = udisks_block_get_size (block);
-
- icon = g_themed_icon_new ("drive-removable-media"); /* for now */
-
- if (size > 0)
- {
- s = udisks_client_get_size_for_display (window->client, size, FALSE, FALSE);
- /* Translators: Used in the main window for a block device, the first %s is the size */
- desc = g_strdup_printf (C_("block-window", "%s Block Device"), s);
- g_free (s);
- }
- else
- {
- /* Translators: Used in the main window for a block device where the size is not known */
- desc = g_strdup (C_("block-window", "Block Device"));
- }
+ info = udisks_client_get_object_info (window->client, object);
device_desc = get_device_file_for_display (block);
- gtk_image_set_from_gicon (GTK_IMAGE (window->devtab_drive_image), icon, GTK_ICON_SIZE_DIALOG);
+ gtk_image_set_from_gicon (GTK_IMAGE (window->devtab_drive_image),
+ udisks_object_info_get_icon (info),
+ GTK_ICON_SIZE_DIALOG);
gtk_widget_show (window->devtab_drive_image);
- s = g_strdup_printf ("<big><b>%s</b></big>", desc);
+ s = g_strdup_printf ("<big><b>%s</b></big>", udisks_object_info_get_description (info));
gtk_label_set_markup (GTK_LABEL (window->devtab_drive_desc_label), s);
gtk_widget_show (window->devtab_drive_desc_label);
g_free (s);
@@ -2955,7 +2926,8 @@ update_device_page_for_fake_block (GduWindow *window,
update_drive_part_for_block (window, block, show_flags);
/* cleanup */
- g_clear_object (&icon);
+ g_clear_object (&info);
+ g_free (device_desc);
}
/* ---------------------------------------------------------------------------------------------------- */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]