[solang] Basic functional Brasero destination



commit 070b6bd2b1d38899a46afc56f7f5b0ed0cfe607e
Author: Debarshi Ray <rishi gnu org>
Date:   Sat Feb 20 00:58:38 2010 +0200

    Basic functional Brasero destination
    
    A new dependency has been introduced on Brasero >= 2.28.

 README                               |    3 +-
 configure.ac                         |    1 +
 po/POTFILES.in                       |    1 +
 src/application/Makefile.am          |    2 +
 src/application/application.cpp      |    7 +
 src/exporter/Makefile.am             |    3 +
 src/exporter/brasero-destination.cpp |  212 ++++++++++++++++++++++++++++++++++
 src/exporter/brasero-destination.h   |  107 +++++++++++++++++
 8 files changed, 335 insertions(+), 1 deletions(-)
---
diff --git a/README b/README
index 0070974..e24112c 100644
--- a/README
+++ b/README
@@ -36,7 +36,7 @@ Features:
 ---------
 - Browser, enlarged and slideshow renderers for viewing the entire
   collection, editing, a single photo and slideshows respectively.
-- Folder exporter to export selected photos to a folder.
+- Exporters to export selected photos to a folder or CD/DVD.
 - Date view for showing photo dates.
 - Basic editing like brightness, contrast, flipping, rotation, saturation and
   scaling, and undo, redo of operations.
@@ -50,6 +50,7 @@ Features:
 Dependencies:
 -------------
  - babl
+ - libbrasero-burn >= 2.28.3
  - dbus-glib-1
  - gdl-1.0
  - gegl
diff --git a/configure.ac b/configure.ac
index 413ff86..decaa8f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,6 +35,7 @@ if test x"$DBUS_BINDING_TOOL" = x"no"; then
 fi
 
 PKG_CHECK_MODULES(BABL, [babl])
+PKG_CHECK_MODULES(BRASERO, [libbrasero-burn >= 2.28.3])
 PKG_CHECK_MODULES(DBUS, [dbus-glib-1])
 PKG_CHECK_MODULES(GDL, [gdl-1.0])
 PKG_CHECK_MODULES(GEGLMM, [geglmm >= 0.1.0])
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 4de8c97..a859c3b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -19,6 +19,7 @@ src/editor/flip-vert-operation.cpp
 src/editor/rotate-clock-operation.cpp
 src/editor/rotate-counter-operation.cpp
 src/editor/rotate-operation.cpp
+src/exporter/brasero-destination.cpp
 src/exporter/directory-destination.cpp
 src/exporter/exporter-dialog.cpp
 src/renderer/browser-renderer.cpp
diff --git a/src/application/Makefile.am b/src/application/Makefile.am
index 0e0fdc7..c26dc18 100644
--- a/src/application/Makefile.am
+++ b/src/application/Makefile.am
@@ -21,6 +21,7 @@ solang_LDADD = \
 	$(top_builddir)/src/attribute/libattribute.la \
 	$(top_builddir)/src/editor/libeditor.la \
 	$(top_builddir)/src/common/libcommon.la \
+	$(BRASERO_LIBS) \
 	$(DBUS_LIBS) \
 	$(GTKIMAGEVIEW_LIBS) \
 	$(GTKMM_LIBS) \
@@ -43,6 +44,7 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/exporter \
 	-I$(top_srcdir)/src/renderer \
 	$(SOLANG_CFLAGS) \
+	$(BRASERO_CFLAGS) \
 	$(DBUS_CFLAGS) \
 	$(GTKIMAGEVIEW_CFLAGS) \
 	$(GTKMM_CFLAGS) \
diff --git a/src/application/application.cpp b/src/application/application.cpp
index c38e152..734cb5f 100644
--- a/src/application/application.cpp
+++ b/src/application/application.cpp
@@ -28,6 +28,7 @@
 #include <giomm.h>
 
 #include "application.h"
+#include "brasero-destination.h"
 #include "browser-model-column-record.h"
 #include "browser-renderer.h"
 //#include "camera-source.h"
@@ -298,6 +299,12 @@ Application::init() throw()
                                                true));
     plugins_.push_back(directory_exporter);
 
+    IPhotoDestinationPtr brasero_destination(
+                             new BraseroDestination());
+    IPluginPtr brasero_exporter(new Exporter(brasero_destination,
+                                             false));
+    plugins_.push_back(brasero_exporter);
+
 //    IPhotoSourcePtr directory_source(new DirectorySource());
 //    IPluginPtr directory_importer(new Importer(directory_source, true));
 //    plugins_.push_back(directory_importer);
diff --git a/src/exporter/Makefile.am b/src/exporter/Makefile.am
index d9f05b3..3ae3dbe 100644
--- a/src/exporter/Makefile.am
+++ b/src/exporter/Makefile.am
@@ -8,6 +8,8 @@ libexporter_la_SOURCES = \
 	photo-destination.h \
 	photo-destination.cpp \
 	photo-destination-enums.h \
+	brasero-destination.cpp \
+	brasero-destination.h \
 	directory-destination.h \
 	directory-destination.cpp
 
@@ -24,6 +26,7 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/renderer \
 	-I$(top_srcdir)/src/storage \
 	$(SOLANG_CFLAGS) \
+	$(BRASERO_CFLAGS) \
 	$(DBUS_CFLAGS) \
 	$(GTKMM_CFLAGS) \
 	$(GDL_CFLAGS) \
diff --git a/src/exporter/brasero-destination.cpp b/src/exporter/brasero-destination.cpp
new file mode 100644
index 0000000..7fdb5d0
--- /dev/null
+++ b/src/exporter/brasero-destination.cpp
@@ -0,0 +1,212 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * Copyright (C) 2009, 2010 Debarshi Ray <rishi gnu org>
+ *
+ * Solang 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.
+ *
+ * Solang 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif // HAVE_CONFIG_H
+
+#include <brasero-burn-dialog.h>
+#include <brasero-burn-lib.h>
+#include <glibmm/i18n.h>
+
+#include "brasero-destination.h"
+#include "photo.h"
+#include "photo-destination-enums.h"
+#include "progress-observer.h"
+
+namespace Solang
+{
+
+BraseroDestination::BraseroDestination() throw() :
+    PhotoDestination(),
+    braseroDrive_(0),
+    braseroSessionCfg_(0),
+    braseroTrackDataCfg_(0),
+    braseroDriveSelection_(0),
+    braseroBurnBegin_(),
+    initEnd_()
+{
+    brasero_burn_library_start(0, 0);
+
+    braseroBurnBegin_.connect(
+        sigc::mem_fun(*this,
+                      &BraseroDestination::on_brasero_burn_begin));
+}
+
+BraseroDestination::~BraseroDestination() throw()
+{
+    brasero_burn_library_stop();
+}
+
+void
+BraseroDestination::init(Application & application) throw()
+{
+    initEnd_.emit(true);
+}
+
+void
+BraseroDestination::final(Application & application) throw()
+{
+}
+
+void
+BraseroDestination::export_photo(
+                          const PhotoPtr & photo,
+                          const ProgressObserverPtr & observer)
+                          throw()
+{
+    brasero_track_data_cfg_add(braseroTrackDataCfg_,
+                               photo->get_uri().c_str(),
+                               0);
+    observer->receive_event_notifiation();
+}
+
+void
+BraseroDestination::export_photos(
+                          const PhotoList & photos,
+                          const ProgressObserverPtr & observer)
+                          throw()
+{
+    if (0 == braseroDrive_)
+    {
+        return;
+    }
+
+    observer->set_event_description(_("Exporting Photos"));
+    observer->set_num_events(photos.size());
+
+    braseroSessionCfg_ = brasero_session_cfg_new();
+    brasero_burn_session_set_burner(
+        BRASERO_BURN_SESSION(braseroSessionCfg_), braseroDrive_);
+    g_object_unref(braseroDrive_);
+    braseroDrive_ = 0;
+
+    braseroTrackDataCfg_ = brasero_track_data_cfg_new();
+    brasero_burn_session_add_track(
+        BRASERO_BURN_SESSION(braseroSessionCfg_),
+        BRASERO_TRACK(braseroTrackDataCfg_),
+        NULL);
+
+    PhotoList::const_iterator it;
+
+    for (it = photos.begin(); photos.end() != it; it++)
+    {
+        export_photo(*it, observer);
+    }
+
+    g_object_unref(braseroTrackDataCfg_);
+    braseroTrackDataCfg_ = 0;
+
+    braseroBurnBegin_.emit();
+}
+
+void BraseroDestination::final() throw()
+{
+}
+
+sigc::signal<void, bool> &
+BraseroDestination::init_end() throw()
+{
+    return initEnd_;
+}
+
+void
+BraseroDestination::read_selection() throw()
+{
+    braseroDrive_
+        = brasero_drive_selection_get_active(
+              BRASERO_DRIVE_SELECTION(braseroDriveSelection_));
+}
+
+Gtk::Widget &
+BraseroDestination::get_browser() throw()
+{
+    braseroDriveSelection_ = brasero_drive_selection_new();
+    brasero_drive_selection_show_type(
+        BRASERO_DRIVE_SELECTION(braseroDriveSelection_),
+        static_cast<BraseroDriveType>(BRASERO_DRIVE_TYPE_FILE
+                                      | BRASERO_DRIVE_TYPE_WRITER));
+
+    return *Gtk::manage(Glib::wrap(
+                            GTK_COMBO_BOX(braseroDriveSelection_),
+                            false));
+}
+
+Glib::ustring
+BraseroDestination::get_label() const throw()
+{
+    return Glib::ustring(_("_CD/DVD..."));
+}
+
+Glib::ustring
+BraseroDestination::get_name() const throw()
+{
+    return Glib::ustring("Brasero");
+}
+
+gint
+BraseroDestination::get_options() const throw()
+{
+    return PHOTO_DESTINATION_CREATE_ARCHIVE_FALSE;
+}
+
+Gtk::StockID
+BraseroDestination::get_stock_id() const throw()
+{
+    return Gtk::Stock::CDROM;
+}
+
+void
+BraseroDestination::set_create_archive(bool value) throw()
+{
+    // NB: Creation of archives is not supported.
+}
+
+void
+BraseroDestination::brasero_burn_begin_idle() throw()
+{
+    GtkWidget * const burn_dialog = brasero_burn_dialog_new();
+
+    gtk_window_set_title(GTK_WINDOW(burn_dialog),
+                         _("Export to CD/DVD"));
+    brasero_burn_dialog_run(BRASERO_BURN_DIALOG(burn_dialog),
+                            BRASERO_BURN_SESSION(braseroSessionCfg_));
+    gtk_widget_destroy(burn_dialog);
+
+    g_object_unref(braseroSessionCfg_);
+    braseroSessionCfg_ = 0;
+}
+
+void
+BraseroDestination::on_brasero_burn_begin() throw()
+{
+    // FIXME: Sometimes the brasero_burn_dialog_run gets stuck and
+    //        freezes the application. This is a workaround.
+
+    while (true == Gtk::Main::events_pending())
+    {
+        Gtk::Main::iteration();
+    }
+
+    Glib::signal_idle().connect_once(
+        sigc::mem_fun(*this,
+                      &BraseroDestination::brasero_burn_begin_idle),
+        Glib::PRIORITY_LOW);
+}
+
+} // namespace Solang
diff --git a/src/exporter/brasero-destination.h b/src/exporter/brasero-destination.h
new file mode 100644
index 0000000..4d4f53d
--- /dev/null
+++ b/src/exporter/brasero-destination.h
@@ -0,0 +1,107 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * Copyright (C) 2009, 2010 Debarshi Ray <rishi gnu org>
+ *
+ * Solang 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.
+ *
+ * Solang 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/>.
+ */
+
+#ifndef SOLANG_BRASERO_DESTINATION_H
+#define SOLANG_BRASERO_DESTINATION_H
+
+#include <brasero-drive.h>
+#include <brasero-drive-selection.h>
+#include <brasero-session-cfg.h>
+#include <brasero-track-data-cfg.h>
+#include <glibmm.h>
+
+#include "photo-destination.h"
+
+namespace Solang
+{
+
+class BraseroDestination :
+    public PhotoDestination
+{
+    public:
+        BraseroDestination() throw();
+
+        virtual
+        ~BraseroDestination() throw();
+
+        virtual void
+        init(Application & application) throw();
+
+        virtual void
+        final(Application & application) throw();
+
+        virtual void
+        export_photo(const PhotoPtr & photo,
+                     const ProgressObserverPtr & observer) throw();
+
+        virtual void
+        export_photos(const PhotoList & photos,
+                      const ProgressObserverPtr & observer) throw();
+
+        virtual void
+        final() throw();
+
+        virtual sigc::signal<void, bool> &
+        init_end() throw();
+
+        virtual void
+        read_selection() throw();
+
+        virtual Gtk::Widget &
+        get_browser() throw();
+
+        virtual Glib::ustring
+        get_label() const throw();
+
+        virtual Glib::ustring
+        get_name() const throw();
+
+        virtual gint
+        get_options() const throw();
+
+        virtual Gtk::StockID
+        get_stock_id() const throw();
+
+        virtual void
+        set_create_archive(bool value) throw();
+
+    protected:
+        void
+        brasero_burn_begin_idle() throw();
+
+        void
+        on_brasero_burn_begin() throw();
+
+        BraseroDrive * braseroDrive_;
+
+        BraseroSessionCfg * braseroSessionCfg_;
+
+        BraseroTrackDataCfg * braseroTrackDataCfg_;
+
+        GtkWidget * braseroDriveSelection_;
+
+        Glib::Dispatcher braseroBurnBegin_;
+
+        sigc::signal<void, bool> initEnd_;
+
+    private:
+};
+
+} // namespace Solang
+
+#endif // SOLANG_BRASERO_DESTINATION_H



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]