[niepce] importer: implement dummy camera importer and base ImporterUI (part 3)
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] importer: implement dummy camera importer and base ImporterUI (part 3)
- Date: Mon, 22 May 2017 03:08:20 +0000 (UTC)
commit 1fe298392c1b21fb9119cf0b45860b2877e809b5
Author: Hubert Figuière <hub figuiere net>
Date: Sun May 21 20:07:23 2017 -0400
importer: implement dummy camera importer and base ImporterUI (part 3)
src/engine/Makefile.am | 2 +
src/engine/importer/cameraimporter.cpp | 37 ++++++++++++++
src/engine/importer/cameraimporter.hpp | 50 +++++++++++++++++++
src/fwk/toolkit/frame.hpp | 8 +++-
src/niepce/ui/Makefile.am | 4 ++
src/niepce/ui/dialogs/importdialog.cpp | 36 ++++++++++---
src/niepce/ui/dialogs/importdialog.hpp | 3 +-
.../ui/dialogs/importers/cameraimporterui.cpp | 40 +++++++++++++++
.../ui/dialogs/importers/cameraimporterui.hpp | 48 ++++++++++++++++++
.../ui/dialogs/importers/directoryimporterui.cpp | 24 +--------
.../ui/dialogs/importers/directoryimporterui.hpp | 19 ++-----
src/niepce/ui/dialogs/importers/iimporterui.hpp | 7 ++-
src/niepce/ui/dialogs/importers/importerui.cpp | 38 ++++++++++++++
src/niepce/ui/dialogs/importers/importerui.hpp | 52 ++++++++++++++++++++
14 files changed, 320 insertions(+), 48 deletions(-)
---
diff --git a/src/engine/Makefile.am b/src/engine/Makefile.am
index 96e891f..b26bd29 100644
--- a/src/engine/Makefile.am
+++ b/src/engine/Makefile.am
@@ -51,6 +51,8 @@ libniepceengine_a_SOURCES = \
importer/iimporter.hpp \
importer/directoryimporter.hpp \
importer/directoryimporter.cpp \
+ importer/cameraimporter.hpp \
+ importer/cameraimporter.cpp \
importer/importedfile.hpp \
importer/importedfile.cpp \
$(NULL)
diff --git a/src/engine/importer/cameraimporter.cpp b/src/engine/importer/cameraimporter.cpp
new file mode 100644
index 0000000..9db00aa
--- /dev/null
+++ b/src/engine/importer/cameraimporter.cpp
@@ -0,0 +1,37 @@
+
+
+#include "cameraimporter.hpp"
+
+namespace eng {
+
+CameraImporter::CameraImporter()
+{
+}
+
+CameraImporter::~CameraImporter()
+{
+}
+
+const std::string& CameraImporter::id() const
+{
+ static std::string _id = "CameraImporter";
+ return _id;
+}
+
+bool CameraImporter::list_source_content(const std::string & source,
+ const SourceContentReady& callback)
+{
+}
+
+bool CameraImporter::get_previews_for(const std::string& source,
+ const std::list<std::string>& paths,
+ const PreviewReady& callback)
+{
+}
+
+bool CameraImporter::do_import(const std::string & source,
+ const FileImporter & importer)
+{
+}
+
+}
diff --git a/src/engine/importer/cameraimporter.hpp b/src/engine/importer/cameraimporter.hpp
new file mode 100644
index 0000000..52d4878
--- /dev/null
+++ b/src/engine/importer/cameraimporter.hpp
@@ -0,0 +1,50 @@
+/*
+ * niepce - engine/importer/cameraimporter.hpp
+ *
+ * Copyright (C) 2014-2017 Hubert Figuière
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#pragma once
+
+#include <string>
+#include <list>
+
+#include "fwk/utils/files.hpp"
+#include "engine/importer/iimporter.hpp"
+
+namespace eng {
+
+
+class CameraImporter
+ : public IImporter {
+public:
+ CameraImporter();
+ virtual ~CameraImporter();
+
+ const std::string& id() const override;
+ bool list_source_content(const std::string & source,
+ const SourceContentReady& callback) override;
+ bool get_previews_for(const std::string& source,
+ const std::list<std::string>& paths,
+ const PreviewReady& callback) override;
+
+ bool do_import(const std::string & source,
+ const FileImporter & importer) override;
+
+};
+
+}
diff --git a/src/fwk/toolkit/frame.hpp b/src/fwk/toolkit/frame.hpp
index a2b33eb..3432a5b 100644
--- a/src/fwk/toolkit/frame.hpp
+++ b/src/fwk/toolkit/frame.hpp
@@ -30,11 +30,17 @@
#include <giomm/menu.h>
#include <gtkmm/builder.h>
#include <gtkmm/headerbar.h>
+#include <gtkmm/window.h>
#include "fwk/toolkit/uicontroller.hpp"
+namespace Gio {
+class ActionMap;
+class SimpleAction;
+}
+
namespace Gtk {
- class Dialog;
+class Dialog;
}
namespace fwk {
diff --git a/src/niepce/ui/Makefile.am b/src/niepce/ui/Makefile.am
index 11e7b64..b659540 100644
--- a/src/niepce/ui/Makefile.am
+++ b/src/niepce/ui/Makefile.am
@@ -35,8 +35,12 @@ libniepceui_a_SOURCES = \
dialogs/importdialog.hpp dialogs/importdialog.cpp \
dialogs/preferencesdialog.hpp dialogs/preferencesdialog.cpp \
dialogs/importdialog.hpp dialogs/importdialog.cpp \
+ dialogs/importers/importerui.hpp \
+ dialogs/importers/importerui.cpp \
dialogs/importers/directoryimporterui.hpp \
dialogs/importers/directoryimporterui.cpp \
+ dialogs/importers/cameraimporterui.hpp \
+ dialogs/importers/cameraimporterui.cpp \
selectioncontroller.hpp selectioncontroller.cpp \
filmstripcontroller.hpp filmstripcontroller.cpp \
thumb-view/eog-thumb-nav.cpp thumb-view/eog-thumb-nav.hpp \
diff --git a/src/niepce/ui/dialogs/importdialog.cpp b/src/niepce/ui/dialogs/importdialog.cpp
index 4213bdc..b9a2713 100644
--- a/src/niepce/ui/dialogs/importdialog.cpp
+++ b/src/niepce/ui/dialogs/importdialog.cpp
@@ -32,11 +32,14 @@
#include "fwk/base/debug.hpp"
#include "fwk/utils/pathutils.hpp"
+#include "fwk/toolkit/application.hpp"
+#include "fwk/toolkit/configuration.hpp"
#include "fwk/toolkit/widgets/imagegridview.hpp"
#include "engine/importer/directoryimporter.hpp"
#include "engine/importer/importedfile.hpp"
#include "importdialog.hpp"
#include "importers/directoryimporterui.hpp"
+#include "importers/cameraimporterui.hpp"
namespace ui {
@@ -63,7 +66,8 @@ void ImportDialog::add_importer_ui(IImporterUI& importer)
m_import_source_combo->append(importer.id(), importer.name());
Gtk::Widget* importer_widget = importer.setup_widget(
std::static_pointer_cast<Frame>(shared_from_this()));
- m_importer_ui_stack->add(*importer_widget, importer.name());
+ importer_widget->show_all();
+ m_importer_ui_stack->add(*importer_widget, importer.id());
importer.set_source_selected_callback([this] (const std::string& source) {
this->set_to_import(source);
});
@@ -75,6 +79,8 @@ void ImportDialog::setup_widget()
return;
}
+ fwk::Configuration & cfg = fwk::Application::app()->config();
+
Glib::RefPtr<Gtk::Builder> a_builder = builder();
a_builder->get_widget("date_tz_combo", m_date_tz_combo);
a_builder->get_widget("ufraw_import_check", m_ufraw_import_check);
@@ -84,16 +90,18 @@ void ImportDialog::setup_widget()
// Sources
a_builder->get_widget("importer_ui_stack", m_importer_ui_stack);
a_builder->get_widget("import_source_combo", m_import_source_combo);
- m_import_source_combo->signal_changed().connect([] {});
+ m_import_source_combo->signal_changed()
+ .connect(sigc::mem_fun(*this, &ImportDialog::import_source_changed));
- // Directory source, hardcoded.
- // XXX fix it
- m_importers[0] = std::make_shared<DirectoryImporterUI>();
- add_importer_ui(*m_importers[0]);
+ std::shared_ptr<IImporterUI> importer = std::make_shared<DirectoryImporterUI>();
+ m_importers[importer->id()] = importer;
+ add_importer_ui(*importer);
+ importer = std::make_shared<CameraImporterUI>();
+ m_importers[importer->id()] = importer;
+ add_importer_ui(*importer);
- // XXX restore from preferences.
- m_current_importer = m_importers[0];
- m_import_source_combo->set_active_id(m_current_importer->id());
+ auto last_importer = cfg.getValue("last_importer", "DirectoryImporter");
+ m_import_source_combo->set_active_id(last_importer);
// Metadata pane.
a_builder->get_widget("attributes_scrolled", m_attributes_scrolled);
@@ -124,6 +132,16 @@ void ImportDialog::setup_widget()
m_is_setup = true;
}
+void ImportDialog::import_source_changed()
+{
+ auto id = m_import_source_combo->get_active_id();
+ m_current_importer = m_importers[id];
+ m_importer_ui_stack->set_visible_child(id);
+
+ fwk::Configuration & cfg = fwk::Application::app()->config();
+ cfg.setValue("last_importer", id);
+}
+
void ImportDialog::set_to_import(const std::string& f)
{
m_images_list_model->clear();
diff --git a/src/niepce/ui/dialogs/importdialog.hpp b/src/niepce/ui/dialogs/importdialog.hpp
index 33d821c..53f7603 100644
--- a/src/niepce/ui/dialogs/importdialog.hpp
+++ b/src/niepce/ui/dialogs/importdialog.hpp
@@ -82,6 +82,7 @@ public:
// { return m_list_to_import; }
const Glib::ustring & source_path() const
{ return m_folder_path_source; }
+ void import_source_changed();
void set_to_import(const std::string& f);
const std::shared_ptr<IImporterUI>& importer_ui() const
{ return m_current_importer; }
@@ -95,7 +96,7 @@ private:
void preview_received();
void add_importer_ui(IImporterUI& importer);
- std::array<std::shared_ptr<ui::IImporterUI>, 1> m_importers;
+ std::map<std::string, std::shared_ptr<ui::IImporterUI>> m_importers;
std::shared_ptr<ui::IImporterUI> m_current_importer; // as shared_ptr<> for lambda capture
Glib::ustring m_folder_path_source;
diff --git a/src/niepce/ui/dialogs/importers/cameraimporterui.cpp
b/src/niepce/ui/dialogs/importers/cameraimporterui.cpp
new file mode 100644
index 0000000..7b4d708
--- /dev/null
+++ b/src/niepce/ui/dialogs/importers/cameraimporterui.cpp
@@ -0,0 +1,40 @@
+/*
+ * niepce - ui/dialogs/importer/cameraimporterui.cpp
+ *
+ * Copyright (C) 2017 Hubert Figuière
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glibmm/i18n.h>
+#include <gtkmm/label.h>
+
+#include "fwk/toolkit/frame.hpp"
+#include "engine/importer/cameraimporter.hpp"
+#include "cameraimporterui.hpp"
+
+namespace ui {
+
+CameraImporterUI::CameraImporterUI()
+ : ImporterUI(std::make_shared<eng::CameraImporter>(), _("Camera"))
+{
+}
+
+Gtk::Widget* CameraImporterUI::setup_widget(const fwk::Frame::Ptr&)
+{
+ Gtk::Label* label = Gtk::manage(new Gtk::Label("camera! camera! camera!"));
+ return label;
+}
+
+}
diff --git a/src/niepce/ui/dialogs/importers/cameraimporterui.hpp
b/src/niepce/ui/dialogs/importers/cameraimporterui.hpp
new file mode 100644
index 0000000..c72be2b
--- /dev/null
+++ b/src/niepce/ui/dialogs/importers/cameraimporterui.hpp
@@ -0,0 +1,48 @@
+/*
+ * niepce - ui/dialogs/importer/cameraimporterui.hpp
+ *
+ * Copyright (C) 2017 Hubert Figuière
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <string>
+#include "importerui.hpp"
+
+namespace Gtk {
+class Widget;
+}
+
+namespace fwk {
+class Frame;
+}
+
+namespace ui {
+
+class CameraImporterUI
+ : public ImporterUI
+{
+public:
+ CameraImporterUI();
+
+ Gtk::Widget* setup_widget(const fwk::Frame::Ptr&) override;
+
+private:
+ std::string select_source();
+ void do_select_directories();
+};
+
+}
diff --git a/src/niepce/ui/dialogs/importers/directoryimporterui.cpp
b/src/niepce/ui/dialogs/importers/directoryimporterui.cpp
index 13bd70d..d5774c7 100644
--- a/src/niepce/ui/dialogs/importers/directoryimporterui.cpp
+++ b/src/niepce/ui/dialogs/importers/directoryimporterui.cpp
@@ -29,26 +29,11 @@
namespace ui {
DirectoryImporterUI::DirectoryImporterUI()
- : m_importer(std::make_shared<eng::DirectoryImporter>())
- , m_name(_("Directory"))
+ : ImporterUI(std::make_shared<eng::DirectoryImporter>(), _("Directory"))
+ , m_directory_name(nullptr)
{
}
-std::shared_ptr<eng::IImporter> DirectoryImporterUI::get_importer()
-{
- return m_importer;
-}
-
-const std::string& DirectoryImporterUI::name() const
-{
- return m_name;
-}
-
-const std::string& DirectoryImporterUI::id() const
-{
- return m_importer->id();
-}
-
Gtk::Widget* DirectoryImporterUI::setup_widget(const fwk::Frame::Ptr& frame)
{
m_frame = frame;
@@ -64,11 +49,6 @@ Gtk::Widget* DirectoryImporterUI::setup_widget(const fwk::Frame::Ptr& frame)
return main_widget;
}
-void DirectoryImporterUI::set_source_selected_callback(const SourceSelected& cb)
-{
- m_source_selected_cb = cb;
-}
-
void DirectoryImporterUI::do_select_directories()
{
auto source = select_source();
diff --git a/src/niepce/ui/dialogs/importers/directoryimporterui.hpp
b/src/niepce/ui/dialogs/importers/directoryimporterui.hpp
index 8b179be..563f341 100644
--- a/src/niepce/ui/dialogs/importers/directoryimporterui.hpp
+++ b/src/niepce/ui/dialogs/importers/directoryimporterui.hpp
@@ -19,37 +19,30 @@
#pragma once
-#include "iimporterui.hpp"
+#include "importerui.hpp"
namespace fwk {
class Frame;
}
+namespace eng {
+class DirectoryImporter;
+}
+
namespace ui {
class DirectoryImporterUI
- : public IImporterUI
+ : public ImporterUI
{
public:
DirectoryImporterUI();
- std::shared_ptr<eng::IImporter> get_importer() override;
-
- const std::string& name() const override;
- const std::string& id() const override;
Gtk::Widget* setup_widget(const fwk::Frame::Ptr&) override;
- void set_source_selected_callback(const SourceSelected&) override;
private:
std::string select_source();
void do_select_directories();
- std::shared_ptr<eng::DirectoryImporter> m_importer;
- std::string m_name;
- SourceSelected m_source_selected_cb;
-
- std::weak_ptr<fwk::Frame> m_frame;
- Glib::RefPtr<Gtk::Builder> m_builder;
Gtk::Label *m_directory_name;
};
diff --git a/src/niepce/ui/dialogs/importers/iimporterui.hpp b/src/niepce/ui/dialogs/importers/iimporterui.hpp
index fb4ab0f..0e5539c 100644
--- a/src/niepce/ui/dialogs/importers/iimporterui.hpp
+++ b/src/niepce/ui/dialogs/importers/iimporterui.hpp
@@ -3,12 +3,15 @@
#pragma once
#include <memory>
-
-#include "engine/importer/iimporter.hpp"
+#include <string>
+#include <functional>
namespace Gtk {
class Widget;
}
+namespace eng {
+class IImporter;
+}
namespace fwk {
class Frame;
}
diff --git a/src/niepce/ui/dialogs/importers/importerui.cpp b/src/niepce/ui/dialogs/importers/importerui.cpp
new file mode 100644
index 0000000..ce146d8
--- /dev/null
+++ b/src/niepce/ui/dialogs/importers/importerui.cpp
@@ -0,0 +1,38 @@
+
+
+#include "fwk/toolkit/frame.hpp"
+#include "engine/importer/iimporter.hpp"
+#include "importerui.hpp"
+
+namespace ui {
+
+ImporterUI::ImporterUI(std::shared_ptr<eng::IImporter>&& importer,
+ const std::string& name)
+ : m_importer(importer)
+ , m_name(name)
+{
+}
+
+std::shared_ptr<eng::IImporter> ImporterUI::get_importer()
+{
+ return m_importer;
+}
+
+const std::string& ImporterUI::id() const
+{
+ return m_importer->id();
+}
+
+
+const std::string& ImporterUI::name() const
+{
+ return m_name;
+}
+
+
+void ImporterUI::set_source_selected_callback(const SourceSelected& cb)
+{
+ m_source_selected_cb = cb;
+}
+
+}
diff --git a/src/niepce/ui/dialogs/importers/importerui.hpp b/src/niepce/ui/dialogs/importers/importerui.hpp
new file mode 100644
index 0000000..5016673
--- /dev/null
+++ b/src/niepce/ui/dialogs/importers/importerui.hpp
@@ -0,0 +1,52 @@
+/*
+ * niepce - ui/dialogs/importer/importerui.hpp
+ *
+ * Copyright (C) 2017 Hubert Figuière
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "iimporterui.hpp"
+
+namespace fwk {
+class Frame;
+}
+
+namespace ui {
+
+class ImporterUI
+ : public IImporterUI
+{
+public:
+ ImporterUI(std::shared_ptr<eng::IImporter>&& importer,
+ const std::string& name);
+
+ std::shared_ptr<eng::IImporter> get_importer() override;
+
+ const std::string& name() const override;
+ const std::string& id() const override;
+
+ void set_source_selected_callback(const SourceSelected&) override;
+
+protected:
+ std::shared_ptr<eng::IImporter> m_importer;
+ std::string m_name;
+ std::weak_ptr<fwk::Frame> m_frame;
+ Glib::RefPtr<Gtk::Builder> m_builder;
+ SourceSelected m_source_selected_cb;
+};
+
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]