/* * renumber the item, and set a new label */ static void renumber_label_item( NAObjectItem *item ) { gchar *label, *tmp; na_object_set_new_id( item, NULL ); label = na_object_get_label( item ); /* i18n: the action has been renumbered during import operation */ tmp = g_strdup_printf( "%s %s", label, _( "(renumbered)" )); na_object_set_label( item, tmp ); g_free( tmp ); g_free( label ); }
/* * allocate a new action, and fill it with values read from command-line */ static NAObjectAction * get_action_from_cmdline( void ) { NAObjectAction *action; NAObjectProfile *profile; int i; GSList *basenames; GSList *mimetypes; GSList *schemes; GSList *folders; gboolean toolbar_same_label; gchar *msg; GSList *only_show_in; GSList *not_show_in; GSList *capabilities; action = na_object_action_new_with_defaults(); profile = NA_OBJECT_PROFILE(( GList * ) na_object_get_items( action )->data ); na_object_set_label( action, label ); if( tooltip && g_utf8_strlen( tooltip, -1 )){ na_object_set_tooltip( action, tooltip ); } if( icon && g_utf8_strlen( icon, -1 )){ na_object_set_icon( action, icon ); } na_object_set_enabled( action, enabled ); na_object_set_target_selection( action, target_selection ); na_object_set_target_location( action, target_location ); na_object_set_target_toolbar( action, target_toolbar ); toolbar_same_label = FALSE; if( !label_toolbar || !g_utf8_strlen( label_toolbar, -1 )){ label_toolbar = g_strdup( label ); toolbar_same_label = TRUE; } na_object_set_toolbar_same_label( action, toolbar_same_label ); na_object_set_toolbar_label( action, label_toolbar ); na_object_set_path( profile, command ); na_object_set_parameters( profile, parameters ); i = 0; basenames = NULL; while( basenames_array != NULL && basenames_array[i] != NULL ){ basenames = g_slist_append( basenames, g_strdup( basenames_array[i] )); i++; } if( basenames && g_slist_length( basenames )){ na_object_set_basenames( profile, basenames ); na_core_utils_slist_free( basenames ); } na_object_set_matchcase( profile, matchcase ); mimetypes = NULL; if( isfile ){ msg = g_strdup_printf( DEPRECATED, "accept-files", "mimetype" ); g_warning( "%s", msg ); g_free( msg ); } if( isdir ){ msg = g_strdup_printf( DEPRECATED, "accept-dirs", "mimetype" ); g_warning( "%s", msg ); g_free( msg ); } if( isfile && !isdir ){ mimetypes = g_slist_prepend( mimetypes, g_strdup( "all/allfiles" )); } else if( isdir && !isfile ){ mimetypes = g_slist_prepend( mimetypes, g_strdup( "inode/directory" )); } i = 0; while( mimetypes_array != NULL && mimetypes_array[i] != NULL ){ mimetypes = g_slist_append( mimetypes, g_strdup( mimetypes_array[i] )); i++; } if( mimetypes && g_slist_length( mimetypes )){ na_object_set_mimetypes( profile, mimetypes ); na_core_utils_slist_free( mimetypes ); } if( accept_multiple ){ msg = g_strdup_printf( DEPRECATED, "accept-multiple", "selection-count" ); g_warning( "%s", msg ); g_free( msg ); selection_count = g_strdup( ">0" ); } if( strlen( selection_count )){ na_object_set_selection_count( profile, selection_count ); } i = 0; schemes = NULL; while( schemes_array != NULL && schemes_array[i] != NULL ){ schemes = g_slist_append( schemes, g_strdup( schemes_array[i] )); i++; } if( schemes && g_slist_length( schemes )){ na_object_set_schemes( profile, schemes ); na_core_utils_slist_free( schemes ); } i = 0; folders = NULL; while( folders_array != NULL && folders_array[i] != NULL ){ folders = g_slist_append( folders, g_strdup( folders_array[i] )); i++; } if( folders && g_slist_length( folders )){ na_object_set_folders( profile, folders ); na_core_utils_slist_free( folders ); } if( onlyshow_array ){ only_show_in = NULL; for( i = 0 ; onlyshow_array[i] && strlen( onlyshow_array[i] ) ; ++i ){ only_show_in = g_slist_append( only_show_in, g_strdup( onlyshow_array[i] )); } if( only_show_in && g_slist_length( only_show_in )){ na_object_set_only_show_in( profile, only_show_in ); na_core_utils_slist_free( only_show_in ); } } if( notshow_array ){ not_show_in = NULL; for( i = 0 ; notshow_array[i] && strlen( notshow_array[i] ) ; ++i ){ not_show_in = g_slist_append( not_show_in, g_strdup( notshow_array[i] )); } if( not_show_in && g_slist_length( not_show_in )){ na_object_set_not_show_in( profile, not_show_in ); na_core_utils_slist_free( not_show_in ); } } if( try_exec && strlen( try_exec )){ na_object_set_try_exec( profile, try_exec ); } if( show_registered && strlen( show_registered )){ na_object_set_show_if_registered( profile, show_registered ); } if( show_true && strlen( show_true )){ na_object_set_show_if_true( profile, show_true ); } if( show_running && strlen( show_running )){ na_object_set_show_if_running( profile, show_running ); } if( capability_array ){ capabilities = NULL; for( i = 0 ; capability_array[i] && strlen( capability_array[i] ) ; ++i ){ const gchar *cap = ( const gchar * ) capability_array[i]; /* 'Owner', 'Readable', 'Writable', 'Executable' and 'Local' */ if( strcmp( cap, "Owner" ) && strcmp( cap, "Readable" ) && strcmp( cap, "Writable" ) && strcmp( cap, "Executable" ) && strcmp( cap, "Local" )){ g_warning( "%s: unknown capability", cap ); } else { capabilities = g_slist_append( capabilities, g_strdup( capability_array[i] )); } } if( capabilities && g_slist_length( capabilities )){ na_object_set_capabilities( profile, capabilities ); na_core_utils_slist_free( capabilities ); } } return( action ); }