[nautilus-actions] Let default I/O provider be configurable by the packager



commit 14337a6146817863ac400123438ea3dc785d5f65
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Dec 1 22:21:49 2010 +0100

    Let default I/O provider be configurable by the packager

 ChangeLog                    |    8 +++++
 configure.ac                 |    7 +++-
 m4/na-default-io-provider.m4 |   64 ++++++++++++++++++++++++++++++++++++++++++
 src/core/na-io-provider.c    |    9 +++++-
 4 files changed, 85 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3a4735d..2311ac1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2010-12-01 Pierre Wieser <pwieser trychlos org>
 
+	* configure.ac: call new NA_SET_DEFAULT_IO_PROVIDER macro.
+
+	* m4/na-default-io-provider.m4: New file.
+
+	* src/core/na-io-provider.c (na_io_provider_get_providers_list):
+	Used the configured default I/O provider when no preference has been
+	yet registered.
+
 	* configure.ac:
 	- Pre-release bump version number.
 	- Define NAUTILUS_ACTIONS_DEBUG variable.
diff --git a/configure.ac b/configure.ac
index b1d3a42..0789147 100644
--- a/configure.ac
+++ b/configure.ac
@@ -167,8 +167,11 @@ NA_LOG_DOMAINS
 # add --enable-html-manuals and --enable-pdf-manuals configure options
 NA_ENABLE_MANUALS
 
-# when working in a test environment, nautilus is typically installed in
-# a non-standard location ; lets specify this here
+# add --with-default-io-provider option
+NA_SET_DEFAULT_IO_PROVIDER([desktop])
+
+# when working in a test environment, nautilus extensions are typically
+# installed in a non-standard location ; lets specify them here
 NA_NAUTILUS_EXTDIR
 
 # define NA_MAINTAINER_MODE variable
diff --git a/m4/na-default-io-provider.m4 b/m4/na-default-io-provider.m4
new file mode 100644
index 0000000..1d9cf8a
--- /dev/null
+++ b/m4/na-default-io-provider.m4
@@ -0,0 +1,64 @@
+# Nautilus Actions
+# A Nautilus extension which offers configurable context menu actions.
+#
+# Copyright (C) 2005 The GNOME Foundation
+# Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+# Copyright (C) 2009, 2010 Pierre Wieser and others (see AUTHORS)
+#
+# 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 Library; see the file COPYING.  If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307, USA.
+#
+# Authors:
+#   Frederic Ruaudel <grumz grumz net>
+#   Rodrigo Moya <rodrigo gnome-db org>
+#   Pierre Wieser <pwieser trychlos org>
+#   ... and many others (see AUTHORS)
+
+# serial 1 creation
+
+dnl --with-default-io-provider=gconf|desktop
+dnl   Defines the default I/O Provider when creating a new action
+dnl   Default to 'desktop'
+dnl
+dnl usage:  NA_SET_DEFAULT_IO_PROVIDER([default_io_provider])
+dnl
+dnl ac_define NA_DEFAULT_IO_PROVIDER variable
+
+AC_DEFUN([NA_SET_DEFAULT_IO_PROVIDER],[
+	_AC_ARG_NA_WITH_DEFAULT_IO_PROVIDER([$1])
+	_CHECK_FOR_DEFAULT_IO_PROVIDER
+])
+
+AC_DEFUN([_AC_ARG_NA_WITH_DEFAULT_IO_PROVIDER],[
+	AC_ARG_WITH(
+		[default-io-provider],
+		AS_HELP_STRING(
+			[--with-default-io-provider@<:@=gconf|desktop@:>@],
+			[define default I/O provider  @<:@$1@:>@]),
+			[with_default_io_provider=$withval],
+			[with_default_io_provider="$1"])
+])
+
+AC_DEFUN([_CHECK_FOR_DEFAULT_IO_PROVIDER],[
+	AC_MSG_CHECKING([for default I/O provider on new actions])
+	AC_MSG_RESULT([${with_default_io_provider}])
+	if test "x${with_default_io_provider}" != "xgconf"; then
+		if test "x${with_default_io_provider}" != "xdesktop"; then
+			AC_MSG_ERROR([a default I/O provider must be specified, must be 'gconf' or 'desktop'])
+		fi
+	fi
+
+	AC_DEFINE_UNQUOTED([NA_DEFAULT_IO_PROVIDER],["na-${with_default_io_provider}"],[Default I/O Provider])
+])
diff --git a/src/core/na-io-provider.c b/src/core/na-io-provider.c
index 110da1d..473d5fb 100644
--- a/src/core/na-io-provider.c
+++ b/src/core/na-io-provider.c
@@ -330,7 +330,14 @@ na_io_provider_get_providers_list( const NAPivot *pivot )
 
 		order = na_iprefs_read_string_list( NA_IPREFS( pivot ), IO_PROVIDER_KEY_ORDER, NULL );
 
-		g_debug( "%s: dumping providers order", thisfn );
+		if( g_slist_length( order ) > 0 ){
+			g_debug( "%s: dumping providers order", thisfn );
+
+		} else {
+			g_debug( "%s: initializing empty list with default I/O provider", thisfn );
+			order = g_slist_append( order, g_strdup( NA_DEFAULT_IO_PROVIDER ));
+		}
+
 		na_core_utils_slist_dump( thisfn, order );
 
 		setup_io_providers( pivot, order );



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