[gnome-disk-utility] Include name/vpd-name of selected presentable in window title



commit ba6cd29fe743ad38a54a054fb24657735d3310f3
Author: David Zeuthen <davidz redhat com>
Date:   Thu Dec 10 17:54:33 2009 -0500

    Include name/vpd-name of selected presentable in window title
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 src/gdu/gdu-machine.c      |    2 +-
 src/palimpsest/gdu-shell.c |  106 +++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 106 insertions(+), 2 deletions(-)
---
diff --git a/src/gdu/gdu-machine.c b/src/gdu/gdu-machine.c
index 85a0031..6b707d1 100644
--- a/src/gdu/gdu-machine.c
+++ b/src/gdu/gdu-machine.c
@@ -126,7 +126,7 @@ gdu_machine_get_name (GduPresentable *presentable)
         ssh_address = gdu_pool_get_ssh_address (machine->priv->pool);
 
         if (ssh_address == NULL) {
-                ret = g_strdup (_("This Machine"));
+                ret = g_strdup (_("Local Storage"));
         } else {
                 /* TODO: use display-hostname */
                 ret = g_strdup_printf (_("Storage on %s"), ssh_address);
diff --git a/src/palimpsest/gdu-shell.c b/src/palimpsest/gdu-shell.c
index 2b7a695..1a5ede3 100644
--- a/src/palimpsest/gdu-shell.c
+++ b/src/palimpsest/gdu-shell.c
@@ -253,6 +253,109 @@ compute_sections_to_show (GduShell *shell)
         return sections_to_show;
 }
 
+
+static void
+update_title (GduShell *shell)
+{
+        GduPresentable *presentable;
+        gchar *name;
+        gchar *vpd_name;
+        gchar *s;
+        GduPool *pool;
+        const gchar *ssh_address;
+        GduDevice *device;
+        gchar *device_file;
+
+        presentable = shell->priv->presentable_now_showing;
+
+        if (presentable == NULL) {
+                /* Translators: Window title when no item is selected.
+                 */
+                s = g_strdup (_("Disk Utility"));
+                goto out;
+        }
+
+        pool = gdu_presentable_get_pool (presentable);
+        name = gdu_presentable_get_name (presentable);
+        vpd_name = gdu_presentable_get_vpd_name (presentable);
+        device = gdu_presentable_get_device (presentable);
+        device_file = NULL;
+        if (device != NULL) {
+                device_file = g_strdup (gdu_device_get_device_file (device));
+                g_object_unref (device);
+        }
+
+        ssh_address = gdu_pool_get_ssh_address (pool);
+
+        if (ssh_address != NULL) {
+                if (GDU_IS_MACHINE (presentable)) {
+                        /* Translators: Window title when the item representing a remote machine is selected.
+                         * First %s is the hostname of the remote host (e.g. 'widget.gnome.org')
+                         */
+                        s = g_strdup_printf (_("%s â?? Disk Utility"),
+                                             ssh_address);
+                } else {
+                        if (device_file != NULL) {
+                                /* Translators: Window title when an item on a remote machine is selected and there is a device file.
+                                 * First %s is the name of the item (e.g. '80 GB Solid-State Disk' or 'Saturn').
+                                 * Second %s is the VPD name of the item (e.g. 'ATA INTEL SSDSA2MH080G1GC' or '6 TB RAID-6 Array').
+                                 * Third is the device file (e.g. '/dev/sda')
+                                 * Fourth %s is the hostname of the remote host (e.g. 'widget.gnome.org')
+                                 */
+                                s = g_strdup_printf (_("%s (%s) [%s] @ %s â?? Disk Utility"),
+                                                     name,
+                                                     vpd_name,
+                                                     device_file,
+                                                     ssh_address);
+                        } else {
+                                /* Translators: Window title when an item on a remote machine is selected.
+                                 * First %s is the name of the item (e.g. '80 GB Solid-State Disk' or 'Saturn').
+                                 * Second %s is the VPD name of the item (e.g. 'ATA INTEL SSDSA2MH080G1GC' or '6 TB RAID-6 Array').
+                                 * Third %s is the hostname of the remote host (e.g. 'widget.gnome.org')
+                                 */
+                                s = g_strdup_printf (_("%s (%s) @ %s â?? Disk Utility"),
+                                                     name,
+                                                     vpd_name,
+                                                     ssh_address);
+                        }
+                }
+        } else {
+                if (GDU_IS_MACHINE (presentable)) {
+                        /* Translators: Window title when the item representing the local machine is selected.
+                         */
+                        s = g_strdup (_("Disk Utility"));
+                } else {
+                        if (device_file != NULL) {
+                                /* Translators: Window title when an item on the local machine is selected and there is a device file.
+                                 * First %s is the name of the item (e.g. '80 GB Solid-State Disk' or 'Saturn').
+                                 * Second %s is the VPD name of the item (e.g. 'ATA INTEL SSDSA2MH080G1GC' or '6 TB RAID-6 Array').
+                                 * Third is the device file (e.g. '/dev/sda')
+                                 */
+                                s = g_strdup_printf (_("%s (%s) [%s] â?? Disk Utility"),
+                                                     name,
+                                                     vpd_name,
+                                                     device_file);
+                        } else {
+                                /* Translators: Window title when an item on the local machine is selected.
+                                 * First %s is the name of the item (e.g. '80 GB Solid-State Disk' or 'Saturn').
+                                 * Second %s is the VPD name of the item (e.g. 'ATA INTEL SSDSA2MH080G1GC' or '6 TB RAID-6 Array').
+                                 */
+                                s = g_strdup_printf (_("%s (%s) â?? Disk Utility"),
+                                                     name,
+                                                     vpd_name);
+                        }
+                }
+        }
+        g_free (vpd_name);
+        g_free (name);
+        g_object_unref (pool);
+        g_free (device_file);
+
+ out:
+        gtk_window_set_title (GTK_WINDOW (shell->priv->app_window), s);
+        g_free (s);
+}
+
 /* called when a new presentable is selected
  *  - or a presentable changes
  *  - or the job state of a presentable changes
@@ -266,6 +369,8 @@ gdu_shell_update (GduShell *shell)
         gboolean reset_sections;
         GList *sections_to_show;
 
+        update_title (shell);
+
         reset_sections = (shell->priv->presentable_now_showing != last_presentable);
 
         last_presentable = shell->priv->presentable_now_showing;
@@ -996,7 +1101,6 @@ gdu_shell_raise_error (GduShell       *shell,
         g_signal_connect (dialog, "map", G_CALLBACK (fix_focus_cb), NULL);
 
 
-        gtk_window_set_title (GTK_WINDOW (dialog), window_title);
         // TODO: no support for GIcon in GtkWindow
         //gtk_window_set_icon_name (GTK_WINDOW (dialog), window_icon_name);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]