summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-07-21 13:48:43 +0100
committerCarl Hetherington <cth@carlh.net>2012-07-21 13:48:43 +0100
commitc8989c45d2b8721c7d6b7a47a253b9a527f64f52 (patch)
tree83b5fb4d556965b97748dbb401f2b3113f18b076 /src
parent5ec26979d2547b7444c4e1f00aa76d86d22f4c84 (diff)
Add dialogue to choose DVD title when ripping.
Diffstat (limited to 'src')
-rw-r--r--src/gtk/dvd_title_dialog.cc76
-rw-r--r--src/gtk/dvd_title_dialog.h32
-rw-r--r--src/gtk/wscript1
-rw-r--r--src/lib/dvd.h3
-rw-r--r--src/tools/dvdomatic.cc13
5 files changed, 124 insertions, 1 deletions
diff --git a/src/gtk/dvd_title_dialog.cc b/src/gtk/dvd_title_dialog.cc
new file mode 100644
index 000000000..60e4e5845
--- /dev/null
+++ b/src/gtk/dvd_title_dialog.cc
@@ -0,0 +1,76 @@
+/*
+ Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <cassert>
+#include <iostream>
+#include "lib/exceptions.h"
+#include "dvd_title_dialog.h"
+#include "gtk_util.h"
+
+using namespace std;
+
+DVDTitleDialog::DVDTitleDialog ()
+{
+ string const dvd = find_dvd ();
+ if (dvd.empty ()) {
+ throw DVDError ("could not find DVD");
+ }
+
+ list<DVDTitle> t = dvd_titles (dvd);
+ if (t.empty ()) {
+ throw DVDError ("no titles found on DVD");
+ }
+
+ set_title ("Choose DVD title");
+ get_vbox()->set_border_width (6);
+ get_vbox()->set_spacing (3);
+
+ Gtk::RadioButtonGroup g;
+ for (list<DVDTitle>::const_iterator i = t.begin(); i != t.end(); ++i) {
+ Gtk::RadioButton* b = manage (new Gtk::RadioButton);
+ stringstream s;
+ s << "Title " << i->number << ": " << g_format_size (i->size);
+ b->set_label (s.str ());
+ if (i == t.begin ()) {
+ b->set_active ();
+ g = b->get_group ();
+ } else {
+ b->set_group (g);
+ }
+ get_vbox()->pack_start (*b);
+ _buttons[*i] = b;
+ }
+
+ add_button ("Cancel", Gtk::RESPONSE_CANCEL);
+ add_button ("Copy Title", Gtk::RESPONSE_OK);
+
+ show_all ();
+}
+
+DVDTitle
+DVDTitleDialog::selected ()
+{
+ std::map<DVDTitle, Gtk::RadioButton *>::const_iterator i = _buttons.begin ();
+ while (i != _buttons.end() && i->second->get_active() == false) {
+ ++i;
+ }
+
+ assert (i != _buttons.end ());
+ return i->first;
+}
diff --git a/src/gtk/dvd_title_dialog.h b/src/gtk/dvd_title_dialog.h
new file mode 100644
index 000000000..26aef286f
--- /dev/null
+++ b/src/gtk/dvd_title_dialog.h
@@ -0,0 +1,32 @@
+/*
+ Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <gtkmm.h>
+#include "lib/dvd.h"
+
+class DVDTitleDialog : public Gtk::Dialog
+{
+public:
+ DVDTitleDialog ();
+
+ DVDTitle selected ();
+
+private:
+ std::map<DVDTitle, Gtk::RadioButton *> _buttons;
+};
diff --git a/src/gtk/wscript b/src/gtk/wscript
index e5611b028..1693f8eb2 100644
--- a/src/gtk/wscript
+++ b/src/gtk/wscript
@@ -23,5 +23,6 @@ def build(bld):
job_manager_view.cc
gtk_util.cc
job_wrapper.cc
+ dvd_title_dialog.cc
"""
obj.target = 'dvdomatic-gtk'
diff --git a/src/lib/dvd.h b/src/lib/dvd.h
index d3f6043ce..28fef4d16 100644
--- a/src/lib/dvd.h
+++ b/src/lib/dvd.h
@@ -17,6 +17,9 @@
*/
+#include <list>
+#include <stdint.h>
+
class DVDTitle
{
public:
diff --git a/src/tools/dvdomatic.cc b/src/tools/dvdomatic.cc
index 803eec3c4..97fd984d3 100644
--- a/src/tools/dvdomatic.cc
+++ b/src/tools/dvdomatic.cc
@@ -26,12 +26,15 @@
#include "gtk/config_dialog.h"
#include "gtk/gpl.h"
#include "gtk/job_wrapper.h"
+#include "gtk/dvd_title_dialog.h"
+#include "gtk/gtk_util.h"
#include "lib/film.h"
#include "lib/format.h"
#include "lib/config.h"
#include "lib/filter.h"
#include "lib/util.h"
#include "lib/scaler.h"
+#include "lib/exceptions.h"
using namespace std;
using namespace boost;
@@ -162,7 +165,15 @@ jobs_make_dcp_from_existing_transcode ()
void
jobs_copy_from_dvd ()
{
- film->copy_from_dvd ();
+ try {
+ DVDTitleDialog d;
+ if (d.run () != Gtk::RESPONSE_OK) {
+ return;
+ }
+ film->copy_from_dvd ();
+ } catch (DVDError& e) {
+ error_dialog (e.what ());
+ }
}
void