[gnome-disk-utility/udisks2-port] Show whether a swap device is running and make it possible to start/stop it
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/udisks2-port] Show whether a swap device is running and make it possible to start/stop it
- Date: Wed, 30 Mar 2011 19:04:38 +0000 (UTC)
commit fc6042cf6b141281ec49f70eecf94ba3302809b3
Author: David Zeuthen <davidz redhat com>
Date: Wed Mar 30 15:03:06 2011 -0400
Show whether a swap device is running and make it possible to start/stop it
IOW, treat swap devices just as mountable filesystems.
Signed-off-by: David Zeuthen <davidz redhat com>
data/ui/palimpsest.ui | 34 +++++++++++++
src/palimpsest/gduvolumegrid.c | 13 ++++-
src/palimpsest/gduwindow.c | 107 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 151 insertions(+), 3 deletions(-)
---
diff --git a/data/ui/palimpsest.ui b/data/ui/palimpsest.ui
index f60fe5a..d7866c5 100644
--- a/data/ui/palimpsest.ui
+++ b/data/ui/palimpsest.ui
@@ -33,6 +33,18 @@
</object>
</child>
<child>
+ <object class="GtkAction" id="devtab-action-activate-swap">
+ <property name="tooltip" translatable="yes">Activate the swap space</property>
+ <property name="icon_name">gdu-action-mount-symbolic</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="devtab-action-deactivate-swap">
+ <property name="tooltip" translatable="yes">Deactivate the swap space</property>
+ <property name="icon_name">gdu-action-unmount-symbolic</property>
+ </object>
+ </child>
+ <child>
<object class="GtkAction" id="devtab-action-lock">
<property name="tooltip" translatable="yes">Lock the encrypted device</property>
<property name="icon_name">changes-prevent-symbolic</property>
@@ -799,6 +811,28 @@
</packing>
</child>
<child>
+ <object class="GtkToolButton" id="toolbutton7">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="related_action">devtab-action-activate-swap</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="toolbutton8">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="related_action">devtab-action-deactivate-swap</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkToolButton" id="toolbutton99">
<property name="visible">True</property>
<property name="can_focus">False</property>
diff --git a/src/palimpsest/gduvolumegrid.c b/src/palimpsest/gduvolumegrid.c
index eaba319..8e7b1b5 100644
--- a/src/palimpsest/gduvolumegrid.c
+++ b/src/palimpsest/gduvolumegrid.c
@@ -1948,20 +1948,27 @@ grid_element_set_details (GduVolumeGrid *grid,
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;
- }
+ element->show_mounted = TRUE;
}
}
else if (g_strcmp0 (usage, "other") == 0 && g_strcmp0 (type, "swap") == 0)
{
const gchar *label;
+ UDisksSwapspace *swapspace;
+
label = udisks_block_device_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", "Swap");
s = g_strdup_printf ("%s\n%s %s", label, size_str, type_for_display);
g_free (type_for_display);
+
+ swapspace = UDISKS_PEEK_SWAPSPACE (element->object);
+ if (swapspace != NULL)
+ {
+ if (udisks_swapspace_get_active (swapspace))
+ element->show_mounted = TRUE;
+ }
}
else
{
diff --git a/src/palimpsest/gduwindow.c b/src/palimpsest/gduwindow.c
index 2821762..ac73657 100644
--- a/src/palimpsest/gduwindow.c
+++ b/src/palimpsest/gduwindow.c
@@ -99,6 +99,8 @@ static void on_devtab_action_unmount_activated (GtkAction *action, gpointer user
static void on_devtab_action_eject_activated (GtkAction *action, gpointer user_data);
static void on_devtab_action_unlock_activated (GtkAction *action, gpointer user_data);
static void on_devtab_action_lock_activated (GtkAction *action, gpointer user_data);
+static void on_devtab_action_activate_swap_activated (GtkAction *action, gpointer user_data);
+static void on_devtab_action_deactivate_swap_activated (GtkAction *action, gpointer user_data);
static void iscsi_connection_switch_on_notify_active (GObject *object,
GParamSpec *pspec,
@@ -519,6 +521,14 @@ gdu_window_constructed (GObject *object)
"activate",
G_CALLBACK (on_devtab_action_lock_activated),
window);
+ g_signal_connect (gtk_builder_get_object (window->builder, "devtab-action-activate-swap"),
+ "activate",
+ G_CALLBACK (on_devtab_action_activate_swap_activated),
+ window);
+ g_signal_connect (gtk_builder_get_object (window->builder, "devtab-action-deactivate-swap"),
+ "activate",
+ G_CALLBACK (on_devtab_action_deactivate_swap_activated),
+ window);
}
static void
@@ -1305,6 +1315,25 @@ update_device_page_for_block (GduWindow *window,
}
}
}
+ else if (g_strcmp0 (udisks_block_device_get_id_usage (block), "other") == 0 &&
+ g_strcmp0 (udisks_block_device_get_id_type (block), "swap") == 0)
+ {
+ UDisksSwapspace *swapspace;
+ swapspace = UDISKS_PEEK_SWAPSPACE (object);
+ if (swapspace != NULL)
+ {
+ if (udisks_swapspace_get_active (swapspace))
+ {
+ gtk_action_set_visible (GTK_ACTION (gtk_builder_get_object (window->builder,
+ "devtab-action-deactivate-swap")), TRUE);
+ }
+ else
+ {
+ gtk_action_set_visible (GTK_ACTION (gtk_builder_get_object (window->builder,
+ "devtab-action-activate-swap")), TRUE);
+ }
+ }
+ }
else if (g_strcmp0 (udisks_block_device_get_id_usage (block), "crypto") == 0)
{
GDBusObject *cleartext_device;
@@ -2229,3 +2258,81 @@ on_devtab_action_lock_activated (GtkAction *action,
}
/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+swapspace_start_cb (UDisksSwapspace *swapspace,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GduWindow *window = GDU_WINDOW (user_data);
+ GError *error;
+
+ error = NULL;
+ if (!udisks_swapspace_call_start_finish (swapspace,
+ res,
+ &error))
+ {
+ gdu_window_show_error (window,
+ _("Error starting swap"),
+ error);
+ g_error_free (error);
+ }
+ g_object_unref (window);
+}
+
+static void
+on_devtab_action_activate_swap_activated (GtkAction *action, gpointer user_data)
+{
+ GduWindow *window = GDU_WINDOW (user_data);
+ GDBusObject *object;
+ UDisksSwapspace *swapspace;
+ const gchar *options[] = {NULL};
+
+ object = gdu_volume_grid_get_selected_device (GDU_VOLUME_GRID (window->volume_grid));
+ swapspace = UDISKS_PEEK_SWAPSPACE (object);
+ udisks_swapspace_call_start (swapspace,
+ options, /* options */
+ NULL, /* cancellable */
+ (GAsyncReadyCallback) swapspace_start_cb,
+ g_object_ref (window));
+}
+
+static void
+swapspace_stop_cb (UDisksSwapspace *swapspace,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GduWindow *window = GDU_WINDOW (user_data);
+ GError *error;
+
+ error = NULL;
+ if (!udisks_swapspace_call_stop_finish (swapspace,
+ res,
+ &error))
+ {
+ gdu_window_show_error (window,
+ _("Error stopping swap"),
+ error);
+ g_error_free (error);
+ }
+ g_object_unref (window);
+}
+
+static void
+on_devtab_action_deactivate_swap_activated (GtkAction *action, gpointer user_data)
+{
+ GduWindow *window = GDU_WINDOW (user_data);
+ GDBusObject *object;
+ UDisksSwapspace *swapspace;
+ const gchar *options[] = {NULL};
+
+ object = gdu_volume_grid_get_selected_device (GDU_VOLUME_GRID (window->volume_grid));
+ swapspace = UDISKS_PEEK_SWAPSPACE (object);
+ udisks_swapspace_call_stop (swapspace,
+ options, /* options */
+ NULL, /* cancellable */
+ (GAsyncReadyCallback) swapspace_stop_cb,
+ g_object_ref (window));
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]