[med-svn] [SCM] aghermann branch, master, updated. 4f7a3b774136ffffbaf9b05d90bd568347bc5461
Andrei Zavada
johnhommer at gmail.com
Fri Nov 16 00:50:46 UTC 2012
The following commit has been merged in the master branch:
commit 99590ad246f0cfe69b1d0b5f775a43fa4fe3f16a
Author: Andrei Zavada <johnhommer at gmail.com>
Date: Mon Nov 5 01:43:30 2012 +0200
use VteTerminal widget instead of xterm for Experiment.tar.bz2 download
diff --git a/ChangeLog b/ChangeLog
index 09fff6c..8409f0b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+v.0.7.3 (2012-..-..)
+ * Display Experiment.tar.bz2 Download process in a vte widget.
+
v. 0.7.2 (2012-10-28)
* Enable SMP for mass profile constructions and most other heavy
operations.
diff --git a/src/ui/mw/Makefile.am b/src/ui/mw/Makefile.am
index 61549a4..8bc2ff4 100644
--- a/src/ui/mw/Makefile.am
+++ b/src/ui/mw/Makefile.am
@@ -14,6 +14,7 @@ liba_a_SOURCES = \
mw.cc \
mw_cb.cc \
mw-construct.cc \
+ mw-splash.cc \
mw-populate.cc \
mw-measurements.cc \
mw-measurements_cb.cc \
diff --git a/src/ui/mw/mw-splash.cc b/src/ui/mw/mw-splash.cc
new file mode 100644
index 0000000..648410b
--- /dev/null
+++ b/src/ui/mw/mw-splash.cc
@@ -0,0 +1,166 @@
+// ;-*-C++-*-
+/*
+ * File name: ui/mw/mw-splash.cc
+ * Project: Aghermann
+ * Author: Andrei Zavada <johnhommer at gmail.com>
+ * Initial version: 2012-11-05
+ *
+ * Purpose: SExpDesignUI::try_download and supporting bits
+ *
+ * License: GPL
+ */
+
+#include <functional>
+#include <stdexcept>
+
+#include <vte/vte.h>
+
+#include "ui/misc.hh"
+#include "mw.hh"
+
+using namespace std;
+
+
+
+
+inline namespace {
+extern "C" {
+
+void
+bDownload_clicked_cb( GtkButton*, gpointer userdata)
+{
+ auto& ED = *(aghui::SExpDesignUI*)userdata;
+ ED.try_download();
+}
+
+void
+download_process_child_exited_cb( VteTerminal*, gpointer userdata)
+{
+ auto& ED = *(aghui::SExpDesignUI*)userdata;
+ if ( ED.dl_watch_busyblock ) {
+ delete ED.dl_watch_busyblock;
+ ED.dl_watch_busyblock = nullptr;
+ ED.ED->scan_tree( bind (&aghui::SExpDesignUI::sb_main_progress_indicator, &ED,
+ placeholders::_1, placeholders::_2, placeholders::_3));
+ ED.populate( false);
+ } else
+ FAFA;
+ //throw runtime_error ("Who's here?");
+}
+
+} // extern "C"
+} // inline namespace
+
+
+
+
+void
+aghui::SExpDesignUI::
+show_empty_experiment_blurb()
+{
+ gtk_container_foreach( (GtkContainer*)cMeasurements,
+ (GtkCallback) gtk_widget_destroy,
+ NULL);
+ const char *blurb =
+ "<b><big>Empty experiment\n</big></b>\n"
+ "When you have your recordings ready as a set of .edf files,\n"
+ "• Create your experiment tree as follows: <i>Experiment/Group/Subject/Session</i>;\n"
+ "• Have your EDF sources named <i>Episode</i>.edf, and placed in the corresponding <i>Session</i> directory, or\n"
+ "• Drag-and-Drop any EDF sources onto this window and identify and place them individually.\n\n"
+ "Once set up, either:\n"
+ "• select <b>Experiment→Change</b> and select the top directory of the (newly created) experiment tree, or\n"
+ "• select <b>Experiment→Rescan Tree</b> if this is the tree you have just populated.\n"
+ "\n"
+ "Or, If you have none yet, here is a <a href=\"http://johnhommer.com/academic/code/aghermann/Experiment.tar.bz2\">set of EEG data</a>, for a primer;"
+ " push the button below to download it into the current directory:";
+ GtkLabel *blurb_label = (GtkLabel*)gtk_label_new( "");
+ gtk_label_set_markup( blurb_label, blurb);
+
+ gtk_box_pack_start( (GtkBox*)cMeasurements,
+ (GtkWidget*)blurb_label,
+ TRUE, TRUE, 0);
+ GtkWidget *bDownload = gtk_button_new_with_label(" Download ");
+ g_object_set( (GObject*)bDownload,
+ "expand", FALSE,
+ "halign", GTK_ALIGN_CENTER,
+ NULL);
+ g_signal_connect( bDownload, "clicked",
+ (GCallback)bDownload_clicked_cb,
+ this);
+ gtk_box_pack_start( (GtkBox*)cMeasurements,
+ bDownload,
+ FALSE, FALSE, 0);
+
+ gtk_box_pack_start( (GtkBox*)cMeasurements,
+ (GtkWidget*)gtk_image_new_from_file(
+ PACKAGE_DATADIR "/" PACKAGE "/idle-bg.svg"),
+ TRUE, FALSE, 0);
+
+ gtk_widget_show_all( (GtkWidget*)cMeasurements);
+}
+
+
+
+
+int
+aghui::SExpDesignUI::
+try_download()
+{
+ gtk_container_foreach( (GtkContainer*)cMeasurements,
+ (GtkCallback) gtk_widget_destroy,
+ NULL);
+ const char
+ *url = "http://johnhommer.com/academic/code/aghermann/Experiment.tar.bz2",
+ *archive_file = "Experiment.tar.bz2";
+ snprintf_buf( " wget -c \"%s\" && "
+ " tar xjf \"%s\" && "
+ " rm -f \"%s\" && "
+ " echo \"Sample data set downloaded and unpacked\" && "
+ " read -p \"Press <Enter> to close this window...\"",
+ url, archive_file, archive_file);
+
+ auto tTerm = (VteTerminal*)vte_terminal_new();
+ // (dl_watch_busyblock = new aghui::SBusyBlock (wMainWindow),
+ dl_watch_busyblock = nullptr;
+ g_signal_connect( tTerm, "child-exited",
+ (GCallback)download_process_child_exited_cb,
+ this);
+ gtk_box_pack_start( (GtkBox*)cMeasurements,
+ (GtkWidget*)tTerm,
+ TRUE, FALSE, 0);
+ // punch a hole for VteTerminal for any user ^C
+ gtk_widget_set_sensitive( (GtkWidget*)tTerm, TRUE);
+ gtk_widget_show_all( (GtkWidget*)cMeasurements);
+ GPid pid;
+ GError *Error = NULL;
+ char *argv[] = {
+ vte_get_user_shell(),
+ "-c",
+ __buf__,
+ NULL
+ };
+ vte_terminal_fork_command_full(
+ tTerm,
+ VTE_PTY_DEFAULT,
+ ED->session_dir().c_str(),
+ argv,
+ NULL, // char **envv,
+ (GSpawnFlags)G_SPAWN_DO_NOT_REAP_CHILD, // GSpawnFlags spawn_flags,
+ NULL, // GSpawnChildSetupFunc child_setup,
+ NULL, // gpointer child_setup_data,
+ &pid,
+ &Error); // GError **error);
+ if ( Error ) {
+ aghui::pop_ok_message(
+ wMainWindow,
+ "Failed to download dataset",
+ "%s\n", Error->message);
+ return 1;
+ } else {
+ vte_terminal_watch_child( tTerm, pid);
+ return 0;
+ }
+}
+
+
+// eof
diff --git a/src/ui/mw/mw.cc b/src/ui/mw/mw.cc
index e326fa1..766742f 100644
--- a/src/ui/mw/mw.cc
+++ b/src/ui/mw/mw.cc
@@ -13,8 +13,8 @@
#include <cstring>
#include <ctime>
#include <functional>
+#include <stdexcept>
-//#include <vte/vte.h>
#include "common/config-validate.hh"
#include "libsigfile/page-metrics-base.hh"
@@ -498,108 +498,6 @@ show_changelog()
-void
-aghui::SExpDesignUI::
-show_empty_experiment_blurb()
-{
- gtk_container_foreach( (GtkContainer*)cMeasurements,
- (GtkCallback) gtk_widget_destroy,
- NULL);
- const char *blurb =
- "<b><big>Empty experiment\n</big></b>\n"
- "When you have your recordings ready as a set of .edf files,\n"
- "• Create your experiment tree as follows: <i>Experiment/Group/Subject/Session</i>;\n"
- "• Have your EDF sources named <i>Episode</i>.edf, and placed in the corresponding <i>Session</i> directory, or\n"
- "• Drag-and-Drop any EDF sources onto this window and identify and place them individually.\n\n"
- "Once set up, either:\n"
- "• select <b>Experiment→Change</b> and select the top directory of the (newly created) experiment tree, or\n"
- "• select <b>Experiment→Rescan Tree</b> if this is the tree you have just populated.\n"
- "\n"
- "Or, If you have none yet, here is a <a href=\"http://johnhommer.com/academic/code/aghermann/Experiment.tar.bz2\">set of EEG data</a>, for a primer;"
- " push the button below to download it into the current directory:";
- GtkLabel *blurb_label = (GtkLabel*)gtk_label_new( "");
- gtk_label_set_markup( blurb_label, blurb);
-
- gtk_box_pack_start( (GtkBox*)cMeasurements,
- (GtkWidget*)blurb_label,
- TRUE, TRUE, 0);
- GtkWidget *bDownload = gtk_button_new_with_label(" Download ");
- g_object_set( (GObject*)bDownload,
- "expand", FALSE,
- "halign", GTK_ALIGN_CENTER,
- NULL);
- g_signal_connect( bDownload, "clicked",
- (GCallback)bDownload_clicked_cb,
- this);
- gtk_box_pack_start( (GtkBox*)cMeasurements,
- bDownload,
- FALSE, FALSE, 0);
-
- gtk_box_pack_start( (GtkBox*)cMeasurements,
- (GtkWidget*)gtk_image_new_from_file(
- PACKAGE_DATADIR "/" PACKAGE "/idle-bg.svg"),
- TRUE, FALSE, 0);
-
- gtk_widget_show_all( (GtkWidget*)cMeasurements);
-}
-
-
-extern "C" void
-bDownload_clicked_cb( GtkButton* button, gpointer userdata)
-{
- auto EDp = (SExpDesignUI*)userdata;
- EDp->try_download();
-}
-
-int
-aghui::SExpDesignUI::
-try_download()
-{
- const char
- *url = "http://johnhommer.com/academic/code/aghermann/Experiment.tar.bz2",
- *archive_file = "Experiment.tar.bz2";
- snprintf_buf( "xterm -e sh -c "
- "'cd \"%s\" && "
- " wget -c \"%s\" && "
- " tar xjf \"%s\" && "
- " rm -f \"%s\" && "
- " echo \"Sample data set downloaded and unpacked\" && "
- " read -p \"Press <Enter> to close this window...\"'",
- ED->session_dir().c_str(), url, archive_file, archive_file);
- aghui::SBusyBlock bb (wMainWindow);
-
- if ( system( __buf__) ) {
- gtk_statusbar_pop( sbMainStatusBar, sbMainContextIdGeneral);
- gtk_statusbar_push( sbMainStatusBar, sbMainContextIdGeneral,
- "Download failed for some reason");
- }
- do_rescan_tree( true);
- populate( true);
- // gtk_container_foreach( (GtkContainer*)cMeasurements,
- // (GtkCallback) gtk_widget_destroy,
- // NULL);
- // GtkWidget *tTerm = vte_terminal_new();
- // gtk_box_pack_start( (GtkBox*)cMeasurements,
- // tTerm,
- // TRUE, FALSE, 0);
- // GPid download_process_pid;
- // char *argv[] = {
- // "ls",
- // ".",
- // };
- // vte_terminal_fork_command_full(
- // (VteTerminal*)tTerm,
- // VTE_PTY_DEFAULT,
- // ED->session_dir(),
- // argv,
- // NULL, // char **envv,
- // (GSpawnFlags)0, // GSpawnFlags spawn_flags,
- // NULL, // GSpawnChildSetupFunc child_setup,
- // NULL, // gpointer child_setup_data,
- // &download_process_pid,
- // NULL); // GError **error);
- return 0;
-}
void
diff --git a/src/ui/mw/mw.hh b/src/ui/mw/mw.hh
index e49081f..3ec9658 100644
--- a/src/ui/mw/mw.hh
+++ b/src/ui/mw/mw.hh
@@ -166,6 +166,7 @@ class SExpDesignUI
void update_subject_details_interactively( agh::CSubject&);
void show_empty_experiment_blurb();
int try_download();
+ aghui::SBusyBlock *dl_watch_busyblock;
// collected ED info
// ED strings (channels, sessions, etc)
--
Sleep experiment manager
More information about the debian-med-commit
mailing list