[Pkg-privacy-commits] [nautilus-wipe] 41/224: Add a small test program

Ulrike Uhlig u-guest at moszumanska.debian.org
Thu Jul 7 19:45:32 UTC 2016


This is an automated email from the git hooks/post-receive script.

u-guest pushed a commit to branch master
in repository nautilus-wipe.

commit 71d00750d11f870d5c03cc470b7a71100272dfb4
Author: Colomban Wendling <ban at herbesfolles.org>
Date:   Sun Feb 21 15:51:28 2010 +0100

    Add a small test program
    
    Small test program for NautilusSrmProgressDialog.
    Another advantage of having this is to easily track down undefined
    references as it is actually linked.
---
 nautilus-srm/Makefile.am |  9 ++++++
 nautilus-srm/test.c      | 84 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 93 insertions(+)

diff --git a/nautilus-srm/Makefile.am b/nautilus-srm/Makefile.am
index f1b919f..0ae0650 100644
--- a/nautilus-srm/Makefile.am
+++ b/nautilus-srm/Makefile.am
@@ -2,6 +2,8 @@ nautilus_extensiondir = $(NAUTILUS_EXTENSIONS_DIR)
 
 nautilus_extension_LTLIBRARIES = libnautilus-srm.la
 
+noinst_PROGRAMS = test
+
 libnautilus_srm_la_SOURCES = nautilus-srm.c \
                              nautilus-srm.h \
                              operation-manager.c \
@@ -15,3 +17,10 @@ libnautilus_srm_la_SOURCES = nautilus-srm.c \
                              compat.h
 
 libnautilus_srm_la_LDFLAGS = $(AM_LIBS) -module -avoid-version
+
+test_LDFLAGS = $(AM_LIBS)
+# Linking against a loadable module is not portable according to libtool.
+# However, I don't really care about portability issue here because it is only a
+# test program (that might even be removed at a time).
+test_LDADD   = libnautilus-srm.la
+test_SOURCES = test.c
diff --git a/nautilus-srm/test.c b/nautilus-srm/test.c
new file mode 100644
index 0000000..1c573e8
--- /dev/null
+++ b/nautilus-srm/test.c
@@ -0,0 +1,84 @@
+
+#include <gtk/gtk.h>
+#include "progress-dialog.h"
+
+#define STEP 0.001
+
+static gdouble fraction = 0.0;
+
+static gboolean
+progress (gpointer data)
+{
+  NautilusSrmProgressDialog *dialog = NAUTILUS_SRM_PROGRESS_DIALOG (data);
+  
+  /*fraction = fraction >= (1.0 - STEP) ? 0.0 : fraction + STEP;*/
+  fraction += STEP;
+  
+  if (fraction >= 1.0) {
+    nautilus_srm_progress_dialog_finish (dialog, TRUE);
+  } else {
+    static const gchar *texts[10] = {
+      "Checking input data integrity",
+      "Preparing environment",
+      "Setting up operation",
+      "Listing files",
+      "Deleting files",
+      "Deleting directories",
+      "Cleaning operation",
+      "Cleaning environment",
+      "Flushing data",
+      "Checking output integrity"
+    };
+    
+    nautilus_srm_progress_dialog_set_fraction (dialog, fraction);
+    nautilus_srm_progress_dialog_set_progress_text (dialog, "%s", texts[(gint)(fraction * 10)]);
+  }
+  
+  return ! nautilus_srm_progress_dialog_is_canceled (dialog) &&
+         ! nautilus_srm_progress_dialog_is_finished (dialog);
+}
+
+static void
+response_handler (GtkDialog *dialog,
+                  gint       response_id,
+                  gpointer   data)
+{
+  g_debug ("I got response %d", response_id);
+  
+  switch (response_id) {
+    case GTK_RESPONSE_CANCEL:
+    case GTK_RESPONSE_CLOSE:
+      gtk_main_quit ();
+      break;
+    
+    case GTK_RESPONSE_DELETE_EVENT:
+      nautilus_srm_progress_dialog_set_has_close_button (NAUTILUS_SRM_PROGRESS_DIALOG (dialog),
+                                                         ! nautilus_srm_progress_dialog_get_has_close_button (NAUTILUS_SRM_PROGRESS_DIALOG (dialog)));
+      break;
+    
+    case NAUTILUS_SRM_PROGRESS_DIALOG_RESPONSE_COMPLETE:
+      nautilus_srm_progress_dialog_set_progress_text (NAUTILUS_SRM_PROGRESS_DIALOG (dialog), "Done!");
+      break;
+  }
+}
+
+int
+main (int     argc,
+      char  **argv)
+{
+  GtkWidget *dialog;
+  
+  gtk_init (&argc, &argv);
+  
+  dialog = nautilus_srm_progress_dialog_new (NULL, 0, "Progress...");
+  //~ nautilus_srm_progress_dialog_set_has_cancel_button (NAUTILUS_SRM_PROGRESS_DIALOG (dialog), TRUE);
+  //~ nautilus_srm_progress_dialog_set_has_close_button (NAUTILUS_SRM_PROGRESS_DIALOG (dialog), TRUE);
+  g_signal_connect (dialog, "response", G_CALLBACK (response_handler), NULL);
+  gtk_widget_show (GTK_WIDGET (dialog));
+  
+  g_timeout_add (20, progress, dialog);
+  gtk_main ();
+  
+  return 0;
+}
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/nautilus-wipe.git



More information about the Pkg-privacy-commits mailing list