[gnome-disk-utility] Register inhibitor for benchmark thread



commit 9a3a685d8dd902afcd35880760ac4cea85f5ff76
Author: Kai Lüke <kailueke riseup net>
Date:   Mon Apr 16 18:10:41 2018 +0900

    Register inhibitor for benchmark thread
    
    The system should not be suspended
    during a benchmark or GNOME Disk
    be killed with a logout.
    
    Invoke the GtkApplication inhibitor
    for the benchmarking thread.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=794485

 src/disks/gdubenchmarkdialog.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/src/disks/gdubenchmarkdialog.c b/src/disks/gdubenchmarkdialog.c
index bf7c29e..2db957e 100644
--- a/src/disks/gdubenchmarkdialog.c
+++ b/src/disks/gdubenchmarkdialog.c
@@ -1168,9 +1168,17 @@ benchmark_thread (gpointer user_data)
   long page_size;
   guint64 disk_size;
   GVariantBuilder options_builder;
+  guint inhibit_cookie;
 
   //g_print ("bm thread start\n");
 
+  inhibit_cookie = gtk_application_inhibit (GTK_APPLICATION (gdu_window_get_application (data->window)),
+                                            GTK_WINDOW (data->dialog),
+                                            GTK_APPLICATION_INHIBIT_SUSPEND |
+                                            GTK_APPLICATION_INHIBIT_LOGOUT,
+                                            /* Translators: Reason why suspend/logout is being inhibited */
+                                            C_("create-inhibit-message", "Benchmarking device"));
+
   g_variant_builder_init (&options_builder, G_VARIANT_TYPE_VARDICT);
   g_variant_builder_add (&options_builder, "{sv}", "writable", g_variant_new_boolean (data->bm_do_write));
 
@@ -1440,6 +1448,9 @@ benchmark_thread (gpointer user_data)
   data->bm_thread = NULL;
   data->bm_state = BM_STATE_NONE;
 
+  if (inhibit_cookie > 0)
+    gtk_application_uninhibit (GTK_APPLICATION (gdu_window_get_application (data->window)), inhibit_cookie);
+
   if (error != NULL)
     {
       G_LOCK (bm_lock);


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