Commit f12b7344 authored by Pierre Wieser's avatar Pierre Wieser

Convert pre-v3 parameters

parent c0f30323
......@@ -45,6 +45,30 @@
* src/utils/nautilus-actions-run.c:
Mark two new strings for translation.
2010-05-12 Pierre Wieser <pwieser@trychlos.org>
* src/api/na-icontext.h:
* src/core/na-icontext.c
(na_icontext_have_all_mimetypes): Removed function.
(na_icontext_read_done): New function.
* src/core/na-object-action.c:
* src/core/na-object-menu.c:
* src/core/na-object-profile.c: Updated accordingly.
* src/api/na-object-api.h
(na_object_get_iversion, na_object_set_iversion): New functions.
* src/core/na-icontext-factory.c:
* src/core/na-object-item-factory.c:
Adjustments on default values.
* src/io-gconf/nagp-reader.c (read_done_profile_attach_profile):
Convert pre-v3 parameters.
* src/plugin-menu/nautilus-actions.c:
Adjust NautilusMenuProvider interface.
2010-05-10 Pierre Wieser <pwieser@trychlos.org>
Monitor .desktop files and directories.
......
......@@ -86,9 +86,10 @@ GType na_icontext_get_type( void );
gboolean na_icontext_is_candidate( const NAIContext *object, guint target, GList *selection );
gboolean na_icontext_is_valid ( const NAIContext *object );
void na_icontext_have_all_mimetypes( NAIContext *object );
void na_icontext_set_scheme ( NAIContext *object, const gchar *scheme, gboolean selected );
void na_icontext_replace_folder ( NAIContext *object, const gchar *old, const gchar *new );
void na_icontext_read_done ( NAIContext *object );
void na_icontext_set_scheme ( NAIContext *object, const gchar *scheme, gboolean selected );
void na_icontext_replace_folder( NAIContext *object, const gchar *old, const gchar *new );
G_END_DECLS
......
......@@ -105,6 +105,7 @@ G_BEGIN_DECLS
#define na_object_is_readonly( obj ) (( gboolean ) GPOINTER_TO_UINT( na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_READONLY )))
#define na_object_get_provider( obj ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_PROVIDER )
#define na_object_get_provider_data( obj ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_PROVIDER_DATA )
#define na_object_get_iversion( obj ) GPOINTER_TO_UINT( na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_IVERSION ))
#define na_object_set_tooltip( obj, tooltip ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_TOOLTIP, ( const void * )( tooltip ))
#define na_object_set_icon( obj, icon ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_ICON, ( const void * )( icon ))
......@@ -115,6 +116,7 @@ G_BEGIN_DECLS
#define na_object_set_readonly( obj, readonly ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_READONLY, ( const void * ) GUINT_TO_POINTER( readonly ))
#define na_object_set_provider( obj, provider ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_PROVIDER, ( const void * )( provider ))
#define na_object_set_provider_data( obj, data ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_PROVIDER_DATA, ( const void * )( data ))
#define na_object_set_iversion( obj, version ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_IVERSION, ( const void * ) GUINT_TO_POINTER( version ))
#define na_object_get_item( obj, id ) na_object_item_get_item( NA_OBJECT_ITEM( obj ),( const gchar * )( id ))
#define na_object_get_position( obj, child ) na_object_item_get_position( NA_OBJECT_ITEM( obj ), NA_OBJECT_ID( child ))
......
......@@ -103,9 +103,9 @@ NADataDef data_def_conditions [] = {
"selected file(s)/folder(s). Each selected items must match at least one of " \
"the mimetype patterns for the action to appear.\n" \
"This obviously only applies when there is a selection.\n" \
"Defaults to '*'." ),
"Defaults to '*/*'." ),
NAFD_TYPE_STRING_LIST,
"[*]",
"[*/*]",
TRUE,
TRUE,
FALSE,
......@@ -131,11 +131,11 @@ NADataDef data_def_conditions [] = {
FALSE,
TRUE,
"Does the mimetypes list is generic ?",
"The generic wildcard may be coded as '*', or '*/*' or 'all' or 'all/*'."
"The generic wildcard may be coded as '*', or '*/*' or 'all' or 'all/*' or 'all/all'."
"In each case, we will try to spend as less time as possible to check " \
"selection mimetypes",
NAFD_TYPE_BOOLEAN,
"false",
"true",
TRUE,
TRUE,
FALSE,
......
......@@ -83,6 +83,7 @@ static gboolean is_valid_isfiledir( const NAIContext *object );
static gboolean is_valid_schemes( const NAIContext *object );
static gboolean is_valid_folders( const NAIContext *object );
static void check_for_all_mimetypes( NAIContext *context );
static gboolean is_positive_assertion( const gchar *assertion );
static gboolean validate_schemes( GSList *object_schemes, NASelectedInfo *iter );
......@@ -175,6 +176,10 @@ interface_base_finalize( NAIContextInterface *klass )
* the Nautilus context menu, depending of the list of currently selected
* items.
*
* This function is called by nautilus-actions::build_nautilus_menus()
* for each item found in NAPivot items list, and, when this an action,
* for each profile of this action.
*
* Returns: %TRUE if this object succeeds to all tests and is so a
* valid candidate to be displayed in Nautilus context menu, %FALSE
* else.
......@@ -182,10 +187,14 @@ interface_base_finalize( NAIContextInterface *klass )
gboolean
na_icontext_is_candidate( const NAIContext *object, guint target, GList *files )
{
static const gchar *thisfn = "na_icontext_is_candidate";
gboolean is_candidate;
g_return_val_if_fail( NA_IS_ICONTEXT( object ), FALSE );
g_debug( "%s: object=%p (%s), target=%d, files=%p (count=%d)",
thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ), target, (void * ) files, g_list_length( files ));
is_candidate = v_is_candidate( NA_ICONTEXT( object ), target, files );
if( is_candidate ){
......@@ -253,37 +262,15 @@ na_icontext_is_valid( const NAIContext *object )
}
/**
* na_icontext_have_all_mimetypes:
* @context: the #NAIContext object to be checked.
* na_icontext_read_done:
* @context: the #NAIContext to be prepared.
*
* Check if this object is valid for all mimetypes. This is done at load
* time, and let us spend as less time as possible when testing for
* candidates.
* Prepares the specified #NAIContext just after it has been readen.
*/
void
na_icontext_have_all_mimetypes( NAIContext *object )
na_icontext_read_done( NAIContext *context )
{
gboolean all = TRUE;
GSList *mimetypes = na_object_get_mimetypes( object );
GSList *im;
for( im = mimetypes ; im ; im = im->next ){
if( !im->data || !strlen( im->data )){
continue;
}
const gchar *imtype = ( const gchar * ) im->data;
if( !strcmp( imtype, "*" ) ||
!strcmp( imtype, "*/*" ) ||
!strcmp( imtype, "all" ) ||
!strcmp( imtype, "all/*" ) ||
!strcmp( imtype, "all/all" )){
continue;
}
all = FALSE;
break;
}
na_object_set_all_mimetypes( object, all );
check_for_all_mimetypes( context );
}
/**
......@@ -380,9 +367,14 @@ is_candidate_for_target( const NAIContext *object, guint target, GList *files )
default:
g_warning( "%s: unknonw target=%d", thisfn, target );
ok = FALSE;
}
}
if( !ok ){
g_debug( "%s: object is not candidate because target doesn't match (asked=%d)", thisfn, target );
}
return( ok );
}
......@@ -393,10 +385,24 @@ is_candidate_for_target( const NAIContext *object, guint target, GList *files )
static gboolean
is_candidate_for_show_in( const NAIContext *object, guint target, GList *files )
{
static const gchar *thisfn = "na_icontext_is_candidate_for_show_in";
gboolean ok = TRUE;
GSList *only_in = na_object_get_only_show_in( object );
GSList *not_in = na_object_get_not_show_in( object );
/* TODO: how-to get current running environment ? */
if( !ok ){
gchar *only_str = na_core_utils_slist_to_text( only_in );
gchar *not_str = na_core_utils_slist_to_text( not_in );
g_debug( "%s: object is not candidate because OnlyShowIn=%s, NotShowIn=%s", thisfn, only_str, not_str );
g_free( not_str );
g_free( only_str );
}
na_core_utils_slist_free( not_in );
na_core_utils_slist_free( only_in );
return( ok );
}
......@@ -406,6 +412,7 @@ is_candidate_for_show_in( const NAIContext *object, guint target, GList *files )
static gboolean
is_candidate_for_try_exec( const NAIContext *object, guint target, GList *files )
{
static const gchar *thisfn = "na_icontext_is_candidate_for_try_exec";
gboolean ok = TRUE;
gchar *tryexec = na_object_get_try_exec( object );
......@@ -418,6 +425,10 @@ is_candidate_for_try_exec( const NAIContext *object, guint target, GList *files
g_object_unref( file );
}
if( !ok ){
g_debug( "%s: object is not candidate because TryExec=%s", thisfn, tryexec );
}
g_free( tryexec );
return( ok );
......@@ -448,6 +459,10 @@ is_candidate_for_show_if_registered( const NAIContext *object, guint target, GLi
}
}
if( !ok ){
g_debug( "%s: object is not candidate because ShowIfRegistered=%s", thisfn, name );
}
g_free( name );
return( ok );
......@@ -456,6 +471,7 @@ is_candidate_for_show_if_registered( const NAIContext *object, guint target, GLi
static gboolean
is_candidate_for_show_if_true( const NAIContext *object, guint target, GList *files )
{
static const gchar *thisfn = "na_icontext_is_candidate_for_show_if_true";
gboolean ok = TRUE;
gchar *command = na_object_get_show_if_true( object );
......@@ -471,6 +487,10 @@ is_candidate_for_show_if_true( const NAIContext *object, guint target, GList *fi
g_free( stdout );
}
if( !ok ){
g_debug( "%s: object is not candidate because ShowIfTrue=%s", thisfn, command );
}
g_free( command );
return( ok );
......@@ -479,6 +499,7 @@ is_candidate_for_show_if_true( const NAIContext *object, guint target, GList *fi
static gboolean
is_candidate_for_show_if_running( const NAIContext *object, guint target, GList *files )
{
static const gchar *thisfn = "na_icontext_is_candidate_for_show_if_running";
gboolean ok = TRUE;
gchar *running = na_object_get_show_if_running( object );
......@@ -488,6 +509,10 @@ is_candidate_for_show_if_running( const NAIContext *object, guint target, GList
*/
}
if( !ok ){
g_debug( "%s: object is not candidate because ShowIfRunning=%s", thisfn, running );
}
g_free( running );
return( ok );
......@@ -509,10 +534,13 @@ is_candidate_for_show_if_running( const NAIContext *object, guint target, GList
static gboolean
is_candidate_for_mimetypes( const NAIContext *object, guint target, GList *files )
{
static const gchar *thisfn = "na_icontext_is_candidate_for_mimetypes";
gboolean ok = TRUE;
gboolean all = na_object_get_all_mimetypes( object );
GList *it;
g_debug( "%s: all=%s", thisfn, all ? "True":"False" );
if( !all ){
GSList *mimetypes = na_object_get_mimetypes( object );
GSList *im;
......@@ -520,7 +548,7 @@ is_candidate_for_mimetypes( const NAIContext *object, guint target, GList *files
guint count_positive = 0;
guint count_compatible = 0;
for( im = mimetypes ; im && ok ; im = im->data ){
for( im = mimetypes ; im && ok ; im = im->next ){
const gchar *imtype = ( const gchar * ) im->data;
positive = is_positive_assertion( imtype );
if( positive ){
......@@ -555,6 +583,12 @@ is_candidate_for_mimetypes( const NAIContext *object, guint target, GList *files
ok = FALSE;
}
if( !ok ){
gchar *mimetypes_str = na_core_utils_slist_to_text( mimetypes );
g_debug( "%s: object is not candidate because Mimetypes=%s", thisfn, mimetypes_str );
g_free( mimetypes_str );
}
na_core_utils_slist_free( mimetypes );
}
......@@ -601,6 +635,7 @@ split_mimetype( const gchar *mimetype, gchar **group, gchar **subgroup )
static gboolean
is_candidate_for_basenames( const NAIContext *object, guint target, GList *files )
{
static const gchar *thisfn = "na_icontext_is_candidate_for_basenames";
gboolean ok = TRUE;
GSList *basenames = na_object_get_basenames( object );
......@@ -608,6 +643,12 @@ is_candidate_for_basenames( const NAIContext *object, guint target, GList *files
gboolean matchcase = na_object_get_matchcase( object );
matchcase = FALSE;
if( !ok ){
gchar *basenames_str = na_core_utils_slist_to_text( basenames );
g_debug( "%s: object is not candidate because Basenames=%s", thisfn, basenames_str );
g_free( basenames_str );
}
na_core_utils_slist_free( basenames );
}
......@@ -617,6 +658,7 @@ is_candidate_for_basenames( const NAIContext *object, guint target, GList *files
static gboolean
is_candidate_for_selection_count( const NAIContext *object, guint target, GList *files )
{
static const gchar *thisfn = "na_icontext_is_candidate_for_selection_count";
gboolean ok = TRUE;
gchar *selection_count = na_object_get_selection_count( object );
......@@ -624,6 +666,10 @@ is_candidate_for_selection_count( const NAIContext *object, guint target, GList
}
if( !ok ){
g_debug( "%s: object is not candidate because SelectionCount=%s", thisfn, selection_count );
}
g_free( selection_count );
return( ok );
......@@ -632,11 +678,18 @@ is_candidate_for_selection_count( const NAIContext *object, guint target, GList
static gboolean
is_candidate_for_schemes( const NAIContext *object, guint target, GList *files )
{
static const gchar *thisfn = "na_icontext_is_candidate_for_schemes";
gboolean ok = TRUE;
GSList *schemes = na_object_get_schemes( object );
if( schemes ){
if( !ok ){
gchar *schemes_str = na_core_utils_slist_to_text( schemes );
g_debug( "%s: object is not candidate because Schemes=%s", thisfn, schemes_str );
g_free( schemes_str );
}
na_core_utils_slist_free( schemes );
}
......@@ -646,11 +699,18 @@ is_candidate_for_schemes( const NAIContext *object, guint target, GList *files )
static gboolean
is_candidate_for_folders( const NAIContext *object, guint target, GList *files )
{
static const gchar *thisfn = "na_icontext_is_candidate_for_folders";
gboolean ok = TRUE;
GSList *folders = na_object_get_folders( object );
if( folders ){
if( !ok ){
gchar *folders_str = na_core_utils_slist_to_text( folders );
g_debug( "%s: object is not candidate because Folders=%s", thisfn, folders_str );
g_free( folders_str );
}
na_core_utils_slist_free( folders );
}
......@@ -660,11 +720,18 @@ is_candidate_for_folders( const NAIContext *object, guint target, GList *files )
static gboolean
is_candidate_for_capabilities( const NAIContext *object, guint target, GList *files )
{
static const gchar *thisfn = "na_icontext_is_candidate_for_capabilities";
gboolean ok = TRUE;
GSList *capabilities = na_object_get_capabilities( object );
if( capabilities ){
if( !ok ){
gchar *capabilities_str = na_core_utils_slist_to_text( capabilities );
g_debug( "%s: object is not candidate because Capabilities=%s", thisfn, capabilities_str );
g_free( capabilities_str );
}
na_core_utils_slist_free( capabilities );
}
......@@ -819,7 +886,6 @@ is_target_selection_candidate( const NAIContext *object, GList *files )
tmp_mimetype2 = g_ascii_strdown( tmp_mimetype, strlen( tmp_mimetype ));
g_free( tmp_mimetype );
tmp_mimetype = tmp_mimetype2;
g_debug( "mimetype=%s", tmp_mimetype );
if( na_selected_info_is_directory( NA_SELECTED_INFO( iter1->data ))){
dir_count++;
......@@ -1004,6 +1070,39 @@ is_valid_folders( const NAIContext *object )
return( valid );
}
/*
* @context: the #NAIContext object to be checked.
*
* Check if this object is valid for all mimetypes. This is done at load
* time, and let us spend as less time as possible when testing for
* candidates.
*/
static void
check_for_all_mimetypes( NAIContext *context )
{
gboolean all = TRUE;
GSList *mimetypes = na_object_get_mimetypes( context );
GSList *im;
for( im = mimetypes ; im ; im = im->next ){
if( !im->data || !strlen( im->data )){
continue;
}
const gchar *imtype = ( const gchar * ) im->data;
if( !strcmp( imtype, "*" ) ||
!strcmp( imtype, "*/*" ) ||
!strcmp( imtype, "all" ) ||
!strcmp( imtype, "all/*" ) ||
!strcmp( imtype, "all/all" )){
continue;
}
all = FALSE;
break;
}
na_object_set_all_mimetypes( context, all );
}
/*
* "image/ *" is a positive assertion
* "!image/jpeg" is a negative one
......@@ -1014,10 +1113,12 @@ is_positive_assertion( const gchar *assertion )
gboolean positive = TRUE;
if( assertion ){
const gchar *stripped = g_strstrip(( gchar * ) assertion );
gchar *dupped = g_strdup( assertion );
const gchar *stripped = g_strstrip( dupped );
if( stripped ){
positive = ( stripped[0] != '!' );
}
g_free( dupped );
}
return( positive );
......
......@@ -348,9 +348,9 @@ ifactory_object_read_done( NAIFactoryObject *instance, const NAIFactoryProvider
*/
deals_with_toolbar_label( instance );
/* test for all mimetypes
/* prepare the context after the reading
*/
na_icontext_have_all_mimetypes( NA_ICONTEXT( instance ));
na_icontext_read_done( NA_ICONTEXT( instance ));
/* last, set other action defaults
*/
......
......@@ -348,7 +348,7 @@ NADataDef data_def_item [] = {
/* this integer version number is introduced with .desktop files and obsoletes
* the previous string version number which was only set on actions
* we so have: "1.0" < "1.1" < "2.0" < 1
* we so have: "1.0" < "1.1" < "2.0" < 3
*/
{ NAFO_DATA_IVERSION,
TRUE,
......@@ -357,7 +357,7 @@ NADataDef data_def_item [] = {
N_( "Version of the format" ),
N_( "The version of the configuration format that will be used to manage backward compatibility." ),
NAFD_TYPE_UINT,
"1",
"3",
TRUE,
TRUE,
FALSE,
......
......@@ -326,9 +326,9 @@ ifactory_object_read_start( NAIFactoryObject *instance, const NAIFactoryProvider
static void
ifactory_object_read_done( NAIFactoryObject *instance, const NAIFactoryProvider *reader, void *reader_data, GSList **messages )
{
/* test for all mimetypes
/* prepare the context after the reading
*/
na_icontext_have_all_mimetypes( NA_ICONTEXT( instance ));
na_icontext_read_done( NA_ICONTEXT( instance ));
/* last, set other action defaults
*/
......
......@@ -328,9 +328,11 @@ ifactory_object_is_valid( const NAIFactoryObject *object )
static void
ifactory_object_read_done( NAIFactoryObject *instance, const NAIFactoryProvider *reader, void *reader_data, GSList **messages )
{
/* test for all mimetypes
g_debug( "na_object_profile_ifactory_object_read_done: profile=%p", ( void * ) instance );
/* prepare the context after the reading
*/
na_icontext_have_all_mimetypes( NA_ICONTEXT( instance ));
na_icontext_read_done( NA_ICONTEXT( instance ));
/* last, set other action defaults
*/
......
......@@ -60,6 +60,8 @@ static void read_done_action_load_profiles_from_list( const NAIFactoryP
static void read_done_action_load_profile( const NAIFactoryProvider *provider, ReaderData *data, const gchar *path, GSList **messages );
static void read_done_profile_attach_profile( const NAIFactoryProvider *provider, NAObjectProfile *profile, ReaderData *data, GSList **messages );
static void convert_pre_v3_parameters( NAObjectProfile *profile );
static void convert_pre_v3_parameters_str( gchar *str );
static NADataBoxed *get_boxed_from_path( const NagpGConfProvider *provider, const gchar *path, ReaderData *reader_data, const NADataDef *def );
static gboolean is_key_writable( NagpGConfProvider *gconf, const gchar *key );
......@@ -315,7 +317,107 @@ read_done_action_load_profile( const NAIFactoryProvider *provider, ReaderData *d
static void
read_done_profile_attach_profile( const NAIFactoryProvider *provider, NAObjectProfile *profile, ReaderData *data, GSList **messages )
{
guint iversion;
g_debug( "nagp_reader_read_done_attach_profile: profile=%p", ( void * ) profile );
na_object_attach_profile( data->parent, profile );
/* converts pre-v3 parameters
*/
iversion = na_object_get_iversion( data->parent );
if( iversion < 3 ){
convert_pre_v3_parameters( profile );
}
}
/*
* starting wih v3, parameters are relabeled
* pre-v3 parameters post-v3 parameters
* ---------------------------- -----------------------------------
* %b: (first) basename (new)
* %B: list of basenames (was %m)
* %c: count (new)
* %d: (first) base directory ................... (unchanged)
* %D: list of base dir (new)
* %f: (first) pathname ................... (unchanged)
* %F: list of pathnames (was %M)
* %h: (first) hostname ................... (unchanged)
* %m: list of basenames -> %B - (removed)
* %M: list of pathnames -> %F - (removed)
* %n: (first) username (was %U)
* %p: (first) port number ................... (unchanged)
* %R: list of URIs -> %U - (removed)
* %s: (first) scheme ................... (unchanged)
* %u: (first) URI ................... (unchanged)
* %U: (first) username -> %n %U: list of URIs (was %R)
* %w: (first) basename w/o ext. (new)
* %W: list of basenames w/o ext. (new)
* %x: (first) extension (new)
* %X: list of extensions (new)
* %%: % ................... (unchanged)
*
* For pre-v3 items,
* - substitute %m with %B
* - substitute %M with %F
* - substitute %U with %n
* - substitute %R with %U
*
* Note that pre-v3 items only have parameters in the command and path fields.
* Are only located in 'profile' objects.
* Are only found in GConf provider, as .desktop files have been simultaneously
* introduced.
*/
static void
convert_pre_v3_parameters( NAObjectProfile *profile )
{
gchar *path = na_object_get_path( profile );
convert_pre_v3_parameters_str( path );
na_object_set_path( profile, path );
g_free( path );
gchar *parms = na_object_get_parameters( profile );
convert_pre_v3_parameters_str( parms );
na_object_set_parameters( profile, parms );
g_free( parms );
}
static void
convert_pre_v3_parameters_str( gchar *str )
{
gchar *iter = str;
while(( iter = g_strstr_len( iter, strlen( iter ), "%" )) != NULL ){
switch( iter[1] ){
/* %m (list of basenames) becomes %B
*/
case 'm':
iter[1] = 'B';
break;
/* %M (list of filenames) becomes %F
*/
case 'M':
iter[1] = 'F';
break;
/* %U ((first) username) becomes %n
*/
case 'U':
iter[1] = 'n';
break;
/* %R (list of URIs) becomes %U
*/
case 'R':
iter[1] = 'U';
break;
}
iter += 2;
}
}
static NADataBoxed *
......
......@@ -86,7 +86,7 @@ static GList *menu_provider_get_background_items( NautilusMenuProvide
static GList *menu_provider_get_file_items( NautilusMenuProvider *provider, GtkWidget *window, GList *files );
static GList *menu_provider_get_toolbar_items( NautilusMenuProvider *provider, GtkWidget *window, NautilusFileInfo *current_folder );
static GList *get_file_or_background_items( NautilusActions *plugin, guint target, void *selection );
static GList *get_file_or_background_items( NautilusActions *plugin, guint target, GList *selection );
static GList *build_nautilus_menus( NautilusActions *plugin, GList *tree, guint target, GList *files );
static NAObjectProfile *get_candidate_profile( NautilusActions *plugin, NAObjectAction *action, guint target, GList *files );
static NautilusMenuItem *create_item_from_profile( NAObjectProfile *profile, guint target, GList *files );
......@@ -404,6 +404,9 @@ menu_provider_get_background_items( NautilusMenuProvider *provider, GtkWidget *w
static const gchar *thisfn = "nautilus_actions_menu_provider_get_background_items";
GList *nautilus_menus_list = NULL;
gchar *uri;
GList *selected;
g_return_val_if_fail( NAUTILUS_IS_ACTIONS( provider ), NULL );
if( !NAUTILUS_ACTIONS( provider )->private->dispose_has_run ){
......@@ -412,8 +415,12 @@ menu_provider_get_background_items( NautilusMenuProvider *provider, GtkWidget *w
thisfn, ( void * ) provider, ( void * ) window, ( void * ) current_folder, uri );
g_free( uri );
selected = na_selected_info_get_list_from_item( current_folder );
nautilus_menus_list = get_file_or_background_items(
NAUTILUS_ACTIONS( provider ), ITEM_TARGET_LOCATION, ( void * ) current_folder );
NAUTILUS_ACTIONS( provider ), ITEM_TARGET_LOCATION, selected );
na_selected_info_free_list( selected );
}
return( nautilus_menus_list );
......@@ -430,9 +437,7 @@ menu_provider_get_file_items( NautilusMenuProvider *provider, GtkWidget *window,
{
static const gchar *thisfn = "nautilus_actions_menu_provider_get_file_items";
GList *nautilus_menus_list = NULL;
g_debug( "%s: provider=%p, window=%p, files=%p, count=%d",
thisfn, ( void * ) provider, ( void * ) window, ( void * ) files, g_list_length( files ));
GList *selected;
g_return_val_if_fail( NAUTILUS_IS_ACTIONS( provider ), NULL );
......@@ -443,8 +448,15 @@ menu_provider_get_file_items( NautilusMenuProvider *provider, GtkWidget *window,
if( !NAUTILUS_ACTIONS( provider )->private->dispose_has_run ){
g_debug( "%s: provider=%p, window=%p, files=%p, count=%d",
thisfn, ( void * ) provider, ( void * ) window, ( void * ) files, g_list_length( files ));
selected = na_selected_info_get_list_from_list(( GList * ) files );
nautilus_menus_list = get_file_or_background_items(
NAUTILUS_ACTIONS( provider ), ITEM_TARGET_SELECTION, ( void * ) files );
NAUTILUS_ACTIONS( provider ), ITEM_TARGET_SELECTION, selected );
na_selected_info_free_list( selected );
}
return( nautilus_menus_list );
......@@ -464,13 +476,15 @@ menu_provider_get_toolbar_items( NautilusMenuProvider *provider, GtkWidget *wind
GList *selected;
GList *pivot_tree;
uri = nautilus_file_info_get_uri( current_folder );
g_debug( "%s: provider=%p, window=%p, current_folder=%p (%s)",
thisfn, ( void * ) provider, ( void * ) window, ( void * ) current_folder, uri );
g_free( uri );
g_return_val_if_fail( NAUTILUS_IS_ACTIONS( provider ), NULL );
if( !NAUTILUS_ACTIONS( provider )->private->dispose_has_run ){
uri = nautilus_file_info_get_uri( current_folder );
g_debug( "%s: provider=%p, window=%p, current_folder=%p (%s)",
thisfn, ( void * ) provider, ( void * ) window, ( void * ) current_folder, uri );
g_free( uri );
pivot_tree = na_pivot_get_items( NAUTILUS_ACTIONS( provider )->private->pivot );
selected = na_selected_info_get_list_from_item( current_folder );
......@@ -485,11 +499,10 @@ menu_provider_get_toolbar_items( NautilusMenuProvider *provider, GtkWidget *wind
}
static GList *
get_file_or_background_items( NautilusActions *plugin, guint target, void *selection )
get_file_or_background_items( NautilusActions *plugin, guint target, GList *selection )
{
GList *menus_list;
GList *pivot_tree;
GList *selected;
gboolean root_menu;
gboolean add_about;
......@@ -497,19 +510,7 @@ get_file_or_background_items( NautilusActions *plugin, guint target, void *selec
pivot_tree = na_pivot_get_items( plugin->private->pivot );
if( target == ITEM_TARGET_LOCATION ){
g_return_val_if_fail( NAUTILUS_IS_FILE_INFO( selection ), NULL );
selected = na_selected_info_get_list_from_item( NAUTILUS_FILE_INFO( selection ));
} else {
g_return_val_if_fail( target == ITEM_TARGET_SELECTION, NULL );
selected = na_selected_info_get_list_from_list(( GList * ) selection );
}
menus_list = build_nautilus_menus( plugin, pivot_tree, target, selected );
/*g_debug( "%s: menus has %d level zero items", thisfn, g_list_length( menus_list ));*/
na_selected_info_free_list( selected );
menus_list = build_nautilus_menus( plugin, pivot_tree, target, selection );
root_menu = na_iprefs_read_bool( NA_IPREFS( plugin->private->pivot ), IPREFS_CREATE_ROOT_MENU, FALSE );
if( root_menu ){
......@@ -517,7 +518,6 @@ get_file_or_background_items( NautilusActions *plugin, guint target, void *selec
}
add_about = na_iprefs_read_bool( NA_IPREFS( plugin->private->pivot ), IPREFS_ADD_ABOUT_ITEM, TRUE );