Commit 5ffab9be authored by Pierre Wieser's avatar Pierre Wieser

Export actions and menus to buffer

parent 4f67441d
2009-03-03 Pierre Wieser <pwieser@trychlos.org>
* po/POTFILES.in: Updated.
* src/api/na-data-types.h
(na_data_types_get_gconf_dump_key): New function.
* src/core/na-data-types.c: New file.
* src/core/Makefile.am: Updated accordingly.
* src/api/na-ifactory-object-data.h:
* src/core/na-object-item-factory.c:
(NAFO_DATA_TYPE): New elementary data.
* src/core/na-ifactory-object.c:
* src/api/na-ifactory-object.h
(na_ifactory_object_get_data_boxed): New function.
* src/core/na-core-utils.c (na_core_utils_dir_is_writable_uri):
Give a better name to the parameter.
* src/core/na-exporter.c:
* src/core/na-exporter.h (na_exporter_to_buffer, na_exporter_to_file):
Reorder of functions in the files.
* src/core/na-factory-object.c:
* src/core/na-factory-object.h:
Now use the new na_ifactory_object_get_data_boxed() function.
* src/core/na-object-action-factory.c:
* src/core/na-object-profile-factory.c:
* src/io-xml/naxml-keys.h:
Move the schema descriptions to data factory.
* src/core/na-object-action.c:
* src/core/na-object-menu.c:
(ifactory_object_read_start): Allocate the 'type' data boxed.
* src/io-gconf/nagp-keys.h: Fix the path of the schemas.
* src/io-xml/naxml-formats.c:
* src/io-xml/naxml-formats.h: New files.
* src/io-xml/Makefile.am: Updated accordingly.
* src/io-xml/naxml-provider.c: Implement NAXMLWriter calls.
* src/io-xml/naxml-writer.c:
* src/io-xml/naxml-writer.h: Export to buffer.
* src/nact/nact-clipboard.c
(nact_clipboard_dnd_drag_end): Fix gtk_selection_data_free() call.
(export_row_object): Also exports menus.
* src/nact/nact-tree-model-dnd.c
(nact_tree_model_dnd_imulti_drag_source_drag_data_get):
Fix and parse the returned URI to get the path of the target folder.
2009-03-01 Pierre Wieser <pwieser@trychlos.org>
* po/POTFILES.in: Add src/core/na-exporter.c file.
......
......@@ -161,3 +161,5 @@
- icon: is defined as localestring in desktop entry spec
but path is defined as string in this same spec
and icon may be a path -> so what to do with this ?
- get_xds_atom_value: test on 64bit platform, then remove debug stuff
......@@ -5,14 +5,16 @@ src/core/na-importer-ask.c
src/core/na-importer-ask.ui
src/core/na-io-provider.c
src/core/na-object-action.c
src/core/na-object-action-factory.c
src/core/na-object-id.c
src/core/na-object-item-factory.c
src/core/na-object-menu.c
src/core/na-object-profile.c
src/core/na-object-profile-factory.c
src/io-desktop/nadp-desktop-provider.c
src/io-gconf/nagp-gconf-provider.c
src/io-xml/naxml-keys.h
src/io-xml/naxml-reader.c
src/io-xml/naxml-provider.c
src/io-xml/naxml-formats.c
src/nact/base-application.c
src/nact/base-assistant.c
src/nact/base-window.c
......
......@@ -71,6 +71,8 @@ enum {
NAFD_TYPE_UINT, /* an unsigned integer */
};
const gchar *na_data_types_get_gconf_dump_key( guint type );
G_END_DECLS
#endif /* __NAUTILUS_ACTIONS_API_NA_FACTORY_DATA_TYPES_H__ */
......@@ -46,6 +46,7 @@ G_BEGIN_DECLS
#define NAFO_DATA_PARENT "na-factory-data-parent"
#define NA_FACTORY_OBJECT_ITEM_GROUP "na-factory-group-item"
#define NAFO_DATA_TYPE "na-factory-data-type"
#define NAFO_DATA_LABEL "na-factory-data-label"
#define NAFO_DATA_TOOLTIP "na-factory-data-tooltip"
#define NAFO_DATA_ICON "na-factory-data-icon"
......
......@@ -49,6 +49,7 @@
*/
#include "na-data-def.h"
#include "na-data-boxed.h"
#include "na-ifactory-provider-provider.h"
G_BEGIN_DECLS
......@@ -172,11 +173,13 @@ typedef struct {
}
NAIFactoryObjectInterface;
GType na_ifactory_object_get_type( void );
GType na_ifactory_object_get_type( void );
void *na_ifactory_object_get_as_void ( const NAIFactoryObject *object, const gchar *name );
NADataBoxed *na_ifactory_object_get_data_boxed( const NAIFactoryObject *object, const gchar *name );
void na_ifactory_object_set_from_void( NAIFactoryObject *object, const gchar *name, const void *data );
void *na_ifactory_object_get_as_void ( const NAIFactoryObject *object, const gchar *name );
void na_ifactory_object_set_from_void ( NAIFactoryObject *object, const gchar *name, const void *data );
#if 0
void na_ifactory_object_set_from_string( NAIFactoryObject *object, guint data_id, const gchar *data );
......
......@@ -41,6 +41,7 @@ AM_CPPFLAGS += \
libna_core_la_SOURCES = \
na-core-utils.c \
na-data-boxed.c \
na-data-types.c \
na-dbus-tracker.h \
na-exporter.c \
na-exporter.h \
......
......@@ -522,7 +522,7 @@ na_core_utils_dir_is_writable_uri( const gchar *uri )
}
static gboolean
info_dir_is_writable( GFile *file, const gchar *path )
info_dir_is_writable( GFile *file, const gchar *path_or_uri )
{
static const gchar *thisfn = "na_core_utils_info_dir_is_writable";
GError *error = NULL;
......@@ -542,14 +542,14 @@ info_dir_is_writable( GFile *file, const gchar *path )
type = g_file_info_get_file_type( info );
if( type != G_FILE_TYPE_DIRECTORY ){
g_debug( "%s: %s is not a directory", thisfn, path );
g_debug( "%s: %s is not a directory", thisfn, path_or_uri );
g_object_unref( info );
return( FALSE );
}
writable = g_file_info_get_attribute_boolean( info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE );
if( !writable ){
g_debug( "%s: %s is not writable", thisfn, path );
g_debug( "%s: %s is not writable", thisfn, path_or_uri );
}
g_object_unref( info );
......
/*
* 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)
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <api/na-data-types.h>
typedef struct {
guint type;
gchar *gconf_dump_key;
}
FactoryType;
static FactoryType st_factory_type[] = {
{ NAFD_TYPE_STRING, "string" },
{ NAFD_TYPE_LOCALE_STRING, "string" },
{ NAFD_TYPE_BOOLEAN, "bool" },
{ NAFD_TYPE_STRING_LIST, "list" },
{ NAFD_TYPE_POINTER, NULL },
{ NAFD_TYPE_UINT, "int" },
{ 0 }
};
/**
* na_data_types_get_gconf_dump_key:
* @type: the FactoryData type.
*
* Returns: the GConf key suitable for this type.
*
* The returned key is owned by FactoryData, and should not be released
* by the caller.
*/
const gchar *
na_data_types_get_gconf_dump_key( guint type )
{
FactoryType *str;
str = st_factory_type;
while( str->type ){
if( str->type == type ){
return( str->gconf_dump_key );
}
str++;
}
return( NULL );
}
......@@ -99,52 +99,62 @@ na_exporter_free_formats( GList *formats )
}
/**
* na_exporter_to_file:
* na_exporter_to_buffer:
* @pivot: the #NAPivot pivot for the running application.
* @item: a #NAObjectItem-derived object.
* @folder: the URI of the target folder.
* @format: the #GQuark target format.
* @messages: a pointer to a #GSList list of strings; the provider
* may append messages to this list, but shouldn't reinitialize it.
*
* Exports the specified @item to the target @uri in the required @format.
* Exports the specified @item in the required @format.
*
* Returns: the URI of the exported file, as a newly allocated string which
* should be g_free() by the caller, or %NULL if an error has been detected.
* Returns: the output buffer, as a newly allocated string which should
* be g_free() by the caller, or %NULL if an error has been detected.
*/
gchar *
na_exporter_to_file( const NAPivot *pivot, const NAObjectItem *item, const gchar *folder, GQuark format, GSList **messages )
na_exporter_to_buffer( const NAPivot *pivot, const NAObjectItem *item, GQuark format, GSList **messages )
{
gchar *export_uri;
NAIExporterFileParms parms;
static const gchar *thisfn = "na_exporter_to_buffer";
gchar *buffer;
NAIExporterBufferParms parms;
NAIExporter *exporter;
gchar *msg;
gchar *name;
gchar *msg;
export_uri = NULL;
g_return_val_if_fail( NA_IS_PIVOT( pivot ), NULL );
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NULL );
g_debug( "%s: pivot=%p, item=%p (%s), format=%u (%s), messages=%p",
thisfn,
( void * ) pivot,
( void * ) item, G_OBJECT_TYPE_NAME( item ),
( guint ) format, g_quark_to_string( format ),
( void * ) messages );
buffer = NULL;
if( iexporter_initialized && !iexporter_finalized ){
exporter = find_exporter_for_format( pivot, format );
g_debug( "%s: exporter=%p (%s)", thisfn, ( void * ) exporter, G_OBJECT_TYPE_NAME( exporter ));
if( exporter ){
parms.version = 1;
parms.exported = ( NAObjectItem * ) item;
parms.folder = ( gchar * ) folder;
parms.format = format;
parms.basename = NULL;
parms.messages = *messages;
parms.buffer = NULL;
parms.messages = messages ? *messages : NULL;
if( NA_IEXPORTER_GET_INTERFACE( exporter )->to_file ){
NA_IEXPORTER_GET_INTERFACE( exporter )->to_file( exporter, &parms );
if( NA_IEXPORTER_GET_INTERFACE( exporter )->to_buffer ){
NA_IEXPORTER_GET_INTERFACE( exporter )->to_buffer( exporter, &parms );
if( parms.basename ){
export_uri = g_strdup_printf( "%s%s%s", folder, G_DIR_SEPARATOR_S, parms.basename );
if( parms.buffer ){
buffer = parms.buffer;
}
} else {
name = exporter_get_name( exporter );
msg = g_strdup_printf( _( "NAIExporter %s doesn't implement 'to_file' interface." ), name );
msg = g_strdup_printf( _( "NAIExporter %s doesn't implement 'to_buffer' interface." ), name );
*messages = g_slist_append( *messages, msg );
g_free( name );
}
......@@ -156,32 +166,45 @@ na_exporter_to_file( const NAPivot *pivot, const NAObjectItem *item, const gchar
}
}
return( export_uri );
return( buffer );
}
/**
* na_exporter_to_buffer:
* na_exporter_to_file:
* @pivot: the #NAPivot pivot for the running application.
* @item: a #NAObjectItem-derived object.
* @folder: the URI of the target folder.
* @format: the #GQuark target format.
* @messages: a pointer to a #GSList list of strings; the provider
* may append messages to this list, but shouldn't reinitialize it.
*
* Exports the specified @item in the required @format.
* Exports the specified @item to the target @uri in the required @format.
*
* Returns: the output buffer, as a newly allocated string which should
* be g_free() by the caller, or %NULL if an error has been detected.
* Returns: the URI of the exported file, as a newly allocated string which
* should be g_free() by the caller, or %NULL if an error has been detected.
*/
gchar *
na_exporter_to_buffer( const NAPivot *pivot, const NAObjectItem *item, GQuark format, GSList **messages )
na_exporter_to_file( const NAPivot *pivot, const NAObjectItem *item, const gchar *folder, GQuark format, GSList **messages )
{
gchar *buffer;
NAIExporterBufferParms parms;
static const gchar *thisfn = "na_exporter_to_file";
gchar *export_uri;
NAIExporterFileParms parms;
NAIExporter *exporter;
gchar *name;
gchar *msg;
gchar *name;
buffer = NULL;
g_return_val_if_fail( NA_IS_PIVOT( pivot ), NULL );
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NULL );
g_debug( "%s: pivot=%p, item=%p (%s), folder=%s, format=%u (%s), messages=%p",
thisfn,
( void * ) pivot,
( void * ) item, G_OBJECT_TYPE_NAME( item ),
folder,
( guint ) format, g_quark_to_string( format ),
( void * ) messages );
export_uri = NULL;
if( iexporter_initialized && !iexporter_finalized ){
......@@ -190,20 +213,21 @@ na_exporter_to_buffer( const NAPivot *pivot, const NAObjectItem *item, GQuark fo
if( exporter ){
parms.version = 1;
parms.exported = ( NAObjectItem * ) item;
parms.folder = ( gchar * ) folder;
parms.format = format;
parms.buffer = NULL;
parms.messages = *messages;
parms.basename = NULL;
parms.messages = messages ? *messages : NULL;
if( NA_IEXPORTER_GET_INTERFACE( exporter )->to_buffer ){
NA_IEXPORTER_GET_INTERFACE( exporter )->to_buffer( exporter, &parms );
if( NA_IEXPORTER_GET_INTERFACE( exporter )->to_file ){
NA_IEXPORTER_GET_INTERFACE( exporter )->to_file( exporter, &parms );
if( parms.buffer ){
buffer = parms.buffer;
if( parms.basename ){
export_uri = g_strdup_printf( "%s%s%s", folder, G_DIR_SEPARATOR_S, parms.basename );
}
} else {
name = exporter_get_name( exporter );
msg = g_strdup_printf( _( "NAIExporter %s doesn't implement 'to_buffer' interface." ), name );
msg = g_strdup_printf( _( "NAIExporter %s doesn't implement 'to_file' interface." ), name );
*messages = g_slist_append( *messages, msg );
g_free( name );
}
......@@ -215,7 +239,7 @@ na_exporter_to_buffer( const NAPivot *pivot, const NAObjectItem *item, GQuark fo
}
}
return( buffer );
return( export_uri );
}
static const NAIExporterFormat *
......
......@@ -46,8 +46,8 @@ G_BEGIN_DECLS
GList *na_exporter_get_formats ( const NAPivot *pivot );
void na_exporter_free_formats( GList *formats );
gchar *na_exporter_to_file ( const NAPivot *pivot, const NAObjectItem *item, const gchar *uri, GQuark format, GSList **messages );
gchar *na_exporter_to_buffer( const NAPivot *pivot, const NAObjectItem *item, GQuark format, GSList **messages );
gchar *na_exporter_to_file ( const NAPivot *pivot, const NAObjectItem *item, const gchar *uri, GQuark format, GSList **messages );
G_END_DECLS
......
......@@ -82,8 +82,6 @@ typedef struct {
}
NafoDefaultIter;
#define NA_IFACTORY_OBJECT_PROP_DATA "na-ifactory-object-prop-data"
extern gboolean ifactory_object_initialized;
extern gboolean ifactory_object_finalized;
......@@ -103,7 +101,6 @@ static guint v_write_start( NAIFactoryObject *serializable, const NAIFact
static guint v_write_done( NAIFactoryObject *serializable, const NAIFactoryProvider *reader, void *reader_data, GSList **messages );
static void attach_boxed_to_object( NAIFactoryObject *object, NADataBoxed *boxed );
static NADataBoxed *data_boxed_from_name( const NAIFactoryObject *object, const gchar *name );
static void free_data_boxed_list( NAIFactoryObject *object );
static void iter_on_data_defs( const NADataGroup *idgroups, gboolean serializable_only, NADataDefIterFunc pfn, void *user_data );
......@@ -291,7 +288,7 @@ set_defaults_iter( NADataDef *def, NafoDefaultIter *data )
if( !def->obsoleted ){
if( def->default_value ){
is_null = TRUE;
boxed = data_boxed_from_name( data->object, def->name );
boxed = na_ifactory_object_get_data_boxed( data->object, def->name );
if( boxed ){
is_null = ( na_data_boxed_get_as_void( boxed ) == NULL );
}
......@@ -370,7 +367,7 @@ na_factory_object_copy( NAIFactoryObject *target, const NAIFactoryObject *source
NADataDef *def = na_data_boxed_get_data_def( src_boxed );
if( def->copyable ){
NADataBoxed *tgt_boxed = data_boxed_from_name( target, def->name );
NADataBoxed *tgt_boxed = na_ifactory_object_get_data_boxed( target, def->name );
if( !tgt_boxed ){
tgt_boxed = na_data_boxed_new( def );
attach_boxed_to_object( target, tgt_boxed );
......@@ -408,7 +405,7 @@ na_factory_object_are_equal( const NAIFactoryObject *a, const NAIFactoryObject *
NADataDef *a_def = na_data_boxed_get_data_def( a_boxed );
if( a_def->comparable ){
NADataBoxed *b_boxed = data_boxed_from_name( b, a_def->name );
NADataBoxed *b_boxed = na_ifactory_object_get_data_boxed( b, a_def->name );
if( b_boxed ){
are_equal = na_data_boxed_are_equal( a_boxed, b_boxed );
if( !are_equal ){
......@@ -428,7 +425,7 @@ na_factory_object_are_equal( const NAIFactoryObject *a, const NAIFactoryObject *
NADataDef *b_def = na_data_boxed_get_data_def( b_boxed );
if( b_def->comparable ){
NADataBoxed *a_boxed = data_boxed_from_name( a, b_def->name );
NADataBoxed *a_boxed = na_ifactory_object_get_data_boxed( a, b_def->name );
if( a_boxed ){
are_equal = na_data_boxed_are_equal( a_boxed, b_boxed );
if( !are_equal ){
......@@ -496,7 +493,7 @@ is_valid_mandatory_iter( const NADataDef *def, NafoValidIter *data )
NADataBoxed *boxed;
if( def->mandatory && !def->obsoleted ){
boxed = data_boxed_from_name( data->object, def->name );
boxed = na_ifactory_object_get_data_boxed( data->object, def->name );
if( !boxed ){
g_debug( "na_factory_object_is_valid_mandatory_iter: invalid %s: mandatory but not set", def->name );
data->is_valid = FALSE;
......@@ -611,7 +608,7 @@ read_data_iter( NADataDef *def, NafoReadIter *iter )
NADataBoxed *boxed = na_factory_provider_read_data( iter->reader, iter->reader_data, iter->object, def, iter->messages );
if( boxed ){
NADataBoxed *exist = data_boxed_from_name( iter->object, def->name );
NADataBoxed *exist = na_ifactory_object_get_data_boxed( iter->object, def->name );
if( exist ){
na_data_boxed_set_from_boxed( exist, boxed );
......@@ -717,7 +714,7 @@ na_factory_object_get_as_value( const NAIFactoryObject *object, const gchar *nam
g_value_unset( value );
boxed = data_boxed_from_name( object, name );
boxed = na_ifactory_object_get_data_boxed( object, name );
if( boxed ){
na_data_boxed_get_as_value( boxed, value );
}
......@@ -745,7 +742,7 @@ na_factory_object_get_as_void( const NAIFactoryObject *object, const gchar *name
value = NULL;
boxed = data_boxed_from_name( object, name );
boxed = na_ifactory_object_get_data_boxed( object, name );
if( boxed ){
value = na_data_boxed_get_as_void( boxed );
}
......@@ -769,7 +766,7 @@ na_factory_object_set_from_value( NAIFactoryObject *object, const gchar *name, c
g_return_if_fail( NA_IS_IFACTORY_OBJECT( object ));
NADataBoxed *boxed = data_boxed_from_name( object, name );
NADataBoxed *boxed = na_ifactory_object_get_data_boxed( object, name );
if( boxed ){
na_data_boxed_set_from_value( boxed, value );
......@@ -801,7 +798,7 @@ na_factory_object_set_from_void( NAIFactoryObject *object, const gchar *name, co
g_return_if_fail( NA_IS_IFACTORY_OBJECT( object ));
NADataBoxed *boxed = data_boxed_from_name( object, name );
NADataBoxed *boxed = na_ifactory_object_get_data_boxed( object, name );
if( boxed ){
na_data_boxed_set_from_void( boxed, data );
......@@ -916,26 +913,6 @@ attach_boxed_to_object( NAIFactoryObject *object, NADataBoxed *boxed )
g_object_set_data( G_OBJECT( object ), NA_IFACTORY_OBJECT_PROP_DATA, list );
}
static NADataBoxed *
data_boxed_from_name( const NAIFactoryObject *object, const gchar *name )
{
GList *list, *ip;
list = g_object_get_data( G_OBJECT( object ), NA_IFACTORY_OBJECT_PROP_DATA );
/*g_debug( "list=%p (count=%u)", ( void * ) list, g_list_length( list ));*/
for( ip = list ; ip ; ip = ip->next ){
NADataBoxed *boxed = NA_DATA_BOXED( ip->data );
NADataDef *def = na_data_boxed_get_data_def( boxed );
if( !strcmp( def->name, name )){
return( boxed );
}
}
return( NULL );
}
static void
free_data_boxed_list( NAIFactoryObject *object )
{
......
......@@ -46,6 +46,8 @@ G_BEGIN_DECLS
typedef gboolean ( *NAFactoryObjectIterBoxedFn )( const NAIFactoryObject *object, NADataBoxed *boxed, void *data );
#define NA_IFACTORY_OBJECT_PROP_DATA "na-ifactory-object-prop-data"
void na_factory_object_define_properties( GObjectClass *class, const NADataGroup *groups );
NADataDef *na_factory_object_get_data_def ( const NAIFactoryObject *object, const gchar *name );
NADataGroup *na_factory_object_get_data_groups ( const NAIFactoryObject *object );
......
......@@ -235,6 +235,42 @@ na_ifactory_object_get_data_def_from_gconf_key( const NAIFactoryObject *object,
}
#endif
/**
* na_ifactory_object_get_data_boxed:
* @object: a #NAIFactoryObject object.
* @name: the name of the elementary data we are searching for.
*
* Returns: The #NADataBoxed object which contains the specified data,
* or %NULL.
*
* The returned #NADataBoxed is owned by #NAIFactoryObject @object, and
* should not be released by the caller.
*/
NADataBoxed *
na_ifactory_object_get_data_boxed( const NAIFactoryObject *object, const gchar *name )
{
GList *list, *ip;
g_return_val_if_fail( NA_IS_IFACTORY_OBJECT( object ), NULL );
if( ifactory_object_initialized && !ifactory_object_finalized ){
list = g_object_get_data( G_OBJECT( object ), NA_IFACTORY_OBJECT_PROP_DATA );
/*g_debug( "list=%p (count=%u)", ( void * ) list, g_list_length( list ));*/
for( ip = list ; ip ; ip = ip->next ){
NADataBoxed *boxed = NA_DATA_BOXED( ip->data );
NADataDef *def = na_data_boxed_get_data_def( boxed );
if( !strcmp( def->name, name )){
return( boxed );
}
}
}
return( NULL );
}
/**
* na_ifactory_object_get_as_void:
* @object: this #NAIFactoryObject instance.
......
......@@ -32,6 +32,8 @@
#include <config.h>
#endif
#include <glib/gi18n.h>
#include <api/na-ifactory-object-data.h>
#include <api/na-data-def.h>
#include <api/na-data-types.h>
......@@ -43,8 +45,9 @@ static NADataDef data_def_action [] = {
{ NAFO_DATA_VERSION,
TRUE,
"Action version",
"Version of the action",
N_( "Version of the format" ),
N_( "The version of the configuration format that will be used to manage " \
"backward compatibility." ),
NAFD_TYPE_STRING,
"2.0",
TRUE,
......@@ -56,8 +59,10 @@ static NADataDef data_def_action [] = {
{ NAFO_DATA_TARGET_SELECTION,
TRUE,
"Target a selection context menu",
"Does the action target the context menu when there is some selection ?",
N_( "Targets the context menu" ),
N_( "Whether the action of the menu targets the selection file manager " \
"context menus.\n" \
"This used to be the historical behavior."),
NAFD_TYPE_BOOLEAN,
"true",
TRUE,
......@@ -82,10 +87,9 @@ static NADataDef data_def_action [] = {
{ NAFO_DATA_TARGET_TOOLBAR,
TRUE,
"Target the toolbar",
"Does the action target the toolbar ? " \
"Only an action may target the toolbar as Nautilus, as of 2.28, " \
"doesn't support menus in toolbar.",
N_( "Targets the toolbar" ),
N_( "Whether the action is candidate to be displayed in file manager toolbar.\n" \
"Note, that as of Nautilus 2.26, menus can not be candidate to toolbar display." ),
NAFD_TYPE_BOOLEAN,
"false",
TRUE,
......@@ -97,9 +101,10 @@ static NADataDef data_def_action [] = {
{ NAFO_DATA_TOOLBAR_LABEL,
TRUE,
"Toolbar label",
"Label of the action in the toolbar. " \
"Defaults to main label if empty or not set.",
N_( "Label of the toolbar item" ),
N_( "The label displayed besides of the icon in the file manager toolbar.\n" \
"Note that actual display may depend of your own Desktop Environment preferences.\n" \
"Defaults to label of the context menu when not set or empty."),
NAFD_TYPE_LOCALE_STRING,
"",
TRUE,
......
......@@ -84,6 +84,7 @@ static guint ifactory_object_get_version( const NAIFactoryObject *instanc
static NADataGroup *ifactory_object_get_groups( const NAIFactoryObject *instance );
static gboolean ifactory_object_are_equal( const NAIFactoryObject *a, const NAIFactoryObject *b );
static gboolean ifactory_object_is_valid( const NAIFactoryObject *object );
static void ifactory_object_read_start( NAIFactoryObject *instance, const NAIFactoryProvider *reader, void *reader_data, GSList **messages );
static void ifactory_object_read_done( NAIFactoryObject *instance, const NAIFactoryProvider *reader, void *reader_data, GSList **messages );
static guint ifactory_object_write_start( NAIFactoryObject *instance, const NAIFactoryProvider *writer, void *writer_data, GSList **messages );
static guint ifactory_object_write_done( NAIFactoryObject *instance, const NAIFactoryProvider *writer, void *writer_data, GSList **messages );
......@@ -284,7 +285,7 @@ ifactory_object_iface_init( NAIFactoryObjectInterface *iface )
iface->copy = NULL;
iface->are_equal = ifactory_object_are_equal;
iface->is_valid = ifactory_object_is_valid;
iface->read_start = NULL;
iface->read_start = ifactory_object_read_start;
iface->read_done = ifactory_object_read_done;
iface->write_start = ifactory_object_write_start;
iface->write_done = ifactory_object_write_done;
......@@ -316,6 +317,14 @@ ifactory_object_is_valid( const NAIFactoryObject *object )
return( object_object_is_valid( NA_OBJECT_ACTION( object )));
}
static void
ifactory_object_read_start( NAIFactoryObject *instance, const NAIFactoryProvider *reader, void *reader_data, GSList **messages )
{
/* create the 'type' data box to be available later when writing/exporting
*/
na_ifactory_object_set_from_void( instance, NAFO_DATA_TYPE, ( void * ) "Action" );
}
static void
ifactory_object_read_done( NAIFactoryObject *instance, const NAIFactoryProvider *reader, void *reader_data, GSList **messages )
{
......
......@@ -32,17 +32,40 @@
#include <config.h>
#endif
#include <glib/gi18n.h>
#include <api/na-ifactory-object-data.h>
#include <api/na-data-def.h>
#include <api/na-data-types.h>
NADataDef data_def_item [] = {
/* this data is marked as 'non-serializable'
* this means it will not be automatically readen/written or imported/exported
* the corresponding NADataBoxed is created at read_start() time
*/
{ NAFO_DATA_TYPE,
FALSE,
N_( "Type of the item" ),
N_( "Defines if the item is an action or a menu. Possible values are :\n" \
"- 'Action',\n" \
"- 'Menu'.\n" \
"The value is case sensitive and must not be localized." ),
NAFD_TYPE_LOCALE_STRING,
NULL,
TRUE,
FALSE,
FALSE,
FALSE,
"type",
FALSE },