summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-11-13 13:07:16 +0000
committerCarl Hetherington <cth@carlh.net>2015-11-13 13:07:16 +0000
commitdf89a39cfd34d0d70609daa214d3b618bb6223bd (patch)
tree1629307cc535fc0ea8804ca935022dddf163135d /src/wx
parent43800d83434697a31bdfae62dd377cfc3900986b (diff)
Allow multiple recipients of KDM emails (#745).
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/cinema_dialog.cc74
-rw-r--r--src/wx/cinema_dialog.h18
-rw-r--r--src/wx/editable_list.h9
-rw-r--r--src/wx/email_dialog.cc45
-rw-r--r--src/wx/email_dialog.h32
-rw-r--r--src/wx/screens_panel.cc6
-rw-r--r--src/wx/wscript1
7 files changed, 166 insertions, 19 deletions
diff --git a/src/wx/cinema_dialog.cc b/src/wx/cinema_dialog.cc
index a54dd7335..e3dff8a48 100644
--- a/src/wx/cinema_dialog.cc
+++ b/src/wx/cinema_dialog.cc
@@ -19,19 +19,59 @@
#include "cinema_dialog.h"
#include "wx_util.h"
+#include <boost/foreach.hpp>
using std::string;
+using std::vector;
+using std::copy;
+using std::back_inserter;
+using std::list;
+using std::cout;
+using boost::bind;
-CinemaDialog::CinemaDialog (wxWindow* parent, string title, string name, string email)
- : TableDialog (parent, std_to_wx (title), 2, 1, true)
+static string
+column (string s)
{
- add (_("Name"), true);
- _name = add (new wxTextCtrl (this, wxID_ANY, std_to_wx (name), wxDefaultPosition, wxSize (256, -1)));
+ return s;
+}
+
+CinemaDialog::CinemaDialog (wxWindow* parent, string title, string name, list<string> emails)
+ : wxDialog (parent, wxID_ANY, std_to_wx (title))
+{
+ wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
+ SetSizer (overall_sizer);
+
+ wxGridBagSizer* sizer = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+ int r = 0;
+
+ add_label_to_sizer (sizer, this, _("Name"), true, wxGBPosition (r, 0));
+ _name = new wxTextCtrl (this, wxID_ANY, std_to_wx (name), wxDefaultPosition, wxSize (500, -1));
+ sizer->Add (_name, wxGBPosition (r, 1));
+ ++r;
+
+ add_label_to_sizer (sizer, this, _("Email addresses for KDM delivery"), true, wxGBPosition (r, 0), wxGBSpan (1, 2));
+ ++r;
+
+ copy (emails.begin(), emails.end(), back_inserter (_emails));
+
+ vector<string> columns;
+ columns.push_back (wx_to_std (_("Address")));
+ _email_list = new EditableList<string, EmailDialog> (
+ this, columns, bind (&CinemaDialog::get_emails, this), bind (&CinemaDialog::set_emails, this, _1), bind (&column, _1)
+ );
+
+ sizer->Add (_email_list, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND);
+ ++r;
- add (_("Email address for KDM delivery"), true);
- _email = add (new wxTextCtrl (this, wxID_ANY, std_to_wx (email), wxDefaultPosition, wxSize (256, -1)));
+ overall_sizer->Add (sizer, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
- layout ();
+ wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
+ if (buttons) {
+ overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
+ }
+
+ overall_sizer->Layout ();
+ overall_sizer->SetSizeHints (this);
}
string
@@ -40,8 +80,22 @@ CinemaDialog::name () const
return wx_to_std (_name->GetValue());
}
-string
-CinemaDialog::email () const
+void
+CinemaDialog::set_emails (vector<string> e)
+{
+ _emails = e;
+}
+
+vector<string>
+CinemaDialog::get_emails () const
+{
+ return _emails;
+}
+
+list<string>
+CinemaDialog::emails () const
{
- return wx_to_std (_email->GetValue());
+ list<string> e;
+ copy (_emails.begin(), _emails.end(), back_inserter (e));
+ return e;
}
diff --git a/src/wx/cinema_dialog.h b/src/wx/cinema_dialog.h
index 56beaa5bd..7d27bd94b 100644
--- a/src/wx/cinema_dialog.h
+++ b/src/wx/cinema_dialog.h
@@ -17,18 +17,26 @@
*/
-#include <wx/wx.h>
#include "table_dialog.h"
+#include "editable_list.h"
+#include "email_dialog.h"
+#include <wx/wx.h>
+#include <list>
+#include <vector>
-class CinemaDialog : public TableDialog
+class CinemaDialog : public wxDialog
{
public:
- CinemaDialog (wxWindow *, std::string, std::string name = "", std::string email = "");
+ CinemaDialog (wxWindow *, std::string, std::string name = "", std::list<std::string> emails = std::list<std::string> ());
std::string name () const;
- std::string email () const;
+ std::list<std::string> emails () const;
private:
+ std::vector<std::string> get_emails () const;
+ void set_emails (std::vector<std::string>);
+
wxTextCtrl* _name;
- wxTextCtrl* _email;
+ EditableList<std::string, EmailDialog>* _email_list;
+ std::vector<std::string> _emails;
};
diff --git a/src/wx/editable_list.h b/src/wx/editable_list.h
index be79f67e6..bb749a4a4 100644
--- a/src/wx/editable_list.h
+++ b/src/wx/editable_list.h
@@ -17,9 +17,15 @@
*/
+#include "wx_util.h"
#include <wx/wx.h>
#include <wx/listctrl.h>
+#include <boost/function.hpp>
+#include <vector>
+/** @param T type of things being edited.
+ * @param S dialog to edit a thing.
+ */
template<class T, class S>
class EditableList : public wxPanel
{
@@ -78,8 +84,9 @@ public:
_list->Bind (wxEVT_COMMAND_LIST_ITEM_SELECTED, boost::bind (&EditableList::selection_changed, this));
_list->Bind (wxEVT_COMMAND_LIST_ITEM_DESELECTED, boost::bind (&EditableList::selection_changed, this));
_list->Bind (wxEVT_SIZE, boost::bind (&EditableList::resized, this, _1));
- selection_changed ();
+ refresh ();
+ selection_changed ();
}
void refresh ()
diff --git a/src/wx/email_dialog.cc b/src/wx/email_dialog.cc
new file mode 100644
index 000000000..fa9e319f6
--- /dev/null
+++ b/src/wx/email_dialog.cc
@@ -0,0 +1,45 @@
+/*
+ Copyright (C) 2015 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 "email_dialog.h"
+#include "wx_util.h"
+
+using std::string;
+using boost::shared_ptr;
+
+EmailDialog::EmailDialog (wxWindow* parent)
+ : TableDialog (parent, _("Email address"), 2, 1, true)
+{
+ add (_("Email address"), true);
+ _email = add (new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (400, -1)));
+
+ layout ();
+}
+
+void
+EmailDialog::set (string address)
+{
+ _email->SetValue (std_to_wx (address));
+}
+
+string
+EmailDialog::get () const
+{
+ return wx_to_std (_email->GetValue ());
+}
diff --git a/src/wx/email_dialog.h b/src/wx/email_dialog.h
new file mode 100644
index 000000000..698cbef69
--- /dev/null
+++ b/src/wx/email_dialog.h
@@ -0,0 +1,32 @@
+/*
+ Copyright (C) 2015 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 "table_dialog.h"
+
+class EmailDialog : public TableDialog
+{
+public:
+ EmailDialog (wxWindow *);
+
+ void set (std::string);
+ std::string get () const;
+
+private:
+ wxTextCtrl* _email;
+};
diff --git a/src/wx/screens_panel.cc b/src/wx/screens_panel.cc
index 5bdfe6c6c..4f8e3ad4d 100644
--- a/src/wx/screens_panel.cc
+++ b/src/wx/screens_panel.cc
@@ -171,7 +171,7 @@ ScreensPanel::add_cinema_clicked ()
{
CinemaDialog* d = new CinemaDialog (this, "Add Cinema");
if (d->ShowModal () == wxID_OK) {
- shared_ptr<Cinema> c (new Cinema (d->name(), d->email()));
+ shared_ptr<Cinema> c (new Cinema (d->name(), d->emails()));
Config::instance()->add_cinema (c);
add_cinema (c);
}
@@ -188,10 +188,10 @@ ScreensPanel::edit_cinema_clicked ()
pair<wxTreeItemId, shared_ptr<Cinema> > c = selected_cinemas().front();
- CinemaDialog* d = new CinemaDialog (this, "Edit cinema", c.second->name, c.second->email);
+ CinemaDialog* d = new CinemaDialog (this, "Edit cinema", c.second->name, c.second->emails);
if (d->ShowModal () == wxID_OK) {
c.second->name = d->name ();
- c.second->email = d->email ();
+ c.second->emails = d->emails ();
_targets->SetItemText (c.first, std_to_wx (d->name()));
Config::instance()->changed ();
}
diff --git a/src/wx/wscript b/src/wx/wscript
index 3b61eb5c6..821043b40 100644
--- a/src/wx/wscript
+++ b/src/wx/wscript
@@ -39,6 +39,7 @@ sources = """
content_properties_dialog.cc
content_sub_panel.cc
dcp_panel.cc
+ email_dialog.cc
image_sequence_dialog.cc
isdcf_metadata_dialog.cc
dir_picker_ctrl.cc