[gtk/mountoperation-trees: 2/3] testmountoperation: Test process dialog




commit e1f69ea278b8fa48d0963d9bcd29559fc9206d5e
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Oct 4 21:25:26 2022 -0400

    testmountoperation: Test process dialog
    
    Without this, it is hard to trigger the
    dialog. Event with this, we have to force
    GtkMountOperation to use its own dialog.

 tests/testmountoperation.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
---
diff --git a/tests/testmountoperation.c b/tests/testmountoperation.c
index d6222c622d..4c908a7c64 100644
--- a/tests/testmountoperation.c
+++ b/tests/testmountoperation.c
@@ -20,6 +20,7 @@
 #include <gtk/gtk.h>
 
 static gboolean ask_question = FALSE;
+static gboolean show_processes = FALSE;
 static gboolean anonymous = FALSE;
 static gboolean dont_ask_username = FALSE;
 static gboolean dont_ask_domain = FALSE;
@@ -100,6 +101,7 @@ main (int argc, char *argv[])
   GError *error = NULL;
   GOptionEntry options[] = {
     { "ask-question", 'q', 0, G_OPTION_ARG_NONE, &ask_question, "Ask a question not a password.", NULL },
+    { "show-processes", 0, 0, G_OPTION_ARG_NONE, &show_processes, "Show (pretend) processes.", NULL },
     { "right-to-left", 'r', 0, G_OPTION_ARG_NONE, &force_rtl, "Force right-to-left layout.", NULL },
     { "anonymous", 'a', 0, G_OPTION_ARG_NONE, &anonymous, "Anonymous login allowed.", NULL },
     { "no-username", 'u', 0, G_OPTION_ARG_NONE, &dont_ask_username, "Don't ask for the username.", NULL },
@@ -137,6 +139,26 @@ main (int argc, char *argv[])
 
       g_signal_emit_by_name (op, "ask_question", "Foo\nbar", choices);
     }
+  else if (show_processes)
+    {
+      static const char *choices[] = {
+        "Yes", "No", "Sauerkraut", NULL
+      };
+      GArray *pids;
+      GPid pid;
+
+      pids = g_array_new (TRUE, FALSE, sizeof (GPid));
+      pid = 1000;
+      g_array_append_val (pids, pid);
+      pid = 2000;
+      g_array_append_val (pids, pid);
+      pid = 3000;
+      g_array_append_val (pids, pid);
+
+      g_signal_emit_by_name (op, "show-processes", "Foo\nbar", pids, choices);
+
+      g_array_unref (pids);
+    }
   else
     {
       GAskPasswordFlags flags;


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