[gthumb: 3/15] added the burn_disc extension



commit b3789548e83ebd9a62a433db06fe22d3bc5a0795
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Thu Feb 25 00:13:56 2010 +0100

    added the burn_disc extension

 extensions/Makefile.am                         |    1 +
 extensions/burn_disc/Makefile.am               |   34 +++++++
 extensions/burn_disc/actions.c                 |  123 ++++++++++++++++++++++++
 extensions/burn_disc/actions.h                 |   32 ++++++
 extensions/burn_disc/burn_disc.extension.in.in |   11 ++
 extensions/burn_disc/callbacks.c               |   95 ++++++++++++++++++
 extensions/burn_disc/callbacks.h               |   30 ++++++
 extensions/burn_disc/main.c                    |   53 ++++++++++
 8 files changed, 379 insertions(+), 0 deletions(-)
---
diff --git a/extensions/Makefile.am b/extensions/Makefile.am
index c2a914c..97cb9ae 100644
--- a/extensions/Makefile.am
+++ b/extensions/Makefile.am
@@ -1,5 +1,6 @@
 SUBDIRS = 			\
 	bookmarks		\
+	burn_disc		\
 	catalogs		\
 	change_date		\
 	comments		\
diff --git a/extensions/burn_disc/Makefile.am b/extensions/burn_disc/Makefile.am
new file mode 100644
index 0000000..10417e2
--- /dev/null
+++ b/extensions/burn_disc/Makefile.am
@@ -0,0 +1,34 @@
+if ENABLE_BRASERO_TOOLS
+
+extensiondir = $(pkglibdir)/extensions
+extension_LTLIBRARIES = libburn_disc.la
+
+libburn_disc_la_SOURCES = 		\
+	actions.c			\
+	actions.h			\
+	callbacks.c			\
+	callbacks.h			\
+	main.c
+
+libburn_disc_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBBRASERO_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb 
+libburn_disc_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
+libburn_disc_la_LIBADD = $(GTHUMB_LIBS) $(LIBBRASERO_LIBS)
+libburn_disc_la_DEPENDENCIES = $(top_builddir)/gthumb/gthumb$(EXEEXT)
+
+extensioninidir = $(extensiondir)
+extensionini_in_files = burn_disc.extension.in.in
+extensionini_DATA = $(extensionini_in_files:.extension.in.in=.extension)
+
+%.extension.in: %.extension.in.in $(extension_LTLIBRARIES)
+	$(AM_V_GEN)( sed -e "s|%LIBRARY%|`. ./$(extension_LTLIBRARIES) && echo $$dlname`|" \
+	$< > $@ )
+
+%.extension: %.extension.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@
+
+EXTRA_DIST = $(extensionini_in_files) 
+
+DISTCLEANFILES = $(extensionini_DATA)
+
+endif
+
+-include $(top_srcdir)/git.mk
diff --git a/extensions/burn_disc/actions.c b/extensions/burn_disc/actions.c
new file mode 100644
index 0000000..91b4900
--- /dev/null
+++ b/extensions/burn_disc/actions.c
@@ -0,0 +1,123 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ *  GThumb
+ *
+ *  Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ *  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., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+
+#include <config.h>
+#include <brasero/brasero-burn-dialog.h>
+#include <brasero/brasero-burn-lib.h>
+#include <brasero/brasero-burn-options.h>
+#include <brasero/brasero-media.h>
+#include <brasero/brasero-session.h>
+#include <brasero/brasero-session-cfg.h>
+#include <brasero/brasero-track-data-cfg.h>
+#include <glib/gi18n.h>
+#include <gthumb.h>
+
+
+void
+gth_browser_activate_action_burn_disc (GtkAction  *action,
+				       GthBrowser *browser)
+{
+	static gboolean  initialized = FALSE;
+	GList           *items;
+	GList           *file_list;
+
+	if (! initialized) {
+		brasero_media_library_start ();
+		brasero_burn_library_start (NULL, NULL);
+		initialized = TRUE;
+	}
+
+	items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
+	if ((items == NULL) || (items->next == NULL))
+		file_list = gth_file_store_get_visibles (GTH_FILE_STORE (gth_browser_get_file_store (browser)));
+	else
+		file_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);
+
+	{
+		BraseroTrackDataCfg *track;
+		GList               *sidecars;
+		GList               *scan;
+		BraseroSessionCfg   *session;
+		GtkWidget           *dialog;
+		GtkResponseType      result;
+
+		session = brasero_session_cfg_new ();
+		track = brasero_track_data_cfg_new ();
+		brasero_burn_session_add_track (BRASERO_BURN_SESSION (session),
+						BRASERO_TRACK (track),
+						NULL);
+		g_object_unref (track);
+
+		for (scan = file_list; scan; scan = scan->next) {
+			GthFileData *file_data = scan->data;
+			char        *uri;
+
+			uri = g_file_get_uri (file_data->file);
+			brasero_track_data_cfg_add (track, uri, NULL);
+
+			g_free (uri);
+		}
+
+		sidecars = NULL;
+		for (scan = file_list; scan; scan = scan->next) {
+			GthFileData *file_data = scan->data;
+			gth_hook_invoke ("add-sidecars", file_data->file, &sidecars);
+		}
+		sidecars = g_list_reverse (sidecars);
+
+		for (scan = sidecars; scan; scan = scan->next) {
+			GFile *file = scan->data;
+			char  *uri;
+
+			uri = g_file_get_uri (file);
+			brasero_track_data_cfg_add (track, uri, NULL);
+
+			g_free (uri);
+		}
+
+		dialog = brasero_burn_options_new (session);
+		gtk_window_set_icon_name (GTK_WINDOW (dialog), gtk_window_get_icon_name (GTK_WINDOW (browser)));
+		gtk_window_set_title (GTK_WINDOW (dialog), _("Write to Disc"));
+		gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (browser));
+		gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+		result = gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
+
+		if (result == GTK_RESPONSE_OK) {
+			dialog = brasero_burn_dialog_new ();
+			gtk_window_set_icon_name (GTK_WINDOW (dialog), gtk_window_get_icon_name (GTK_WINDOW (browser)));
+			gtk_window_set_title (GTK_WINDOW (dialog), _("Write to Disc"));
+			brasero_session_cfg_disable (session);
+			gtk_window_present (GTK_WINDOW (dialog));
+			brasero_burn_dialog_run (BRASERO_BURN_DIALOG (dialog),
+						 BRASERO_BURN_SESSION (session));
+
+			gtk_widget_destroy (dialog);
+		}
+
+		g_object_unref (session);
+	}
+
+	_g_object_list_unref (file_list);
+	_gtk_tree_path_list_free (items);
+}
diff --git a/extensions/burn_disc/actions.h b/extensions/burn_disc/actions.h
new file mode 100644
index 0000000..b31e526
--- /dev/null
+++ b/extensions/burn_disc/actions.h
@@ -0,0 +1,32 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ *  GThumb
+ *
+ *  Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ *  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., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef ACTIONS_H
+#define ACTIONS_H
+
+#include <gtk/gtk.h>
+
+#define DEFINE_ACTION(x) void x (GtkAction *action, gpointer data);
+
+DEFINE_ACTION(gth_browser_activate_action_burn_disc)
+
+#endif /* ACTIONS_H */
diff --git a/extensions/burn_disc/burn_disc.extension.in.in b/extensions/burn_disc/burn_disc.extension.in.in
new file mode 100644
index 0000000..248d236
--- /dev/null
+++ b/extensions/burn_disc/burn_disc.extension.in.in
@@ -0,0 +1,11 @@
+[Extension]
+_Name=Burn CD/DVD
+_Description=Save files to an optical disc.
+_Authors=gthumb development team
+Copyright=Copyright © 2010 The Free Software Foundation, Inc.
+Version=1.0
+Icon=brasero
+
+[Loader]
+Type=module
+File=%LIBRARY%
\ No newline at end of file
diff --git a/extensions/burn_disc/callbacks.c b/extensions/burn_disc/callbacks.c
new file mode 100644
index 0000000..5c72f24
--- /dev/null
+++ b/extensions/burn_disc/callbacks.c
@@ -0,0 +1,95 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ *  GThumb
+ *
+ *  Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ *  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., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+
+#include <config.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+#include <gthumb.h>
+#include "actions.h"
+#include "callbacks.h"
+
+
+#define BROWSER_DATA_KEY "burn-disc-browser-data"
+
+
+static const char *ui_info =
+"<ui>"
+"  <menubar name='MenuBar'>"
+"    <menu name='File' action='FileMenu'>"
+"      <menu name='Export' action='ExportMenu'>"
+"        <placeholder name='Misc_Actions'>"
+"          <menuitem action='File_Export_BurnDisc'/>"
+"        </placeholder>"
+"      </menu>"
+"    </menu>"
+"  </menubar>"
+"</ui>";
+
+
+static GtkActionEntry action_entries[] = {
+	{ "File_Export_BurnDisc", GTK_STOCK_CDROM,
+	  N_("_Optical Disc..."), NULL,
+	  N_("Write files to an optical disc"),
+	  G_CALLBACK (gth_browser_activate_action_burn_disc) }
+};
+
+
+typedef struct {
+	GtkActionGroup *action_group;
+	guint           actions_merge_id;
+} BrowserData;
+
+
+static void
+browser_data_free (BrowserData *data)
+{
+	g_free (data);
+}
+
+
+void
+bd__gth_browser_construct_cb (GthBrowser *browser)
+{
+	BrowserData *data;
+	GError      *error = NULL;
+
+	g_return_if_fail (GTH_IS_BROWSER (browser));
+
+	data = g_new0 (BrowserData, 1);
+
+	data->action_group = gtk_action_group_new ("Burn Disc Action");
+	gtk_action_group_set_translation_domain (data->action_group, NULL);
+	gtk_action_group_add_actions (data->action_group,
+				      action_entries,
+				      G_N_ELEMENTS (action_entries),
+				      browser);
+	gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), data->action_group, 0);
+
+	data->actions_merge_id = gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), ui_info, -1, &error);
+	if (data->actions_merge_id == 0) {
+		g_warning ("building menus failed: %s", error->message);
+		g_error_free (error);
+	}
+
+	g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free);
+}
diff --git a/extensions/burn_disc/callbacks.h b/extensions/burn_disc/callbacks.h
new file mode 100644
index 0000000..035db90
--- /dev/null
+++ b/extensions/burn_disc/callbacks.h
@@ -0,0 +1,30 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ *  GThumb
+ *
+ *  Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ *  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., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef CALLBACKS_H
+#define CALLBACKS_H
+
+#include <gthumb.h>
+
+void  bd__gth_browser_construct_cb  (GthBrowser *browser);
+
+#endif /* CALLBACKS_H */
diff --git a/extensions/burn_disc/main.c b/extensions/burn_disc/main.c
new file mode 100644
index 0000000..a39f0a0
--- /dev/null
+++ b/extensions/burn_disc/main.c
@@ -0,0 +1,53 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ *  GThumb
+ *
+ *  Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ *  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., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+
+#include <config.h>
+#include <gtk/gtk.h>
+#include <gthumb.h>
+#include "callbacks.h"
+
+
+G_MODULE_EXPORT void
+gthumb_extension_activate (void)
+{
+	gth_hook_add_callback ("gth-browser-construct", 10, G_CALLBACK (bd__gth_browser_construct_cb), NULL);
+}
+
+
+G_MODULE_EXPORT void
+gthumb_extension_deactivate (void)
+{
+}
+
+
+G_MODULE_EXPORT gboolean
+gthumb_extension_is_configurable (void)
+{
+	return FALSE;
+}
+
+
+G_MODULE_EXPORT void
+gthumb_extension_configure (GtkWindow *parent)
+{
+}



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