[gnome-disk-utility/wip/mdraid] Add a "Go To Array" hyperlink for Linux RAID members
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/wip/mdraid] Add a "Go To Array" hyperlink for Linux RAID members
- Date: Fri, 21 Sep 2012 15:58:50 +0000 (UTC)
commit 6a91ef277089005586f1783f23de4e7768752d8a
Author: David Zeuthen <zeuthen gmail com>
Date: Fri Sep 21 11:54:23 2012 -0400
Add a "Go To Array" hyperlink for Linux RAID members
http://people.freedesktop.org/~david/gnome-disks-mdraid-20120921-2.png
Signed-off-by: David Zeuthen <zeuthen gmail com>
src/disks/gduwindow.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 53 insertions(+), 1 deletions(-)
---
diff --git a/src/disks/gduwindow.c b/src/disks/gduwindow.c
index 14db797..b3549df 100644
--- a/src/disks/gduwindow.c
+++ b/src/disks/gduwindow.c
@@ -150,6 +150,9 @@ struct _GduWindow
GtkWidget *devtab_job_remaining_label;
GtkWidget *devtab_job_no_progress_label;
GtkWidget *devtab_job_cancel_button;
+
+ /* GtkLabel instances we need to handle ::activate-link for */
+ GtkWidget *devtab_volume_type_value_label;
};
static const struct {
@@ -243,6 +246,9 @@ static const struct {
{G_STRUCT_OFFSET (GduWindow, devtab_job_no_progress_label), "devtab-job-no-progress-label"},
{G_STRUCT_OFFSET (GduWindow, devtab_job_cancel_button), "devtab-job-cancel-button"},
+ /* GtkLabel instances we need to handle ::activate-link for */
+ {G_STRUCT_OFFSET (GduWindow, devtab_volume_type_value_label), "devtab-volume-type-value-label"},
+
{0, NULL}
};
@@ -387,6 +393,10 @@ static void on_drive_job_cancel_button_clicked (GtkButton *button,
static void on_job_cancel_button_clicked (GtkButton *button,
gpointer user_data);
+static gboolean on_activate_link (GtkLabel *label,
+ const gchar *uri,
+ gpointer user_data);
+
G_DEFINE_TYPE (GduWindow, gdu_window, GTK_TYPE_APPLICATION_WINDOW);
static void
@@ -1354,6 +1364,12 @@ gdu_window_constructed (GObject *object)
G_CALLBACK (on_job_cancel_button_clicked),
window);
+ /* GtkLabel instances we need to handle ::activate-link for */
+ g_signal_connect (window->devtab_volume_type_value_label,
+ "activate-link",
+ G_CALLBACK (on_activate_link),
+ window);
+
g_idle_add (on_constructed_in_idle, g_object_ref (window));
}
@@ -2591,7 +2607,7 @@ update_device_page_for_block (GduWindow *window,
UDisksPartition *partition;
UDisksLoop *loop;
gboolean read_only;
- gchar *s;
+ gchar *s, *s2, *s3;
UDisksObject *drive_object;
UDisksDrive *drive = NULL;
GList *jobs;
@@ -2719,6 +2735,19 @@ update_device_page_for_block (GduWindow *window,
else
{
s = udisks_client_get_id_for_display (window->client, usage, type, version, TRUE);
+ if (g_strcmp0 (udisks_block_get_mdraid_member (block), "/") != 0)
+ {
+ s2 = g_strdup_printf ("<a href=\"x-udisks://%s\">%s</a>",
+ udisks_block_get_mdraid_member (block),
+ /* Translators: Shown as a hyperlink in the 'Contents' field for a member of an RAID Array */
+ C_("raid-member", "Go To Array"));
+ /* Translators: Shown in the 'Contents' field for a member of an RAID array.
+ * The first %s is the usual contents string (e.g. "Linux RAID Member").
+ * The second %s is the hyperlink "Go To Array".
+ */
+ s3 = g_strdup_printf (C_("raid-member", "%s â %s"), s, s2);
+ g_free (s); s = s3;
+ }
}
}
else
@@ -4043,3 +4072,26 @@ on_job_cancel_button_clicked (GtkButton *button,
g_list_foreach (jobs, (GFunc) g_object_unref, NULL);
g_list_free (jobs);
}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static gboolean
+on_activate_link (GtkLabel *label,
+ const gchar *uri,
+ gpointer user_data)
+{
+ GduWindow *window = GDU_WINDOW (user_data);
+ gboolean handled = FALSE;
+
+ if (g_str_has_prefix (uri, "x-udisks://"))
+ {
+ UDisksObject *object = udisks_client_peek_object (window->client, uri + strlen ("x-udisks://"));
+ if (object != NULL)
+ {
+ set_selected_object (window, object);
+ handled = TRUE;
+ }
+ }
+
+ return handled;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]