nautilus-sendto r394 - in trunk: . src/plugins src/plugins/nautilus-burn src/plugins/removable-devices



Author: hadess
Date: Fri Feb  6 16:02:13 2009
New Revision: 394
URL: http://svn.gnome.org/viewvc/nautilus-sendto?rev=394&view=rev

Log:
2009-02-06  Bastien Nocera  <hadess hadess net>

	* src/plugins/nst-common.c (copy_fobject), (copy_files_to):
	* src/plugins/nst-common.h: Add helper functions to copy
	files (or directories) recursively to a destination

	* configure.in: Changes for the above, and do enable the
	burn plugin when dependencies are available

	* src/plugins/Makefile.am: Changes for the above

	* src/plugins/removable-devices/Makefile.am:
	* src/plugins/removable-devices/removable-devices.c (send_files):
	Use the helper function

	* src/plugins/nautilus-burn/Makefile.am:
	* src/plugins/nautilus-burn/nautilus-burn.c (send_files):
	Use the helper function, and launch nautilus to show burn:///
	after copying the files

	(Closes: #556774)



Added:
   trunk/src/plugins/nst-common.c
   trunk/src/plugins/nst-common.h
Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/src/plugins/Makefile.am
   trunk/src/plugins/nautilus-burn/Makefile.am
   trunk/src/plugins/nautilus-burn/nautilus-burn.c
   trunk/src/plugins/removable-devices/Makefile.am
   trunk/src/plugins/removable-devices/removable-devices.c

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Fri Feb  6 16:02:13 2009
@@ -202,7 +202,7 @@
 		nautilus-burn)
 			# Disabled by default, see bug #556774
 			PKG_CHECK_MODULES(GIO, gio-2.0,
-					  enable_burn=no, enable_burn=no)
+					  enable_burn=yes, enable_burn=no)
 			if test "${enable_burn}" != "yes" ; then
 				plugin_error_or_ignore "you need gio installed for the nautilus-burn plugin"
 				add_plugin="0"
@@ -285,6 +285,13 @@
 AM_CONDITIONAL(HAVE_GAIM, test "x$enable_gaim" = "xyes")
 AM_CONDITIONAL(HAVE_PIDGIN, test "x$enable_pidgin" = "xyes")
 
+dnl For the GIO based plugins
+enable_nst_common=no
+if test "x$enable_burn" = "xyes" -o "x$enable_removable" = "xyes"; then
+	enable_nst_common=yes
+fi
+AM_CONDITIONAL(HAVE_GIO, test "x$enable_nst_common" = "xyes")
+
 GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
 AC_SUBST(GLIB_GENMARSHAL)
 

Modified: trunk/src/plugins/Makefile.am
==============================================================================
--- trunk/src/plugins/Makefile.am	(original)
+++ trunk/src/plugins/Makefile.am	Fri Feb  6 16:02:13 2009
@@ -1,3 +1,13 @@
-SUBDIRS = $(PLUGINS)
+SUBDIRS = . $(PLUGINS)
 DIST_SUBDIRS = $(ALL_PLUGINS)
 
+NST_COMMON_SOURCES = nst-common.c nst-common.h
+
+if HAVE_GIO
+noinst_LTLIBRARIES = libnstcommon.la
+libnstcommon_la_SOURCES = $(NST_COMMON_SOURCES)
+libnstcommon_la_CFLAGS = $(GIO_CFLAGS)
+libnstcommon_la_LIBADD = $(GIO_LIBS)
+endif
+
+EXTRA_DIST = $(NST_COMMON_SOURCES)

Modified: trunk/src/plugins/nautilus-burn/Makefile.am
==============================================================================
--- trunk/src/plugins/nautilus-burn/Makefile.am	(original)
+++ trunk/src/plugins/nautilus-burn/Makefile.am	Fri Feb  6 16:02:13 2009
@@ -6,6 +6,7 @@
 	-DLOCALEDIR="\"$(datadir)/locale\""	\
         -I$(top_srcdir)/src                     \
         -I$(top_builddir)                       \
+        -I$(srcdir)/../				\
         -DGLADEDIR=\""$(gladedir)"\"            \
         $(NAUTILUS_SENDTO_CFLAGS)               \
 	$(WARN_CFLAGS)				\
@@ -15,5 +16,5 @@
 
 libnstburn_la_SOURCES = nautilus-burn.c
 libnstburn_la_LDFLAGS = -module -avoid-version
-libnstburn_la_LIBADD = $(GIO_LIBS)
+libnstburn_la_LIBADD = $(GIO_LIBS) $(builddir)/../libnstcommon.la
 

Modified: trunk/src/plugins/nautilus-burn/nautilus-burn.c
==============================================================================
--- trunk/src/plugins/nautilus-burn/nautilus-burn.c	(original)
+++ trunk/src/plugins/nautilus-burn/nautilus-burn.c	Fri Feb  6 16:02:13 2009
@@ -24,6 +24,7 @@
 #include "config.h"
 #include <string.h>
 #include <glib/gi18n-lib.h>
+#include "nst-common.h"
 #include "nautilus-sendto-plugin.h"
 
 #define COMBOBOX_OPTION_EXISTING_DVD 0
@@ -116,8 +117,7 @@
 {
 	GFileEnumerator *fenum;
 	GFileInfo *file_info;
-	GFile *child, *destination;
-	GList *l;
+	GFile *child;
 
 	if (GTK_IS_COMBO_BOX (burntype_widget) &&
 	    gtk_combo_box_get_active (GTK_COMBO_BOX (burntype_widget)) == COMBOBOX_OPTION_NEW_DVD) {
@@ -140,30 +140,9 @@
 		}
 	}
 
-	for (l = file_list ; l; l=l->next) {
-		child = g_file_new_for_uri ((const char *)l->data);
-		file_info = g_file_query_info (child,
-					       G_FILE_ATTRIBUTE_STANDARD_NAME,
-					       G_FILE_QUERY_INFO_NONE,
-					       NULL,
-					       NULL);
-
-		if (file_info != NULL) {
-			destination = g_file_get_child(burn, 
-						       g_file_info_get_name(file_info));
-			g_object_unref(file_info);
-
-			g_file_copy (child,
-				     destination,
-				     G_FILE_COPY_OVERWRITE,
-				     NULL,
-				     NULL,
-				     NULL,
-				     NULL);
-			g_object_unref (destination);
-		}
-		g_object_unref (child);
-	}
+	copy_files_to (file_list, burn);
+
+	gtk_show_uri (NULL, "burn:///", GDK_CURRENT_TIME, NULL);
 
 	return TRUE;
 }

Added: trunk/src/plugins/nst-common.c
==============================================================================
--- (empty file)
+++ trunk/src/plugins/nst-common.c	Fri Feb  6 16:02:13 2009
@@ -0,0 +1,98 @@
+/*
+ *
+ * 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 av.
+ *
+ * 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ *
+ * Author:  Maxim Ermilov <ermilov maxim gmail com>
+ */
+
+#include <gio/gio.h>
+
+static gboolean
+copy_fobject (GFile* source, GFile* dst)
+{
+	GFileEnumerator* en;
+	GFileInfo* info;
+	GError *err = NULL;
+	char *file_name;
+	GFile *dest;
+
+	file_name = g_file_get_basename (source);
+	dest = g_file_get_child (dst, file_name);
+	g_free (file_name);
+
+	if (g_file_query_file_type (source, G_FILE_QUERY_INFO_NONE, NULL) != G_FILE_TYPE_DIRECTORY) {
+		gboolean ret;
+		ret = g_file_copy (source, dest, G_FILE_COPY_NONE, NULL, NULL, NULL, NULL);
+
+		g_object_unref (dest);
+
+		return ret;
+	}
+
+	en = g_file_enumerate_children (source, "*", G_FILE_QUERY_INFO_NONE, NULL, NULL);
+	if (!g_file_make_directory (dest, NULL, NULL)) {
+		g_object_unref (en);
+		g_object_unref (dest);
+		return FALSE;
+	}
+
+	while ((info = g_file_enumerator_next_file (en, NULL, &err)) != NULL) {
+		const char *name;
+
+		name = g_file_info_get_name (G_FILE_INFO (info));
+
+		if (name != NULL) {
+			GFile *child;
+
+			child = g_file_get_child (source, name);
+
+			if (!copy_fobject (child, dest)) {
+				g_object_unref (en);
+				g_object_unref (dest);
+				g_object_unref (child);
+
+				return FALSE;
+			}
+			g_object_unref (child);
+		}
+
+		g_object_unref (info);
+	}
+	g_object_unref (en);
+	g_object_unref (dest);
+
+	if (err != NULL)
+		return FALSE;
+	return TRUE;
+}
+
+gboolean
+copy_files_to (GList *file_list, GFile *dest)
+{
+	GList *l;
+	gboolean retval = TRUE;
+
+	for (l = file_list; l != NULL; l = l->next) {
+		GFile *source;
+
+		source = g_file_new_for_commandline_arg (l->data);
+		if (copy_fobject (source, dest) == FALSE)
+			retval = FALSE;
+		g_object_unref (source);
+	}
+
+	return retval;
+}

Added: trunk/src/plugins/nst-common.h
==============================================================================
--- (empty file)
+++ trunk/src/plugins/nst-common.h	Fri Feb  6 16:02:13 2009
@@ -0,0 +1,23 @@
+/*
+ *
+ * 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 av.
+ *
+ * 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ *
+ * Author:  Maxim Ermilov <ermilov maxim gmail com>
+ */
+
+#include <gio/gio.h>
+
+gboolean copy_files_to (GList *file_list, GFile *dest);

Modified: trunk/src/plugins/removable-devices/Makefile.am
==============================================================================
--- trunk/src/plugins/removable-devices/Makefile.am	(original)
+++ trunk/src/plugins/removable-devices/Makefile.am	Fri Feb  6 16:02:13 2009
@@ -6,6 +6,7 @@
 	-DLOCALEDIR="\"$(datadir)/locale\""	\
         -I$(top_srcdir)/src                     \
         -I$(top_builddir)                       \
+        -I$(srcdir)/../				\
         -DGLADEDIR=\""$(gladedir)"\"            \
         $(NAUTILUS_SENDTO_CFLAGS)               \
 	$(WARN_CFLAGS)
@@ -14,5 +15,5 @@
 
 libnstremovable_devices_la_SOURCES = removable-devices.c
 libnstremovable_devices_la_LDFLAGS = -module -avoid-version
-libnstremovable_devices_la_LIBADD = $(DBUS_LIBS)
+libnstremovable_devices_la_LIBADD = $(GIO_LIBS) $(builddir)/../libnstcommon.la
 

Modified: trunk/src/plugins/removable-devices/removable-devices.c
==============================================================================
--- trunk/src/plugins/removable-devices/removable-devices.c	(original)
+++ trunk/src/plugins/removable-devices/removable-devices.c	Fri Feb  6 16:02:13 2009
@@ -23,6 +23,7 @@
 #include <string.h>
 #include <glib/gi18n-lib.h>
 #include <gio/gio.h>
+#include "nst-common.h"
 #include "nautilus-sendto-plugin.h"
 
 enum {
@@ -180,92 +181,24 @@
 }
 
 static gboolean
-copy_fobject (GFile* source, GFile* dst)
-{
-	GFileEnumerator* en;
-	GFileInfo* info;
-	GError *err = NULL;
-	char *file_name;
-	GFile *dest;
-
-	file_name = g_file_get_basename (source);
-	dest = g_file_get_child (dst, file_name);
-	g_free (file_name);
-
-	if (g_file_query_file_type (source, G_FILE_QUERY_INFO_NONE, NULL) != G_FILE_TYPE_DIRECTORY) {
-		gboolean ret;
-		ret = g_file_copy (source, dest, G_FILE_COPY_NONE, NULL, NULL, NULL, NULL);
-
-		g_object_unref (dest);
-
-		return ret;
-	}
-
-	en = g_file_enumerate_children (source, "*", G_FILE_QUERY_INFO_NONE, NULL, NULL);
-	if (!g_file_make_directory (dest, NULL, NULL)) {
-		g_object_unref (en);
-		g_object_unref (dest);
-		return FALSE;
-	}
-
-	while ((info = g_file_enumerator_next_file (en, NULL, &err)) != NULL) {
-		const char *name;
-
-		name = g_file_info_get_name (G_FILE_INFO (info));
-
-		if (name != NULL) {
-			GFile *child;
-
-			child = g_file_get_child (source, name);
-
-			if (!copy_fobject (child, dest)) {
-				g_object_unref (en);
-				g_object_unref (dest);
-				g_object_unref (child);
-
-				return FALSE;
-			}
-			g_object_unref (child);
-		}
-
-		g_object_unref (info);
-	}
-	g_object_unref (en);
-	g_object_unref (dest);
-
-	if (err != NULL)
-		return FALSE;
-	return TRUE;
-}
-
-static gboolean
 send_files (NstPlugin *plugin, GtkWidget *contact_widget,
 	    GList *file_list)
 {
 	GtkListStore *store;
 	GtkTreeIter iter;
 	GMount *dest_mount;
-	GFile *vol_root;
-	GList *l;
+	GFile *mount_root;
 
 	if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (contact_widget), &iter) == FALSE)
 		return TRUE;
 
 	store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (cb)));
 	gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, MOUNT_COL, &dest_mount, -1);
-	vol_root = g_mount_get_root (dest_mount);
-
-	for (l = file_list; l != NULL; l = l->next) {
-		GFile *source;
+	mount_root = g_mount_get_root (dest_mount);
 
-		source = g_file_new_for_commandline_arg (l->data);
-
-		copy_fobject (source, vol_root);
-
-		g_object_unref (source);
-	}
+	copy_files_to (file_list, mount_root);
 
-	g_object_unref (vol_root);
+	g_object_unref (mount_root);
 
 	return TRUE;
 }



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