Skip to content
This repository
Browse code

expdesign: a button to download sample dataset

  • Loading branch information...
commit baa05bba4ebbff167a82cf1d1a395f3103de0240 1 parent d7fcbeb
Andrei Zavada authored
2  src/ui/expdesign-construct.cc
@@ -76,7 +76,7 @@ aghui::SExpDesignUI::construct_widgets()
76 76 this);
77 77
78 78 g_signal_connect( bScanTree, "clicked",
79   - (GCallback) bScanTree_clicked_cb,
  79 + (GCallback)bScanTree_clicked_cb,
80 80 this);
81 81
82 82
77 src/ui/expdesign.cc
@@ -16,6 +16,7 @@
16 16
17 17 #include <cairo.h>
18 18 #include <cairo-svg.h>
  19 +//#include <vte/vte.h>
19 20
20 21 #include "../libagh/boost-config-validate.hh"
21 22 #include "misc.hh"
@@ -588,6 +589,10 @@ aghui::SExpDesignUI::populate_1()
588 589
589 590
590 591
  592 +extern "C"
  593 +void
  594 +bDownload_clicked_cb( GtkButton* button, gpointer userdata);
  595 +
591 596 void
592 597 aghui::SExpDesignUI::show_empty_experiment_blurb()
593 598 {
@@ -599,12 +604,13 @@ aghui::SExpDesignUI::show_empty_experiment_blurb()
599 604 "When you have your recordings ready as a set of .edf files,\n"
600 605 "• Create your experiment tree as follows: <i>Experiment/Group/Subject/Session</i>;\n"
601 606 "• Have your EDF sources named <i>Episode</i>.edf, and placed in the corresponding <i>Session</i> directory, or\n"
602   - "• Drop EDF sources onto here and identify and place them individually.\n\n"
  607 + "• Drag-and-Drop any EDF sources onto this window and identify and place them individually.\n\n"
603 608 "Once set up, either:\n"
604 609 "• click <b>⎇</b> and select the top directory of the (newly created) experiment tree, or\n"
605   - "• click <b>Refresh</b> if this is the tree you have just populated.\n";
606   - // "\n"
607   - // "If you have none yet, here is a small subset of EEG data, for a primer, from <a href=\"http://johnhommer.com/academic/aghermann/sample-dataset.tar.bz2\">here</a>.";
  610 + "• click <b>Refresh</b> if this is the tree you have just populated.\n"
  611 + "\n"
  612 + "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;"
  613 + " press the button below to download it into the current directory:";
608 614 GtkLabel *blurb_label = (GtkLabel*)gtk_label_new( "");
609 615 gtk_label_set_markup( blurb_label, blurb);
610 616 gtk_widget_set_visible( (GtkWidget*)lTaskSelector2, FALSE);
@@ -613,15 +619,78 @@ aghui::SExpDesignUI::show_empty_experiment_blurb()
613 619 gtk_box_pack_start( (GtkBox*)cMeasurements,
614 620 (GtkWidget*)blurb_label,
615 621 TRUE, TRUE, 0);
  622 + GtkWidget *bDownload = gtk_button_new_with_label("Download");
  623 + g_object_set( (GObject*)bDownload,
  624 + "expand", FALSE,
  625 + "halign", GTK_ALIGN_CENTER,
  626 + NULL);
  627 + g_signal_connect( bDownload, "clicked",
  628 + (GCallback)bDownload_clicked_cb,
  629 + this);
  630 + gtk_box_pack_start( (GtkBox*)cMeasurements,
  631 + bDownload,
  632 + FALSE, FALSE, 0);
  633 +
616 634 snprintf_buf( "%s/%s/%s", PACKAGE_DATADIR, PACKAGE, AGH_BG_IMAGE_FNAME);
617 635 gtk_box_pack_start( (GtkBox*)cMeasurements,
618 636 (GtkWidget*)gtk_image_new_from_file( __buf__),
619 637 TRUE, FALSE, 0);
  638 +
620 639 gtk_widget_show_all( (GtkWidget*)cMeasurements);
621 640 }
622 641
623 642
  643 +extern "C" void
  644 +bDownload_clicked_cb( GtkButton* button, gpointer userdata)
  645 +{
  646 + auto EDp = (SExpDesignUI*)userdata;
  647 + EDp->try_download();
  648 +}
624 649
  650 +int
  651 +aghui::SExpDesignUI::try_download()
  652 +{
  653 + char *url = "http://johnhommer.com/academic/code/aghermann/Experiment.tar.bz2",
  654 + *archive_file = "Experiment.tar.bz2";
  655 + snprintf_buf( "xterm -e sh -c "
  656 + "'cd \"%s\" && "
  657 + " wget -c \"%s\" && "
  658 + " tar xjf \"%s\" && "
  659 + " rm -f \"%s\" && "
  660 + " echo \"Sample data set downloaded and unpacked\" && "
  661 + " read -p \"Press <Enter> to close this window...\"'",
  662 + ED->session_dir(), url, archive_file, archive_file);
  663 + set_cursor_busy( true, (GtkWidget*)wMainWindow);
  664 + gtk_widget_set_sensitive( (GtkWidget*)wMainWindow, FALSE);
  665 + if ( system( __buf__) )
  666 + ;
  667 + do_rescan_tree( true);
  668 + populate( true);
  669 + // gtk_container_foreach( (GtkContainer*)cMeasurements,
  670 + // (GtkCallback) gtk_widget_destroy,
  671 + // NULL);
  672 + // GtkWidget *tTerm = vte_terminal_new();
  673 + // gtk_box_pack_start( (GtkBox*)cMeasurements,
  674 + // tTerm,
  675 + // TRUE, FALSE, 0);
  676 + // GPid download_process_pid;
  677 + // char *argv[] = {
  678 + // "ls",
  679 + // ".",
  680 + // };
  681 + // vte_terminal_fork_command_full(
  682 + // (VteTerminal*)tTerm,
  683 + // VTE_PTY_DEFAULT,
  684 + // ED->session_dir(),
  685 + // argv,
  686 + // NULL, // char **envv,
  687 + // (GSpawnFlags)0, // GSpawnFlags spawn_flags,
  688 + // NULL, // GSpawnChildSetupFunc child_setup,
  689 + // NULL, // gpointer child_setup_data,
  690 + // &download_process_pid,
  691 + // NULL); // GError **error);
  692 + return 0;
  693 +}
625 694
626 695
627 696 void
1  src/ui/expdesign.hh
@@ -143,6 +143,7 @@ class SExpDesignUI {
143 143 void do_rescan_tree( bool ensure = true); // with while ... gtk_main_iteration ...
144 144
145 145 void show_empty_experiment_blurb();
  146 + int try_download();
146 147
147 148 // collected ED strings (channels, sessions, etc)
148 149 list<string>

0 comments on commit baa05bb

Please sign in to comment.
Something went wrong with that request. Please try again.