[gnome-disk-utility] Use sftp:// and nautilus for mount point links for remote devices



commit 405a13c084dd0e989194af80445361d6faf2cce0
Author: David Zeuthen <davidz redhat com>
Date:   Wed Dec 9 18:15:13 2009 -0500

    Use sftp:// and nautilus for mount point links for remote devices
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 src/gdu-gtk/gdu-details-element.c        |    5 +-
 src/gdu-gtk/gdu-details-element.h        |    3 +-
 src/gdu-gtk/gdu-details-table.c          |   16 ++++---
 src/gdu-gtk/gdu-drive-benchmark-dialog.c |    3 +-
 src/palimpsest/gdu-section-volumes.c     |   71 +++++++++++++++++++++++++++--
 5 files changed, 83 insertions(+), 15 deletions(-)
---
diff --git a/src/gdu-gtk/gdu-details-element.c b/src/gdu-gtk/gdu-details-element.c
index aa1633a..35d0ff5 100644
--- a/src/gdu-gtk/gdu-details-element.c
+++ b/src/gdu-gtk/gdu-details-element.c
@@ -359,9 +359,10 @@ gdu_details_element_class_init (GduDetailsElementClass *klass)
                                                   G_STRUCT_OFFSET (GduDetailsElementClass, activated),
                                                   NULL,
                                                   NULL,
-                                                  g_cclosure_marshal_VOID__VOID,
+                                                  g_cclosure_marshal_VOID__STRING,
                                                   G_TYPE_NONE,
-                                                  0);
+                                                  1,
+                                                  G_TYPE_STRING);
 }
 
 GduDetailsElement *
diff --git a/src/gdu-gtk/gdu-details-element.h b/src/gdu-gtk/gdu-details-element.h
index 037d7de..8fea72e 100644
--- a/src/gdu-gtk/gdu-details-element.h
+++ b/src/gdu-gtk/gdu-details-element.h
@@ -53,7 +53,8 @@ struct GduDetailsElementClass
         void (*changed) (GduDetailsElement *element);
 
         /* signals */
-        void (*activated) (GduDetailsElement *element);
+        void (*activated) (GduDetailsElement *element,
+                           const gchar       *uri);
 };
 
 GType               gdu_details_element_get_type            (void) G_GNUC_CONST;
diff --git a/src/gdu-gtk/gdu-details-table.c b/src/gdu-gtk/gdu-details-table.c
index 72322b6..08b2201 100644
--- a/src/gdu-gtk/gdu-details-table.c
+++ b/src/gdu-gtk/gdu-details-table.c
@@ -235,9 +235,9 @@ typedef struct {
 static void on_details_element_changed (GduDetailsElement *element,
                                         ElementData       *data);
 
-static void on_activate_link (GtkLabel    *label,
-                              const gchar *uri,
-                              gpointer     user_data);
+static gboolean on_activate_link (GtkLabel    *label,
+                                  const gchar *uri,
+                                  gpointer     user_data);
 
 static void
 element_data_free (ElementData *data)
@@ -369,15 +369,15 @@ on_details_element_changed (GduDetailsElement *element,
         }
 }
 
-static void
+static gboolean
 on_activate_link (GtkLabel    *label,
                   const gchar *uri,
                   gpointer     user_data)
 {
         ElementData *data = user_data;
 
-        g_signal_emit_by_name (data->element, "activated");
-        g_signal_stop_emission_by_name (label, "activate-link");
+        g_signal_emit_by_name (data->element, "activated", uri);
+        return TRUE;
 }
 
 static void
@@ -486,6 +486,10 @@ do_relayout (GduDetailsTable *table)
                                   "changed",
                                   G_CALLBACK (on_details_element_changed),
                                   data);
+                g_signal_connect (data->label,
+                                  "activate-link",
+                                  G_CALLBACK (on_activate_link),
+                                  data);
                 g_signal_connect (data->action_label,
                                   "activate-link",
                                   G_CALLBACK (on_activate_link),
diff --git a/src/gdu-gtk/gdu-drive-benchmark-dialog.c b/src/gdu-gtk/gdu-drive-benchmark-dialog.c
index 125d87e..a426df8 100644
--- a/src/gdu-gtk/gdu-drive-benchmark-dialog.c
+++ b/src/gdu-gtk/gdu-drive-benchmark-dialog.c
@@ -631,7 +631,8 @@ cancel_job_cb (GduDevice  *device,
 
 static void
 on_updated_element_activated (GduDetailsElement    *element,
-                              gpointer     user_data)
+                              const gchar          *uri,
+                              gpointer              user_data)
 {
         GduDriveBenchmarkDialog *dialog = GDU_DRIVE_BENCHMARK_DIALOG (user_data);
 
diff --git a/src/palimpsest/gdu-section-volumes.c b/src/palimpsest/gdu-section-volumes.c
index 0404b4a..35d56f4 100644
--- a/src/palimpsest/gdu-section-volumes.c
+++ b/src/palimpsest/gdu-section-volumes.c
@@ -1279,6 +1279,7 @@ on_fsck_button_clicked (GduButtonElement *button_element,
 
 static void
 on_usage_element_activated (GduDetailsElement *element,
+                            const gchar       *uri,
                             gpointer           user_data)
 {
         GduSectionVolumes *section = GDU_SECTION_VOLUMES (user_data);
@@ -1321,6 +1322,41 @@ on_usage_element_activated (GduDetailsElement *element,
 /* ---------------------------------------------------------------------------------------------------- */
 
 static void
+on_fs_mount_point_element_activated (GduDetailsElement *element,
+                                     const gchar       *uri,
+                                     gpointer           user_data)
+{
+        GduSectionVolumes *section = GDU_SECTION_VOLUMES (user_data);
+        GError *error;
+        gchar *s;
+
+        /* We want to use nautilus instead of gtk_show_uri() because
+         * the latter doesn't handle automatically mounting the mount
+         * - maybe gtk_show_uri() should do that though...
+         */
+
+        s = g_strdup_printf ("nautilus \"%s\"", uri);
+
+        error = NULL;
+        if (!g_spawn_command_line_async (s, &error)) {
+                GtkWidget *dialog;
+                dialog = gdu_error_dialog_new (GTK_WINDOW (gdu_shell_get_toplevel (gdu_section_get_shell (GDU_SECTION (section)))),
+                                               gdu_section_get_presentable (GDU_SECTION (section)),
+                                               _("Error spawning nautilus: %s"),
+                                               error);
+                gtk_widget_show_all (dialog);
+                gtk_window_present (GTK_WINDOW (dialog));
+                gtk_dialog_run (GTK_DIALOG (dialog));
+                gtk_widget_destroy (dialog);
+                g_error_free (error);
+        }
+
+        g_free (s);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
 gdu_section_volumes_update (GduSection *_section)
 {
         GduSectionVolumes *section = GDU_SECTION_VOLUMES (_section);
@@ -1436,6 +1472,10 @@ gdu_section_volumes_update (GduSection *_section)
 
                 section->priv->fs_mount_point_element = gdu_details_element_new (_("Mount Point:"), NULL, NULL);
                 g_ptr_array_add (elements, section->priv->fs_mount_point_element);
+                g_signal_connect (section->priv->fs_mount_point_element,
+                                  "activated",
+                                  G_CALLBACK (on_fs_mount_point_element_activated),
+                                  section);
         }
 
         gdu_details_table_set_elements (GDU_DETAILS_TABLE (section->priv->details_table), elements);
@@ -1574,14 +1614,34 @@ gdu_section_volumes_update (GduSection *_section)
 
                 if (gdu_device_is_mounted (d)) {
                         const gchar* const *mount_paths;
+                        GduPool *pool;
+                        const gchar *ssh_address;
+
+                        pool = gdu_device_get_pool (d);
+                        ssh_address = gdu_pool_get_ssh_address (pool);
 
                         /* For now we ignore if the device is mounted in multiple places */
                         mount_paths = (const gchar* const *) gdu_device_get_mount_paths (d);
-                        s = g_strdup_printf ("<a title=\"%s\" href=\"file://%s\">%s</a>",
-                                              /* Translators: this the mount point hyperlink tooltip */
-                                              _("View files on the volume"),
-                                             mount_paths[0],
-                                             mount_paths[0]);
+
+                        if (ssh_address != NULL) {
+                                /* We don't use the ssh user name right now - we could do that
+                                 * but if the user logs in as root it might be bad...
+                                 */
+                                s = g_strdup_printf ("<a title=\"%s\" href=\"sftp://%s/%s\";>%s</a>",
+                                                     /* Translators: this the mount point hyperlink tooltip for a
+                                                      * remote server - it uses the sftp:// protocol
+                                                      */
+                                                     _("View files on the volume using a SFTP network share"),
+                                                     ssh_address,
+                                                     mount_paths[0],
+                                                     mount_paths[0]);
+                        } else {
+                                s = g_strdup_printf ("<a title=\"%s\" href=\"file://%s\">%s</a>",
+                                                     /* Translators: this the mount point hyperlink tooltip */
+                                                     _("View files on the volume"),
+                                                     mount_paths[0],
+                                                     mount_paths[0]);
+                        }
                         /* Translators: this the the text for the mount point
                          * item - %s is the mount point, e.g. '/media/disk'
                          */
@@ -1589,6 +1649,7 @@ gdu_section_volumes_update (GduSection *_section)
                         gdu_details_element_set_text (section->priv->fs_mount_point_element, s2);
                         g_free (s);
                         g_free (s2);
+                        g_object_unref (pool);
 
                         show_fs_unmount_button = TRUE;
                 } else {



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